コード例 #1
0
        /// <summary>
        /// Selects a decorator using a resolver function.  The implementation directly
        /// before this point in the decorator 'stack' (be it the initial implementation or a
        /// decorator itself) will be passed to the selected implementation.  Thus this implementation
        /// will 'wrap' the one before it.
        /// </summary>
        /// <returns>A customisation helper by which further implementations may be added to the decorator 'stack'.</returns>
        /// <param name="resolverFunc">A function which is used to resolve the decorator object.</param>
        public AutofacDecoratorCustomizer ThenWrapWith(Func <object, IComponentContext, object> resolverFunc)
        {
            if (resolverFunc == null)
            {
                throw new ArgumentNullException(nameof(resolverFunc));
            }

            var decoratorImpl = resolverFunc(Implementation, resolver.GetComponentContext());

            return(new AutofacDecoratorCustomizer(resolver, serviceType, decoratorImpl));
        }
コード例 #2
0
        /// <summary>
        /// Selects the initial implementation type using a generic type parameter.
        /// </summary>
        /// <returns>A customisation helper by which further implementations may be added to the decorator 'stack'.</returns>
        /// <param name="resolverFunc">A function which is used to resolve the initial implementation object.</param>
        public AutofacDecoratorCustomizer UsingInitialImpl(Func <IComponentContext, object> resolverFunc)
        {
            if (resolverFunc == null)
            {
                throw new ArgumentNullException(nameof(resolverFunc));
            }

            var initialImpl = resolverFunc(resolver.GetComponentContext());

            return(new AutofacDecoratorCustomizer(resolver, serviceType, initialImpl));
        }