private void organize(ServiceRegistry services) { DecoratorPolicies = services.FindAndRemovePolicies <IDecoratorPolicy>(); FamilyPolicies = services.FindAndRemovePolicies <IFamilyPolicy>() .Concat(new IFamilyPolicy[] { new EnumerablePolicy(), new FuncOrLazyPolicy(), new CloseGenericFamilyPolicy(), new ConcreteFamilyPolicy(), new EmptyFamilyPolicy() }) .ToArray(); setterPolicies = services.FindAndRemovePolicies <ISetterPolicy>(); InstancePolicies = services.FindAndRemovePolicies <IInstancePolicy>(); var policies = services.FindAndRemovePolicies <IRegistrationPolicy>(); foreach (var policy in policies) { policy.Apply(services); } services.Add(new ScopeInstance <Scope>()); services.Add(new ScopeInstance <IServiceProvider>()); services.Add(new ScopeInstance <IServiceContext>()); services.Add(new ScopeInstance <IContainer>());; services.Add(new RootScopeInstance <IServiceScopeFactory>());; }
public ConstructorInstance Use(Type concreteType) { var instance = new ConstructorInstance(_serviceType, concreteType, ServiceLifetime.Transient); _parent.Add(instance); return(instance); }
public ConstructorInstance <TConcrete> Use <TConcrete>() where TConcrete : class, T { var instance = ConstructorInstance.For <T, TConcrete>(); instance.Lifetime = _lifetime; _parent.Add(instance); return(instance); }
public ConstructorInstance <TConcrete, T> Use <TConcrete>() where TConcrete : class, T { var instance = ConstructorInstance.For <T, TConcrete>(); if (_lifetime != null) { instance.Lifetime = _lifetime.Value; } _parent.Add(instance); return(instance); }
private void organize(ServiceRegistry services) { DecoratorPolicies = services.FindAndRemovePolicies <IDecoratorPolicy>(); FamilyPolicies = services.FindAndRemovePolicies <IFamilyPolicy>() .Concat(new IFamilyPolicy[] { new EnumerablePolicy(), new FuncOrLazyPolicy(), new CloseGenericFamilyPolicy(), new ConcreteFamilyPolicy(), new EmptyFamilyPolicy() }) .ToArray(); setterPolicies = services.FindAndRemovePolicies <ISetterPolicy>(); InstancePolicies = services.FindAndRemovePolicies <IInstancePolicy>(); var policies = services.FindAndRemovePolicies <IRegistrationPolicy>(); foreach (var policy in policies) { policy.Apply(services); } var sets = services.FindAndRemovePolicies <CachedResolverSet>(); foreach (var resolverSet in sets) { if (resolverSet.TryLoadResolvers(out var dict)) { foreach (var pair in dict) { CachedResolverTypes.Add(pair.Key, pair.Value); } } } services.Add(new ScopeInstance <Scope>()); services.Add(new ScopeInstance <IServiceProvider>()); services.Add(new ScopeInstance <IServiceContext>()); services.Add(new ScopeInstance <IContainer>());; services.Add(new RootScopeInstance <IServiceScopeFactory>());; }