private static IPlanBuilderPolicy CreatePlanBuilder(PolicyList innerPolicies) { BuilderStrategyChain chain = new BuilderStrategyChain(); chain.Add(new CallConstructorStrategy()); chain.Add(new SetPropertiesStrategy()); return(new DynamicMethodPlanBuilderPolicy(chain, innerPolicies)); }
public void CreationPolicyWillRecordSingletonsUsingLocalLifetimeContainerOnly() { BuilderStrategyChain chain = new BuilderStrategyChain(); chain.Add(new CreationStrategy()); Locator parentLocator = new Locator(); LifetimeContainer container = new LifetimeContainer(); parentLocator.Add(typeof(ILifetimeContainer), container); Locator childLocator = new Locator(parentLocator); PolicyList policies = new PolicyList(); policies.SetDefault <ICreationPolicy>(new DefaultCreationPolicy()); policies.SetDefault <ISingletonPolicy>(new SingletonPolicy(true)); BuilderContext ctx = new BuilderContext(chain, childLocator, policies); object obj = ctx.HeadOfChain.BuildUp(ctx, typeof(object), null, null); Assert.IsNotNull(obj); Assert.IsNull(childLocator.Get(new DependencyResolutionLocatorKey(typeof(object), null))); }
private static IPlanBuilderPolicy CreatePlanBuilder() { BuilderStrategyChain chain = new BuilderStrategyChain(); chain.Add(new CallConstructorStrategy()); chain.Add(new SetPropertiesStrategy()); chain.Add(new CallMethodsStrategy()); PolicyList policies = new PolicyList(); policies.SetDefault <IConstructorChooserPolicy>(new AttributeBasedConstructorChooser()); policies.SetDefault <IPropertyChooserPolicy>(new AttributeBasedPropertyChooser()); policies.SetDefault <IMethodChooserPolicy>(new AttributeBasedMethodChooser()); return(new DynamicMethodPlanBuilderPolicy(chain, policies)); }
public MockBuilderContext(params IBuilderStrategy[] strategies) { Guard.ArgumentNotNull(strategies, "strategies"); foreach (IBuilderStrategy strategy in strategies) { chain.Add(strategy); } }
private static IPlanBuilderPolicy CreatePlanBuilder(MockReturnExistingPlanBuilderStrategy mockPlanBuilderStrategy) { BuilderStrategyChain chain = new BuilderStrategyChain(); chain.Add(mockPlanBuilderStrategy); PolicyList policies = new PolicyList(); return(new DynamicMethodPlanBuilderPolicy(chain, policies)); }
public MockBuilderContext(params IBuilderStrategy[] strategies) { if (strategies == null) { throw new ArgumentNullException("strategies"); } foreach (IBuilderStrategy strategy in strategies) { chain.Add(strategy); } }
public void CreationPolicyWillRecordSingletonsUsingLocalLifetimeContainerOnly() { BuilderStrategyChain chain = new BuilderStrategyChain(); chain.Add(new CreationStrategy()); Locator parentLocator = new Locator(); LifetimeContainer container = new LifetimeContainer(); parentLocator.Add(typeof(ILifetimeContainer), container); Locator childLocator = new Locator(parentLocator); PolicyList policies = new PolicyList(); policies.SetDefault<ICreationPolicy>(new DefaultCreationPolicy()); policies.SetDefault<ISingletonPolicy>(new SingletonPolicy(true)); BuilderContext ctx = new BuilderContext(chain, childLocator, policies); object obj = ctx.HeadOfChain.BuildUp(ctx, typeof(object), null, null); Assert.IsNotNull(obj); Assert.IsNull(childLocator.Get(new DependencyResolutionLocatorKey(typeof(object), null))); }