当前位置: 首页>>代码示例>>C#>>正文


C# Registry.BuildInstancesOf方法代码示例

本文整理汇总了C#中Registry.BuildInstancesOf方法的典型用法代码示例。如果您正苦于以下问题:C# Registry.BuildInstancesOf方法的具体用法?C# Registry.BuildInstancesOf怎么用?C# Registry.BuildInstancesOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Registry的用法示例。


在下文中一共展示了Registry.BuildInstancesOf方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AsAnotherScope

        public void AsAnotherScope()
        {
            var registry = new Registry();
            CreatePluginFamilyExpression<IGateway> expression =
                registry.BuildInstancesOf<IGateway>().CacheBy(InstanceScope.ThreadLocal);
            Assert.IsNotNull(expression);

            PluginGraph pluginGraph = registry.Build();

            PluginFamily family = pluginGraph.FindFamily(typeof (IGateway));

            family.Lifecycle.ShouldBeOfType<ThreadLocalStorageLifecycle>();
        }
开发者ID:satish860,项目名称:StructureMap3,代码行数:13,代码来源:CreatePluginFamilyTester.cs

示例2: CanMakeAClassWithNoConstructorParametersWithoutADefinedMemento

        public void CanMakeAClassWithNoConstructorParametersWithoutADefinedMemento()
        {
            var registry = new Registry();
            registry.Scan(x => x.Assembly("StructureMap.Testing.Widget3"));

            registry.BuildInstancesOf<IGateway>();

            PluginGraph graph = registry.Build();
            var pipelineGraph = new PipelineGraph(graph);

            var session = new BuildSession(graph);

            var gateway =
                (DefaultGateway) session.CreateInstance(typeof (IGateway), "Default");

            Assert.IsNotNull(gateway);
        }
开发者ID:hp4711,项目名称:structuremap,代码行数:17,代码来源:InstanceFactoryTester.cs

示例3: SetUp

        public void SetUp()
        {
            var registry = new Registry();
            registry.BuildInstancesOf<Rule>();
            registry.Scan(x =>
            {
                x.Assembly("StructureMap.Testing.Widget");
                x.Assembly("StructureMap.Testing.Widget2");
            });

            PluginGraph graph = registry.Build();

            var pipelineGraph = new PipelineGraph(graph);
            _session = new BuildSession(pipelineGraph, graph.InterceptorLibrary);
        }
开发者ID:joshuaflanagan,项目名称:structuremap,代码行数:15,代码来源:ConfiguredInstanceTester.cs

示例4: BuildPluginFamilyAsPerRequest

        public void BuildPluginFamilyAsPerRequest()
        {
            var registry = new Registry();
            CreatePluginFamilyExpression<IGateway> expression =
                registry.BuildInstancesOf<IGateway>();
            Assert.IsNotNull(expression);

            PluginGraph pluginGraph = registry.Build();

            PluginFamily family = pluginGraph.FindFamily(typeof (IGateway));
            family.Lifecycle.ShouldBeNull();
        }
开发者ID:satish860,项目名称:StructureMap3,代码行数:12,代码来源:CreatePluginFamilyTester.cs

示例5: BuildInstancesOfType

        public void BuildInstancesOfType()
        {
            var registry = new Registry();
            registry.BuildInstancesOf<IGateway>();
            PluginGraph pluginGraph = registry.Build();

            Assert.IsTrue(pluginGraph.ContainsFamily(typeof (IGateway)));
        }
开发者ID:satish860,项目名称:StructureMap3,代码行数:8,代码来源:CreatePluginFamilyTester.cs

示例6: PutAnInterceptorIntoTheInterceptionChainOfAPluginFamilyInTheDSL

        public void PutAnInterceptorIntoTheInterceptionChainOfAPluginFamilyInTheDSL()
        {
            var lifecycle = new StubbedLifecycle();

            var registry = new Registry();
            registry.BuildInstancesOf<IGateway>().LifecycleIs(lifecycle);

            PluginGraph pluginGraph = registry.Build();

            pluginGraph.FindFamily(typeof (IGateway)).Lifecycle.ShouldBeTheSameAs(lifecycle);
        }
