/// <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 ); Type targetType = context.Request.Service; reference.Instance = targetType.IsInterface ? this._factory.CreateProxy(typeof(object), wrapper, context.Request.Service) : this._factory.CreateProxy(context.Request.Service, wrapper); }
/// <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 ); Type targetType = context.Request.Service; Type[] additionalInterfaces = context.Parameters.OfType<AdditionalInterfaces>().Any() ? context.Parameters.OfType<AdditionalInterfaces>().First().GetValue(context, null) as Type[] : new Type[] { }; reference.Instance = targetType.IsInterface ? this._factory.CreateProxy(typeof(object), wrapper, new[] { targetType }.Concat(additionalInterfaces).ToArray()) : this._factory.CreateProxy(targetType, wrapper, additionalInterfaces); }
/// <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); }