コード例 #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;
 }