public static TestingBuilderContext GetFullContext() { TestingBuilderContext context = new TestingBuilderContext(); context.Strategies.Add(new BuildKeyMappingStrategy()); context.Strategies.Add(new LifetimeStrategy()); context.Strategies.Add(new BuildPlanStrategy()); StagedStrategyChain <BuilderStage> buildPlanChain = new StagedStrategyChain <BuilderStage>(); buildPlanChain.AddNew <DynamicMethodConstructorStrategy>(BuilderStage.Creation); buildPlanChain.AddNew <DynamicMethodPropertySetterStrategy>(BuilderStage.Initialization); buildPlanChain.AddNew <DynamicMethodCallStrategy>(BuilderStage.Initialization); DynamicMethodBuildPlanCreatorPolicy creatorPolicy = new DynamicMethodBuildPlanCreatorPolicy(buildPlanChain); context.PersistentPolicies.SetDefault <IDynamicBuilderMethodCreatorPolicy>( new DefaultDynamicBuilderMethodCreatorPolicy()); context.PersistentPolicies.SetDefault <IBuildPlanCreatorPolicy>(creatorPolicy); context.PersistentPolicies.SetDefault <IConstructorSelectorPolicy>( new ConstructorSelectorPolicy <InjectionConstructorAttribute>()); context.PersistentPolicies.SetDefault <IPropertySelectorPolicy>( new PropertySelectorPolicy <DependencyAttribute>()); context.PersistentPolicies.SetDefault <IMethodSelectorPolicy>( new MethodSelectorPolicy <InjectionMethodAttribute>()); return(context); }
static EnterpriseLibraryFactory() { builder = new Builder(); StagedStrategyChain <BuilderStage> stagedStrategyChain = new StagedStrategyChain <BuilderStage>(); stagedStrategyChain.AddNew <ConfigurationNameMappingStrategy>(BuilderStage.PreCreation); stagedStrategyChain.AddNew <LocatorLookupStrategy>(BuilderStage.PreCreation); stagedStrategyChain.AddNew <ConfiguredObjectStrategy>(BuilderStage.PreCreation); stagedStrategyChain.AddNew <InstrumentationStrategy>(BuilderStage.PostInitialization); strategyChain = stagedStrategyChain.MakeStrategyChain(); }
public void SetUp() { baseStrategyChain = new StagedStrategyChain <BuilderStage>(); baseStrategyChain.AddNew <PolicyInjectionStrategy>(BuilderStage.PreCreation); baseStrategyChain.AddNew <BuildKeyMappingStrategy>(BuilderStage.PreCreation); baseStrategyChain.AddNew <BuildPlanStrategy>(BuilderStage.Creation); buildPlanStrategyChain = new StagedStrategyChain <BuilderStage>(); buildPlanStrategyChain.AddNew <DynamicMethodConstructorStrategy>(BuilderStage.Creation); buildPlanStrategyChain.AddNew <DynamicMethodPropertySetterStrategy>(BuilderStage.Initialization); }
public void SetUp() { baseStrategyChain = new StagedStrategyChain<BuilderStage>(); baseStrategyChain.AddNew<PolicyInjectionStrategy>(BuilderStage.PreCreation); baseStrategyChain.AddNew<BuildKeyMappingStrategy>(BuilderStage.PreCreation); baseStrategyChain.AddNew<BuildPlanStrategy>(BuilderStage.Creation); buildPlanStrategyChain = new StagedStrategyChain<BuilderStage>(); buildPlanStrategyChain.AddNew<DynamicMethodConstructorStrategy>(BuilderStage.Creation); buildPlanStrategyChain.AddNew<DynamicMethodPropertySetterStrategy>(BuilderStage.Initialization); }
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()); // Not used in Win8 //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); }
public void SetUp() { builder = new Builder(); strategies = new StagedStrategyChain <BuilderStage>(); strategies.AddNew <ConfigurationNameMappingStrategy>(BuilderStage.PreCreation); MockNameMapper.invoked = false; }
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<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 <IBuildPlanCreatorPolicy>(policy); return(context); }
private TestingBuilderContext GetContext() { StagedStrategyChain <BuilderStage> chain = new StagedStrategyChain <BuilderStage>(); chain.AddNew <DynamicMethodConstructorStrategy>(BuilderStage.Creation); DynamicMethodBuildPlanCreatorPolicy policy = new DynamicMethodBuildPlanCreatorPolicy(chain); TestingBuilderContext context = new TestingBuilderContext(); context.Strategies.Add(new SingletonStrategy()); context.PersistentPolicies.SetDefault <IConstructorSelectorPolicy>( new ConstructorSelectorPolicy <InjectionConstructorAttribute>()); context.PersistentPolicies.SetDefault <IBuildPlanCreatorPolicy>(policy); return(context); }
private MockBuilderContext GetContext() { StagedStrategyChain <BuilderStage> chain = new StagedStrategyChain <BuilderStage>(); chain.AddNew <DynamicMethodPropertySetterStrategy>(BuilderStage.Initialization); DynamicMethodBuildPlanCreatorPolicy policy = new DynamicMethodBuildPlanCreatorPolicy(chain); MockBuilderContext context = new MockBuilderContext(); context.Strategies.Add(new LifetimeStrategy()); context.Policies.SetDefault <IConstructorSelectorPolicy>( new ConstructorSelectorPolicy <InjectionConstructorAttribute>()); context.Policies.SetDefault <IPropertySelectorPolicy>( new PropertySelectorPolicy <DependencyAttribute>()); context.Policies.SetDefault <IBuildPlanCreatorPolicy>(policy); return(context); }
DependencyContainer(IReadableLocator innerLocator, IPolicyList innerPolicies, StagedStrategyChain <BuilderStage> innerStrategies, IDependencyContainerConfigurator configurator) { locator = new Locator(innerLocator); policies = new PolicyList(innerPolicies); strategies = new StagedStrategyChain <BuilderStage>(innerStrategies); RegisterSingletonInstance <IObjectFactory>(this); if (innerStrategies == null) { strategies.AddNew <BuildKeyMappingStrategy>(BuilderStage.PreCreation); strategies.AddNew <SingletonStrategy>(BuilderStage.PreCreation); strategies.AddNew <ConstructorReflectionStrategy>(BuilderStage.PreCreation); strategies.AddNew <MethodReflectionStrategy>(BuilderStage.PreCreation); strategies.AddNew <PropertyReflectionStrategy>(BuilderStage.PreCreation); strategies.AddNew <EventBrokerReflectionStrategy>(BuilderStage.PreCreation); strategies.AddNew <InterceptionReflectionStrategy>(BuilderStage.PreCreation); strategies.AddNew <InterfaceInterceptionStrategy>(BuilderStage.Creation); strategies.AddNew <VirtualInterceptionStrategy>(BuilderStage.Creation); strategies.AddNew <CreationStrategy>(BuilderStage.Creation); strategies.AddNew <PropertySetterStrategy>(BuilderStage.Initialization); strategies.AddNew <MethodCallStrategy>(BuilderStage.Initialization); strategies.AddNew <EventBrokerStrategy>(BuilderStage.Initialization); strategies.AddNew <BuilderAwareStrategy>(BuilderStage.PostInitialization); strategies.AddNew <RemotingInterceptionStrategy>(BuilderStage.PostInitialization); } if (innerPolicies == null) { policies.SetDefault <ICreationPolicy>(new DefaultCreationPolicy()); } locator.Add(typeof(EventBrokerService), new EventBrokerService()); if (configurator != null) { configurator.Configure(this); } }
public void RegisterStrategy <TStrategy>(BuilderStage stage) where TStrategy : IBuilderStrategy, new() { strategies.AddNew <TStrategy>(stage); }