public static PluginGraph BuildGraphFromAssembly(Assembly assembly) { var graph = new PluginGraph(); graph.Scan(x => x.Assembly(assembly)); graph.Seal(); return(graph); }
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); }
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"); }
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"); }
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"); }
public void SetUp() { var graph = new PluginGraph(); graph.Scan(x => x.Assembly("StructureMap.Testing.Widget")); DataMother.WriteDocument("IntegratedTest.XML"); MementoSource source1 = new XmlFileMementoSource("IntegratedTest.XML", "GrandChildren", "GrandChild"); MementoSource source2 = new XmlFileMementoSource("IntegratedTest.XML", "Children", "Child"); MementoSource source3 = new XmlFileMementoSource("IntegratedTest.XML", "Parents", "Parent"); graph.FindFamily(typeof (GrandChild)).AddMementoSource(source1); graph.FindFamily(typeof (Child)).AddMementoSource(source2); graph.FindFamily(typeof (Parent)).AddMementoSource(source3); container = new Container(graph); }
public void CanCreateTheAutoFilledInstance() { // Builds a PluginGraph that includes all of the PluginFamily's and Plugin's // defined in this file var pluginGraph = new PluginGraph(); pluginGraph.Scan(x => x.Assembly(Assembly.GetExecutingAssembly())); pluginGraph.Seal(); var manager = new Container(pluginGraph); var mustang = (Mustang) manager.GetInstance(typeof (IAutomobile), "Mustang"); Assert.IsNotNull(mustang); Assert.IsTrue(mustang.Engine is PushrodEngine); }