本文整理汇总了C#中Registry.BuildInstancesOf方法的典型用法代码示例。如果您正苦于以下问题:C# Registry.BuildInstancesOf方法的具体用法?C# Registry.BuildInstancesOf怎么用?C# Registry.BuildInstancesOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Registry
的用法示例。
在下文中一共展示了Registry.BuildInstancesOf方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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>();
}
示例2: 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);
}
示例3: 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);
}
示例4: 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();
}
示例5: BuildInstancesOfType
public void BuildInstancesOfType()
{
var registry = new Registry();
registry.BuildInstancesOf<IGateway>();
PluginGraph pluginGraph = registry.Build();
Assert.IsTrue(pluginGraph.ContainsFamily(typeof (IGateway)));
}
示例6: PutAnInterceptorIntoTheInterceptionChainOfAPluginFamilyInTheDSL
public void PutAnInterceptorIntoTheInterceptionChainOfAPluginFamilyInTheDSL()
{
var lifecycle = new StubbedLifecycle();
var registry = new Registry();
registry.BuildInstancesOf<IGateway>().LifecycleIs(lifecycle);
PluginGraph pluginGraph = registry.Build();
pluginGraph.FindFamily(typeof (IGateway)).Lifecycle.ShouldBeTheSameAs(lifecycle);
}
示例7: CanOverrideTheDefaultInstanceAndCreateAnAllNewPluginOnTheFly
public void CanOverrideTheDefaultInstanceAndCreateAnAllNewPluginOnTheFly()
{
var registry = new Registry();
registry.BuildInstancesOf<IGateway>().TheDefaultIsConcreteType<FakeGateway>();
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 (FakeGateway), gateway);
}
示例8: CanOverrideTheDefaultInstance1
public void CanOverrideTheDefaultInstance1()
{
var registry = new Registry();
// Specify the default implementation for an interface
registry.BuildInstancesOf<IGateway>().TheDefaultIsConcreteType<StubbedGateway>();
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 (StubbedGateway), gateway);
}
示例9: 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);
}
示例10: GotPluginsThatAreMarkedAsPluggable
public void GotPluginsThatAreMarkedAsPluggable()
{
var registry = new Registry();
registry.Scan(x => x.AssemblyContainingType<IWidget>());
registry.BuildInstancesOf<IWidget>();
PluginGraph pluginGraph = registry.Build();
PluginFamily pluginFamily = pluginGraph.FindFamily(typeof (IWidget));
Plugin plugin = pluginFamily.FindPlugin(typeof (ColorWidget));
Assert.IsNotNull(plugin);
}
示例11: SetUp
public void SetUp()
{
var registry = new Registry();
registry.ForRequestedType(typeof (IService<>))
.AddConcreteType(typeof (Service<>))
.AddConcreteType(typeof (Service2<>));
registry.BuildInstancesOf<ISomething>()
.TheDefaultIsConcreteType<SomethingOne>()
.AddConcreteType<SomethingTwo>();
registry.BuildInstancesOf<IServiceProvider>().AddConcreteType<MyDataSet>().AddConcreteType<MyDataView>();
PluginGraph graph = registry.Build();
var pipeline = new PipelineGraph(graph);
_model = new Container(graph).Model;
_container = new Container(graph);
}