From: <jer...@us...> - 2007-04-01 22:21:18
|
Revision: 36 http://structuremap.svn.sourceforge.net/structuremap/?rev=36&view=rev Author: jeremydmiller Date: 2007-04-01 15:21:15 -0700 (Sun, 01 Apr 2007) Log Message: ----------- Added the <DefaultInstance> node capability, documentation, set the default profile from code Modified Paths: -------------- trunk/Docs/Configuration.htm trunk/Docs/Default.htm trunk/Source/StructureMap/Configuration/ConfigurationParser.cs trunk/Source/StructureMap/Configuration/FamilyParser.cs trunk/Source/StructureMap/Configuration/GraphObject.cs trunk/Source/StructureMap/Configuration/PluginGraphReport.cs trunk/Source/StructureMap/Configuration/StructureMapConfigurationSection.cs trunk/Source/StructureMap/Configuration/UserControlMemento.cs trunk/Source/StructureMap/Configuration/XmlConstants.cs trunk/Source/StructureMap/Graph/PluginGraph.cs trunk/Source/StructureMap/InstanceMemento.cs trunk/Source/StructureMap/Source/XmlNodeInstanceMemento.cs trunk/Source/StructureMap/Verification/StartUp.cs trunk/Source/StructureMap.Testing/Configuration/DSL/UserControlExpressionTester.cs trunk/Source/StructureMap.Testing/Configuration/FamilyParserTester.cs trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs trunk/Source/StructureMap.Testing/ObjectMother.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj trunk/Source/StructureMap.Testing/StructureMapConfigurationTester.cs trunk/Source/StructureMap.Testing/TestData/DataMother.cs trunk/Source/StructureMap.Testing.Widget/IWidget.cs trunk/Source/StructureMap.Testing.Widget/Rule.cs Added Paths: ----------- trunk/Source/StructureMap.Testing/Configuration/DefaultInstanceNodeTester.cs trunk/Source/StructureMap.Testing/TestData/DefaultInstance.xml Modified: trunk/Docs/Configuration.htm =================================================================== --- trunk/Docs/Configuration.htm 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Docs/Configuration.htm 2007-04-01 22:21:15 UTC (rev 36) @@ -54,6 +54,7 @@ <A href="#log4net">log4net</A><BR> <A href="#Machine">Machine</A><BR> <A href="#PluginFamily">PluginFamily</A><BR> + <A href="#DefaultInstance">DefaultInstance</A><BR> <A href="#Profile">Profile</A><BR> <A href="#Instance">Instance</A><BR> <A href="#Interceptors">Interceptors</A><BR> @@ -63,6 +64,7 @@ <A href="#Setter">Setter</A><BR> <A href="#Source">Source</A><BR> <A href="#Property">Property</A></P> + <HR width="100%" SIZE="1"> <!--StructureMap node--> <A name="StructureMap"></A> @@ -81,6 +83,10 @@ <TD>Directs StructureMap to use the named Profile as the default profile at runtime</TD> </TR> + <tr> + <td>MementoStyle</td> + <td>Specifies the type of Instance Memento definition between "Node" normalized and "Attribute" normalized. For backwards compatibility, the default value is "Node"</td> + </tr> </TABLE> </DIV> <p><A href="#TopOfPage">Back to Top</A><BR> @@ -175,11 +181,19 @@ <HR> <A name="Machine"></A> <H3><Machine> Element</H3> - <P>Machine level overrides for default instances of one or more PluginFamily\x92s</P> + <P>Machine level overrides for default instances of one or more PluginFamily\x92s. New in version 2.0 is the ability to define the instance for the type specified by the Type attribute inline in an embedded <Instance> node</P> <H4>Sample</H4> - <pre class="xml-sample"><Machine Name="SERVER" Profile="Local"> + <pre class="xml-sample"> +<Machine Name="SERVER" Profile="Local"> <Override Type="StructureMap.Testing.Widget.IWidget" DefaultKey="Orange"/> -</Machine></pre> +</Machine> + + <Override Type="StructureMap.Testing.Widget.Rule"> + <Instance Type="Color" Color="Green"/> + </Override> + + +</pre> <H4>Required Attributes</H4> <DIV class="schema-table"><TABLE width="100%" border="1" cellPadding="1" cellSpacing="1" ID="Table3"> <TR> @@ -253,6 +267,62 @@ <A href="#TopOfPage">Back to Top</A><BR> <BR> <HR> + + + + + <A name="DefaultInstance"></A> + <H3><DefaultInstance> Element</H3> + <P>Shorthand way to explicitly define the default instance of a PluginType in one element. Explicitly directs and + configures StructureMap to create instances of the CLR Type specified by the "PluginType" attribute. The DefaultInstance node also represents an Instance node, and the arguments to the constructor function and setter properties follow the same rules as an Instance node.</P> + <H4>Sample</H4> + <pre class="xml-sample"><DefaultInstance PluginType="StructureMap.Testing.Widget.Rule,StructureMap.Testing" PluggedType="StructureMap.Testing.Widget.ColorRule,StructureMap.Testing" Scope="Singleton"> Color="Red" + <BR> </DefaultInstance></pre> + <H4>Required Attributes</H4> + <DIV class="schema-table"><TABLE width="100%" border="1" cellPadding="1" cellSpacing="1" ID="Table19"> + <TR> + <TH width="25%"> + Attribute</TH><TH width="75%">Description</TH></TR> + <TR> + <TD>PluginType</TD> + <TD>Assembly qualified name of the PluginType, as in PluginType instance = ObjectFactory.GetInstance<PluginType>()</TD> + </TR> + <TR> + <TD>PluggedType</TD> + <TD>The assembly qualified name of the concrete type</TD> + </TR> + </TABLE> + </DIV> + <H4>Optional Attributes</H4> + <DIV class="schema-table"><TABLE width="100%" border="1" cellPadding="1" cellSpacing="1" ID="Table20"> + <TR> + <TH width="25%"> + Attribute</TH><TH width="75%">Description</TH></TR> + <TR> + <TD>Name</TD> + <TD>The InstanceKey of the default instance. If unspecified, StructureMap will create a default name. This is mostly for diagnostics.</TD> + </TR> + <TR> + <TD>Scope</TD> + <TD>Controls the "scope" of the requested + instance. The default value is + PerRequest. Valid values are + PerRequest, Singleton, ThreadLocal, + HttpContext, and Hybrid (uses HttpContext if + available, otherwise ThreadLocal)</TD> + </TR> + </TABLE> + </DIV> + <BR> + <A href="#TopOfPage">Back to Top</A><BR> + <BR> + <HR> + + + + + + <A name="Profile"></A> <H3><Profile> Element</H3> <P>Models a named set of overrides for default instances of one or more @@ -261,7 +331,14 @@ <pre class="xml-sample"><Profile Name="Blue"> <Override Type="StructureMap.Testing.Widget.Rule" DefaultKey="Blue"/> <Override Type="StructureMap.Testing.Widget.IWidget" DefaultKey="Blue"/> -</Profile></pre> +</Profile> + +<Override Type="StructureMap.Testing.Widget.Rule"> + <Instance Type="Color" Color="Green"/> +</Override> + + +</pre> <H4>Required Attributes</H4> <DIV class="schema-table"><TABLE width="100%" border="1" cellPadding="1" cellSpacing="1" ID="Table7"> <TR> @@ -285,7 +362,16 @@ <Property Name="Attribute" Value="MyDad" /> <Property Name="Value" Value="10" /> </Instance><BR> -</PluginFamily></pre> +</PluginFamily> + +* OR * + +<PluginFamily><BR> <Instance Key="Bigger" PluggedType="Assembly Qualified Name"> + <Property Name="Attribute" Value="MyDad" /> + <Property Name="Value" Value="10" /> + </Instance><BR> +</PluginFamily> +</pre> <H4>Required Attributes</H4> <DIV class="schema-table"><TABLE width="100%" border="1" cellPadding="1" cellSpacing="1" ID="Table8"> <TR> @@ -308,6 +394,10 @@ <TR> <TH width="25%"> Attribute</TH><TH width="75%">Description</TH></TR> + <tr> + <td>PluggedType</td> + <td>An alternative to the Type attribute. Allows you to specify the assembly qualified type of the concrete class directly</td> + </tr> <TR> <TD>Template</TD> <TD>When using the Modified: trunk/Docs/Default.htm =================================================================== --- trunk/Docs/Default.htm 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Docs/Default.htm 2007-04-01 22:21:15 UTC (rev 36) @@ -15,7 +15,7 @@ border="0" alt="SourceForge.net Logo"></A> </p> <P style="LINE-HEIGHT: 25px"> - <A href="default.htm">Home</A><BR> + <A href="Default.htm">Home</A><BR> <a href="http://sourceforge.net/projects/structuremap">StructureMap on SourceForge</a><br> <A href="Basic Architecture.htm">Basic Architecture</A><BR> <A href="Concepts.htm">Concepts</A><BR> @@ -53,10 +53,26 @@ generic flexibility mechanisms. Used judiciously, StructureMap can greatly enhance the opportunities for code reuse by minimizing direct coupling between classes and configuration mechanisms.</p> + <p> + StructureMap is released under the permissive Apache 2 OSS license. You are + free to download, modify, or redistribute StructureMap in any way you see fit.</p> <p> - New in version 1.0 is the ability to create - self-diagnostic deployment configurations</p> - <p>Consider using StructureMap if you\x85</p> + New for version 2.0</p> + <ul> + <li>Full support for pluggable generic types. IService<T> and Service<T>. + Auto wiring support for generic arguments</li> + <li>Simpler, more terse Xml configuration. Fewer steps and less Xml.</li> + <li>Define Profile instances inline for less Xml</li> + <li>New Fluent Interface API for programmatic configuration. If so desired, all configuration can now be done in code at application startup</li> + <li>The default StructureMap.config file is now optional</li> + <li>Use multiple configuration files additively for easier configuration of composite + applications</li> + <li>Pluggable ASP.Net UserControl's</li> + <li>Inject prototype instances</li> + <li>Inject prebuilt singleton instances </li> + </ul> + <p> + Consider using StructureMap if you\x85</p> <ul> <li> Require significant extensibility @@ -72,44 +88,14 @@ <p>Do not use StructureMap if an application or process requires little flexibility. The abstraction and indirection afforded by StructureMap is unnecessary and even harmful in simpler systems or processes. </p> - <p>New for version 1.0</p> - <ul> - <li>New terser <a href="AttributeNormalized.htm"> - Attribute Normalized Xml</a> configuration style</li> - <li>The ability to <a href="Configuration.htm#Include"> - include secondary configuration files</a></li> - <li>Set a default profile at the top level of - configuration</li> - <li><a href="StructureMapDoctor.htm"> - StructureMapExplorer</a>, a WinForms tool to explore and - debug StructureMap configurations</li> - <li>New <a href="NAnt%20Tasks.htm">ancillary NAnt tasks</a>, - including functionality to create a file "manifest" to - verify the contents of an application deployment</li> - <li>New <a href="MementoSources.htm">configuration - storage choices</a></li> - <li>New Instance <a href="Scoping.htm">lifecycle scoping - </a>options</li> - <li>The "<a href="MementoSources.htm">TemplatedMementoSource</a>" - option for large instance graphs</li> - <li>Streamlined codebase with less coupling and greater - test coverage. Greatly improved diagnostics.</li> - <li>New methods on ObjectFactory<ul> - <li>GetAllInstances() - returns all instances of a - certain type</li> - <li>WhatDoIHave() - for runtime troubleshooting</li> - <li>GetInstance(Type, InstanceMemento)</li> - </ul> - </li> - </ul> <h3>Status</h3> - <p>StructureMap has been in multiple production systems + <p>StructureMap is the oldest IoC/DI tool for .Net development and has been used in multiple production systems since - June 2004. The current version 1.0 was released in - May 2006. StructureMap is maintained and developed by + June 2004. The current version 2.0 was released in April 2007. StructureMap is maintained and developed by <a href="mailto:jer...@ya...?subject=StructureMap">Jeremy D. Miller</a>, <a href="http://codebetter.com/blogs/jeremy.miller">The - Shade Tree Developer</a></p> + Shade Tree Developer</a>. + </p> <p>Recent Articles</p> <ul> <li> @@ -123,9 +109,9 @@ </ul> <h3>Feature List</h3> <UL> - <LI> + <li> Creates objects using the <a href="http://picocontainer.codehaus.org/Constructor+Injection"> - Constructor Injection pattern</a> + Constructor Injection pattern</a> </li> <LI> Optionally, attach dependencies and other properties through Setter Injection (v0.90) Modified: trunk/Source/StructureMap/Configuration/ConfigurationParser.cs =================================================================== --- trunk/Source/StructureMap/Configuration/ConfigurationParser.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap/Configuration/ConfigurationParser.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -133,10 +133,6 @@ parseAssemblies(builder); } - public void ParseFamilies(IGraphBuilder builder) - { - parseFamilies(builder); - } public void ParseInstances(IGraphBuilder builder) { @@ -168,14 +164,21 @@ } - private void parseFamilies(IGraphBuilder builder) + public void ParseFamilies(IGraphBuilder builder) { - FamilyParser familyParser = new FamilyParser(builder); + FamilyParser familyParser = new FamilyParser(builder, _mementoCreator); + XmlNodeList familyNodes = findNodes(XmlConstants.PLUGIN_FAMILY_NODE); foreach (XmlElement familyElement in familyNodes) { familyParser.ParseFamily(familyElement); } + + XmlNodeList defaultNodes = findNodes(XmlConstants.DEFAULT_INSTANCE); + foreach (XmlElement element in defaultNodes) + { + familyParser.ParseDefaultElement(element); + } } Modified: trunk/Source/StructureMap/Configuration/FamilyParser.cs =================================================================== --- trunk/Source/StructureMap/Configuration/FamilyParser.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap/Configuration/FamilyParser.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -10,10 +10,12 @@ public class FamilyParser { private readonly IGraphBuilder _builder; + private readonly XmlMementoCreator _mementoCreator; - public FamilyParser(IGraphBuilder builder) + public FamilyParser(IGraphBuilder builder, XmlMementoCreator mementoCreator) { _builder = builder; + _mementoCreator = mementoCreator; } public void ParseFamily(XmlElement familyElement) @@ -32,6 +34,23 @@ attachInterceptors(typePath, familyElement); } + public void ParseDefaultElement(XmlElement element) + { + TypePath pluginTypePath = TypePath.GetTypePath(element.GetAttribute(XmlConstants.PLUGIN_TYPE)); + InstanceScope scope = findScope(element); + string name = element.GetAttribute(XmlConstants.NAME); + if (string.IsNullOrEmpty(name)) + { + name = "DefaultInstanceOf" + pluginTypePath.AssemblyQualifiedName; + } + + InstanceMemento memento = _mementoCreator.CreateMemento(element); + memento.InstanceKey = name; + + _builder.AddPluginFamily(pluginTypePath, name, new string[0], scope); + _builder.RegisterMemento(pluginTypePath, memento); + } + private InstanceScope findScope(XmlElement familyElement) { InstanceScope returnValue = InstanceScope.PerRequest; @@ -87,5 +106,7 @@ _builder.AddInterceptor(pluginTypePath, interceptorMemento); } } + + } } \ No newline at end of file Modified: trunk/Source/StructureMap/Configuration/GraphObject.cs =================================================================== --- trunk/Source/StructureMap/Configuration/GraphObject.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap/Configuration/GraphObject.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; namespace StructureMap.Configuration Modified: trunk/Source/StructureMap/Configuration/PluginGraphReport.cs =================================================================== --- trunk/Source/StructureMap/Configuration/PluginGraphReport.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap/Configuration/PluginGraphReport.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -89,7 +89,6 @@ FamilyToken[] returnValue = new FamilyToken[_families.Count]; _families.Values.CopyTo(returnValue, 0); - return returnValue; } Modified: trunk/Source/StructureMap/Configuration/StructureMapConfigurationSection.cs =================================================================== --- trunk/Source/StructureMap/Configuration/StructureMapConfigurationSection.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap/Configuration/StructureMapConfigurationSection.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -1,7 +1,4 @@ - - using System.Configuration; -using System.Diagnostics; using System.Xml; namespace StructureMap.Configuration @@ -18,8 +15,8 @@ public static XmlNode GetStructureMapConfiguration() { object config = ConfigurationManager.GetSection(XmlConstants.STRUCTUREMAP); - + return null; /* object o = ConfigurationSettings.GetConfig(XmlConstants.STRUCTUREMAP); @@ -32,4 +29,4 @@ */ } } -} +} \ No newline at end of file Modified: trunk/Source/StructureMap/Configuration/UserControlMemento.cs =================================================================== --- trunk/Source/StructureMap/Configuration/UserControlMemento.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap/Configuration/UserControlMemento.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -65,4 +65,4 @@ get { throw new NotImplementedException(); } } } -} +} \ No newline at end of file Modified: trunk/Source/StructureMap/Configuration/XmlConstants.cs =================================================================== --- trunk/Source/StructureMap/Configuration/XmlConstants.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap/Configuration/XmlConstants.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -30,6 +30,8 @@ public const string NODE_STYLE = "Node"; public const string ATTRIBUTE_STYLE = "Attribute"; public const string PLUGGED_TYPE = "PluggedType"; + public const string PLUGIN_TYPE = "PluginType"; + public const string DEFAULT_INSTANCE = "DefaultInstance"; private XmlConstants() Modified: trunk/Source/StructureMap/Graph/PluginGraph.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginGraph.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap/Graph/PluginGraph.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -2,7 +2,6 @@ using System.Collections; using System.Collections.Generic; using System.Reflection; -using StructureMap.Configuration; using StructureMap.Configuration.DSL; namespace StructureMap.Graph Modified: trunk/Source/StructureMap/InstanceMemento.cs =================================================================== --- trunk/Source/StructureMap/InstanceMemento.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap/InstanceMemento.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -254,7 +254,7 @@ public Plugin CreateInferredPlugin() { - string pluggedTypeName = getPropertyValue(XmlConstants.PLUGGED_TYPE); + string pluggedTypeName = getPluggedType(); if (string.IsNullOrEmpty(pluggedTypeName)) { return null; @@ -266,6 +266,11 @@ } } + protected virtual string getPluggedType() + { + return this.getPropertyValue(XmlConstants.PLUGGED_TYPE); + } + public virtual object Build(IInstanceCreator creator) { return creator.BuildInstance(this); Modified: trunk/Source/StructureMap/Source/XmlNodeInstanceMemento.cs =================================================================== --- trunk/Source/StructureMap/Source/XmlNodeInstanceMemento.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap/Source/XmlNodeInstanceMemento.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -1,4 +1,5 @@ using System.Xml; +using StructureMap.Configuration; using StructureMap.Configuration.Tokens; namespace StructureMap.Source @@ -33,6 +34,11 @@ } + protected override string getPluggedType() + { + return getAttribute(XmlConstants.PLUGGED_TYPE); + } + private XmlNode getChildNode(string Key) { string xpath = string.Format("Property[@Name='{0}']", Key); Modified: trunk/Source/StructureMap/Verification/StartUp.cs =================================================================== --- trunk/Source/StructureMap/Verification/StartUp.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap/Verification/StartUp.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -61,7 +61,7 @@ PluginGraphConsoleWriter consoleWriter = new PluginGraphConsoleWriter(report); consoleWriter.WriteAll = true; consoleWriter.WriteProblems = true; - + using (TextWriter writer = new StreamWriter(_allFile)) { consoleWriter.Write(writer); Modified: trunk/Source/StructureMap.Testing/Configuration/DSL/UserControlExpressionTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Configuration/DSL/UserControlExpressionTester.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap.Testing/Configuration/DSL/UserControlExpressionTester.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -1,5 +1,4 @@ using NUnit.Framework; -using Rhino.Mocks; using StructureMap.Configuration; using StructureMap.Configuration.DSL; using StructureMap.Graph; @@ -19,9 +18,10 @@ { string theUrl = "alskdjf"; - UserControlExpression expression = new UserControlExpression(typeof(IControl), theUrl); + UserControlExpression expression = new UserControlExpression(typeof (IControl), theUrl); - UserControlMemento memento = (UserControlMemento) ((IMementoBuilder) expression).BuildMemento(new PluginGraph()); + UserControlMemento memento = + (UserControlMemento) ((IMementoBuilder) expression).BuildMemento(new PluginGraph()); Assert.IsNotNull(memento); Assert.AreEqual(theUrl, memento.Url); @@ -35,10 +35,11 @@ string theUrl = "alskdjf"; string theName = "the name"; - UserControlExpression expression = new UserControlExpression(typeof(IControl), theUrl); + UserControlExpression expression = new UserControlExpression(typeof (IControl), theUrl); expression.WithName(theName); - UserControlMemento memento = (UserControlMemento)((IMementoBuilder)expression).BuildMemento(new PluginGraph()); + UserControlMemento memento = + (UserControlMemento) ((IMementoBuilder) expression).BuildMemento(new PluginGraph()); Assert.IsNotNull(memento); Assert.AreEqual(theUrl, memento.Url); @@ -48,6 +49,5 @@ public interface IControl { - } -} +} \ No newline at end of file Added: trunk/Source/StructureMap.Testing/Configuration/DefaultInstanceNodeTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Configuration/DefaultInstanceNodeTester.cs (rev 0) +++ trunk/Source/StructureMap.Testing/Configuration/DefaultInstanceNodeTester.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -0,0 +1,59 @@ +using NUnit.Framework; +using Rhino.Mocks; +using StructureMap.Attributes; +using StructureMap.Graph; +using StructureMap.Testing.TestData; +using StructureMap.Testing.Widget; + +namespace StructureMap.Testing.Configuration +{ + [TestFixture] + public class DefaultInstanceNodeTester + { + private InstanceManager _manager; + private PluginGraph _graph; + + [SetUp] + public void SetUp() + { + _graph = DataMother.GetPluginGraph("DefaultInstance.xml"); + _manager = new InstanceManager(_graph); + } + + [Test] + public void CreateTheInferredPluginCorrectly() + { + // Who needs the Law of Demeter? + InstanceMemento memento = _graph.PluginFamilies[typeof (IWidget)].Source.GetAllMementos()[0]; + Assert.IsNotEmpty(memento.ConcreteKey); + Assert.IsNotNull(memento.ConcreteKey); + } + + [Test] + public void DefaultNameOfRule() + { + PluginFamily family = _graph.PluginFamilies[typeof (Rule)]; + Assert.AreEqual("TheBlueOne", family.DefaultInstanceKey); + } + + [Test] + public void GetTheWidget() + { + ColorWidget widget = (ColorWidget) _manager.CreateInstance<IWidget>(); + Assert.AreEqual("Red", widget.Color); + + ColorWidget widget2 = (ColorWidget)_manager.CreateInstance<IWidget>(); + Assert.AreNotSame(widget, widget2); + } + + [Test] + public void GetTheRule() + { + ColorRule rule = (ColorRule) _manager.CreateInstance<Rule>(); + Assert.AreEqual("Blue", rule.Color); + + ColorRule rule2 = (ColorRule)_manager.CreateInstance<Rule>(); + Assert.AreSame(rule, rule2); + } + } +} Modified: trunk/Source/StructureMap.Testing/Configuration/FamilyParserTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Configuration/FamilyParserTester.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap.Testing/Configuration/FamilyParserTester.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -6,6 +6,7 @@ using StructureMap.Configuration; using StructureMap.Graph; using StructureMap.Graph.Configuration; +using StructureMap.Source; using StructureMap.Testing.Widget3; namespace StructureMap.Testing.Configuration @@ -23,7 +24,7 @@ public void SetUp() { _builderMock = new DynamicMock(typeof (IGraphBuilder)); - _parser = new FamilyParser((IGraphBuilder) _builderMock.MockInstance); + _parser = new FamilyParser((IGraphBuilder) _builderMock.MockInstance, new XmlMementoCreator(XmlMementoStyle.NodeNormalized, XmlConstants.TYPE_ATTRIBUTE, XmlConstants.ATTRIBUTE_STYLE)); _document = new XmlDocument(); _document.LoadXml("<PluginFamily />"); Modified: trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -3,7 +3,6 @@ using System.Reflection; using NUnit.Framework; using StructureMap.Configuration; -using StructureMap.Configuration.DSL; using StructureMap.Configuration.Tokens; using StructureMap.Graph; using StructureMap.Testing.GenericWidgets; @@ -184,7 +183,7 @@ [Test] public void TryDiagnosticsWithGenerics() { - Debug.WriteLine(typeof(ISimpleThing<>).AssemblyQualifiedName); + Debug.WriteLine(typeof (ISimpleThing<>).AssemblyQualifiedName); DataMother.WriteDocument("GenericsTesting.xml"); PluginGraphReport report = PluginGraphBuilder.BuildReportFromXml("GenericsTesting.xml"); Modified: trunk/Source/StructureMap.Testing/ObjectMother.cs =================================================================== --- trunk/Source/StructureMap.Testing/ObjectMother.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap.Testing/ObjectMother.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -32,7 +32,6 @@ _instanceManager = new InstanceManager(_pluginGraph); _instanceDefaultManager = _pluginGraph.DefaultManager; - } Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2007-04-01 22:21:15 UTC (rev 36) @@ -181,6 +181,7 @@ </Compile> <Compile Include="Configuration\ConfigurationParserCollectionTester.cs" /> <Compile Include="Configuration\ConfigurationParserTester.cs" /> + <Compile Include="Configuration\DefaultInstanceNodeTester.cs" /> <Compile Include="Configuration\DiagnosticGraphBuilderTester.cs"> <SubType>Code</SubType> </Compile> @@ -490,6 +491,7 @@ </ItemGroup> <ItemGroup> <Content Include="Sample.xml" /> + <EmbeddedResource Include="TestData\DefaultInstance.xml" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <PropertyGroup> Modified: trunk/Source/StructureMap.Testing/StructureMapConfigurationTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/StructureMapConfigurationTester.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap.Testing/StructureMapConfigurationTester.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -30,7 +30,9 @@ Assert.IsNotNull(report); } - [Test, ExpectedException(typeof(ApplicationException), "StructureMap detected configuration or environmental problems. Check the StructureMap error file")] + [Test, + ExpectedException(typeof (ApplicationException), + "StructureMap detected configuration or environmental problems. Check the StructureMap error file")] public void OnStartUpFail() { StructureMapConfiguration.OnStartUp().FailOnException(); @@ -81,16 +83,14 @@ StructureMapConfiguration.UseDefaultStructureMapConfigFile = false; StructureMapConfiguration.PullConfigurationFromAppConfig = true; - ColorThing<string, bool> thing = (ColorThing<string, bool>) ObjectFactory.GetInstance < IThing<string, bool>>(); + ColorThing<string, bool> thing = + (ColorThing<string, bool>) ObjectFactory.GetInstance<IThing<string, bool>>(); Assert.AreEqual("Cornflower", thing.Color, "Cornflower is the color from the App.config file"); } - - } public interface ISomething { - } public class Something : ISomething Modified: trunk/Source/StructureMap.Testing/TestData/DataMother.cs =================================================================== --- trunk/Source/StructureMap.Testing/TestData/DataMother.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap.Testing/TestData/DataMother.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -11,8 +11,8 @@ public class DataMother { private static ArrayList _files = new ArrayList(); - + private DataMother() { } Added: trunk/Source/StructureMap.Testing/TestData/DefaultInstance.xml =================================================================== --- trunk/Source/StructureMap.Testing/TestData/DefaultInstance.xml (rev 0) +++ trunk/Source/StructureMap.Testing/TestData/DefaultInstance.xml 2007-04-01 22:21:15 UTC (rev 36) @@ -0,0 +1,4 @@ +<StructureMap MementoStyle="Attribute"> + <DefaultInstance PluginType="StructureMap.Testing.Widget.IWidget,StructureMap.Testing.Widget" PluggedType="StructureMap.Testing.Widget.ColorWidget,StructureMap.Testing.Widget" Color="Red" /> + <DefaultInstance PluginType="StructureMap.Testing.Widget.Rule,StructureMap.Testing.Widget" PluggedType="StructureMap.Testing.Widget.ColorRule,StructureMap.Testing.Widget" Color="Blue" Scope="Singleton" Name="TheBlueOne"/> +</StructureMap> Modified: trunk/Source/StructureMap.Testing.Widget/IWidget.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget/IWidget.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap.Testing.Widget/IWidget.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -47,7 +47,7 @@ public object Clone() { - return this.MemberwiseClone(); + return MemberwiseClone(); } } Modified: trunk/Source/StructureMap.Testing.Widget/Rule.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget/Rule.cs 2007-04-01 18:18:16 UTC (rev 35) +++ trunk/Source/StructureMap.Testing.Widget/Rule.cs 2007-04-01 22:21:15 UTC (rev 36) @@ -152,6 +152,4 @@ get { return _Value; } } } - - } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |