public override INHibernateProxy GetProxy(object id, ISessionImplementor session) { INHibernateProxy proxy; try { NHibernate.ByteCode.LinFu.LazyInitializer interceptor = new NHibernate.ByteCode.LinFu.LazyInitializer(this.EntityName, this.PersistentClass, id, this.GetIdentifierMethod, this.SetIdentifierMethod, this.ComponentIdType, session); //CacheLazyInitializer interceptor = new CacheLazyInitializer(this.EntityName, this.PersistentClass, id, this.GetIdentifierMethod, this.SetIdentifierMethod, this.ComponentIdType, session); object obj2 = base.IsClassProxy ? factory.CreateProxy(this.PersistentClass, interceptor, this.Interfaces) : factory.CreateProxy(this.Interfaces[0], interceptor, this.Interfaces); proxy = (INHibernateProxy)obj2; object target = TryGetCachedTarget(this.PersistentClass, id); if (target != null) { interceptor.SetImplementation(target); } } catch (Exception exception) { log.Error("Creating a proxy instance failed", exception); throw new HibernateException("Creating a proxy instance failed", exception); } return(proxy); }
/// <summary> /// Wraps the instance in the specified context in a proxy. /// </summary> /// <param name="context">The context in which the instance was activated.</param> /// <param name="reference">The <see cref="InstanceReference"/> to wrap.</param> public override void Wrap(IContext context, InstanceReference reference) { var wrapper = new LinFuWrapper(Kernel, context, reference.Instance); reference.Instance = _factory.CreateProxy(context.Request.Service, wrapper); }