本文整理汇总了C#中Registry.IncludeRegistry方法的典型用法代码示例。如果您正苦于以下问题:C# Registry.IncludeRegistry方法的具体用法?C# Registry.IncludeRegistry怎么用?C# Registry.IncludeRegistry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Registry
的用法示例。
在下文中一共展示了Registry.IncludeRegistry方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetContainer
public static IContainer GetContainer()
{
var register = new Registry();
register.IncludeRegistry<MirutradingRegistry>();
IContainer container = new Container(register);
return container;
}
示例2: Process
public void Process(Type type, Registry registry)
{
if (!Registry.IsPublicRegistry(type)) return;
// TODO -- good exception message
var r = (Registry)Activator.CreateInstance(type);
registry.IncludeRegistry(r);
}
示例3: Initialize
public static IContainer Initialize() {
//var container = new Container(_ =>
//{
// _.Scan(x =>
// {
// x.TheCallingAssembly();
// x.WithDefaultConventions();
// });
//});
var registry = new Registry();
registry.IncludeRegistry<PurpleRegistry>();
// build a container
var container = new Container(registry);
return container;
}
示例4: include_a_registry
public void include_a_registry()
{
var registry = new Registry();
registry.IncludeRegistry<YellowBlueRegistry>();
registry.IncludeRegistry<RedGreenRegistry>();
registry.IncludeRegistry<PurpleRegistry>();
// build a container
var container = new Container(registry);
// verify the default implementation and total registered implementations
container.GetInstance<IWidget>().ShouldBeOfType<AWidget>();
container.GetAllInstances<IWidget>().Count().ShouldEqual(5);
}
示例5: include_an_existing_registry_should_not_reevaluate_the_registry
public void include_an_existing_registry_should_not_reevaluate_the_registry()
{
var registry1 = new Registry();
registry1.IncludeRegistry<MutatingRegistry>();
var registry2 = new Registry();
registry2.IncludeRegistry<MutatingRegistry>();
var container = new Container(config => {
config.AddRegistry(registry1);
config.AddRegistry(registry2);
});
container.GetInstance<IWidget>().ShouldBeOfType<AWidget>();
}
示例6: include_an_existing_registry_should_not_reevaluate_the_registry
public void include_an_existing_registry_should_not_reevaluate_the_registry()
{
var registry1 = new Registry();
registry1.IncludeRegistry<MutatingRegistry>();
var registry2 = new Registry();
registry2.IncludeRegistry<MutatingRegistry>();
var container = new Container(config =>
{
config.AddRegistry(registry1);
config.AddRegistry(registry2);
});
container.Model.Registries.Count(x => x.GetType() == typeof(MutatingRegistry)).ShouldBe(1);
}
示例7: include_a_registry
public void include_a_registry()
{
var registry = new Registry();
registry.IncludeRegistry<YellowBlueRegistry>();
registry.IncludeRegistry<RedGreenRegistry>();
registry.IncludeRegistry<PurpleRegistry>();
var container = new Container(registry);
container.GetInstance<IWidget>().ShouldBeOfType<AWidget>();
container.GetAllInstances<IWidget>().Count.ShouldEqual(5);
}
示例8: include_an_existing_registry_should_not_reevaluate_the_registry
public void include_an_existing_registry_should_not_reevaluate_the_registry()
{
var registry1 = new Registry();
registry1.IncludeRegistry<MutatingRegistry>();
var registry2 = new Registry();
registry2.IncludeRegistry<MutatingRegistry>();
var container = new Container(config =>
{
config.AddRegistry(registry1);
config.AddRegistry(registry2);
});
// If MutatingRegistry is applied more than once, it will
// change the default IWidget to MutatedWidget and cause
// the following specification to fail
container.GetInstance<IWidget>().ShouldBeOfType<AWidget>();
}