private PolicyList CreatePolicyList(ConfigurationSection settings, bool applyInjectionPolicies)
        {
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();
            configurationSource.Add(PolicyInjectionSettings.SectionName, settings);

			PolicyList policyList = new PolicyList();
			policyList.SetDefault<IPolicyInjectionPolicy>(new PolicyInjectionPolicy(applyInjectionPolicies));
            //policyList.Set<IPolicyInjectionPolicy>(new PolicyInjectionPolicy(false),
            //                                       typeof(ClassThatDependsOnIInterface));
			policyList.Set<IConfigurationObjectPolicy>(new ConfigurationObjectPolicy(configurationSource),
													   typeof(IConfigurationSource));

            policyList.SetDefault<IBuildPlanCreatorPolicy>(new DynamicMethodBuildPlanCreatorPolicy(buildPlanStrategyChain));
		    policyList.SetDefault<IDynamicBuilderMethodCreatorPolicy>(new DefaultDynamicBuilderMethodCreatorPolicy());
            policyList.SetDefault<IConstructorSelectorPolicy>(new ConstructorSelectorPolicy<Attribute>());
            policyList.SetDefault<IPropertySelectorPolicy>(new PropertySelectorPolicy<Attribute>());

			return policyList;
        }
示例#2
0
        private void InitializeBuilderState()
        {
            registeredNames = new NamedTypesRegistry(ParentNameRegistry);
            extensions = new List<UnityContainerExtension>();

            lifetimeContainer = new LifetimeContainer();
            strategies = new StagedStrategyChain<UnityBuildStage>(ParentStrategies);
            buildPlanStrategies = new StagedStrategyChain<UnityBuildStage>(ParentBuildPlanStrategies);
            policies = new PolicyList(ParentPolicies);
            policies.Set<IRegisteredNamesPolicy>(new RegisteredNamesPolicy(registeredNames), null);

            cachedStrategies = null;
            cachedStrategiesLock = new object();
        }