本文整理汇总了C#中Registry.As方法的典型用法代码示例。如果您正苦于以下问题:C# Registry.As方法的具体用法?C# Registry.As怎么用?C# Registry.As使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Registry
的用法示例。
在下文中一共展示了Registry.As方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public void Apply(PluginGraph graph)
{
var registry = new Registry();
_interfaces.Each(@interface =>
{
var expression = registry.For(@interface);
ConfigureFamily(expression);
var exactMatches = _concretions.Where(x => x.CanBeCastTo(@interface)).ToArray();
if (exactMatches.Length == 1)
{
expression.Use(exactMatches.Single());
}
else
{
exactMatches.Each(type => expression.Add(type));
}
if ([email protected]())
{
addConcretionsThatCouldBeClosed(@interface, expression);
}
});
_concretions.Each(t => graph.ConnectedConcretions.Fill(t));
registry.As<IPluginGraphConfiguration>().Configure(graph);
}
示例2: Apply
public void Apply(PluginGraph graph)
{
var registry = new Registry();
_interfaces.Each(@interface => {
var expression = registry.For(@interface);
ConfigureFamily(expression);
_concretions.Where(x => x.CanBeCastTo(@interface)).Each(type => expression.Add(type));
});
registry.As<IPluginGraphConfiguration>().Configure(graph);
}
示例3: Configure
/// <summary>
/// Add configuration to a PluginGraph with the Registry DSL
/// </summary>
/// <param name = "action"></param>
public void Configure(Action<Registry> action)
{
var registry = new Registry();
action(registry);
registry.As<IPluginGraphConfiguration>().Configure(this);
}
示例4: Process_to_PluginGraph
public void Process_to_PluginGraph()
{
var graph = new PluginGraph();
var scanner = new DefaultConventionScanner();
var registry = new Registry();
scanner.Process(typeof (Convention), registry);
registry.As<IPluginGraphConfiguration>().Configure(graph);
graph.Families.Has(typeof (IServer)).ShouldBeFalse();
graph.Families.Has(typeof (IConvention)).ShouldBeTrue();
var family = graph.Families[typeof (IConvention)];
family.Instances.Count().ShouldBe(1);
}