Author: gbayon
Date: Tue Jun 28 10:38:44 2005
New Revision: 202250

URL: http://svn.apache.org/viewcvs?rev=202250&view=rev
Log:
- Inject DaoManager (IOC)
- Remove ServiceConfig, ServiceBase

Removed:
    ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/BaseService.cs
    ibatis/trunk/cs/npetshop2/NPetshop.Service/ServiceConfig.cs
Modified:
    ibatis/trunk/cs/npetshop2/NPetshop.Persistence/Maps/Category.xml
    ibatis/trunk/cs/npetshop2/NPetshop.Presentation/NPetshop.Presentation.csproj
    ibatis/trunk/cs/npetshop2/NPetshop.Presentation/NPetshopContainer.cs
    ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/AccountService.cs
    ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/BillingService.cs
    ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/CatalogService.cs
    ibatis/trunk/cs/npetshop2/NPetshop.Service/NPetshop.Service.csproj
    ibatis/trunk/cs/npetshop2/NPetshop.Test/Persistence/DaoTest.cs
    ibatis/trunk/cs/npetshop2/NPetshop.Test/Presentation/ControllerTest.cs
    ibatis/trunk/cs/npetshop2/NPetshop.Test/bin/Debug/NPetshop.Test.dll.config
    ibatis/trunk/cs/npetshop2/NPetshop.Web/Global.asax.cs
    ibatis/trunk/cs/npetshop2/NPetshop.Web/Web.config

Modified: ibatis/trunk/cs/npetshop2/NPetshop.Persistence/Maps/Category.xml
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/npetshop2/NPetshop.Persistence/Maps/Category.xml?rev=202250&r1=202249&r2=202250&view=diff
==============================================================================
--- ibatis/trunk/cs/npetshop2/NPetshop.Persistence/Maps/Category.xml (original)
+++ ibatis/trunk/cs/npetshop2/NPetshop.Persistence/Maps/Category.xml Tue Jun 28 
10:38:44 2005
@@ -23,5 +23,14 @@
                        from Categories 
                        where Category_Id = #value#
                </select>
+               
+               <select id="GetCategoryList" resultMap="CategoryResult">
+                       select 
+                               Category_Id, 
+                               Category_Name, 
+                               Category_Description 
+                       from Categories 
+               </select>
+
        </statements>
 </sqlMap>

Modified: 
ibatis/trunk/cs/npetshop2/NPetshop.Presentation/NPetshop.Presentation.csproj
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/npetshop2/NPetshop.Presentation/NPetshop.Presentation.csproj?rev=202250&r1=202249&r2=202250&view=diff
==============================================================================
--- 
ibatis/trunk/cs/npetshop2/NPetshop.Presentation/NPetshop.Presentation.csproj 
(original)
+++ 
ibatis/trunk/cs/npetshop2/NPetshop.Presentation/NPetshop.Presentation.csproj 
Tue Jun 28 10:38:44 2005
@@ -124,6 +124,11 @@
                     AssemblyName = "Castle.MVC"
                     HintPath = "..\External-bin\Castle.MVC.dll"
                 />
+                <Reference
+                    Name = "IBatisNet.DataAccess"
+                    AssemblyName = "IBatisNet.DataAccess"
+                    HintPath = "..\External-bin\IBatisNet.DataAccess.dll"
+                />
             </References>
         </Build>
         <Files>

Modified: ibatis/trunk/cs/npetshop2/NPetshop.Presentation/NPetshopContainer.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/npetshop2/NPetshop.Presentation/NPetshopContainer.cs?rev=202250&r1=202249&r2=202250&view=diff
==============================================================================
--- ibatis/trunk/cs/npetshop2/NPetshop.Presentation/NPetshopContainer.cs 
(original)
+++ ibatis/trunk/cs/npetshop2/NPetshop.Presentation/NPetshopContainer.cs Tue 
Jun 28 10:38:44 2005
@@ -1,11 +1,15 @@
 
 
+using System;
+using System.Configuration;
 using Castle.Facilities.TypedFactory;
 using Castle.MVC.Navigation;
 using Castle.MVC.StatePersister;
 using Castle.MVC.States;
 using Castle.MVC.Views;
 using Castle.Windsor;
+using IBatisNet.DataAccess;
+using IBatisNet.DataAccess.Configuration;
 using NPetshop.Service.Impl;
 using NPetshop.Service.Interfaces;
 
