本文整理汇总了C#中Container.SetDefaultsToProfile方法的典型用法代码示例。如果您正苦于以下问题:C# Container.SetDefaultsToProfile方法的具体用法?C# Container.SetDefaultsToProfile怎么用?C# Container.SetDefaultsToProfile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Container
的用法示例。
在下文中一共展示了Container.SetDefaultsToProfile方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasADefaultInstanceKey
public void HasADefaultInstanceKey()
{
var manager = new Container(graph);
manager.SetDefaultsToProfile("Green");
var widget = (ColorWidget) manager.GetInstance<IWidget>();
Assert.AreEqual("Green", widget.Color);
}
开发者ID:satish860,项目名称:StructureMap3,代码行数:9,代码来源:InlineInstanceDefinitionInProfileAndMachineNodesTester.cs
示例2: CreateContainer
protected override IServiceLocator CreateContainer()
{
Registry registry = new UserInterfaceRegistry();
IContainer container = new Container(registry);
var commandLine = Environment.CommandLine.Split(' ');
if (commandLine.Length > 1)
container.SetDefaultsToProfile(commandLine[1]);
return new StructureMapAdapter(container);
}
示例3: Add_default_instance_by_lambda
public void Add_default_instance_by_lambda()
{
string theProfileName = "something";
IContainer container = new Container(r =>
{
r.Profile(theProfileName, x =>
{
x.For<IWidget>().Use(() => new AWidget());
x.For<Rule>().Use(() => new DefaultRule());
});
});
container.SetDefaultsToProfile(theProfileName);
Assert.IsInstanceOfType(typeof (AWidget), container.GetInstance<IWidget>());
Assert.IsInstanceOfType(typeof (DefaultRule), container.GetInstance<Rule>());
}
示例4: 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);
}
示例5: HasTheOverrideForProfile
public void HasTheOverrideForProfile()
{
var manager = new Container(graph);
manager.SetDefaultsToProfile("Blue");
var rule = (ColorRule) manager.GetInstance<Rule>();
Assert.AreEqual("Blue", rule.Color);
var widget = (ColorWidget) manager.GetInstance<IWidget>();
Assert.AreEqual("Blue", widget.Color);
}
开发者ID:satish860,项目名称:StructureMap3,代码行数:11,代码来源:InlineInstanceDefinitionInProfileAndMachineNodesTester.cs
示例6: SetTheProfile
public void SetTheProfile()
{
var manager = new Container(graph);
manager.SetDefaultsToProfile("Green");
var greenRule = (ColorRule) manager.GetInstance(typeof (Rule));
Assert.AreEqual("Green", greenRule.Color);
manager.SetDefaultsToProfile("Blue");
var blueRule = (ColorRule) manager.GetInstance(typeof (Rule));
Assert.AreEqual("Blue", blueRule.Color);
}
开发者ID:satish860,项目名称:StructureMap3,代码行数:13,代码来源:InlineInstanceDefinitionInProfileAndMachineNodesTester.cs
示例7: Add_default_instance_with_concrete_type
public void Add_default_instance_with_concrete_type()
{
string theProfileName = "something";
IContainer manager = new Container(registry =>
{
registry.Profile(theProfileName, p =>
{
p.For<IWidget>().UseConcreteType<AWidget>();
p.For<Rule>().UseConcreteType<DefaultRule>();
});
});
manager.SetDefaultsToProfile(theProfileName);
Assert.IsInstanceOfType(typeof (AWidget), manager.GetInstance<IWidget>());
Assert.IsInstanceOfType(typeof (DefaultRule), manager.GetInstance<Rule>());
}