Пример #1
0
        public IActivationStrategy?GetStrategy(IBindingRequest request, CachedResolutionPolicy cache)
        {
            var finalTargetType = genericTemplate.MakeGenericType(request.DesiredType.GetGenericArguments());
            var activator       = cache.Bind(request.DesiredType, true).DoBinding(
                TypeActivatorFactory.CreateTypeActivator(
                    finalTargetType, constructorSelector)
                );

            options?.Invoke(activator);
            return(activator.GetFinalFactory());
        }
Пример #2
0
        public StandardTypeResolutionPolicy()
        {
            var cache = new CachedResolutionPolicy(InterceptionPolicy.AsInterceptionRule());

            Policies.Add(new ArgumentBindingPolicy());
            Policies.Add(cache);
            Policies.Add(new MemorizeResult(cache, new GetIocServiceTypes()));
            Policies.Add(new GenericResolutionPolicy(cache));
            Policies.Add(new MemorizeResult(cache, new EnumerateMultipleBindingsPolicy(this)));
            Policies.Add(new MemorizeResult(cache, new FunctionsIntoFactories()));
            Policies.Add(new MemorizeResult(cache, new TuplesToScopeResolutionPolicy()));
            Policies.Add(new MemorizeResult(cache, new SelfBindByDefault()));
            Policies.Add(new MemorizeResult(cache, new ConventionResolutionPolicy()));
            Policies.Add(new DefaultValuePolicy());
        }
Пример #3
0
 public MemorizeResult(CachedResolutionPolicy cache, ITypeResolutionPolicy innerPolicy)
 {
     this.cache  = cache;
     InnerPolicy = innerPolicy;
 }
Пример #4
0
 public GenericResolutionPolicy(CachedResolutionPolicy cache)
 {
     this.cache = cache;
 }