|
From: <jer...@us...> - 2008-10-21 22:10:30
|
Revision: 189
http://structuremap.svn.sourceforge.net/structuremap/?rev=189&view=rev
Author: jeremydmiller
Date: 2008-10-21 22:10:22 +0000 (Tue, 21 Oct 2008)
Log Message:
-----------
documentation
Modified Paths:
--------------
trunk/Source/HTML/HTML.csproj
trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs
trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs
trunk/Source/StructureMap/Configuration/DSL/Registry.cs
trunk/Source/StructureMap/InitializationExpression.cs
trunk/Source/StructureMap/ObjectFactory.cs
trunk/Source/StructureMap/Pipeline/SmartInstance.cs
trunk/Source/StructureMap.Testing/AlternativeConfigurationTester.cs
trunk/Source/StructureMap.Testing/Diagnostics/DoctorTester.cs
trunk/Source/StructureMap.Testing/Examples.cs
trunk/Source/StructureMap.Testing/Graph/ContainerTester.cs
trunk/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs
trunk/Source/StructureMap.Testing/Pipeline/SmartInstanceTester.cs
Added Paths:
-----------
trunk/Source/HTML/ConfiguringStructureMap.htm
trunk/Source/HTML/InstanceExpression.htm
trunk/Source/HTML/RegistryDSL.htm
trunk/Source/StructureMap.Testing/Graph/ExplicitArgumentTester.cs
Removed Paths:
-------------
trunk/Source/HTML/AutoMocking.htm
trunk/Source/HTML/BestPractices.htm
trunk/Source/HTML/ChangingDefaultsAtRuntime.htm
trunk/Source/HTML/CompositeConfiguration.htm
trunk/Source/HTML/ConcreteTypes.htm
trunk/Source/HTML/ConfigurationArchitecture.htm
trunk/Source/HTML/ConfiguringStructureMap.htm
trunk/Source/HTML/CreatingContainer.htm
trunk/Source/HTML/EnvironmentTests.htm
trunk/Source/HTML/FAQ.htm
trunk/Source/HTML/FluentInterfaceAPI.htm
trunk/Source/HTML/GentleGuide.htm
trunk/Source/HTML/ImplicitInstances.htm
trunk/Source/HTML/Profiles.htm
trunk/Source/HTML/Scoping.htm
trunk/Source/HTML/StructureMapAndMocks.htm
trunk/Source/HTML/StructureMapDoctor.htm
trunk/Source/HTML/TroubleShooting.htm
trunk/Source/HTML/WhatWillStructureMapDoWhenI.htm
Deleted: trunk/Source/HTML/AutoMocking.htm
===================================================================
--- trunk/Source/HTML/AutoMocking.htm 2008-10-21 22:02:21 UTC (rev 188)
+++ trunk/Source/HTML/AutoMocking.htm 2008-10-21 22:10:22 UTC (rev 189)
@@ -1,9 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
- <head>
- <title></title>
- </head>
- <body>
-
- </body>
-</html>
\ No newline at end of file
Deleted: trunk/Source/HTML/BestPractices.htm
===================================================================
--- trunk/Source/HTML/BestPractices.htm 2008-10-21 22:02:21 UTC (rev 188)
+++ trunk/Source/HTML/BestPractices.htm 2008-10-21 22:10:22 UTC (rev 189)
@@ -1,9 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
- <head>
- <title></title>
- </head>
- <body>
-
- </body>
-</html>
\ No newline at end of file
Deleted: trunk/Source/HTML/ChangingDefaultsAtRuntime.htm
===================================================================
--- trunk/Source/HTML/ChangingDefaultsAtRuntime.htm 2008-10-21 22:02:21 UTC (rev 188)
+++ trunk/Source/HTML/ChangingDefaultsAtRuntime.htm 2008-10-21 22:10:22 UTC (rev 189)
@@ -1,9 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
- <head>
- <title></title>
- </head>
- <body>
-
- </body>
-</html>
\ No newline at end of file
Deleted: trunk/Source/HTML/CompositeConfiguration.htm
===================================================================
--- trunk/Source/HTML/CompositeConfiguration.htm 2008-10-21 22:02:21 UTC (rev 188)
+++ trunk/Source/HTML/CompositeConfiguration.htm 2008-10-21 22:10:22 UTC (rev 189)
@@ -1,9 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
- <head>
- <title></title>
- </head>
- <body>
-
- </body>
-</html>
\ No newline at end of file
Deleted: trunk/Source/HTML/ConcreteTypes.htm
===================================================================
--- trunk/Source/HTML/ConcreteTypes.htm 2008-10-21 22:02:21 UTC (rev 188)
+++ trunk/Source/HTML/ConcreteTypes.htm 2008-10-21 22:10:22 UTC (rev 189)
@@ -1,9 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
- <head>
- <title></title>
- </head>
- <body>
-
- </body>
-</html>
\ No newline at end of file
Deleted: trunk/Source/HTML/ConfigurationArchitecture.htm
===================================================================
--- trunk/Source/HTML/ConfigurationArchitecture.htm 2008-10-21 22:02:21 UTC (rev 188)
+++ trunk/Source/HTML/ConfigurationArchitecture.htm 2008-10-21 22:10:22 UTC (rev 189)
@@ -1,9 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
- <head>
- <title></title>
- </head>
- <body>
-
- </body>
-</html>
\ No newline at end of file
Deleted: trunk/Source/HTML/ConfiguringStructureMap.htm
===================================================================
--- trunk/Source/HTML/ConfiguringStructureMap.htm 2008-10-21 22:02:21 UTC (rev 188)
+++ trunk/Source/HTML/ConfiguringStructureMap.htm 2008-10-21 22:10:22 UTC (rev 189)
@@ -1,9 +0,0 @@
-<!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-10-21 22:10:22 UTC (rev 189)
@@ -0,0 +1,558 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <title>Configuring StructureMap</title>
+ </head>
+ <body>
+ <h1>Configuring StructureMap</h1>
+
+
+ <p>
+ </p>
+ <p>
+ The first step in using StructureMap is configuring a Container or
+ ObjectFactory. The configuration options have changed more than anything
+ else from the initial releases to StructureMap 2.5. You have three forms
+ of configuration to choose from:</p>
+ <ol>
+ <li>The Registry DSL</li>
+ <li>Xml configuration (StructureMap.config, the App.config file, or named files)</li>
+ <li>StructureMap Attributes</li>
+ </ol>
+ <p>
+ The configuration is highly modular and you can mix and match configuration
+ choices within the same Container instance. The strong recommendation is
+ to use the Registry DSL as much as possible, and use the Xml configuration
+ strictly for configuration that absolutely must be external to the code
+ (connection strings, file paths, Url's, etc.). The attributes are
+ deprecated and largely unnecessary now, but still supported for backwards
+ compatibility.</p>
+ <ul>
+ <li>Registry - </li>
+ <li>StructureMap.config - </li>
+ <li>Xml files - </li>
+ <li>StructureMapConfiguration - StructureMapConfiguration is a static class that
+ provides an alternative for bootstrapping that was introduced in 2.0. This
+ class has been problematic and confusing in real world usage. At this
+ point, StructureMapConfiguration is deprecated and you are strongly urged to use
+ the ObjectFactory.Initialize() method instead.</li>
+ </ul>
+ <p>
+ </p>
+ <h4>
+ Initializing the Container</h4>
+ <p>
+ The recommended mechanism for initializing the Container is the Initialize()
+ method. The Initialize() method is a Nested Closure that acts against an
+ InitializationExpression object. The InitializationExpression has methods
+ for all all the possible configuration directives.</p>
+ <p>
+ </p>
+ <p>
+ </p>
+ <p>
+ </p>
+ <p>
+ </p>
+ <h4>
+ Using a Bootstrapper</h4>
+ <p>
+ </p>
+ <p>
+ </p>
+ <h4>
+ The StructureMap.config File</h4>
+ <p>
+ Historically, StructureMap looked for all of its configuration in a file named
+ "StructureMap.config" file in the ApplicationBase folder. By default, if
+ the StructureMap.config file is found in the ApplicationBase folder, the Xml
+ configuration from StructureMap.config will be applied to the internal container
+ of ObjectFactory. Technically, you could still do all configuration in the
+ StructureMap.config file. In this case, the StructureMap.config file would
+ be read and applied in the first call to any of the ObjectFactory methods that
+ request services. Likewise, StructureMap will not throw any exceptions if
+ the StructureMap.config file cannot be found.</p>
+ <p>
+ The default behavior can be overriden. First, if you are using the
+ StructureMap.config file, you might want to make the existence of this file
+ mandatory to prevent odd problems from missing configuration:</p>
+<!--
+{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green128\blue0;\red43\green145\blue175;\red0\green0\blue255;}??\fs20 \cf3 // This code enforces the existence of the StructureMap.config file\par ??\cf0 \cf3 // Initialize() will throw an exception if the StructureMap.config file\par ??\cf0 \cf3 // cannot be found\par ??\cf0 \cf4 ObjectFactory\cf0 .Initialize(x =>\par ?? \{\par ?? x.UseDefaultStructureMapConfigFile = \cf5 true\cf0 ;\par ?? \});}
+-->
+<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;">
+ <p style="margin: 0px;">
+
+ <span style="color: green;">// This code enforces the existence of the
+ StructureMap.config file</span></p>
+ <p style="margin: 0px;">
+
+ <span style="color: green;">// Initialize() will throw an exception if the
+ StructureMap.config file</span></p>
+ <p style="margin: 0px;">
+
+ <span style="color: green;">// cannot be found</span></p>
+ <p style="margin: 0px;">
+
+ <span style="color: #2b91af;">ObjectFactory</span>.Initialize(x =></p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+
+ x.UseDefaultStructureMapConfigFile = <span style="color: blue;">true</span>;</p>
+ <p style="margin: 0px;">
+ });</p>
+</div>
+<!--EndFragment-->
+<p>
+ You can also specifically ignore the StructureMap.config file at initialization
+ time so that the StructureMap.config file will never be used:</p>
+<!--
+{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red163\green21\blue21;}??\fs20 \cf3 ObjectFactory\cf0 .Initialize(x =>\par ?? \{\par ?? x.IgnoreStructureMapConfig = \cf4 true\cf0 ;\par ?? \par ?? x.ForRequestedType<\cf3 IWidget\cf0 >().TheDefault.Is\par ?? .OfConcreteType<\cf3 DoctorTester\cf0 .\cf3 NumberWidget\cf0 >()\par ?? .WithCtorArg(\cf5 "age"\cf0 ).EqualToAppSetting(\cf5 "age"\cf0 );\par ?? \});}
+-->
+<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;">
+ <p style="margin: 0px;">
+
+ <span style="color: #2b91af;">ObjectFactory</span>.Initialize(x =></p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+
+ x.IgnoreStructureMapConfig = <span style="color: blue;">true</span>;</p>
+ <p style="margin: 0px;">
+ });</p>
+</div>
+<!--EndFragment-->
+<p>
+ </p>
+<p>
+ </p>
+<p>
+ </p>
+<p>
+ </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 Bootstrapper\cf0 : \cf4 IBootstrapper\par ??\cf0 \{\par ?? \cf3 private\cf0 \cf3 static\cf0 \cf3 bool\cf0 _hasStarted;\par ??\par ??\cf3 #region\cf0 IBootstrapper Members\par ??\par ?? \cf3 public\cf0 \cf3 void\cf0 BootstrapStructureMap()\par ?? \{\par ?? \cf4 ValidationMessages\cf0 .Register();\par ??\par ?? \cf4 FilterTypeRegistry\cf0 .ResetAll();\par ??\par ?? \cf4 ObjectFactory\cf0 .Initialize(x =>\par ?? \{\par ?? x.AddRegistry(\cf3 new\cf0 \cf4 CoreRegistry\cf0 ());\par ?? x.AddRegistry(\cf3 new\cf0 \cf4 SearchRegistry\cf0 ());\par ?? x.AddRegistry(\cf3 new\cf0 \cf4 WebCoreRegistry\cf0 ());\par ?? x.AddRegistry(\cf3 new\cf0 \cf4 WebRegistry\cf0 ());\par ?? x.AddRegistry(\cf3 new\cf0 \cf4 RuleRegistry\cf0 ());\par ?? \});\par ??\par ?? \cf4 ConventionRegistry\cf0 .RegisterFor<\cf4 CultureValue\cf0 , \cf4 CultureValueObjectListConvention\cf0 >();\par ?? \}\par ??\par ??\cf3 #endregion\par ??\par ??\cf0 \cf3 public\cf0 \cf3 static\cf0 \cf3 void\cf0 Restart()\par ?? \{\par ?? \cf3 if\cf0 (_hasStarted)\par ?? \{\par ?? \cf4 ObjectFactory\cf0 .ResetDefaults();\par ?? \}\par ?? \cf3 else\par ??\cf0 \{\par ?? Bootstrap();\par ?? _hasStarted = \cf3 true\cf0 ;\par ?? \}\par ?? \}\par ??\par ?? \cf3 public\cf0 \cf3 static\cf0 \cf3 void\cf0 Bootstrap()\par ?? \{\par ?? \cf3 new\cf0 \cf4 Bootstrapper\cf0 ().BootstrapStructureMap();\par ?? \}\par ?? \}}
+-->
+<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;">
+ <p style="margin: 0px;">
+ <span style="color: blue;">public</span> <span style="color: blue;">
+ class</span> <span style="color: #2b91af;">Bootstrapper</span> :
+ <span style="color: #2b91af;">IBootstrapper</span></p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+ <span style="color: blue;">public</span>
+ <span style="color: blue;">void</span> BootstrapStructureMap()</p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+
+ <span style="color: #2b91af;">ObjectFactory</span>.Initialize(x =></p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+
+ x.AddRegistry(<span style="color: blue;">new</span>
+ <span style="color: #2b91af;">CoreRegistry</span>());</p>
+ <p style="margin: 0px;">
+
+ x.AddRegistry(<span style="color: blue;">new</span>
+ <span style="color: #2b91af;">SearchRegistry</span>());</p>
+ <p style="margin: 0px;">
+
+ x.AddRegistry(<span style="color: blue;">new</span>
+ <span style="color: #2b91af;">WebCoreRegistry</span>());</p>
+ <p style="margin: 0px;">
+
+ x.AddRegistry(<span style="color: blue;">new</span>
+ <span style="color: #2b91af;">WebRegistry</span>());</p>
+ <p style="margin: 0px;">
+
+ x.AddRegistry(<span style="color: blue;">new</span>
+ <span style="color: #2b91af;">RuleRegistry</span>());</p>
+ <p style="margin: 0px;">
+ });</p>
+ <p style="margin: 0px;">
+ }</p>
+ <p style="margin: 0px;">
+ }</p>
+ </div>
+<!--EndFragment-->
+<p style="margin: 0px">
+ </p>
+ <p style="margin: 0px">
+ </p>
+ <p style="margin: 0px">
+ * need an example of calling this from Global.asax</p>
+ <p style="margin: 0px">
+ * one of doing from main executable</p>
+ <p style="margin: 0px">
+ *adding Xml file</p>
+ <p style="margin: 0px">
+ * the StructureMap.config file</p>
+ <p style="margin: 0px">
+ * sample Xml file</p>
+ <p style="margin: 0px">
+ </p>
+ <p style="margin: 0px">
+ </p>
+ <p style="margin: 0px">
+ </p>
+ <h4 style="margin: 0px">
+ Adding Configuration to a Container after Initialization</h4>
+ <p style="margin: 0px">
+ </p>
+ <p style="margin: 0px">
+ Sometimes you may want to add additional types and Instances to an existing
+ container. The Configure() method on both ObjectFactory and IContainer is
+ used for this purpose.
+ </p>
+ <p style="margin: 0px">
+ </p>
+ <p style="margin: 0px">
+ Here's a scenario. You're building a composite desktop application, and
+ for performance reasons you want to delay loading the screens and features for a
+ module of the application until the user explicitly activates that module.
+ When the user decides to start using that module, your code needs to immediately
+ add more types and Instances to the already running ObjectFactory. The
+ following code would search an assembly named
+ "MyCompany.MyApp.ExtensionAssembly" for Registry classes. The
+ configuration embedded in these new Registry classes would be added to the
+ Container internal to ObjectFactory.</p>
+ <p style="margin: 0px">
+ </p>
+<!--
+{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green128\blue0;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 \cf3 // Adding configuration from an extension Assembly\par ??\cf0 \cf3 // after ObjectFactory is already configured\par ??\cf0 \cf4 ObjectFactory\cf0 .Configure(x =>\par ?? \{\par ?? x.Scan(scan =>\par ?? \{\par ?? scan.Assembly(\cf5 "MyCompany.MyApp.ExtensionAssembly"\cf0 );\par ?? scan.LookForRegistries();\par ?? \});\par ?? \});}
+-->
+ <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;">
+ <p style="margin: 0px;">
+
+ <span style="color: green;">// Adding configuration from an extension Assembly</span></p>
+ <p style="margin: 0px;">
+
+ <span style="color: green;">// after ObjectFactory is already configured</span></p>
+ <p style="margin: 0px;">
+
+ <span style="color: #2b91af;">ObjectFactory</span>.Configure(x =></p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+
+ x.Scan(scan =></p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+
+ scan.Assembly(<span style="color: #a31515;">"MyCompany.MyApp.ExtensionAssembly"</span>);</p>
+ <p style="margin: 0px;">
+
+ scan.LookForRegistries();</p>
+ <p style="margin: 0px;">
+
+ });</p>
+ <p style="margin: 0px;">
+ });</p>
+ </div>
+<!--EndFragment-->
+<p style="margin: 0px">
+ </p>
+ <p style="margin: 0px">
+ </p>
+ <h4 style="margin: 0px">
+ Using Container independent of ObjectFactory</h4>
+ <p style="margin: 0px">
+ </p>
+ <p style="margin: 0px">
+ New to 2.5 is the ability to create an instance of the underlying Container
+ class independent of the static ObjectFactory class (actually, you always could
+ do this, but it's much easier in 2.5). The IContainer interface has
+ roughly the same methods as ObjectFactory (the only major difference is that
+ ObjectFactory.GetNamedInstance<T>(name) is IContainer.GetInstance<T>(name) )
+ You can build a Container with a single Registry object:</p>
+ <p style="margin: 0px">
+ </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;\red43\green145\blue175;}??\fs20 \cf3 var\cf0 container = \cf3 new\cf0 \cf4 Container\cf0 (\cf3 new\cf0 \cf4 BasicActionRegistry\cf0 ());}
+-->
+ <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;">
+ <p style="margin: 0px;">
+
+ <span style="color: blue;">var</span> container = <span style="color: blue;">new</span>
+ <span style="color: #2b91af;">Container</span>(<span style="color: blue;">new</span>
+ <span style="color: #2b91af;">BasicActionRegistry</span>());</p>
+ </div>
+<!--EndFragment-->
+<p style="margin: 0px">
+ </p>
+<p style="margin: 0px">
+ Or more commonly, you can build the Container in a manner very similar to the
+ ObjectFactory.Initialize() method. One of the constructors for Container
+ takes in an Action<ConfigurationExpression><ConfigurationExpression> expression
+ that can be used to configure the Container in one atomic action like this code
+ below:</p>
+<p style="margin: 0px">
+ </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;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 \cf3 var\cf0 container = \cf3 new\cf0 \cf4 Container\cf0 (x =>\par ?? \{\par ?? x.Scan(scanner =>\par ?? \{\par ?? scanner.Assembly(\cf5 "StructureMap.Testing.Widget"\cf0 )\par ?? \});\par ??\par ?? x.ForRequestedType<\cf4 Rule\cf0 >().TheDefault.Is.OfConcreteType<\cf4 ColorRule\cf0 >()\par ?? .WithCtorArg(\cf5 "Color"\cf0 ).EqualTo(\cf5 "Blue"\cf0 );\par ??\par ??\par ?? x.IncludeConfigurationFromConfigFile = \cf3 true\cf0 ;\par ??\par ?? x.AddConfigurationFromXmlFile(\cf5 "ExternalFile.xml"\cf0 );\par ?? \});}
+-->
+<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;">
+ <p style="margin: 0px;">
+
+ <span style="color: blue;">var</span> container = <span style="color: blue;">new</span>
+ <span style="color: #2b91af;">Container</span>(x =></p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+
+ x.Scan(scanner =></p>
+ <p style="margin: 0px;">
+
+ {</p>
+ <p style="margin: 0px;">
+
+ scanner.Assembly(<span style="color: #a31515;">"StructureMap.Testing.Widget"</span>)</p>
+ <p style="margin: 0px;">
+
+ });</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+
+ x.ForRequestedType<<span style="color: #2b91af;">Rule</span>>().TheDefault.Is.OfConcreteType<<span
+ style="color: #2b91af;">ColorRule</span>>()</p>
+ <p style="margin: 0px;">
+
+ .WithCtorArg(<span style="color: #a31515;">"Color"</span>).EqualTo(<span
+ style="color: #a31515;">"Blue"</span>);</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+
+ x.IncludeConfigurationFromConfigFile = <span style="color: blue;">true</span>;</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+
+ x.AddConfigurationFromXmlFile(<span style="color: #a31515;">"ExternalFile.xml"</span>);</p>
+ <p style="margin: 0px;">
+ });</p>
+</div>
+<!--EndFragment-->
+<p style="margin: 0px">
+ </p>
+<p style="margin: 0px">
+ The ConfigurationExpression class is a Registry, so you can use all of the
+ Registry DSL in the Lambda expression passed into the Container constructor.
+ In addition to the Registry DSL, you also have these options:</p>
+<p style="margin: 0px">
+ </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;\red43\green145\blue175;}??\fs20 \cf3 bool\cf0 IncludeConfigurationFromConfigFile \{ \cf3 set\cf0 ; \}\par ?? \cf3 void\cf0 AddRegistry<T>() \cf3 where\cf0 T : \cf4 Registry\cf0 , \cf3 new\cf0 ();\par ?? \cf3 void\cf0 AddRegistry(\cf4 Registry\cf0 registry);\par ?? \cf3 void\cf0 AddConfigurationFromXmlFile(\cf3 string\cf0 fileName);\par ?? \cf3 void\cf0 AddConfigurationFromNode(\cf4 XmlNode\cf0 node);}
+-->
+<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;">
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+ <span style="color: blue;">bool</span>
+ IncludeConfigurationFromConfigFile { <span style="color: blue;">set</span>; }</p>
+ <p style="margin: 0px;">
+ <span style="color: blue;">void</span>
+ AddRegistry<T>() <span style="color: blue;">where</span> T :
+ <span style="color: #2b91af;">Registry</span>, <span style="color: blue;">new</span>();</p>
+ <p style="margin: 0px;">
+ <span style="color: blue;">void</span>
+ AddRegistry(<span style="color: #2b91af;">Registry</span> registry);</p>
+ <p style="margin: 0px;">
+ <span style="color: blue;">void</span>
+ AddConfigurationFromXmlFile(<span style="color: blue;">string</span> fileName);</p>
+ <p style="margin: 0px;">
+ <span style="color: blue;">void</span>
+ AddConfigurationFromNode(<span style="color: #2b91af;">XmlNode</span> node);</p>
+ <p style="margin: 0px;">
+ </p>
+</div>
+<!--EndFragment-->
+<p style="margin: 0px">
+ </p>
+<p style="margin: 0px">
+ These other options will allow you to add configuration from additional Registry
+ classes, the StructureMap section in the App.config file, or other Xml files.</p>
+<p style="margin: 0px">
+ </p>
+<p style="margin: 0px">
+ Lastly, you can create a Container directly with a no argument constructor, then
+ use the Inject() methods or later use the Configure() method.</p>
+<p style="margin: 0px">
+ </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 Test\cf0 ]\par ?? \cf4 public\cf0 \cf4 void\cf0 Add_an_assembly_on_the_fly_and_pick_up_plugins2()\par ?? \{\par ?? \cf4 var\cf0 container = \cf4 new\cf0 \cf3 Container\cf0 ();\par ?? container.Configure(\par ?? registry =>\par ?? \{\par ?? registry.Scan(x =>\par ?? \{\par ?? x.AssemblyContainingType(\cf4 typeof\cf0 (\cf3 IService\cf0 <>));\par ?? x.AddAllTypesOf(\cf4 typeof\cf0 (\cf3 IService\cf0 <>));\par ?? \});\par ?? \}\par ?? );\par ??\par ?? \cf3 IList\cf0 <\cf3 IService\cf0 <\cf4 string\cf0 >> instances = container.GetAllInstances<\cf3 IService\cf0 <\cf4 string\cf0 >>();\par ?? instances.Count.ShouldBeGreaterThan(0);\par ?? \}}
+-->
+<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;">
+ <p style="margin: 0px;">
+ [<span style="color: #2b91af;">Test</span>]</p>
+ <p style="margin: 0px;">
+ <span style="color: blue;">public</span>
+ <span style="color: blue;">void</span>
+ Add_an_assembly_on_the_fly_and_pick_up_plugins2()</p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+
+ <span style="color: blue;">var</span> container = <span style="color: blue;">new</span>
+ <span style="color: #2b91af;">Container</span>();</p>
+ <p style="margin: 0px;">
+ container.Configure(</p>
+ <p style="margin: 0px;">
+
+ registry =></p>
+ <p style="margin: 0px;">
+
+ {</p>
+ <p style="margin: 0px;">
+
+ registry.Scan(x =></p>
+ <p style="margin: 0px;">
+
+ {</p>
+ <p style="margin: 0px;">
+
+ x.AssemblyContainingType(<span style="color: blue;">typeof</span> (<span
+ style="color: #2b91af;">IService</span><>));</p>
+ <p style="margin: 0px;">
+
+ x.AddAllTypesOf(<span style="color: blue;">typeof</span> (<span
+ style="color: #2b91af;">IService</span><>));</p>
+ <p style="margin: 0px;">
+
+ });</p>
+ <p style="margin: 0px;">
+
+ }</p>
+ <p style="margin: 0px;">
+
+ );</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+
+ <span style="color: #2b91af;">IList</span><<span style="color: #2b91af;">IService</span><<span
+ style="color: blue;">string</span>>> instances = container.GetAllInstances<<span
+ style="color: #2b91af;">IService</span><<span style="color: blue;">string</span>>>();</p>
+ <p style="margin: 0px;">
+
+ instances.Count.ShouldBeGreaterThan(0);</p>
+ <p style="margin: 0px;">
+ }</p>
+</div>
+<!--EndFragment-->
+<p style="margin: 0px">
+ </p>
+<p style="margin: 0px">
+ </p>
+<p style="margin: 0px">
+ </p>
+<p style="margin: 0px">
+ </p>
+<p>
+ </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;\red43\green145\blue175;\red0\green128\blue0;}??\fs20 \cf3 public\cf0 \cf3 class\cf0 \cf4 WebCoreRegistry\cf0 : \cf4 Registry\par ??\cf0 \{\par ?? \cf3 public\cf0 WebCoreRegistry()\par ?? \{\par ?? \cf5 // This is used as a sort of lightweight ScriptManager in\par ??\cf0 \cf5 // our website application\par ??\cf0 ForRequestedType<\cf4 ICachedSet\cf0 >().TheDefaultIsConcreteType<\cf4 CachedSet\cf0 >()\par ?? .CacheBy(\cf4 InstanceScope\cf0 .Hybrid);\par ??\par ?? ForRequestedType<\cf4 IControlBuilder\cf0 >().TheDefault.Is.OfConcreteType<\cf4 AspNetControlBuilder\cf0 >();\par ?? ForRequestedType<\cf4 IPartialRenderer\cf0 >().TheDefault.Is.OfConcreteType<\cf4 PartialRenderer\cf0 >();\par ??\par ?? Scan(x =>\par ?? \{\par ?? \cf5 // Scan "this" assembly. In other words, the assembly that \par ??\cf0 \cf5 // contains the WebCoreRegistry class\par ??\cf0 x.TheCallingAssembly();\par ??\par ?? x.IncludeNamespaceContainingType<\cf4 AuthenticationContext\cf0 >();\par ?? x.IncludeNamespaceContainingType<\cf4 ISecurityDataService\cf0 >();\par ??\par ?? x.WithDefaultConventions();\par ?? \});\par ?? \}\par ?? \}}
+-->
+<div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;">
+ <p style="margin: 0px;">
+ <span style="color: blue;">public</span> <span style="color: blue;">
+ class</span> <span style="color: #2b91af;">WebCoreRegistry</span> :
+ <span style="color: #2b91af;">Registry</span></p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+ <span style="color: blue;">public</span>
+ WebCoreRegistry()</p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+
+ <span style="color: green;">// This is used as a sort of lightweight
+ ScriptManager in</span></p>
+ <p style="margin: 0px;">
+
+ <span style="color: green;">// our website application</span></p>
+ <p style="margin: 0px;">
+ ForRequestedType<<span
+ style="color: #2b91af;">ICachedSet</span>>().TheDefaultIsConcreteType<<span
+ style="color: #2b91af;">CachedSet</span>>()</p>
+ <p style="margin: 0px;">
+
+ .CacheBy(<span style="color: #2b91af;">InstanceScope</span>.Hybrid);</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+ ForRequestedType<<span
+ style="color: #2b91af;">IControlBuilder</span>>().TheDefault.Is.OfConcreteType<<span
+ style="color: #2b91af;">AspNetControlBuilder</span>>();</p>
+ <p style="margin: 0px;">
+ ForRequestedType<<span
+ style="color: #2b91af;">IPartialRenderer</span>>().TheDefault.Is.OfConcreteType<<span
+ style="color: #2b91af;">PartialRenderer</span>>();</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+ Scan(x =></p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+
+ <span style="color: green;">// Scan "this" assembly. In other words, the
+ assembly that </span>
+ </p>
+ <p style="margin: 0px;">
+
+ <span style="color: green;">// contains the WebCoreRegistry class</span></p>
+ <p style="margin: 0px;">
+
+ x.TheCallingAssembly();</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+
+ x.IncludeNamespaceContainingType<<span style="color: #2b91af;">AuthenticationContext</span>>();</p>
+ <p style="margin: 0px;">
+
+ x.IncludeNamespaceContainingType<<span style="color: #2b91af;">ISecurityDataService</span>>();</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+
+ x.WithDefaultConventions();</p>
+ <p style="margin: 0px;">
+ });</p>
+ <p style="margin: 0px;">
+ }</p>
+ <p style="margin: 0px;">
+ }</p>
+</div>
+<!--EndFragment-->
+<p>
+ </p>
+<h4>
+ </h4>
+<p style="margin: 0px">
+ </p>
+<p style="margin: 0px">
+ </p>
+<p style="margin: 0px">
+ </p>
+<h4 style="margin: 0px">
+ </h4>
+<h4 style="margin: 0px">
+ StructureMapConfiguration/h4>
+ <p style="margin: 0px">
+ </p>
+ <p style="margin: 0px">
+ </p>
+
+
+ </body>
+</html>
\ No newline at end of file
Deleted: trunk/Source/HTML/CreatingContainer.htm
===================================================================
--- trunk/Source/HTML/CreatingContainer.htm 2008-10-21 22:02:21 UTC (rev 188)
+++ trunk/Source/HTML/CreatingContainer.htm 2008-10-21 22:10:22 UTC (rev 189)
@@ -1,9 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
- <head>
- <title></title>
- </head>
- <body>
-
- </body>
-</html>
\ No newline at end of file
Deleted: trunk/Source/HTML/EnvironmentTests.htm
===================================================================
--- trunk/Source/HTML/EnvironmentTests.htm 2008-10-21 22:02:21 UTC (rev 188)
+++ trunk/Source/HTML/EnvironmentTests.htm 2008-10-21 22:10:22 UTC (rev 189)
@@ -1,9 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
- <head>
- <title></title>
- </head>
- <body>
-
- </body>
-</html>
\ No newline at end of file
Deleted: trunk/Source/HTML/FAQ.htm
===================================================================
--- trunk/Source/HTML/FAQ.htm 2008-10-21 22:02:21 UTC (rev 188)
+++ trunk/Source/HTML/FAQ.htm 2008-10-21 22:10:22 UTC (rev 189)
@@ -1,9 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
- <head>
- <title></title>
- </head>
- <body>
-
- </body>
-</html>
\ No newline at end of file
Deleted: trunk/Source/HTML/FluentInterfaceAPI.htm
===================================================================
--- trunk/Source/HTML/FluentInterfaceAPI.htm 2008-10-21 22:02:21 UTC (rev 188)
+++ trunk/Source/HTML/FluentInterfaceAPI.htm 2008-10-21 22:10:22 UTC (rev 189)
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
- <head>
- <title>Configuring StructureMap with the Programmatic API</title>
- </head>
- <body>
- <h4>Configuring StructureMap with the Programmatic API</h4>
-
- <p>
- </p>
-
- </body>
-</html>
\ No newline at end of file
Deleted: trunk/Source/HTML/GentleGuide.htm
===================================================================
--- trunk/Source/HTML/GentleGuide.htm 2008-10-21 22:02:21 UTC (rev 188)
+++ trunk/Source/HTML/GentleGuide.htm 2008-10-21 22:10:22 UTC (rev 189)
@@ -1,9 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
- <head>
- <title></title>
- </head>
- <body>
-
- </body>
-</html>
\ No newline at end of file
Modified: trunk/Source/HTML/HTML.csproj
===================================================================
--- trunk/Source/HTML/HTML.csproj 2008-10-21 22:02:21 UTC (rev 188)
+++ trunk/Source/HTML/HTML.csproj 2008-10-21 22:10:22 UTC (rev 189)
@@ -58,42 +58,26 @@
-->
<ItemGroup>
<Content Include="AttributeNormalized.htm" />
- <Content Include="AutoMocking.htm" />
- <Content Include="BestPractices.htm" />
- <Content Include="ChangingDefaultsAtRuntime.htm" />
- <Content Include="CompositeConfiguration.htm" />
+ <Content Include="ConfiguringStructureMap.htm" />
<Content Include="Example.xml" />
<Content Include="Glossary.htm" />
- <Content Include="ConcreteTypes.htm" />
- <Content Include="ConfigurationArchitecture.htm" />
- <Content Include="ConfiguringStructureMap.htm" />
- <Content Include="CreatingContainer.htm" />
<Content Include="Default.htm" />
<Content Include="Diagnostics.htm" />
- <Content Include="EnvironmentTests.htm" />
<Content Include="ExplicitArguments.htm" />
<Content Include="ExtendingStructureMap.htm" />
- <Content Include="FAQ.htm" />
- <Content Include="FluentInterfaceAPI.htm" />
+ <Content Include="InstanceExpression.htm" />
+ <Content Include="RegistryDSL.htm" />
<Content Include="Generics.htm" />
- <Content Include="GentleGuide.htm" />
- <Content Include="ImplicitInstances.htm" />
<Content Include="InjectingServicesAtRuntime.htm" />
<Content Include="Interception.htm" />
<Content Include="NodeNormalized.htm" />
- <Content Include="Profiles.htm" />
<Content Include="QuickStart.htm" />
<Content Include="RuntimeArchitecture.htm" />
<Content Include="Sample.xml" />
<Content Include="ScanningAssemblies.htm" />
- <Content Include="Scoping.htm" />
<Content Include="ConstructorAndSetterInjection.htm" />
- <Content Include="StructureMapAndMocks.htm" />
- <Content Include="StructureMapDoctor.htm" />
- <Content Include="TroubleShooting.htm" />
<Content Include="RetrievingServices.htm" />
<Content Include="UsingStructureMapWithinUnitTests.htm" />
- <Content Include="WhatWillStructureMapDoWhenI.htm" />
<Content Include="XmlConfiguration.htm" />
</ItemGroup>
<ItemGroup>
Deleted: trunk/Source/HTML/ImplicitInstances.htm
===================================================================
--- trunk/Source/HTML/ImplicitInstances.htm 2008-10-21 22:02:21 UTC (rev 188)
+++ trunk/Source/HTML/ImplicitInstances.htm 2008-10-21 22:10:22 UTC (rev 189)
@@ -1,9 +0,0 @@
-<!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/InstanceExpression.htm
===================================================================
--- trunk/Source/HTML/InstanceExpression.htm (rev 0)
+++ trunk/Source/HTML/InstanceExpression.htm 2008-10-21 22:10:22 UTC (rev 189)
@@ -0,0 +1,551 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <title>The Instance Expression</title>
+ </head>
+ <body>
+ <h1>The Instance Expression</h1>
+ <p>
+ One of the most common tasks in the Registry DSL [LINK] is defining how an
+ Instance will be created. In an effort to standardize the Registry DSL and
+ make the API more predictable and consistent, we have introduced the
+ "InstanceExpression" as a shared
+ <a href="http://martinfowler.com/dslwip/ExpressionBuilder.html">Expression
+ Builder</a>. As of 2.5, all operations in the Registry DSL that require
+ the definition of an Instance expose an option to use an InstanceExpression with
+ these options:</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;\red43\green145\blue175;\red0\green128\blue0;}??\fs20 \cf3 public\cf0 \cf3 interface\cf0 \cf4 IInstanceExpression\cf0 <T> : \cf4 IsExpression\cf0 <T>\par ?? \{\par ?? \cf5 // Attach an Instance object that is configured\par ??\cf0 \cf5 // independently of the DSL\par ??\cf0 \cf3 void\cf0 Instance(\cf4 Instance\cf0 instance);\par ?? \cf3 void\cf0 IsThis(\cf4 Instance\cf0 instance);\par ?? \par ?? \cf5 // Use a pre-built object\par ??\cf0 \cf4 LiteralInstance\cf0 IsThis(T obj);\par ?? \cf4 LiteralInstance\cf0 Object(T theObject);\par ??\par ?? \cf5 // Use a type\par ??\cf0 \cf4 SmartInstance\cf0 <PLUGGEDTYPE> OfConcreteType<PLUGGEDTYPE>() \cf3 where\cf0 PLUGGEDTYPE : T;\par ?? \cf4 ConfiguredInstance\cf0 OfConcreteType(\cf4 Type\cf0 type);\par ??\par ?? \cf5 // Build by a Lambda or an Anonymous Delegate\par ??\cf0 \cf4 ConstructorInstance\cf0 <T> ConstructedBy(\cf4 Func\cf0 <T> func);\par ?? \cf4 ConstructorInstance\cf0 <T> ConstructedBy(\cf4 Func\cf0 <\cf4 IContext\cf0 , T> func);\par ??\par ?? \cf5 // Refer to a named Instance\par ??\cf0 \cf4 ReferencedInstance\cf0 TheInstanceNamed(\cf3 string\cf0 key);\par ?? \cf4 DefaultInstance\cf0 TheDefault();\par ??\par ?? \cf5 // Use a cloned copy of the template\par ??\cf0 \cf4 PrototypeInstance\cf0 PrototypeOf(T template);\par ??\par ?? \cf5 // Cache the template as a binary serialized blob\par ??\cf0 \cf4 SerializedInstance\cf0 SerializedCopyOf(T template);\par ?? \par ?? \cf5 // Load an ASCX control\par ??\cf0 \cf4 UserControlInstance\cf0 LoadControlFrom(\cf3 string\cf0 url);\par ?? \}}
+-->
+ <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;">
+ <p style="margin: 0px;">
+ <span style="color: blue;">public</span> <span style="color: blue;">
+ interface</span> <span style="color: #2b91af;">IInstanceExpression</span><T> : <span style="color: #2b91af;">IsExpression</span><T></p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+ <span style="color: green;">// Attach an Instance
+ object that is configured</span></p>
+ <p style="margin: 0px;">
+ <span style="color: green;">/// independently of
+ the DSL. This is an extensibility point</span></p>
+ <p style="margin: 0px;">
+ <span style="color: blue;">void</span> Instance(<span
+ style="color: #2b91af;">Instance</span> instance);</p>
+ <p style="margin: 0px;">
+ <span style="color: blue;">void</span> IsThis(<span
+ style="color: #2b91af;">Instance</span> instance);</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+ <span style="color: green;">// Use a pre-built
+ object</span></p>
+ <p style="margin: 0px;">
+ <span style="color: #2b91af;">LiteralInstance</span>
+ IsThis(T obj);</p>
+ <p style="margin: 0px;">
+ <span style="color: #2b91af;">LiteralInstance</span>
+ Object(T theObject);</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+ <span style="color: green;">// Use a type and
+ build with its constructor function</span></p>
+ <p style="margin: 0px;">
+ <span style="color: #2b91af;">SmartInstance</span><PLUGGEDTYPE>
+ OfConcreteType<PLUGGEDTYPE>() <span style="color: blue;">where</span>
+ PLUGGEDTYPE : T;</p>
+ <p style="margin: 0px;">
+ <span style="color: #2b91af;">ConfiguredInstance</span>
+ OfConcreteType(<span style="color: #2b91af;">Type</span> type);</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+ <span style="color: green;">// Build by a Lambda
+ or an Anonymous Delegate</span></p>
+ <p style="margin: 0px;">
+ <span style="color: #2b91af;">ConstructorInstance</span><T>
+ ConstructedBy(<span style="color: #2b91af;">Func</span><T> func);</p>
+ <p style="margin: 0px;">
+ <span style="color: #2b91af;">ConstructorInstance</span><T>
+ ConstructedBy(<span style="color: #2b91af;">Func</span><<span
+ style="color: #2b91af;">IContext</span>, T> func);</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+ <span style="color: green;">// Refer to a named
+ Instance</span></p>
+ <p style="margin: 0px;">
+ <span style="color: #2b91af;">ReferencedInstance</span>
+ TheInstanceNamed(<span style="color: blue;">string</span> key);</p>
+ <p style="margin: 0px;">
+ <span style="color: #2b91af;">DefaultInstance</span>
+ TheDefault();</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+ <span style="color: green;">// Use a cloned copy
+ of the template</span></p>
+ <p style="margin: 0px;">
+ <span style="color: #2b91af;">PrototypeInstance</span>
+ PrototypeOf(T template);</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+ <span style="color: green;">// Cache the template
+ as a binary serialized blob</span></p>
+ <p style="margin: 0px;">
+ <span style="color: #2b91af;">SerializedInstance</span>
+ SerializedCopyOf(T template);</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+ <span style="color: green;">// Load an ASCX
+ control</span></p>
+ <p style="margin: 0px;">
+ <span style="color: #2b91af;">UserControlInstance</span>
+ LoadControlFrom(<span style="color: blue;">string</span> url);</p>
+ <p style="margin: 0px;">
+ }</p>
+ </div>
+<!--EndFragment-->
+<p>
+ Here's several examples of how the InstanceExpression is invoked. In the
+ code sample below, the text "**********;" represents a call to an
+ InstanceExpression.</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;\red43\green145\blue175;\red0\green128\blue0;\red163\green21\blue21;}??\fs20 \cf3 public\cf0 \cf3 class\cf0 \cf4 InstanceExampleRegistry\cf0 : \cf4 Registry\par ??\cf0 \{\par ?? \cf3 public\cf0 InstanceExampleRegistry()\par ?? \{\par ?? \cf5 // Shortcut for just specifying "use this type -- with auto wiring"\par ??\cf0 ForRequestedType<\cf4 IService\cf0 >().TheDefaultIsConcreteType<\cf4 RemoteService\cf0 >();\par ?? \par ?? \cf5 // Set the default Instance of a PluginType\par ??\cf0 ForRequestedType<\cf4 IService\cf0 >().TheDefault.Is.OfConcreteType<\cf4 RemoteService\cf0 >();\par ?? \par ?? \cf5 // Add an additional Instance of a PluginType\par ??\cf0 InstanceOf<\cf4 IService\cf0 >().Is.OfConcreteType<\cf4 RemoteService\cf0 >();\par ??\par ?? \cf5 // Add multiple additional Instances of a PluginType\par ??\cf0 ForRequestedType<\cf4 IService\cf0 >().AddInstances(x =>\par ?? \{\par ?? x.ConstructedBy(() => \cf3 new\cf0 \cf4 ColorService\cf0 (\cf6 "Red"\cf0 ));\par ??\par ?? x.OfConcreteType<\cf4 RemoteService\cf0 >();\par ??\par ?? x.Object(\cf3 new\cf0 \cf4 ColorService\cf0 (\cf6 "Red"\cf0 ));\par ?? \});\par ??\par ?? \cf5 // Use the InstanceExpression to define the default Instance\par ??\cf0 \cf5 // of a PluginType within a Profile\par ??\cf0 CreateProfile(\cf6 "Connected"\cf0 , x =>\par ?? \{\par ?? x.Type<\cf4 IService\cf0 >().Is.OfConcreteType<\cf4 RemoteService\cf0 >();\par ?? \});\par ?? \}\par ?? \}}
+-->
+ <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;">
+ <p style="margin: 0px;">
+ <span style="color: blue;">public</span> <span style="color: blue;">class</span>
+ <span style="color: #2b91af;">InstanceExampleRegistry</span> :
+ <span style="color: #2b91af;">Registry</span></p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+ <span style="color: blue;">public</span>
+ InstanceExampleRegistry()</p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+
+ <span style="color: green;">// Set the default Instance of a PluginType</span></p>
+ <p style="margin: 0px;">
+ ForRequestedType<<span
+ style="color: #2b91af;">IService</span>>().TheDefault.Is.**********;</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+
+ <span style="color: green;">// Add an additional Instance of a PluginType</span></p>
+ <p style="margin: 0px;">
+ InstanceOf<<span
+ style="color: #2b91af;">IService</span>>().Is.**********;</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+
+ <span style="color: green;">// Add multiple additional Instances of a PluginType</span></p>
+ <p style="margin: 0px;">
+ ForRequestedType<<span
+ style="color: #2b91af;">IService</span>>().AddInstances(x =></p>
+ <p style="margin: 0px;">
+ {</p>
+ <p style="margin: 0px;">
+
+ x.**********;</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+
+ x.**********;</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+
+ x.**********;</p>
+ <p style="margin: 0px;">
+ });</p>
+ <p style="margin: 0px;">
+ </p>
+ <p style="margin: 0px;">
+
+ <span style="color: green;">// Use the InstanceExpression to define the default
+ Instance</span></p>
+ <p style="margin: 0px;">
+
+ <span style="color: green;">// of a PluginType within a Profile</span></p>
+ <p style="margin: 0px;">
+ CreateProfile(<span
+ style="color: #a31515;">"Connected"</span>, x =></p>
+ <p style="margin: 0px;">
+ &nb...
[truncated message content] |