本文整理汇总了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)));
}
示例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>();
}
示例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>();
}
示例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>();
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例14: BuildInstancesOfType
public void BuildInstancesOfType()
{
var registry = new Registry();
registry.BuildInstancesOf<IGateway>();
PluginGraph pluginGraph = registry.Build();
Assert.IsTrue(pluginGraph.ContainsFamily(typeof (IGateway)));
}
示例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);
}