Exemple #1
0
        public IInterceptionPolicyBuilder For <TInterceptorProvider>(
            int order,
            Action <IInterceptorProviderPolicyBuilder> configureTargets,
            params object[] arguments) where TInterceptorProvider : IInterceptorProvider
        {
            Func <IInterceptorProvider> providerAccessor = () =>
            {
                var provider       = ActivatorUtilities.CreateInstance <TInterceptorProvider>(ServiceProvider, arguments);
                var orderedElement = provider as IOrderedSequenceItem;
                if (null != orderedElement)
                {
                    orderedElement.Order = order;
                }
                return(provider);
            };
            var targetBuilder = new InterceptorProviderPolicyBuilder <TInterceptorProvider>(providerAccessor);

            configureTargets?.Invoke(targetBuilder);
            _policy.Add(targetBuilder.Build());
            return(this);
        }
Exemple #2
0
        public IInterceptionPolicyBuilder For <TInterceptorProvider>(
            int order,
            Action <IInterceptorProviderPolicyBuilder> configureTargets,
            params object[] arguments) where TInterceptorProvider : IInterceptorProvider
        {
            IInterceptorProvider GetInteceptorProvider()
            {
                var provider = ActivatorUtilities.CreateInstance <TInterceptorProvider>(ServiceProvider, arguments);

                if (provider is IOrderedSequenceItem orderedElement)
                {
                    orderedElement.Order = order;
                }
                return(provider);
            }

            var targetBuilder = new InterceptorProviderPolicyBuilder <TInterceptorProvider>(GetInteceptorProvider);

            configureTargets?.Invoke(targetBuilder);
            _policy.Add(targetBuilder.Build());
            return(this);
        }