@@ -16,14 +20,29 @@
        /// </summary>
        public class NPetshopContainer : WindsorContainer
        {
-               public NPetshopContainer(bool test): base()
+               public NPetshopContainer(): base()
                {
                        TypedFactoryFacility facility = new 
TypedFactoryFacility();
                        AddFacility("typedfactory", facility );
                        facility.AddTypedFactoryEntry( 
                                new FactoryEntry("stateFactory", 
typeof(IStateFactory), "Create", "Release") );
 
+                       // Add DaoManager
+                       bool test = 
Convert.ToBoolean(ConfigurationSettings.AppSettings["test"]);
+                       DomDaoManagerBuilder builder = new 
DomDaoManagerBuilder();
+                       if (test)
+                       {
+                               
builder.Configure(@"..\..\..\NPetshop.Persistence\dao.config");
+                       }
+                       else
+                       {
+                               
builder.Configure(@"..\NPetshop.Persistence\dao.config");                       
                                
+                       }
+                       this.Kernel.AddComponentInstance("DaoManager", 
typeof(DaoManager),  DaoManager.GetInstance("SqlMapDao") );
+                       
+                       // Add services
                        AddServices();
+                       // Add Controllers
                        AddControllers();
                        AddMVC(test);
                }

Modified: ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/AccountService.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/AccountService.cs?rev=202250&r1=202249&r2=202250&view=diff
==============================================================================
--- ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/AccountService.cs (original)
+++ ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/AccountService.cs Tue Jun 
28 10:38:44 2005
@@ -1,6 +1,9 @@
 
 
 using System.Collections;
+
+using IBatisNet.DataAccess;
+
 using NPetshop.Domain.Accounts;
 using NPetshop.Persistence.Interfaces.Accounts;
 using NPetshop.Service.Interfaces;
@@ -10,15 +13,17 @@
        /// <summary>
        /// Summary description for AccountService.
        /// </summary>
-       public class AccountService : BaseService, IAccountService
+       public class AccountService : IAccountService
        {
                #region Private Fields 
                private IAccountDao _accountDao = null;
+               private DaoManager _daoManager = null;
                #endregion
 
                #region Constructor
-               public AccountService():base() 
+               public AccountService(DaoManager daoManager) 
                {
+                       _daoManager = daoManager;
                        _accountDao = _daoManager.GetDao( typeof(IAccountDao) ) 
as IAccountDao;
                }
                #endregion

Modified: ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/BillingService.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/BillingService.cs?rev=202250&r1=202249&r2=202250&view=diff
==============================================================================
--- ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/BillingService.cs (original)
+++ ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/BillingService.cs Tue Jun 
28 10:38:44 2005
@@ -13,17 +13,19 @@
        /// <summary>
        /// Summary description for OrderService.
        /// </summary>
-       public class BillingService : BaseService, IBillingService
+       public class BillingService : IBillingService
        {
                #region Private Fields 
+               private DaoManager _daoManager = null;
                private IOrderDao _orderDao = null;
                private IItemDao _itemDao = null;
                private ISequenceDao _sequenceDao = null;
                #endregion
 
                #region Constructor
-               public BillingService():base()
+               public BillingService(DaoManager daoManager) 
                {
+                       _daoManager = daoManager;
                        _itemDao = _daoManager[typeof(IItemDao)] as IItemDao;
                        _orderDao = _daoManager[typeof(IOrderDao)] as IOrderDao;
                        _sequenceDao = _daoManager[typeof(ISequenceDao)] as 
ISequenceDao;

Modified: ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/CatalogService.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/CatalogService.cs?rev=202250&r1=202249&r2=202250&view=diff
==============================================================================
--- ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/CatalogService.cs (original)
+++ ibatis/trunk/cs/npetshop2/NPetshop.Service/Impl/CatalogService.cs Tue Jun 
28 10:38:44 2005
@@ -12,17 +12,19 @@
        /// <summary>
        /// Summary description for CatalogService.
        /// </summary>
-       public class CatalogService : BaseService, ICatalogService
+       public class CatalogService : ICatalogService
        {
                #region Private Fields 
+               private DaoManager _daoManager = null;
                private IItemDao _itemDao = null;
                private IProductDao _productDao = null;
                private ICategoryDao _categoryDao = null;
                #endregion
 
                #region Constructor
-               public CatalogService():base() 
+               public CatalogService(DaoManager daoManager) 
                {
+                       _daoManager = daoManager;
                        _categoryDao = _daoManager[typeof(ICategoryDao)] as 
ICategoryDao;
                        _productDao = _daoManager[typeof(IProductDao)] as 
IProductDao;
                        _itemDao = _daoManager[typeof(IItemDao)] as IItemDao;

Modified: ibatis/trunk/cs/npetshop2/NPetshop.Service/NPetshop.Service.csproj
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/npetshop2/NPetshop.Service/NPetshop.Service.csproj?rev=202250&r1=202249&r2=202250&view=diff
==============================================================================
--- ibatis/trunk/cs/npetshop2/NPetshop.Service/NPetshop.Service.csproj 
(original)
+++ ibatis/trunk/cs/npetshop2/NPetshop.Service/NPetshop.Service.csproj Tue Jun 
28 10:38:44 2005
@@ -109,17 +109,7 @@
                     BuildAction = "Compile"
                 />
                 <File
-                    RelPath = "ServiceConfig.cs"
-                    SubType = "Code"
-                    BuildAction = "Compile"
-                />
-                <File
                     RelPath = "Impl\AccountService.cs"
-                    SubType = "Code"
-                    BuildAction = "Compile"
-                />
-                <File
-                    RelPath = "Impl\BaseService.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />

Modified: ibatis/trunk/cs/npetshop2/NPetshop.Test/Persistence/DaoTest.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/npetshop2/NPetshop.Test/Persistence/DaoTest.cs?rev=202250&r1=202249&r2=202250&view=diff
==============================================================================
--- ibatis/trunk/cs/npetshop2/NPetshop.Test/Persistence/DaoTest.cs (original)
+++ ibatis/trunk/cs/npetshop2/NPetshop.Test/Persistence/DaoTest.cs Tue Jun 28 
10:38:44 2005
@@ -1,5 +1,7 @@
 using System;
+using System.Collections;
 using NPetshop.Persistence.Interfaces.Accounts;
+using NPetshop.Persistence.Interfaces.Catalog;
 using NUnit.Framework;
 
 
@@ -20,6 +22,16 @@
 
                        Assert.IsNotNull(accountDao);
                        Assert.IsTrue(type.IsInstanceOfType(accountDao));
+               }
+
+               [Test]                                          
+               public void TestCategoryDao()
+               {
+                       ICategoryDao categoryDao = 
(ICategoryDao)daoManager[typeof(ICategoryDao)];
+
+                       IList list = categoryDao.GetCategoryList();
+                       Assert.IsNotNull(list);
+                       Assert.IsTrue(list.Count>0);
                }
        }
 }

Modified: ibatis/trunk/cs/npetshop2/NPetshop.Test/Presentation/ControllerTest.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/npetshop2/NPetshop.Test/Presentation/ControllerTest.cs?rev=202250&r1=202249&r2=202250&view=diff
==============================================================================
--- ibatis/trunk/cs/npetshop2/NPetshop.Test/Presentation/ControllerTest.cs 
(original)
+++ ibatis/trunk/cs/npetshop2/NPetshop.Test/Presentation/ControllerTest.cs Tue 
Jun 28 10:38:44 2005
@@ -27,9 +27,7 @@
                        _catalogController = null;
                        _state = null;
 
-                       _container = new NPetshopContainer(true);
-
-                       ServiceConfig config = ServiceConfig.GetInstance(true);
+                       _container = new NPetshopContainer();
 
                        _catalogController = 
_container[typeof(CatalogController)] as CatalogController;
                        _state = _catalogController.State as NPetshopState;

Modified: 
ibatis/trunk/cs/npetshop2/NPetshop.Test/bin/Debug/NPetshop.Test.dll.config
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/npetshop2/NPetshop.Test/bin/Debug/NPetshop.Test.dll.config?rev=202250&r1=202249&r2=202250&view=diff
==============================================================================
--- ibatis/trunk/cs/npetshop2/NPetshop.Test/bin/Debug/NPetshop.Test.dll.config 
(original)
+++ ibatis/trunk/cs/npetshop2/NPetshop.Test/bin/Debug/NPetshop.Test.dll.config 
Tue Jun 28 10:38:44 2005
@@ -139,4 +139,7 @@
                </logger>
        </log4net>
        
+       <appSettings>
+               <add key="test" value="true" />
+       </appSettings>
 </configuration>

Modified: ibatis/trunk/cs/npetshop2/NPetshop.Web/Global.asax.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/npetshop2/NPetshop.Web/Global.asax.cs?rev=202250&r1=202249&r2=202250&view=diff
==============================================================================
--- ibatis/trunk/cs/npetshop2/NPetshop.Web/Global.asax.cs (original)
+++ ibatis/trunk/cs/npetshop2/NPetshop.Web/Global.asax.cs Tue Jun 28 10:38:44 
2005
@@ -41,7 +41,7 @@
                
                protected void Application_Start(Object sender, EventArgs e)
                {
-                       _container = new NPetshopContainer(false);
+                       _container = new NPetshopContainer();
                }
  
                protected void Session_Start(Object sender, EventArgs e)

Modified: ibatis/trunk/cs/npetshop2/NPetshop.Web/Web.config
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/npetshop2/NPetshop.Web/Web.config?rev=202250&r1=202249&r2=202250&view=diff
==============================================================================
--- ibatis/trunk/cs/npetshop2/NPetshop.Web/Web.config (original)
+++ ibatis/trunk/cs/npetshop2/NPetshop.Web/Web.config Tue Jun 28 10:38:44 2005
@@ -85,6 +85,10 @@
                </mvc>
        </castle> 
        
+       <appSettings>
+               <add key="test" value="false" />
+       </appSettings>
+
   <system.web>
     <!--  DYNAMIC DEBUG COMPILATION
           Set compilation debug="true" to enable ASPX debugging.  Otherwise, 
setting this value to


Reply via email to