private MockBuilderContext CreateContext()
        {
            MockBuilderContext context = new MockBuilderContext();
            context.Strategies.Add(new LifetimeStrategy());
            context.Strategies.Add(new EventBrokerWireupStrategy());

            return context;
        }
Пример #2
0
        /// <summary>
        /// A convenience method to do a new buildup operation on an existing context. This
        ///             overload allows you to specify extra policies which will be in effect for the duration
        ///             of the build.
        /// </summary>
        /// <param name="newBuildKey">Key defining what to build up.</param><param name="childCustomizationBlock">A delegate that takes a <see cref="T:Microsoft.Practices.ObjectBuilder2.IBuilderContext"/>. This
        ///             is invoked with the new child context before the build up process starts. This gives callers
        ///             the opportunity to customize the context for the build process.</param>
        /// <returns>
        /// Created object.
        /// </returns>
        public object NewBuildUp(NamedTypeBuildKey newBuildKey, Action<IBuilderContext> childCustomizationBlock)
        {
            var newContext = new MockBuilderContext
            {
                strategies = strategies,
                policies = policies,
                transientPolicies = transientPolicies,
                lifetime = lifetime,
                originalBuildKey = newBuildKey,
                buildKey = newBuildKey
            };

            childCustomizationBlock(newContext);

            this.ChildContext = newContext;

            return newContext.Strategies.ExecuteBuildUp(newContext);
        }
        private MockBuilderContext CreateContext()
        {
            MockBuilderContext context = new MockBuilderContext();
            context.Strategies.Add(new EventBrokerReflectionStrategy());

            return context;
        }
Пример #4
0
        /// <summary>
        /// A convenience method to do a new buildup operation on an existing context.
        /// </summary>
        /// <param name="newBuildKey">Key to use to build up.</param>
        /// <returns>
        /// Created object.
        /// </returns>
        public object NewBuildUp(NamedTypeBuildKey newBuildKey)
        {
            MockBuilderContext newContext = new MockBuilderContext();
            newContext.strategies = strategies;
            newContext.policies = policies;
            newContext.transientPolicies = transientPolicies;
            newContext.lifetime = lifetime;
            newContext.originalBuildKey = newBuildKey;
            newContext.buildKey = newBuildKey;
            this.ChildContext = newContext;

            return newContext.Strategies.ExecuteBuildUp(newContext);
        }