Exemple #1
0
        private MockBuilderContext GetContext()
        {
            StagedStrategyChain <BuilderStage> chain = new StagedStrategyChain <BuilderStage>();

            chain.AddNew <DynamicMethodCallStrategy>(BuilderStage.Initialization);

            DynamicMethodBuildPlanCreatorPolicy policy =
                new DynamicMethodBuildPlanCreatorPolicy(chain);

            MockBuilderContext context = new MockBuilderContext();

            context.Strategies.Add(new LifetimeStrategy());

            context.PersistentPolicies.SetDefault <IDynamicBuilderMethodCreatorPolicy>(
                DynamicBuilderMethodCreatorFactory.CreatePolicy());
            context.PersistentPolicies.SetDefault <IConstructorSelectorPolicy>(
                new ConstructorSelectorPolicy <InjectionConstructorAttribute>());
            context.PersistentPolicies.SetDefault <IPropertySelectorPolicy>(
                new PropertySelectorPolicy <DependencyAttribute>());
            context.PersistentPolicies.SetDefault <IMethodSelectorPolicy>(
                new MethodSelectorPolicy <InjectionMethodAttribute>());

            context.PersistentPolicies.SetDefault <IBuildPlanCreatorPolicy>(policy);

            return(context);
        }
        private static MockBuilderContext GetContext()
        {
            var chain = new StagedStrategyChain <BuilderStage>();

            chain.AddNew <DynamicMethodConstructorStrategy>(BuilderStage.Creation);

            var policy = new DynamicMethodBuildPlanCreatorPolicy(chain);

            var context = new MockBuilderContext();

            context.Strategies.Add(new LifetimeStrategy());

            context.PersistentPolicies.SetDefault <IConstructorSelectorPolicy>(
                new ConstructorSelectorPolicy <InjectionConstructorAttribute>());
            context.PersistentPolicies.SetDefault <IDynamicBuilderMethodCreatorPolicy>(
                DynamicBuilderMethodCreatorFactory.CreatePolicy());
            context.PersistentPolicies.SetDefault <IBuildPlanCreatorPolicy>(policy);

            return(context);
        }