本文整理汇总了C#中StructureMap.Graph.PluginGraph.FindFamily方法的典型用法代码示例。如果您正苦于以下问题:C# PluginGraph.FindFamily方法的具体用法?C# PluginGraph.FindFamily怎么用?C# PluginGraph.FindFamily使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StructureMap.Graph.PluginGraph
的用法示例。
在下文中一共展示了PluginGraph.FindFamily方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: add_type_adds_a_plugin_for_type_once_and_only_once
public void add_type_adds_a_plugin_for_type_once_and_only_once()
{
var graph = new PluginGraph();
graph.AddType(typeof (IThingy), typeof (BigThingy));
PluginFamily family = graph.FindFamily(typeof (IThingy));
family.InstanceCount.ShouldEqual(1);
graph.AddType(typeof (IThingy), typeof (BigThingy));
family.InstanceCount.ShouldEqual(1);
}
示例2: EnumSetter
public void EnumSetter()
{
var graph = new PluginGraph();
PluginFamily family = graph.FindFamily(typeof (IGridColumn));
family.AddPlugin(typeof (EnumGridColumn));
family.AddInstance(_source.GetMemento("Enum"));
var manager = new Container(graph);
var column = (EnumGridColumn) manager.GetInstance<IGridColumn>("Enum");
Assert.AreEqual(FontStyleEnum.BodyText, column.FontStyle);
}
示例3: StringSetter
public void StringSetter()
{
var graph = new PluginGraph();
PluginFamily family = graph.FindFamily(typeof (IGridColumn));
family.AddPlugin(typeof (StringGridColumn));
InstanceMemento memento = _source.GetMemento("String");
family.AddInstance(memento);
var manager = new Container(graph);
var column = (StringGridColumn) manager.GetInstance<IGridColumn>("String");
Assert.AreEqual(memento.GetProperty("Name"), column.Name);
}
示例4: PrimitiveNonStringSetter
public void PrimitiveNonStringSetter()
{
var graph = new PluginGraph();
PluginFamily family = graph.FindFamily(typeof (IGridColumn));
family.AddPlugin(typeof (LongGridColumn));
InstanceMemento memento = _source.GetMemento("Long");
long count = long.Parse(memento.GetProperty("Count"));
family.AddInstance(memento);
var manager = new Container(graph);
var column = (LongGridColumn) manager.GetInstance<IGridColumn>("Long");
Assert.AreEqual(count, column.Count);
}
示例5: FindMasterInstances
public void FindMasterInstances(PluginGraph graph)
{
var master = new Dictionary<Type, Instance>();
foreach (var pair in _instances)
{
PluginFamily family = graph.FindFamily(pair.Key);
Instance masterInstance = ((IDiagnosticInstance) pair.Value)
.FindInstanceForProfile(family, _name, graph.Log);
master.Add(pair.Key, masterInstance);
}
_instances = master;
}
示例6: FindPluginFamilies
public void FindPluginFamilies()
{
var graph = new PluginGraph();
graph.Scan(x => { x.Assembly("StructureMap.Testing.Widget"); });
graph.FindFamily(typeof (IWidget)).DefaultInstanceKey = "Blue";
graph.CreateFamily(typeof (WidgetMaker));
graph.Seal();
foreach (PluginFamily family in graph.PluginFamilies)
{
Console.WriteLine(family.PluginType.AssemblyQualifiedName);
}
Assert.AreEqual(5, graph.FamilyCount);
}
示例7: BuildClassWithEnumeration
public void BuildClassWithEnumeration()
{
var graph = new PluginGraph();
PluginFamily family = graph.FindFamily(typeof (Cow));
family.AddPlugin(typeof (Cow), "Default");
var manager = new Container(graph);
manager.Configure(r => r.InstanceOf<Cow>().Is.OfConcreteType<Cow>()
.WithName("Angus")
.WithProperty("Name").EqualTo("Bessie")
.WithProperty("Breed").EqualTo("Angus")
.WithProperty("Weight").EqualTo("1200"));
var angus = manager.GetInstance<Cow>("Angus");
Assert.IsNotNull(angus);
Assert.AreEqual("Bessie", angus.Name, "Name");
Assert.AreEqual(BreedEnum.Angus, angus.Breed, "Breed");
Assert.AreEqual(1200, angus.Weight, "Weight");
}
示例8: ReadChildArrayProperty
public void ReadChildArrayProperty()
{
var graph = new PluginGraph();
graph.FindFamily(typeof (Rule)).AddPlugin(typeof (ComplexRule));
MemoryInstanceMemento memento = ComplexRule.GetMemento();
memento.SetProperty(XmlConstants.PLUGGED_TYPE, typeof (ComplexRule).AssemblyQualifiedName);
memento.AddChildArray("cars", new InstanceMemento[]
{
MemoryInstanceMemento.CreateReferencedInstanceMemento("Ford"),
MemoryInstanceMemento.CreateReferencedInstanceMemento("Chevy"),
MemoryInstanceMemento.CreateReferencedInstanceMemento("Dodge"),
});
var instance = (IStructuredInstance) memento.ReadInstance(graph, typeof (Rule));
Instance[] instances = instance.GetChildArray("cars");
Assert.AreEqual(3, instances.Length);
assertIsReference(instances[0], "Ford");
assertIsReference(instances[1], "Chevy");
assertIsReference(instances[2], "Dodge");
}
示例9: FindRegistriesWithinPluginGraphSeal
public void FindRegistriesWithinPluginGraphSeal()
{
var graph = new PluginGraph();
var scanner = new AssemblyScanner();
scanner.AssemblyContainingType(typeof (RedGreenRegistry));
scanner.LookForRegistries();
scanner.ScanForAll(graph);
graph.Seal();
var colors = new List<string>();
PluginFamily family = graph.FindFamily(typeof (IWidget));
family.Instances.Each(instance => colors.Add(instance.Name));
Assert.Contains("Red", colors);
Assert.Contains("Green", colors);
Assert.Contains("Yellow", colors);
Assert.Contains("Blue", colors);
Assert.Contains("Brown", colors);
Assert.Contains("Black", colors);
}
示例10: when_retrieving_by_try_get_named_instance_that_does_exist
public void when_retrieving_by_try_get_named_instance_that_does_exist()
{
var red = new ColorService("red");
var green = new ColorService("green");
var graph = new PluginGraph();
PluginFamily family = graph.FindFamily(typeof (IService));
family.AddInstance(new ObjectInstance(red).WithName("red"));
family.AddInstance(new ObjectInstance(green).WithName("green"));
var session = new BuildSession(graph);
session.TryGetInstance<IService>("red").ShouldBeTheSameAs(red);
session.TryGetInstance<IService>("green").ShouldBeTheSameAs(green);
}
示例11: FindPlugins
public void FindPlugins()
{
var graph = new PluginGraph();
graph.Scan(x =>
{
x.Assembly("StructureMap.Testing.Widget");
x.Assembly("StructureMap.Testing.Widget2");
});
graph.FindFamily(typeof (Rule));
graph.Seal();
PluginFamily family = graph.FindFamily(typeof (Rule));
Assert.IsNotNull(family);
Assert.AreEqual(5, family.PluginCount, "There are 5 Rule classes in the two assemblies");
}
示例12: PutsRightNumberOfPluginsIntoAFamily
public void PutsRightNumberOfPluginsIntoAFamily()
{
var graph = new PluginGraph();
graph.Scan(x => { x.Assembly("StructureMap.Testing.Widget"); });
graph.FindFamily(typeof (IWidget)).DefaultInstanceKey = "Blue";
graph.Seal();
PluginFamily family = graph.FindFamily(typeof (IWidget));
Assert.IsNotNull(family);
Assert.AreEqual("Blue", family.DefaultInstanceKey);
Assert.AreEqual(4, family.PluginCount, "3 different IWidget classes are marked as Pluggable");
}
示例13: PicksUpManuallyAddedPlugin
public void PicksUpManuallyAddedPlugin()
{
var graph = new PluginGraph();
graph.Scan(x => { x.Assembly("StructureMap.Testing.Widget"); });
graph.FindFamily(typeof (IWidget)).DefaultInstanceKey = "Blue";
PluginFamily family = graph.FindFamily(typeof (IWidget));
family.AddPlugin(typeof (NotPluggableWidget), "NotPluggable");
graph.Seal();
Assert.IsNotNull(family);
Assert.AreEqual(
5,
family.PluginCount,
"5 different IWidget classes are marked as Pluggable, + the manual add");
}
示例14: 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.ConfigureWithoutScanning(graph);
Assert.IsFalse(graph.ContainsFamily(typeof (IServer)));
Assert.IsTrue(graph.ContainsFamily(typeof(IConvention)));
PluginFamily family = graph.FindFamily(typeof (IConvention));
family.Seal();
Assert.AreEqual(1, family.InstanceCount);
}
示例15: ConfiguredInstance
public ConfiguredInstance(InstanceMemento memento, PluginGraph graph, Type pluginType)
: base(memento.FindPlugin(graph.FindFamily(pluginType)))
{
read(memento, graph, pluginType);
}