コード例 #1
0
        private void RegisterDelegatingFactoryWithContext(bool buildSingletonObjectsWhenInvoked)
        {
            var targetBuilder = new ThingThatBuildsTargets();
            var factory = new DelegateInvokingFactoryObject<TargetToBuild>(targetBuilder.BuildTarget, buildSingletonObjectsWhenInvoked);

            Assume.That(ContextRegistry.GetContext(), Is.InstanceOf<IConfigurableApplicationContext>(), "test requires a registered context that implements IConfigurableApplicationContext!");

            var ctx = (IConfigurableApplicationContext)ContextRegistry.GetContext();
            ctx.ObjectFactory.RegisterSingleton("target", factory);
        }
コード例 #2
0
        private void RegisterDelegatingFactoryWithContext(bool buildSingletonObjectsWhenInvoked)
        {
            var targetBuilder = new ThingThatBuildsTargets();
            var factory       = new DelegateInvokingFactoryObject <TargetToBuild>(targetBuilder.BuildTarget, buildSingletonObjectsWhenInvoked);

            Assume.That(ContextRegistry.GetContext(), Is.InstanceOf <IConfigurableApplicationContext>(), "test requires a registered context that implements IConfigurableApplicationContext!");

            var ctx = (IConfigurableApplicationContext)ContextRegistry.GetContext();

            ctx.ObjectFactory.RegisterSingleton("target", factory);
        }