コード例 #1
0
        private static ISession BuildSessionWrapped(TransactionProtectionWrapper wrapper)
        {
            var proxyFactory = new SerializableProxyFactory
            {
                Interfaces      = Commons.SessionProxyInterfaces,
                TargetSource    = wrapper,
                ProxyTargetType = false
            };

            proxyFactory.AddAdvice(wrapper);

            return((ISession)proxyFactory.GetProxy());
        }
コード例 #2
0
ファイル: ProxyFactory.cs プロジェクト: paulbatum/nhibernate
		public override INHibernateProxy GetProxy(object id, ISessionImplementor session)
		{
			try
			{
				var initializer = new LazyInitializer(EntityName, PersistentClass.IsInterface ? typeof (object) : PersistentClass,
				                                      id, GetIdentifierMethod, SetIdentifierMethod, ComponentIdType, session);

				var proxyFactory = new SerializableProxyFactory
				                   	{Interfaces = Interfaces, TargetSource = initializer, ProxyTargetType = IsClassProxy};
				proxyFactory.AddAdvice(initializer);

				object proxyInstance = proxyFactory.GetProxy();
				return (INHibernateProxy) proxyInstance;
			}
			catch (Exception ex)
			{
				log.Error("Creating a proxy instance failed", ex);
				throw new HibernateException("Creating a proxy instance failed", ex);
			}
		}
コード例 #3
0
 public override global::NHibernate.Proxy.INHibernateProxy GetProxy(object id, global::NHibernate.Engine.ISessionImplementor session)
 {
     try
     {
         // PersistentClass = PersistentClass.IsInterface ? typeof(object) : PersistentClass
         LazyInitializer initializer = new LazyInitializerSrlzSupport(EntityName, PersistentClass,
                                                                      id, GetIdentifierMethod, SetIdentifierMethod, ComponentIdType, session);
         SerializableProxyFactory proxyFactory = new SerializableProxyFactory();
         proxyFactory.Interfaces      = Interfaces;
         proxyFactory.TargetSource    = initializer;
         proxyFactory.ProxyTargetType = IsClassProxy;
         proxyFactory.AddAdvice(initializer);
         object proxyInstance = proxyFactory.GetProxy();
         return((INHibernateProxy)proxyInstance);
     }
     catch (Exception ex)
     {
         log.Error("Creating a proxy instance failed", ex);
         throw new HibernateException("Creating a proxy instance failed", ex);
     }
 }
コード例 #4
0
ファイル: ProxyFactory.cs プロジェクト: renefc3/nhibernate
        public override INHibernateProxy GetProxy(object id, ISessionImplementor session)
        {
            try
            {
                var initializer = new LazyInitializer(EntityName, PersistentClass.IsInterface ? typeof(object) : PersistentClass,
                                                      id, GetIdentifierMethod, SetIdentifierMethod, ComponentIdType, session);

                var proxyFactory = new SerializableProxyFactory
                {
                    Interfaces = Interfaces, TargetSource = initializer, ProxyTargetType = IsClassProxy
                };
                proxyFactory.AddAdvice(initializer);

                object proxyInstance = proxyFactory.GetProxy();
                return((INHibernateProxy)proxyInstance);
            }
            catch (Exception ex)
            {
                log.Error("Creating a proxy instance failed", ex);
                throw new HibernateException("Creating a proxy instance failed", ex);
            }
        }