本文整理汇总了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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}