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


C# Registry.Profile方法代码示例

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


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

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

示例2: AddAProfileWithANamedDefault

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

            var registry = new Registry();

            registry.For<IWidget>().Add(new NamedWidget(theDefaultName)).Named(theDefaultName);
            registry.For<IWidget>().Use<AWidget>();

            registry.Profile(theProfileName, p => {
                p.For<IWidget>().Use(theDefaultName);
                p.For<Rule>().Use("DefaultRule");
            });

            var container = new Container(registry);
            container.GetProfile(theProfileName).GetInstance<IWidget>().ShouldBeOfType<NamedWidget>()
                     .Name.ShouldEqual(theDefaultName);
        }
开发者ID:smerrell,项目名称:structuremap,代码行数:19,代码来源:profiles_acceptance_tester.cs

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

示例4: Add_default_instance_with_literal

        public void Add_default_instance_with_literal()
        {
            var registry = new Registry();
            var theWidget = new AWidget();

            string theProfileName = "something";
            registry.Profile(theProfileName, p => {
                p.For<IWidget>().Use(theWidget);
            });

            PluginGraph graph = registry.Build();
            graph.Profile("something").Families[typeof (IWidget)].GetDefaultInstance()
                                                                 .ShouldBeOfType<ObjectInstance>()
                                                                 .Object.ShouldBeTheSameAs(theWidget);
        }
开发者ID:smerrell,项目名称:structuremap,代码行数:15,代码来源:profiles_acceptance_tester.cs

示例5: Add_default_instance_with_literal

        public void Add_default_instance_with_literal()
        {
            var registry = new Registry();
            var theWidget = new AWidget();

            string theProfileName = "something";
            registry.Profile(theProfileName)
                .For<IWidget>().Use(theWidget);

            PluginGraph graph = registry.Build();
            var instance = (ObjectInstance) graph.ProfileManager.GetDefault(typeof (IWidget), "something");

            Assert.AreSame(theWidget, instance.Object);
        }
开发者ID:joshuaflanagan,项目名称:structuremap,代码行数:14,代码来源:ProfileExpressionTester.cs


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