コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <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 <AdditionalInterfaceParameter>().Select(ai => (Type)ai.GetValue(context, null)).ToArray();

            reference.Instance = targetType.IsInterface
                ? this._factory.CreateProxy(typeof(object), wrapper, new[] { targetType }.Concat(additionalInterfaces).ToArray())
                : this._factory.CreateProxy(targetType, wrapper, additionalInterfaces);
        }
コード例 #3
0
        /// <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);
        }