private static ISession BuildSessionWrapped(TransactionProtectionWrapper wrapper) { var proxyFactory = new SerializableProxyFactory { Interfaces = Commons.SessionProxyInterfaces, TargetSource = wrapper, ProxyTargetType = false }; proxyFactory.AddAdvice(wrapper); return((ISession)proxyFactory.GetProxy()); }
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); } }
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); } }
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); } }