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


C# Registry.Build方法代码示例

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


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

示例1: BuildInstancesOfType

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

            Assert.IsTrue(pluginGraph.Families.Has(typeof (IGateway)));
        }
开发者ID:e-tobi,项目名称:structuremap,代码行数:8,代码来源:CreatePluginFamilyTester.cs

示例2: as_another_lifecycle

        public void as_another_lifecycle()
        {
            var registry = new Registry();
            registry.For<IGateway>(Lifecycles.ThreadLocal).ShouldNotBeNull();

            var pluginGraph = registry.Build();

            var family = pluginGraph.Families[typeof(IGateway)];

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

示例3: AsAnotherScope

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

            PluginGraph pluginGraph = registry.Build();

            PluginFamily family = pluginGraph.Families[typeof(IGateway)];

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

示例4: 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

示例5: SetUp

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

            var graph = registry.Build();

            _session = BuildSession.ForPluginGraph(graph);
        }
开发者ID:goraw,项目名称:structuremap,代码行数:13,代码来源:ConfiguredInstanceTester.cs

示例6: AddAProfileWithANamedDefault

        public void AddAProfileWithANamedDefault()
        {
            string theProfileName = "TheProfile";
            string theDefaultName = "TheDefaultName";

            var registry = new Registry();
            registry.Profile(theProfileName)
                .For<IWidget>().UseNamedInstance(theDefaultName)
                .For<Rule>().UseNamedInstance("DefaultRule");

            ObjectInstance masterInstance =
                registry.For<IWidget>().Add(new AWidget()).WithName(theDefaultName);

            ProfileManager manager = registry.Build().ProfileManager;
            Assert.AreSame(masterInstance, manager.GetDefault(typeof (IWidget), theProfileName));
        }
开发者ID:joshuaflanagan,项目名称:structuremap,代码行数:16,代码来源:ProfileExpressionTester.cs

示例7: ConfiguredInstanceTester

        public ConfiguredInstanceTester()
        {
            var registry = new Registry();
            registry.For<Rule>();
            registry.Scan(x =>
            {
                x.Assembly("StructureMap.Testing.Widget");
                x.Assembly("StructureMap.Testing.Widget2");

                x.WithDefaultConventions();
            });

            var graph = registry.Build();

            _session = BuildSession.ForPluginGraph(graph);
        }
开发者ID:khellang,项目名称:structuremap,代码行数:16,代码来源:ConfiguredInstanceTester.cs

示例8: 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

示例9: ModelQueryTester

        public ModelQueryTester()
        {
            var registry = new Registry();
            registry.For(typeof(IService<>)).Add(typeof(Service<>));
            registry.For(typeof(IService<>)).Add(typeof(Service2<>));

            registry.For<ISomething>().Use<SomethingOne>();
            registry.For<ISomething>().Add<SomethingTwo>();

            registry.For<IServiceProvider>().Add<MyDataSet>();
            registry.For<IServiceProvider>().Add<MyDataView>();

            var graph = registry.Build();

            _model = new Container(graph).Model;

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

示例10: AddAProfileWithInlineInstanceDefinition

        public void AddAProfileWithInlineInstanceDefinition()
        {
            string theProfileName = "TheProfile";

            var registry = new Registry();
            registry.Profile(theProfileName)
                .For<IWidget>().UseConcreteType<AWidget>();

            PluginGraph graph = registry.Build();

            ProfileManager profileManager = graph.ProfileManager;
            Instance defaultInstance = profileManager.GetDefault(typeof (IWidget), theProfileName);

            Assert.AreEqual(StructureMap.Pipeline.Profile.InstanceKeyForProfile(theProfileName), defaultInstance.Name);

            var manager = new Container(graph);
            manager.SetDefaultsToProfile(theProfileName);
            var widget = (AWidget) manager.GetInstance<IWidget>();
            Assert.IsNotNull(widget);
        }
开发者ID:joshuaflanagan,项目名称:structuremap,代码行数:20,代码来源:ProfileExpressionTester.cs

示例11: 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

示例12: Return_the_same_object_within_a_session_for_the_default_of_a_plugin_type

        public void Return_the_same_object_within_a_session_for_the_default_of_a_plugin_type()
        {
            var count = 0;

            var instance = new LambdaInstance<ColorRule>("counting", () =>
            {
                count++;
                return new ColorRule("Red");
            });
            var registry = new Registry();
            registry.For<ColorRule>().UseInstance(instance);

            var graph = registry.Build();
            var session = BuildSession.ForPluginGraph(graph);

            var result1 = session.GetInstance(typeof (ColorRule));
            var result2 = session.GetInstance(typeof (ColorRule));
            var result3 = session.GetInstance(typeof (ColorRule));
            var result4 = session.GetInstance(typeof (ColorRule));

            count.ShouldBe(1);

            result1.ShouldBeTheSameAs(result2);
            result1.ShouldBeTheSameAs(result3);
            result1.ShouldBeTheSameAs(result4);
        }
开发者ID:RANENTONG,项目名称:structuremap,代码行数:26,代码来源:BuildSessionTester.cs

示例13: 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

示例14: 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

示例15: 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


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