From: <jer...@us...> - 2008-06-23 17:44:03
|
Revision: 125 http://structuremap.svn.sourceforge.net/structuremap/?rev=125&view=rev Author: jeremydmiller Date: 2008-06-23 10:44:01 -0700 (Mon, 23 Jun 2008) Log Message: ----------- docs Modified Paths: -------------- trunk/Source/HTML/HTML.csproj trunk/Source/StructureMap/Configuration/PrimitiveArrayReader.cs trunk/Source/StructureMap/Container.cs trunk/Source/StructureMap/ExplicitArgsExpression.cs trunk/Source/StructureMap/IContainer.cs trunk/Source/StructureMap/ObjectFactory.cs trunk/Source/StructureMap.AutoMocking/RhinoAutoMocker.cs trunk/Source/StructureMap.Testing/AutoMocking/RhinoAutoMockerTester.cs trunk/Source/StructureMap.Testing/Configuration/DictionaryAndArrayArgumentTester.cs trunk/Source/StructureMap.Testing/Configuration/PrimitiveArrayReaderTester.cs trunk/Source/StructureMap.Testing/Graph/ContainerTester.cs trunk/Source/StructureMap.Testing/Graph/ExplicitArgumentTester.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj trunk/Source/StructureMap.Testing/TestData/StructureMap.config trunk/Source/StructureMap.Testing.Widget5/OtherGridColumn.cs trunk/Source/StructureMap.sln Added Paths: ----------- trunk/Source/HTML/AttributeNormalized.htm trunk/Source/HTML/AutoMocking.htm trunk/Source/HTML/BestPractices.htm trunk/Source/HTML/ChangingDefaultsAtRuntime.htm trunk/Source/HTML/CompositeConfiguration.htm trunk/Source/HTML/Concepts.htm trunk/Source/HTML/ConcreteTypes.htm trunk/Source/HTML/ConfigurationArchitecture.htm trunk/Source/HTML/ConfiguringStructureMap.htm trunk/Source/HTML/ConstructorAndSetterInjection.htm trunk/Source/HTML/CreatingContainer.htm trunk/Source/HTML/Default.htm trunk/Source/HTML/Diagnostics.htm trunk/Source/HTML/EnvironmentTests.htm trunk/Source/HTML/ExtendingStructureMap.htm trunk/Source/HTML/FAQ.htm trunk/Source/HTML/FluentInterfaceAPI.htm trunk/Source/HTML/Generics.htm trunk/Source/HTML/GentleGuide.htm trunk/Source/HTML/HTML.csproj.user trunk/Source/HTML/ImplicitInstances.htm trunk/Source/HTML/InjectingServicesAtRuntime.htm trunk/Source/HTML/Interception.htm trunk/Source/HTML/NodeNormalized.htm trunk/Source/HTML/Profiles.htm trunk/Source/HTML/QuickStart.htm trunk/Source/HTML/RetrievingServices.htm trunk/Source/HTML/RuntimeArchitecture.htm trunk/Source/HTML/Sample.xml trunk/Source/HTML/ScanningAssemblies.htm trunk/Source/HTML/Scoping.htm trunk/Source/HTML/StructureMapAndMocks.htm trunk/Source/HTML/StructureMapDoctor.htm trunk/Source/HTML/TroubleShooting.htm trunk/Source/HTML/UsingStructureMapWithinUnitTests.htm trunk/Source/HTML/WhatWillStructureMapDoWhenI.htm trunk/Source/HTML/XmlConfiguration.htm trunk/Source/StructureMap.Testing/Examples.cs trunk/Source/StructureMap.sln.cache Removed Paths: ------------- trunk/Source/StructureMap/Delegates.cs Property Changed: ---------------- trunk/ Property changes on: trunk ___________________________________________________________________ Name: svn:ignore - build results + build results push.bat Added: trunk/Source/HTML/AttributeNormalized.htm =================================================================== --- trunk/Source/HTML/AttributeNormalized.htm (rev 0) +++ trunk/Source/HTML/AttributeNormalized.htm 2008-06-23 17:44:01 UTC (rev 125) @@ -0,0 +1,462 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> + <head> + <title>Title</title> + <link rel="stylesheet" type="text/css" href="style.css"> + <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> + <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> + <style type="text/css"> + .style1 + { + font-weight: bold; + } + </style> + </head> + <body> + <h1>Attribute Normalized Xml Instances</h1> + <p>This style is a more terse configuration format that was + added in version 1.0. My recommendaton is to always use attribute normalized + Xml configuration by marking the <StructureMap> node with the + MementoStyle="Attribute" attribute by default anytime you are using Xml + configuration. </p> + <h4>Instance Root Node</h4> + <p>An Instance is defined in Xml starting from a root node. The actual name of + the root node varies depending upon the context that an Instance is being + configured. For example, the AddInstance, DefaultInstance, + PluginFamily/Instance, Interceptor, and Source nodes in Xml configuration are + all Instance roots. The rules for an Instance node are the same regardless + of the context. The root node optionally specifies the name of the + instance and the concrete type of the instance.</p> + <p>For a class called ColorRule,</p> +<!-- +{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red163\green21\blue21;\red0\green0\blue255;}??\fs20 [\cf3 Pluggable\cf0 (\cf4 "Color"\cf0 )]\par ?? \cf5 public\cf0 \cf5 class\cf0 \cf3 ColorRule\cf0 : \cf3 Rule\par ??\cf0 \{\par ?? \cf5 private\cf0 \cf5 string\cf0 _Color;\par ?? \cf5 public\cf0 \cf5 string\cf0 ID = \cf3 Guid\cf0 .NewGuid().ToString();\par ??\par ?? \cf5 public\cf0 ColorRule(\cf5 string\cf0 Color)\par ?? \{\par ?? _Color = Color;\par ?? \}\par ??\par ??\par ?? \cf5 public\cf0 \cf5 string\cf0 Color\par ?? \{\par ?? \cf5 get\cf0 \{ \cf5 return\cf0 _Color; \}\par ?? \}\par ?? \}} +--> + <div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"> + <p style="margin: 0px;"> + [<span style="color: #2b91af;">Pluggable</span>(<span + style="color: #a31515;">"Color"</span>)]</p> + <p style="margin: 0px;"> + <span style="color: blue;">public</span> <span style="color: blue;">class</span> + <span style="color: #2b91af;">ColorRule</span> : <span style="color: #2b91af;"> + Rule</span></p> + <p style="margin: 0px;"> + {</p> + <p style="margin: 0px;"> + <span style="color: blue;">private</span> + <span style="color: blue;">string</span> _Color;</p> + <p style="margin: 0px;"> + <span style="color: blue;">public</span> + <span style="color: blue;">string</span> ID = <span style="color: #2b91af;">Guid</span>.NewGuid().ToString();</p> + <p style="margin: 0px;"> + </p> + <p style="margin: 0px;"> + <span style="color: blue;">public</span> + ColorRule(<span style="color: blue;">string</span> Color)</p> + <p style="margin: 0px;"> + {</p> + <p style="margin: 0px;"> + _Color = Color;</p> + <p style="margin: 0px;"> + }</p> + <p style="margin: 0px;"> + </p> + <p style="margin: 0px;"> + </p> + <p style="margin: 0px;"> + <span style="color: blue;">public</span> + <span style="color: blue;">string</span> Color</p> + <p style="margin: 0px;"> + {</p> + <p style="margin: 0px;"> + + <span style="color: blue;">get</span> { <span style="color: blue;">return</span> + _Color; }</p> + <p style="margin: 0px;"> + }</p> + <p style="margin: 0px;"> + }</p> + </div> +<!--EndFragment--> +<p>an Instance node might look like:</p> +<!-- +{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1 <\cf3 Instance\cf1 \cf4 Key\cf1 =\cf0 "\cf1 Red\cf0 "\cf1 \cf4 Type\cf1 =\cf0 "\cf1 Color\cf0 "\cf1 \cf4 Color\cf1 =\cf0 "\cf1 Red\cf0 "\cf1 />} +--> + <div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"> + <p style="margin: 0px;"> + <span style="color: blue;"> <</span><span + style="color: #a31515;">Instance</span><span style="color: blue;"> </span> + <span style="color: red;">Key</span><span style="color: blue;">=</span>"<span + style="color: blue;">Red</span>"<span style="color: blue;"> </span> + <span style="color: red;">Type</span><span style="color: blue;">=</span>"<span + style="color: blue;">Color</span>"<span style="color: blue;"> </span> + <span style="color: red;">Color</span><span style="color: blue;">=</span>"<span + style="color: blue;">Red</span>"<span style="color: blue;"> /></span></p> + </div> +<!--EndFragment--> +<p>The "name" of an Instance is definied by the Key attribute. The concrete + type can be specified in one of two ways. You can either use the "Type" + attribute above to specify the aliased concrete type, or do it more explicitly + by setting the PluggedType attribute to the assembly qualified name of the + concrete type.</p> +<!-- +{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1 <\cf3 Instance\cf1 \cf4 Key\cf1 =\cf0 "\cf1 Red\cf0 "\cf1 \cf4 PluggedType\cf1 =\cf0 "\cf1 StructureMap.Testing.Widget.Color, StructureMap.Testing.Widget\cf0 "\cf1 \cf4 Color\cf1 =\cf0 "\cf1 Red\cf0 "\cf1 />} +--> + <div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"> + <p style="margin: 0px;"> + <span style="color: blue;"> <</span><span + style="color: #a31515;">Instance</span><span style="color: blue;"> </span> + <span style="color: red;">Key</span><span style="color: blue;">=</span>"<span + style="color: blue;">Red</span>"<span style="color: blue;"> </span> + <span style="color: red;">PluggedType</span><span style="color: blue;">=</span>"<span + style="color: blue;">StructureMap.Testing.Widget.Color, + StructureMap.Testing.Widget</span>"<span style="color: blue;"> </span> + <span style="color: red;">Color</span><span style="color: blue;">=</span>"<span + style="color: blue;">Red</span>"<span style="color: blue;"> /></span></p> +</div> +<!--EndFragment--> +<p> </p> + <h4>Primitive Properties (Strings and basic value types)</h4> + <p>Primitive constructor or setter arguments are defined by + adding an attribute @propertyName="propertyValue" to the + instance node.="font-family: Courier New; font-size: 10pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt;"> +<pre style="margin: 0px;"> [Pluggable("Color", "Only for testing")]</pre> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> ColorWidget : IWidget</pre> +<pre style="margin: 0px;"> {</pre> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> ColorWidget(<span style="color: blue;">string</span> Color)</pre> +<pre style="margin: 0px;"> {</pre> +<pre style="margin: 0px;"> _Color = Color;</pre> +<pre style="margin: 0px;"> }</pre> +<pre style="margin: 0px;"> }</pre> +</div> +<br> +<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt;"> +<pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: maroon;">Widget</span><span style="color: fuchsia;"> </span><span style="color: red;">Type</span><span style="color: blue;">="Color"</span><span style="color: fuchsia;"> </span><span style="color: red;">Key</span><span style="color: blue;">="Red"</span><span style="color: fuchsia;"> </span><span style="color: #FF0000">Color</span><span style="color: blue;">="Red" /></span></pre> +</div> + +<h4>Long Strings</h4> + <p>There is an optional mode to define a property value + inside a CDATA tag for very long strings like sql statements + or Javascript templates. </p> +<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt;"> +<pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: #800000">Instance </span><span style="color: red;">Type</span><span style="color: blue;">="Sql"</span><span style="color: fuchsia;"> </span><span style="color: red;">Key</span><span style="color: blue;">="SomeQuery"></span></pre> +<pre style="margin: 0px;"><span style="color: blue;"> <bigProp></span></pre> +<pre style="margin: 0px;"> <span style="color: blue;"><![</span><span style="color: fuchsia;">CDATA[</span></pre> +<pre style="margin: 0px;"><span style="color: fuchsia;"> select </span><span style="color: blue;">*</span><span style="color: fuchsia;"> from table</span></pre> +<pre style="margin: 0px;"><span style="color: fuchsia;"> where</span></pre> +<pre style="margin: 0px;"><span style="color: fuchsia;"> somecolumn = </span><span style="color: blue;">'something'</span><span style="color: fuchsia;"> or</span></pre> +<pre style="margin: 0px;"><span style="color: fuchsia;"> some_other_column = </span><span style="color: blue;">'something else'</span></pre> +<pre style="margin: 0px;"><span style="color: fuchsia;"> </span><span style="color: blue;">]]></span></pre> +<pre style="margin: 0px;"><span style="color: #0000FF"> </span><span style="color: blue;"></</span><span style="color: #800000">bigProp</span><span style="color: blue;">></span></pre> +<pre style="margin: 0px;"> <span style="color: blue;"></</span><span style="color: maroon;">Property</span><span style="color: blue;">></span></pre> +</div> + + <h4>Enumeration Properties</h4> + <p>Enumeration arguments are defined the same way as + primitive properties. Use the string names of the + enumeration for the values.</p> +<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt;"> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">enum</span> BreedEnum</pre> +<pre style="margin: 0px;"> {</pre> +<pre style="margin: 0px;"> Hereford,</pre> +<pre style="margin: 0px;"> Angus,</pre> +<pre style="margin: 0px;"> Longhorn</pre> +<pre style="margin: 0px;"> }</pre> +<pre style="margin: 0px;"> </pre> +<pre style="margin: 0px;"> [Pluggable("Cow")]</pre> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> Cow</pre> +<pre style="margin: 0px;"> {</pre> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> BreedEnum Breed;</pre> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">long</span> Weight;</pre> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> Name;</pre> +<pre style="margin: 0px;"> </pre> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> Cow(<span style="color: blue;">long</span> Weight, BreedEnum Breed, <span style="color: blue;">string</span> Name)</pre> +<pre style="margin: 0px;"> {</pre> +<pre style="margin: 0px;"> <span style="color: blue;">this</span>.Breed = Breed;</pre> +<pre style="margin: 0px;"> <span style="color: blue;">this</span>.Weight = Weight;</pre> +<pre style="margin: 0px;"> <span style="color: blue;">this</span>.Name = Name;</pre> +<pre style="margin: 0px;"> }</pre> +<pre style="margin: 0px;"> }</pre> +</div> +<br> +<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt;"> +<pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: #800000">Instance</span><span style="color: fuchsia;"> </span><span style="color: red;">Type</span><span style="color: blue;">="Cow"</span><span style="color: fuchsia;"> </span><span style="color: red;">Key</span><span style="color: blue;">="Maggie" </span><span style="color: #FF0000">Breed</span><span style="color: blue;">="Angus" /></span></pre> +</div> + <h4>Child Properties</h4> + <p>Child properties of non-primitive types are defined as + embedded memento nodes. Child properties can be either + defined inline or use a reference to a named instance of the + property type. If a child property is omitted or + defined with no value, StructureMap will use the default + instance of the property type. Simply add a child node to the main instance + node with the name of the constructor argument or setter property name.</p> +<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt;"> +<pre style="margin: 0px;"> [PluginFamily, Pluggable("Default", "")]</pre> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> GrandChild</pre> +<pre style="margin: 0px;"> {</pre> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> GrandChild(<span style="color: blue;">bool</span> RightHanded, <span style="color: blue;">int</span> BirthYear)</pre> +<pre style="margin: 0px;"> {</pre> +<pre style="margin: 0px;"> }</pre> +<pre style="margin: 0px;"> }</pre> +<pre style="margin: 0px;"> </pre> +<pre style="margin: 0px;"> </pre> +<pre style="margin: 0px;"> [Pluggable("Leftie", "")]</pre> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> LeftieGrandChild : GrandChild</pre> +<pre style="margin: 0px;"> {</pre> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> LeftieGrandChild(<span style="color: blue;">int</span> BirthYear) : <span style="color: blue;">base</span>(<span style="color: blue;">false</span>, BirthYear)</pre> +<pre style="margin: 0px;"> {</pre> +<pre style="margin: 0px;"> }</pre> +<pre style="margin: 0px;"> }</pre> +<pre style="margin: 0px;"> </pre> +<pre style="margin: 0px;"> </pre> +<pre style="margin: 0px;"> [PluginFamily, Pluggable("Default", "")]</pre> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> Child</pre> +<pre style="margin: 0px;"> {</pre> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> Child(<span style="color: blue;">string</span> Name, GrandChild MyGrandChild)</pre> +<pre style="margin: 0px;"> {</pre> +<pre style="margin: 0px;"> }</pre> +<pre style="margin: 0px;"> }</pre> +</div> +<br> +<h4>Inline Definition</h4> +<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt;"> +<pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: maroon;">StructureMap.Testing.Widget.Child</span><span style="color: fuchsia;"> </span><span style="color: red;">Type</span><span style="color: blue;">="Default"</span><span style="color: fuchsia;"> </span><span style="color: red;">Key</span><span style="color: blue;">="Tom" </span><span style="color: red;">Name</span><span style="color: blue;">="Tom"></span></pre> +<pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: maroon;">MyGrandChild</span><span style="color: fuchsia;"> </span><span style="color: red;">Name</span><span style="color: blue;">="MyGrandChild"</span><span style="color: fuchsia;"> </span><span style="color: red;">Type</span><span style="color: blue;">="Leftie" </span><span style="color: #FF0000">BirthYear</span><span style="color: blue;">="1984" /></span></pre> +<pre style="margin: 0px;"> <span style="color: blue;"></</span><span style="color: maroon;">StructureMap.Testing.Widget.Child</span><span style="color: blue;">></span></pre> +</div> +<h4>Reference Definition</h4> +<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt;"> +<pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: maroon;">StructureMap.Testing.Widget.Child</span><span style="color: fuchsia;"> </span><span style="color: red;">Type</span><span style="color: blue;">="Default"</span><span style="color: fuchsia;"> </span><span style="color: red;">Key</span><span style="color: blue;">="Marsha" </span><span style="color: red;">Name</span><span style="color: blue;">="Marsha"></span></pre> +<pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: maroon;">MyGrandChild</span><span style="color: fuchsia;"> </span><span style="color: red;">Key</span><span style="color: blue;">="Tommy"/></span></pre> +<pre style="margin: 0px;"> <span style="color: blue;"></</span><span style="color: maroon;">StructureMap.Testing.Widget.Child</span><span style="color: blue;">></span> </pre> +</div> +<h3>Non Primitive Array Property</h3> +<p>If a property or constructor argument is an array of a non-primitive type, create + a child node to the top level instance node with the name of the property. + Simply add new InstanceMemento nodes with the name <Child> under the property + nodes for each element of the array. These <Child> nodes are Attribute + Normalized InstanceMemento's and follow the same rules expressed in this + document.</p> +<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt;"> +<pre style="margin: 0px;"> [Pluggable("Compound")]</pre> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> CompoundStrategy : IStrategy</pre> +<pre style="margin: 0px;"> {</pre> +<pre style="margin: 0px;"> <span style="color: blue;">public</span> CompoundStrategy(IStrategy[] innerStrategies)</pre> +<pre style="margin: 0px;"> {</pre> +<pre style="margin: 0px;"> }</pre> +<pre style="margin: 0px;"> }</pre> +</div> +<br> +<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt;"> +<pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: maroon;">Instance</span><span style="color: fuchsia;"> </span><span style="color: red;">Key</span><span style="color: blue;">="ArrayTest"</span><span style="color: fuchsia;"> </span><span style="color: red;">Type</span><span style="color: blue;">="Compound"></span></pre> +<pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: maroon;">innerStrategies</span><span style="color: blue;">></span></pre> +<pre style="margin: 0px;"> <span style="color: blue;"><!</span><span style="color: green;">-- Referenced Instance --</span><span style="color: blue;">></span></pre> +<pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: #800000">Child</span><span style="color: fuchsia;"> </span><span style="color: red;">Key</span><span style="color: blue;">="Red" /></span></pre> +<pre style="margin: 0px;"> </pre> +<pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: #800000">Child</span><span style="color: blue;">><!</span><span style="color: green;">-- Default Instance --</span><span style="color: blue;">></</span><span style="color: #800000">Child</span><span style="color: blue;">></span></pre> +<pre style="margin: 0px;"> </pre> +<pre style="margin: 0px;"> <span style="color: blue;"><!</span><span style="color: green;">-- Inline Definition --</span><span style="color: blue;">></span></pre> +<pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: #800000">Child</span><span style="color: fuchsia;"> </span><span style="color: red;">Type</span><span style="color: blue;">="Random" </span><span style="color: #FF0000">seed</span><span style="color: blue;">="0.034"/></span></pre> +<pre style="margin: 0px;"> <span style="color: blue;"></</span><span style="color: maroon;">innerStrategies</span><span style="color: blue;">></span></pre> +<pre style="margin: 0px;"> <span style="color: blue;"></</span><span style="color: maroon;">Instance</span><span style="color: blue;">></span></pre> +</div> +<h3>Primitive Arrays</h3> + <p>Primitive arrays like string[] or int[] can be defined in Xml. For a class + with arguments like:</p> +<!-- +{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;}??\fs20 \cf3 public\cf0 ClassWithStringAndIntArray(\cf3 int\cf0 [] numbers, \cf3 string\cf0 [] strings)\par ?? \{\par ?? _numbers = numbers;\par ?? _strings = strings;\par ?? \}} +--> + <div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"> + <p style="margin: 0px;"> + <span style="color: blue;">public</span> + ClassWithStringAndIntArray(<span style="color: blue;">int</span>[] numbers, + <span style="color: blue;">string</span>[] strings)</p> + <p style="margin: 0px;"> + {</p> + <p style="margin: 0px;"> + _numbers = numbers;</p> + <p style="margin: 0px;"> + _strings = strings;</p> + <p style="margin: 0px;"> + }</p> + </div> +<!--EndFragment--> +<p>The Xml configuration is:</p> +<!-- +{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1 <\cf3 DefaultInstance\par ??\cf1 \cf4 PluginType\cf1 =\cf0 "\cf1 StructureMap.Testing.Configuration.ClassWithStringAndIntArray, StructureMap.Testing\cf0 "\par ??\cf1 \cf4 PluggedType\cf1 =\cf0 "\cf1 StructureMap.Testing.Configuration.ClassWithStringAndIntArray, StructureMap.Testing\cf0 "\cf1 >\par ??\par ?? <\cf3 numbers\cf1 \cf4 Values\cf1 =\cf0 "\cf1 1,2,3\cf0 "\cf1 />\par ?? <\cf3 strings\cf1 \cf4 Values\cf1 =\cf0 "\cf1 1,2,3\cf0 "\cf1 />\par ?? </\cf3 DefaultInstance\cf1 >} +--> + <div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"> + <p style="margin: 0px;"> + <span style="color: blue;"> <</span><span style="color: #a31515;">DefaultInstance</span></p> + <p style="margin: 0px;"> + <span style="color: blue;"> </span><span style="color: red;"> + PluginType</span><span style="color: blue;">=</span>"<span style="color: blue;">StructureMap.Testing.Configuration.ClassWithStringAndIntArray, + StructureMap.Testing</span>"</p> + <p style="margin: 0px;"> + <span style="color: blue;"> </span><span style="color: red;"> + PluggedType</span><span style="color: blue;">=</span>"<span + style="color: blue;">StructureMap.Testing.Configuration.ClassWithStringAndIntArray, + StructureMap.Testing</span>"<span style="color: blue;">></span></p> + <p style="margin: 0px;"> + </p> + <p style="margin: 0px;"> + <span class="style1" style="color: blue;"> <</span><span + class="style1" style="color: #a31515;">numbers</span><span class="style1" + style="color: blue;"> </span><span class="style1" style="color: red;">Values</span><span + class="style1" style="color: blue;">=</span>"<span class="style1" + style="color: blue;">1,2,3</span>"<span class="style1" style="color: blue;">/></span></p> + <p style="margin: 0px;"> + <span class="style1" style="color: blue;"> <</span><span + class="style1" style="color: #a31515;">strings</span><span class="style1" + style="color: blue;"> </span><span class="style1" style="color: red;">Values</span><span + class="style1" style="color: blue;">=</span>"<span class="style1" + style="color: blue;">1,2,3</span>"<span class="style1" style="color: blue;">/></span></p> + <p style="margin: 0px;"> + <span style="color: blue;"> </</span><span style="color: #a31515;">DefaultInstance</span><span + style="color: blue;">></span></p> + </div> +<!--EndFragment--> +<p>By default, the Values attribute is assumed to be a comma delimited list. + The delimiter of the list can be optionally overriden by using the Delimiter + attribute.</p> +<!-- +{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1 <\cf3 DefaultInstance\par ??\cf1 \cf4 PluginType\cf1 =\cf0 "\cf1 StructureMap.Testing.Configuration.ClassWithStringAndIntArray, StructureMap.Testing\cf0 "\par ??\cf1 \cf4 PluggedType\cf1 =\cf0 "\cf1 StructureMap.Testing.Configuration.ClassWithStringAndIntArray, StructureMap.Testing\cf0 "\cf1 >\par ??\par ?? <\cf3 numbers\cf1 \cf4 Values\cf1 =\cf0 "\cf1 1;2;3\cf0 "\cf1 \cf4 Delimiter\cf1 =\cf0 "\cf1 ;\cf0 "\cf1 />\par ?? <\cf3 strings\cf1 \cf4 Values\cf1 =\cf0 "\cf1 1,2,3\cf0 "\cf1 />\par ?? </\cf3 DefaultInstance\cf1 >} +--> +<div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"> + <p style="margin: 0px;"> + <span style="color: blue;"> <</span><span style="color: #a31515;">DefaultInstance</span></p> + <p style="margin: 0px;"> + <span style="color: blue;"> </span><span style="color: red;"> + PluginType</span><span style="color: blue;">=</span>"<span style="color: blue;">StructureMap.Testing.Configuration.ClassWithStringAndIntArray, + StructureMap.Testing</span>"</p> + <p style="margin: 0px;"> + <span style="color: blue;"> </span><span style="color: red;"> + PluggedType</span><span style="color: blue;">=</span>"<span + style="color: blue;">StructureMap.Testing.Configuration.ClassWithStringAndIntArray, + StructureMap.Testing</span>"<span style="color: blue;">></span></p> + <p style="margin: 0px;"> + </p> + <p style="margin: 0px;"> + <span style="color: blue;"> <</span><span + style="color: #a31515;">numbers</span><span style="color: blue;"> </span> + <span style="color: red;">Values</span><span style="color: blue;">=</span>"<span + style="color: blue;">1;2;3</span>"<span style="color: blue;"> </span> + <span style="color: red;">Delimiter</span><span style="color: blue;">=</span>"<span + style="color: blue;">;</span>"<span style="color: blue;">/></span></p> + <p style="margin: 0px;"> + <span style="color: blue;"> <</span><span + style="color: #a31515;">strings</span><span style="color: blue;"> </span> + <span style="color: red;">Values</span><span style="color: blue;">=</span>"<span + style="color: blue;">1,2,3</span>"<span style="color: blue;">/></span></p> + <p style="margin: 0px;"> + <span style="color: blue;"> </</span><span style="color: #a31515;">DefaultInstance</span><span + style="color: blue;">></span></p> +</div> +<!--EndFragment--> +<h3>Dictionaries and NameValueCollection</h3> +<p>Any form of IDictionary<Key, Value> or a NameValueCollection can be configured in + Xml by the following syntax. Say you have a class that needs a Dictionary + of properties:</p> +<!-- +{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;}??\fs20 \cf3 public\cf0 \cf3 class\cf0 \cf4 ClassWithDictionary\par ??\cf0 \{\par ?? \cf3 private\cf0 \cf3 readonly\cf0 \cf4 IDictionary\cf0 <\cf3 string\cf0 , \cf3 string\cf0 > _dictionary;\par ??\par ?? \cf3 public\cf0 ClassWithDictionary(\cf4 IDictionary\cf0 <\cf3 string\cf0 , \cf3 string\cf0 > dictionary)\par ?? \{\par ?? _dictionary = dictionary;\par ?? \}\par ??\par ?? \cf3 public\cf0 \cf4 IDictionary\cf0 <\cf3 string\cf0 , \cf3 string\cf0 > Dictionary\par ?? \{\par ?? \cf3 get\cf0 \{ \cf3 return\cf0 _dictionary; \}\par ?? \}\par ?? \}} +--> +<div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"> + <p style="margin: 0px;"> + <span style="color: blue;">public</span> <span style="color: blue;"> + class</span> <span style="color: #2b91af;">ClassWithDictionary</span></p> + <p style="margin: 0px;"> + {</p> + <p style="margin: 0px;"> + <span style="color: blue;">private</span> + <span style="color: blue;">readonly</span> <span style="color: #2b91af;"> + IDictionary</span><<span style="color: blue;">string</span>, + <span style="color: blue;">string</span>> _dictionary;</p> + <p style="margin: 0px;"> + </p> + <p style="margin: 0px;"> + <span style="color: blue;">public</span> + ClassWithDictionary(<span style="color: #2b91af;">IDictionary</span><<span + style="color: blue;">string</span>, <span style="color: blue;">string</span>> + dictionary)</p> + <p style="margin: 0px;"> + {</p> + <p style="margin: 0px;"> + _dictionary = + dictionary;</p> + <p style="margin: 0px;"> + }</p> + <p style="margin: 0px;"> + </p> + <p style="margin: 0px;"> + <span style="color: blue;">public</span> + <span style="color: #2b91af;">IDictionary</span><<span style="color: blue;">string</span>, + <span style="color: blue;">string</span>> Dictionary</p> + <p style="margin: 0px;"> + {</p> + <p style="margin: 0px;"> + + <span style="color: blue;">get</span> { <span style="color: blue;">return</span> + _dictionary; }</p> + <p style="margin: 0px;"> + }</p> + <p style="margin: 0px;"> + }</p> +</div> +<!--EndFragment--> +<p>The "dictionary" argument to the constructor function could be defined as:</p> +<!-- +{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1 <\cf3 DefaultInstance\par ??\cf1 \cf4 PluginType\cf1 =\cf0 "\cf1 StructureMap.Testing.Configuration.ClassWithDictionary, StructureMap.Testing\cf0 "\par ??\cf1 \cf4 PluggedType\cf1 =\cf0 "\cf1 StructureMap.Testing.Configuration.ClassWithDictionary, StructureMap.Testing\cf0 "\cf1 >\par ?? <\cf3 Property\cf1 \cf4 Name\cf1 =\cf0 '\cf1 dictionary\cf0 '\cf1 >\par ?? <\cf3 Pair\cf1 \cf4 Key\cf1 =\cf0 '\cf1 color\cf0 '\cf1 \cf4 Value\cf1 =\cf0 '\cf1 red\cf0 '\cf1 />\par ?? <\cf3 Pair\cf1 \cf4 Key\cf1 =\cf0 '\cf1 state\cf0 '\cf1 \cf4 Value\cf1 =\cf0 '\cf1 texas\cf0 '\cf1 />\par ?? <\cf3 Pair\cf1 \cf4 Key\cf1 =\cf0 '\cf1 direction\cf0 '\cf1 \cf4 Value\cf1 =\cf0 '\cf1 north\cf0 '\cf1 />\par ?? </\cf3 Property\cf1 >\par ?? </\cf3 DefaultInstance\cf1 >} +--> +<div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"> +<!-- +{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;}??\fs20 \cf1 <\cf3 DefaultInstance\par ??\cf1 \cf4 PluginType\cf1 =\cf0 "\cf1 StructureMap.Testing.Configuration.ClassWithDictionary, StructureMap.Testing\cf0 "\par ??\cf1 \cf4 PluggedType\cf1 =\cf0 "\cf1 StructureMap.Testing.Configuration.ClassWithDictionary, StructureMap.Testing\cf0 "\cf1 >\par ?? <\cf3 dictionary\cf1 >\par ?? <\cf3 Pair\cf1 \cf4 Key\cf1 =\cf0 '\cf1 color\cf0 '\cf1 \cf4 Value\cf1 =\cf0 '\cf1 red\cf0 '\cf1 />\par ?? <\cf3 Pair\cf1 \cf4 Key\cf1 =\cf0 '\cf1 state\cf0 '\cf1 \cf4 Value\cf1 =\cf0 '\cf1 texas\cf0 '\cf1 />\par ?? <\cf3 Pair\cf1 \cf4 Key\cf1 =\cf0 '\cf1 direction\cf0 '\cf1 \cf4 Value\cf1 =\cf0 '\cf1 north\cf0 '\cf1 />\par ?? </\cf3 dictionary\cf1 >\par ?? </\cf3 DefaultInstance\cf1 >} +--> + <div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"> + <p style="margin: 0px;"> + <span style="color: blue;"> <</span><span style="color: #a31515;">DefaultInstance</span></p> + <p style="margin: 0px;"> + <span style="color: blue;"> </span><span style="color: red;"> + PluginType</span><span style="color: blue;">=</span>"<span style="color: blue;">StructureMap.Testing.Configuration.ClassWithDictionary, + StructureMap.Testing</span>"</p> + <p style="margin: 0px;"> + <span style="color: blue;"> </span><span style="color: red;"> + PluggedType</span><span style="color: blue;">=</span>"<span + style="color: blue;">StructureMap.Testing.Configuration.ClassWithDictionary, + StructureMap.Testing</span>"<span style="color: blue;">></span></p> + <p style="margin: 0px;"> + <span style="color: blue;"> <</span><span + style="color: #a31515;">dictionary</span><span style="color: blue;">></span></p> + <p style="margin: 0px;"> + <span style="color: blue;"> <</span><span + style="color: #a31515;">Pair</span><span style="color: blue;"> </span> + <span style="color: red;">Key</span><span style="color: blue;">="color" </span> + <span style="color: red;">Value</span><span style="color: blue;">="red"/></span></p> + <p style="margin: 0px;"> + <span style="color: blue;"> <</span><span + style="color: #a31515;">Pair</span><span style="color: blue;"> </span> + <span style="color: red;">Key</span><span style="color: blue;">="state" </span> + <span style="color: red;">Value</span><span style="color: blue;">="texas"/></span></p> + <p style="margin: 0px;"> + <span style="color: blue;"> <</span><span + style="color: #a31515;">Pair</span><span style="color: blue;"> </span> + <span style="color: red;">Key</span><span style="color: blue;">="direction" </span> + <span style="color: red;">Value</span><span style="color: blue;">="north"/></span></p> + <p style="margin: 0px;"> + <span style="color: blue;"> </</span><span + style="color: #a31515;">dictionary</span><span style="color: blue;">></span></p> + <p style="margin: 0px;"> + <span style="color: blue;"> </</span><span style="color: #a31515;">DefaultInstance</span><span + style="color: blue;">></span></p> + </div> +<!--EndFragment--> +<p style="margin: 0px;"> + </p> + + </div> +<!--EndFragment--> +<p>Just create a new node for the IDictionary property called <[propertyName]> under + the main instance node. Then add a <Pair Key="key" Value="value"/> node + for each name/value pair in the IDictionary. </p> +<p> </p> + + </body> +</html> Added: trunk/Source/HTML/AutoMocking.htm =================================================================== --- trunk/Source/HTML/AutoMocking.htm (rev 0) +++ trunk/Source/HTML/AutoMocking.htm 2008-06-23 17:44:01 UTC (rev 125) @@ -0,0 +1,9 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> + <head> + <title></title> + </head> + <body> + + </body> +</html> \ No newline at end of file Added: trunk/Source/HTML/BestPractices.htm =================================================================== --- trunk/Source/HTML/BestPractices.htm (rev 0) +++ trunk/Source/HTML/BestPractices.htm 2008-06-23 17:44:01 UTC (rev 125) @@ -0,0 +1,9 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> + <head> + <title></title> + </head> + <body> + + </body> +</html> \ No newline at end of file Added: trunk/Source/HTML/ChangingDefaultsAtRuntime.htm =================================================================== --- trunk/Source/HTML/ChangingDefaultsAtRuntime.htm (rev 0) +++ trunk/Source/HTML/ChangingDefaultsAtRuntime.htm 2008-06-23 17:44:01 UTC (rev 125) @@ -0,0 +1,9 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> + <head> + <title></title> + </head> + <body> + + </body> +</html> \ No newline at end of file Added: trunk/Source/HTML/CompositeConfiguration.htm =================================================================== --- trunk/Source/HTML/CompositeConfiguration.htm (rev 0) +++ trunk/Source/HTML/CompositeConfiguration.htm 2008-06-23 17:44:01 UTC (rev 125) @@ -0,0 +1,9 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> + <head> + <title></title> + </head> + <body> + + </body> +</html> \ No newline at end of file Added: trunk/Source/HTML/Concepts.htm =================================================================== --- trunk/Source/HTML/Concepts.htm (rev 0) +++ trunk/Source/HTML/Concepts.htm 2008-06-23 17:44:01 UTC (rev 125) @@ -0,0 +1,49 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> + <head> + <title></title> + </head> + <body> + <h3>Patterns and Concepts</h3> + <p> + Object oriented systems are composed of a myriad array of objects communicating + by sending messages to exposed interfaces. To a large degree, the qualities of + an OO design are determined by the structure, organization, and responsibility + assignments of the objects in a system. The qualities of a system most + affected by structure are flexibility, extensibility, maintainability, and + testability. Applications usually meet their demise when the system is + determined to be too difficult or costly to change. The symptoms of a dying + application are a loss of clearly defined structure, an unclear division + of responsibilities in the code, and difficulty testing and troubleshooting the + application. </p> + <p> + Over the years a series of rules and principles have been discovered and + developed to describe well-structured systems. Possibly most important is + <em>Separation of Concerns</em> – pulling separate aspects of the system like + persistence, security, or business logic into separate classes and packages. + Another key concept is the combination of highly cohesive classes in a loosely + coupled structure. The more highly coupled two components of a system are, the + more difficult the system is to maintain, test, and reuse. A class should have a + cohesive set of responsibilities in a narrow domain. In other words, + simpleton classes that do only one thing are much easier to code and test than + <em>God</em> classes that take on far too many unrelated responsibilities. </p> + <p> </p> + <h4>Separation of Concerns</h4> + <h4>Services and Dependencies</h4> + <h4>Dependency Injection</h4> + <h4>Container</h4> + <h4>Service Locator</h4> + <h3>StructureMap Terms</h3> + <h4>PluginType</h4> + <p>Object Oriented Design</p> + <h4>Auto Wiring</h4> + <p>Every "real" IoC container supports the concept of "Auto Wiring." Auto + Wiring simply means that StructureMap can figure out dependency chains for you.</p> + <h4>Instance</h4> + <h4>Scoping</h4> + <h4>PluginFamily</h4> + <h4>Profile</h4> + <h4>Interceptor</h4> + <h4>PostProcessor</h4> + </body> +</html> \ No newline at end of file Added: trunk/Source/HTML/ConcreteTypes.htm =================================================================== --- trunk/Source/HTML/ConcreteTypes.htm (rev 0) +++ trunk/Source/HTML/ConcreteTypes.htm 2008-06-23 17:44:01 UTC (rev 125) @@ -0,0 +1,9 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> + <head> + <title></title> + </head> + <body> + + </body> +</html> \ No newline at end of file Added: trunk/Source/HTML/ConfigurationArchitecture.htm =================================================================== --- trunk/Source/HTML/ConfigurationArchitecture.htm (rev 0) +++ trunk/Source/HTML/ConfigurationArchitecture.htm 2008-06-23 17:44:01 UTC (rev 125) @@ -0,0 +1,9 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> + <head> + <title></title> + </head> + <body> + + </body> +</html> \ No newline at end of file Added: trunk/Source/HTML/ConfiguringStructureMap.htm =================================================================== --- trunk/Source/HTML/ConfiguringStructureMap.htm (rev 0) +++ trunk/Source/HTML/ConfiguringStructureMap.htm 2008-06-23 17:44:01 UTC (rev 125) @@ -0,0 +1,9 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> + <head> + <title></title> + </head> + <body> + + </body> +</html> \ No newline at end of file Added: trunk/Source/HTML/ConstructorAndSetterInjection.htm =================================================================== --- trunk/Source/HTML/ConstructorAndSetterInjection.htm (rev 0) +++ trunk/Source/HTML/ConstructorAndSetterInjection.htm 2008-06-23 17:44:01 UTC (rev 125) @@ -0,0 +1,391 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> + <head> + <title>Constructor and Setter Injection</title> + </head> + <body> + <h1>Constructor and Setter Injection</h1> + + <p>StructureMap supports two forms of Dependency Injection:</p> + + <ol> + <li>Constructor Injection -- "Pushing" dependencies into a concrete class through + constructor arguments.</li> + <li>Setter Injection -- "Pushing" depencencies into a concrete class through public + properties. The "Setter" nomenclature is taken from Java where properties + are getSomething() and setSomething(value).</li> + </ol> + + <p>You can certainly mix and match Setter Injection with Constructor Injection on + the same classes, but Constructor Injection will always be used (except for + empty constructors) and Setter Injection has to be explicitly configured. + See + <a href="http://martinfowler.com/articles/injection.html#ConstructorVersusSetterInjection"> + Martin Fowler's discussion on Constructor versus Setter Injection</a> for more + information. My feeling has always been that Constructor Injection is + preferrable from a design perspective. When you exclusively use + Constructor Injection, the code is somewhat self-documenting because the + constructor arguments will clearly delineate the dependencies of a concrete + class. It's also important to think about the constructor method of a + class being a contract. If you satisfy all of the arguments of the + constructor method, the class should be ready to function. Relying on + Setter Injection can make a class harder to use because it isn't always obvious + which setters need to be created externally to use the class. Of course, + not using any form of Dependency Injection can be the worst answer because then + you have no idea what it really takes to bootstrap the service. </p> + <h2>Using Constructor Injection</h2> + <p>Now, the first question you might ask is how does StructureMap know which + constructor function to use in a class that has multiple constructors? The + answer is that StructureMap will automatically select the "greediest" public + constructor of a class to use for injection. In this case, the "greediest" + constructor is the constructor with the most arguments. In the case of a + tie, StructureMap will use the first constructor that it encountered. For + example, in the code below, the second constructor that takes in two arguments + would be used because it is "greedier."</p> +<!-- +{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;}??\fs20 \cf3 public\cf0 GreaterThanRule()\par ?? \{\par ?? \}\par ??\par ?? \cf3 public\cf0 GreaterThanRule(\cf3 string\cf0 Attribute, \cf3 int\cf0 Value)\par ?? \{\par ?? _Attribute = Attribute;\par ?? _Value = Value;\par ?? \}} +--> + <div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"> + <p style="margin: 0px;"> + <span style="color: blue;">public</span> + GreaterThanRule()</p> + <p style="margin: 0px;"> + {</p> + <p style="margin: 0px;"> + }</p> + <p style="margin: 0px;"> + </p> + <p style="margin: 0px;"> + <span style="color: blue;">public</span> + GreaterThanRule(<span style="color: blue;">string</span> Attribute, + <span style="color: blue;">int</span> Value)</p> + <p style="margin: 0px;"> + {</p> + <p style="margin: 0px;"> + _Attribute = Attribute;</p> + <p style="margin: 0px;"> + _Value = Value;</p> + <p style="margin: 0px;"> + }</p> + </div> +<!--EndFragment--> +<p> </p> + <p>You can always override this behavior by decorating the constructor you want + StructureMap to use with the [StructureMap.DefaultConstructor] attribute like + this sample:</p> +<!-- +{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;}??\fs20 [\cf3 DefaultConstructor\cf0 ]\par ?? \cf4 public\cf0 DataSession(\cf3 IDatabaseEngine\cf0 database)\par ?? : \cf4 this\cf0 (database,\par ?? \cf4 new\cf0 \cf3 CommandFactory\cf0 (database),\par ?? \cf4 new\cf0 \cf3 AutoCommitExecutionState\cf0 (database.GetConnection(), database.GetDataAdapter()),\par ?? \cf4 new\cf0 \cf3 TransactionalExecutionState\cf0 (database.GetConnection(), database.GetDataAdapter()))\par ?? \{\par ?? \}} +--> + <div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"> + <p style="margin: 0px;"> + [<span style="color: #2b91af;">DefaultConstructor</span>]</p> + <p style="margin: 0px;"> + <span style="color: blue;">public</span> + DataSession(<span style="color: #2b91af;">IDatabaseEngine</span> database)</p> + <p style="margin: 0px;"> + : + <span style="color: blue;">this</span>(database,</p> + <p style="margin: 0px;"> + + <span style="color: blue;">new</span> <span style="color: #2b91af;"> + CommandFactory</span>(database),</p> + <p style="margin: 0px;"> + + <span style="color: blue;">new</span> <span style="color: #2b91af;"> + AutoCommitExecutionState</span>(database.GetConnection(), + dat... [truncated message content] |