开发者ID:satish860,项目名称:StructureMap3,代码行数:11,代码来源:CreatePluginFamilyTester.cs

示例7: CanOverrideTheDefaultInstanceAndCreateAnAllNewPluginOnTheFly

        public void CanOverrideTheDefaultInstanceAndCreateAnAllNewPluginOnTheFly()
        {
            var registry = new Registry();
            registry.BuildInstancesOf<IGateway>().TheDefaultIsConcreteType<FakeGateway>();
            PluginGraph pluginGraph = registry.Build();

            Assert.IsTrue(pluginGraph.ContainsFamily(typeof (IGateway)));

            var manager = new Container(pluginGraph);
            var gateway = (IGateway) manager.GetInstance(typeof (IGateway));

            Assert.IsInstanceOfType(typeof (FakeGateway), gateway);
        }
开发者ID:satish860,项目名称:StructureMap3,代码行数:13,代码来源:CreatePluginFamilyTester.cs

示例8: CanOverrideTheDefaultInstance1

        public void CanOverrideTheDefaultInstance1()
        {
            var registry = new Registry();
            // Specify the default implementation for an interface
            registry.BuildInstancesOf<IGateway>().TheDefaultIsConcreteType<StubbedGateway>();

            PluginGraph pluginGraph = registry.Build();
            Assert.IsTrue(pluginGraph.ContainsFamily(typeof (IGateway)));

            var manager = new Container(pluginGraph);
            var gateway = (IGateway) manager.GetInstance(typeof (IGateway));

            Assert.IsInstanceOfType(typeof (StubbedGateway), gateway);
        }
开发者ID:satish860,项目名称:StructureMap3,代码行数:14,代码来源:CreatePluginFamilyTester.cs

示例9: TheDefaultInstanceIsPickedUpFromTheAttribute

        public void TheDefaultInstanceIsPickedUpFromTheAttribute()
        {
            var registry = new Registry();
            registry.BuildInstancesOf<IGateway>();
            registry.Scan(x => x.AssemblyContainingType<IGateway>());

            PluginGraph pluginGraph = registry.Build();

            Assert.IsTrue(pluginGraph.ContainsFamily(typeof (IGateway)));

            var manager = new Container(pluginGraph);
            var gateway = (IGateway) manager.GetInstance(typeof (IGateway));

            Assert.IsInstanceOfType(typeof (DefaultGateway), gateway);
        }
开发者ID:joshuaflanagan,项目名称:structuremap,代码行数:15,代码来源:CreatePluginFamilyTester.cs

示例10: GotPluginsThatAreMarkedAsPluggable

        public void GotPluginsThatAreMarkedAsPluggable()
        {
            var registry = new Registry();
            registry.Scan(x => x.AssemblyContainingType<IWidget>());

            registry.BuildInstancesOf<IWidget>();
            PluginGraph pluginGraph = registry.Build();

            PluginFamily pluginFamily = pluginGraph.FindFamily(typeof (IWidget));
            Plugin plugin = pluginFamily.FindPlugin(typeof (ColorWidget));
            Assert.IsNotNull(plugin);
        }
开发者ID:hp4711,项目名称:structuremap,代码行数:12,代码来源:PluginGraphBuilderTester.cs

示例11: SetUp

        public void SetUp()
        {
            var registry = new Registry();
            registry.ForRequestedType(typeof (IService<>))
                .AddConcreteType(typeof (Service<>))
                .AddConcreteType(typeof (Service2<>));

            registry.BuildInstancesOf<ISomething>()
                .TheDefaultIsConcreteType<SomethingOne>()
                .AddConcreteType<SomethingTwo>();

            registry.BuildInstancesOf<IServiceProvider>().AddConcreteType<MyDataSet>().AddConcreteType<MyDataView>();

            PluginGraph graph = registry.Build();
            var pipeline = new PipelineGraph(graph);

            _model = new Container(graph).Model;

            _container = new Container(graph);
        }
开发者ID:hp4711,项目名称:structuremap,代码行数:20,代码来源:ModelQueryTester.cs


注:本文中的Registry.BuildInstancesOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。