예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dao"></param>
        /// <returns></returns>
        public static IDao NewInstance(Dao dao)
        {
            ProxyGenerator proxyGenerator = new ProxyGenerator();
            IInterceptor   handler        = new DaoProxy(dao);

            Type[] interfaces = { dao.DaoInterface, typeof(IDao) };

            return(proxyGenerator.CreateProxy(interfaces, handler, dao.DaoInstance) as IDao);
        }
예제 #2
0
 /// <summary>
 /// Initialize dao object.
 /// </summary>
 public void Initialize(DaoManager daoManager)
 {
     try
     {
         _daoManager        = daoManager;
         _daoImplementation = TypeUtils.ResolveType(this.Implementation);
         _daoInterface      = TypeUtils.ResolveType(this.Interface);
         // Create a new instance of the Dao object.
         _daoInstance = _daoImplementation.GetConstructor(Type.EmptyTypes).Invoke(null) as IDao;
         _proxy       = DaoProxy.NewInstance(this);
     }
     catch (Exception e)
     {
         throw new ConfigurationException(string.Format("Error configuring DAO. Cause: {0}", e.Message), e);
     }
 }