/// <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.CreateInterfaceProxyWithTarget(dao.DaoInstance, handler)); }
/// <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); }
/// <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 ConfigurationErrorsException(string.Format("Error configuring DAO. Cause: {0}", e.Message), e); } }
/// <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); }