<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>Sayed Y. Hashimi</title>
  <link rel="alternate" type="text/html" href="http://www.sayedhashimi.com/" />
  <link rel="self" href="http://www.sayedhashimi.com/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2007-11-09T12:22:14.9635-08:00</updated>
  <author>
    <name>Sayed Y. Hashimi</name>
  </author>
  <subtitle>Smart Client, ClickOnce, .NET, Java</subtitle>
  <id>http://www.sayedhashimi.com/</id>
  <generator uri="http://www.dasblog.net" version="1.8.5223.2">DasBlog</generator>
  <entry>
    <title>MTOM with Axis2 version 1.3</title>
    <link rel="alternate" type="text/html" href="http://www.sayedhashimi.com/PermaLink,guid,56ac3f2c-ba05-4ba3-83fa-9f54e3f5021f.aspx" />
    <id>http://www.sayedhashimi.com/PermaLink,guid,56ac3f2c-ba05-4ba3-83fa-9f54e3f5021f.aspx</id>
    <published>2007-11-09T12:22:14.9635-08:00</published>
    <updated>2007-11-09T12:22:14.9635-08:00</updated>
    <category term="Web Services" label="Web Services" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <font size="2">
          <p>
      A step-by-step guide to writing a web service which supports MTOM and a web service
      client to call it. The example assumes a Windows environment and Eclipse as the development
      environment. 
   </p>
          <b>
            <p>
      Setup the Development Environment
   </p>
          </b>
          <p>
      1. Download Tomcat version 5.5 from 
   </p>
        </font>
        <a href="http://tomcat.apache.org/download-55.cgi">
          <u>
            <font color="#0000ff" size="2">http://tomcat.apache.org/download-55.cgi
   </font>
          </u>
        </a>
        <font size="2">
          <p>
      2. Set the JAVA_HOME environment variable to the Java JDK directory. Note that you
      have to set the variable to the JDK and not the JRE install folder.
   </p>
          <p>
      3. Run startup.bat from the Tomcat distribution bin directory to make sure Tomcat
      will run. If all is good, run shutdown.bat from the bin directory to stop the Tomcat
      server.
   </p>
          <p>
      4. Download Axis2 version 1.3 (
   </p>
        </font>
        <a href="http://ws.apache.org/axis2/download/1_3/download.cgi">
          <u>
            <font color="#0000ff" size="2">http://ws.apache.org/axis2/download/1_3/download.cgi
   </font>
          </u>
        </a>
        <font size="2">)
   <p>
      a. Download the Standard Distribution and the WAR distribution.
   </p><p>
      5. Copy the axis2.war file from the WAR distribution in step 4 to the webapps folder
      under Tomcat. Start Tomcat by running startup.bat. If Tomcat was able to consume the
      war file, then you should be able to browse to 
   </p></font>
        <a href="http://localhost:8080/axis2/">
          <u>
            <font color="#0000ff" size="2">http://localhost:8080/axis2/
   </font>
          </u>
        </a>
        <font size="2"> to see the Axis2 web application default page.
   <p>
      6. Upon startup, Tomcat unpacked the axis2.war file. Have a look at the axis2.xml
      configuration file within axis2\WEB-INF\conf\ folder.
   </p><p>
      7. The axis2.xml file contains the administrator username and password for axis2 administration.
      By default the username and password to admin and axis2, respectively. You can modify
      this by changing the values and restarting Tomcat.
   </p><p>
      8. Point your browser to the axis2 web application and choose the Administration link. 
   </p></font>
        <a href="http://localhost:8080/axis2/axis2-admin/login">
          <u>
            <font color="#0000ff" size="2">http://localhost:8080/axis2/axis2-admin/login
   </font>
          </u>
        </a>
        <font size="2">. Type in the username and password to access the admin
   console.
   <p>
      9. So far we have Tomcat and Axis2 up and running. To make this exercise less painful,
      we should also download TCPMon so we can view the SOAP message we create. Download
      TCPMon from: 
   </p></font>
        <a href="http://ws.apache.org/commons/tcpmon/download.cgi">
          <u>
            <font color="#0000ff" size="2">http://ws.apache.org/commons/tcpmon/download.cgi
   </font>
          </u>
        </a>
        <font size="2">. This utility is very cool and easy to use. Before
   you start TCPMon (by running tcpmon.bat from the build), have a look at the user guide. </font>
        <a href="http://wso2.org/project/wsas/java/2.1/docs/tools/tcpmonguide.html">
          <u>
            <font color="#0000ff" size="2">http://wso2.org/project/wsas/java/2.1/docs/tools/tcpmonguide.html
   </font>
          </u>
        </a>
        <font size="2">
          <b>
            <p>
      Create MTOM Enabled Web Service
   </p>
          </b>
          <p>
      1. Create a new Java Project in Eclipse. Name the project TestMTOM.
   </p>
          <p>
      2. Add the axis2 jar files to the classpath. The axis2 jar files are within the lib
      directory of the axis2 standard distribution.
   </p>
          <p>
      3. Create a new class named TestService within a package named com.test. Paste the
      following for the class implementation.
   </p>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      package
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> com.test;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> java.io.File;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> java.io.FileNotFoundException;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> java.io.FileOutputStream;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> java.io.IOException;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> java.io.InputStream;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> java.io.OutputStream;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> javax.activation.DataHandler;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> org.apache.axiom.om.OMElement;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> org.apache.axiom.om.OMText;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      public
   </p>
          </font>
        </b>
        <font face="Courier New" color="#000000" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">class
   </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> TestService </font>
          <p>
      {
   </p>
          <p>
          </p>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">private
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">static
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">final
   </font>
        </b>
        <font face="Courier New" size="2"> String </font>
        <i>
          <font face="Courier New" color="#0000c0" size="2">OUTPUT_FILE
   </font>
        </i>
        <font face="Courier New" size="2"> = </font>
        <font face="Courier New" color="#2a00ff" size="2">"C:\\HOLD\\att.pdf"</font>
        <font face="Courier New" size="2">;
   <p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">public
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">void
   </font>
        </b>
        <font face="Courier New" size="2"> receiveMTOM(OMElement element) </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">throws
   </font>
        </b>
        <font face="Courier New" size="2"> Exception 
   <p>
      {
   </p><p>
      System.
   </p></font>
        <i>
          <font face="Courier New" color="#0000c0" size="2">out
   </font>
        </i>
        <font face="Courier New" size="2">.println(</font>
        <font face="Courier New" color="#2a00ff" size="2">"received
   request..."</font>
        <font face="Courier New" size="2">);
   <p></p><p>
      OMText binaryNode = (OMText) (element.getFirstElement()).getFirstOMChild();
   </p><p>
      binaryNode.setOptimize(
   </p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">true
   </font>
        </b>
        <font face="Courier New" size="2">);
   <p>
      DataHandler dh = (DataHandler) binaryNode.getDataHandler();
   </p><p>
      InputStream is = dh.getInputStream();
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">byte
   </font>
        </b>
        <font face="Courier New" size="2">[] buf = <i>readFully</i>(is);
   <p><i>writeOutput</i>(buf);
   </p><p></p><p>
      System.
   </p></font>
        <i>
          <font face="Courier New" color="#0000c0" size="2">out
   </font>
        </i>
        <font face="Courier New" size="2">.println(</font>
        <font face="Courier New" color="#2a00ff" size="2">"done
   writing output file."</font>
        <font face="Courier New" size="2">);
   <p>
      }
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">private
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">static
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">void
   </font>
        </b>
        <font face="Courier New" size="2"> writeOutput(</font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">byte
   </font>
        </b>
        <font face="Courier New" size="2">[] buf)</font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">throws
   </font>
        </b>
        <font face="Courier New" size="2"> IOException
   <p>
      {
   </p><p>
      File of = 
   </p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">new
   </font>
        </b>
        <font face="Courier New" size="2"> File(</font>
        <i>
          <font face="Courier New" color="#0000c0" size="2">OUTPUT_FILE
   </font>
        </i>
        <font face="Courier New" size="2">);
   <p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">if
   </font>
        </b>
        <font face="Courier New" size="2">(of.exists())
   <p>
      {
   </p><p>
      of.delete();
   </p><p>
      }
   </p><p>
      of.createNewFile();
   </p><p><i>setContents</i>(
   </p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">new
   </font>
        </b>
        <font face="Courier New" size="2"> File(</font>
        <i>
          <font face="Courier New" color="#0000c0" size="2">OUTPUT_FILE
   </font>
        </i>
        <font face="Courier New" size="2">),buf);
   <p>
      }
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">private
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">static
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">void
   </font>
        </b>
        <font face="Courier New" size="2"> setContents(File aFile, </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">byte
   </font>
        </b>
        <font face="Courier New" size="2">[] aContents) </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">throws
   </font>
        </b>
        <font face="Courier New" size="2"> FileNotFoundException, IOException
   <p>
      {
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">if
   </font>
        </b>
        <font face="Courier New" size="2"> (aFile == </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">null
   </font>
        </b>
        <font face="Courier New" size="2">)
   <p>
      {
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">throw
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">new
   </font>
        </b>
        <font face="Courier New" size="2"> IllegalArgumentException(</font>
        <font face="Courier New" color="#2a00ff" size="2">"File
   should not be null."</font>
        <font face="Courier New" size="2">);
   <p>
      }
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">if
   </font>
        </b>
        <font face="Courier New" size="2"> (!aFile.exists())
   <p>
      {
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">throw
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">new
   </font>
        </b>
        <font face="Courier New" size="2"> FileNotFoundException(</font>
        <font face="Courier New" color="#2a00ff" size="2">"File
   does not exist: "</font>
        <font face="Courier New" size="2"> + aFile);
   <p>
      }
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">if
   </font>
        </b>
        <font face="Courier New" size="2"> (!aFile.isFile())
   <p>
      {
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">throw
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">new
   </font>
        </b>
        <font face="Courier New" size="2"> IllegalArgumentException(</font>
        <font face="Courier New" color="#2a00ff" size="2">"Should
   not be a directory: "</font>
        <font face="Courier New" size="2"> + aFile);
   <p>
      }
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">if
   </font>
        </b>
        <font face="Courier New" size="2"> (!aFile.canWrite())
   <p>
      {
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">throw
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">new
   </font>
        </b>
        <font face="Courier New" size="2"> IllegalArgumentException(</font>
        <font face="Courier New" color="#2a00ff" size="2">"File
   cannot be written: "</font>
        <font face="Courier New" size="2"> + aFile);
   <p>
      }
   </p><p></p></font>
        <font face="Courier New" color="#3f5fbf" size="2">/**
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">declared</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">here</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">only</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">to</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">make</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">visible</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">to</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">finally</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">clause;</font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">generic</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">reference
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*/
   </font>
        <font face="Courier New" size="2">
          <p>
      OutputStream output = 
   </p>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">null
   </font>
        </b>
        <font face="Courier New" size="2">;
   <p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">try
   </font>
        </b>
        <font face="Courier New" size="2">
          <p>
      {
   </p>
          <p>
      output = 
   </p>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">new
   </font>
        </b>
        <font face="Courier New" size="2"> FileOutputStream(aFile);
   <p>
      output.write(aContents);
   </p><p>
      }
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">finally
   </font>
        </b>
        <font face="Courier New" size="2">
          <p>
      {
   </p>
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">/**
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">flush</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">and</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">close</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">both</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">"output"</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">and</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">its</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">underlying</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">FileWriter
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*/
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">if
   </font>
        </b>
        <font face="Courier New" size="2"> (output != </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">null
   </font>
        </b>
        <font face="Courier New" size="2">)
   <p>
      output.close();
   </p><p>
      }
   </p><p>
      }
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">private
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">static
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">byte
   </font>
        </b>
        <font face="Courier New" size="2">[] readFully(InputStream is) </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">throws
   </font>
        </b>
        <font face="Courier New" size="2"> IOException
   <p>
      {
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">int
   </font>
        </b>
        <font face="Courier New" size="2"> size = 10000;
   <p></p></font>
        <font face="Courier New" color="#3f5fbf" size="2">/**
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">Offset</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#7f7f9f" size="2">-</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">how</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">much</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">we've</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">read
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*/
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">int
   </font>
        </b>
        <font face="Courier New" size="2"> off = 0;
   <p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">int
   </font>
        </b>
        <font face="Courier New" size="2"> got;
   <p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">byte
   </font>
        </b>
        <font face="Courier New" size="2">[] ret = </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">new
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">byte
   </font>
        </b>
        <font face="Courier New" size="2">[size];
   <p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">try
   </font>
        </b>
        <font face="Courier New" size="2">
          <p>
      {
   </p>
          <p>
          </p>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">while
   </font>
        </b>
        <font face="Courier New" size="2"> (</font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">true
   </font>
        </b>
        <font face="Courier New" size="2">)
   <p>
      {
   </p><p>
      got = is.read(ret, off, size - off);
   </p><p></p></font>
        <font face="Courier New" color="#3f5fbf" size="2">/**
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">End</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">of</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">stream
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*/
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">if
   </font>
        </b>
        <font face="Courier New" size="2"> (got == -1)
   <p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">break
   </font>
        </b>
        <font face="Courier New" size="2">;
   <p>
      off += got;
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">if
   </font>
        </b>
        <font face="Courier New" size="2"> (off == size)
   <p>
      {
   </p><p></p></font>
        <font face="Courier New" color="#3f5fbf" size="2">/**
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">If</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">we've</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">read</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">to</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">the</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">end</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">of</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">our</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">buffer,
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">enlarge</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">it.
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*/
   </font>
        <font face="Courier New" size="2">
          <p>
      size *= 2;
   </p>
          <p>
          </p>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">byte
   </font>
        </b>
        <font face="Courier New" size="2">[] tmp = </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">new
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">byte
   </font>
        </b>
        <font face="Courier New" size="2">[size];
   <p>
      System.<i>arraycopy</i>(ret, 0, tmp, 0, off);
   </p><p>
      ret = tmp;
   </p><p>
      }
   </p><p>
      }
   </p><p>
      }
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">finally
   </font>
        </b>
        <font face="Courier New" size="2">
          <p>
      {
   </p>
          <p>
          </p>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">if
   </font>
        </b>
        <font face="Courier New" size="2">(is!=</font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">null
   </font>
        </b>
        <font face="Courier New" size="2">)is.close();
   <p>
      }
   </p><p></p></font>
        <font face="Courier New" color="#3f5fbf" size="2">/**
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">If</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">we've</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">got</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">a</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">bigger</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">buffer</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">than</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">we</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">need,</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">resize</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">it</font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*/
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">if
   </font>
        </b>
        <font face="Courier New" size="2"> (off != size)
   <p>
      {
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">byte
   </font>
        </b>
        <font face="Courier New" size="2">[] tmp = </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">new
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">byte
   </font>
        </b>
        <font face="Courier New" size="2">[off];
   <p>
      System.<i>arraycopy</i>(ret, 0, tmp, 0, off);
   </p><p>
      ret = tmp;
   </p><p>
      }
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">return
   </font>
        </b>
        <font face="Courier New" size="2"> ret;
   <p>
      }
   </p><p>
      }
   </p></font>
        <font size="2">
          <p>
      The receiveMTOM() method expects an 
   </p>
        </font>
        <font face="Courier New" size="2">OMElement</font>
        <font face="Courier New" size="2">,
   which then contains the binary file. The method simply pulls the binary file out of
   the SOAP message and saves it to the local file system. The file is identified by
   the OUTPUT_FILE static variable. Note that we have to 
   <p></p></font>
        <font face="Courier New" size="2">binaryNode.setOptimize(</font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">true
   </font>
        </b>
        <font face="Courier New" size="2">);
   </font>
        <font size="2">
          <p>
      prior to calling the getDataHandler() method. 
   </p>
          <p>
      4. The service implementation is done. Now we have to create a service.xml file. To
      do that, first create a folder under the root of the project and name it META-INF.
      Within this folder, create an xml file and name it services.xml. Paste the following
      into that file.
   </p>
        </font>
        <font face="Courier New" color="#008080" size="2">
          <p>
      &lt;
   </p>
        </font>
        <font face="Courier New" color="#3f7f7f" size="2">service </font>
        <font face="Courier New" color="#7f007f" size="2">name</font>
        <font face="Courier New" color="#000000" size="2">=</font>
        <font face="Courier New" color="#2a00ff" size="2">"TestService"</font>
        <font face="Courier New" color="#008080" size="2">&gt;
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#008080" size="2">&lt;</font>
        <font face="Courier New" color="#3f7f7f" size="2">description</font>
        <font face="Courier New" color="#008080" size="2">&gt;
   </font>
        <font face="Courier New" size="2">
          <p>
      This service is to get the running Axis version
   </p>
          <p>
          </p>
        </font>
        <font face="Courier New" color="#008080" size="2">&lt;/</font>
        <font face="Courier New" color="#3f7f7f" size="2">description</font>
        <font face="Courier New" color="#008080" size="2">&gt;
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#008080" size="2">&lt;</font>
        <font face="Courier New" color="#3f7f7f" size="2">parameter </font>
        <font face="Courier New" color="#7f007f" size="2">name</font>
        <font face="Courier New" size="2">=</font>
        <font face="Courier New" color="#2a00ff" size="2">"ServiceClass"</font>
        <font face="Courier New" color="#008080" size="2">&gt;</font>
        <font face="Courier New" size="2">com.test.TestService</font>
        <font face="Courier New" color="#008080" size="2">&lt;/</font>
        <font face="Courier New" color="#3f7f7f" size="2">parameter</font>
        <font face="Courier New" color="#008080" size="2">&gt;
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#008080" size="2">&lt;</font>
        <font face="Courier New" color="#3f7f7f" size="2">parameter </font>
        <font face="Courier New" color="#7f007f" size="2">name</font>
        <font face="Courier New" size="2">=</font>
        <font face="Courier New" color="#2a00ff" size="2">"enableMTOM"</font>
        <font face="Courier New" color="#008080" size="2">&gt;</font>
        <font face="Courier New" size="2">true</font>
        <font face="Courier New" color="#008080" size="2">&lt;/</font>
        <font face="Courier New" color="#3f7f7f" size="2">parameter</font>
        <font face="Courier New" color="#008080" size="2">&gt;
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#008080" size="2">&lt;</font>
        <font face="Courier New" color="#3f7f7f" size="2">operation </font>
        <font face="Courier New" color="#7f007f" size="2">name</font>
        <font face="Courier New" size="2">=</font>
        <font face="Courier New" color="#2a00ff" size="2">"receiveMTOM"</font>
        <font face="Courier New" color="#008080" size="2">&gt;
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#008080" size="2">&lt;</font>
        <font face="Courier New" color="#3f7f7f" size="2">messageReceiver </font>
        <font face="Courier New" color="#7f007f" size="2">class</font>
        <font face="Courier New" size="2">=</font>
        <font face="Courier New" color="#2a00ff" size="2">"org.apache.axis2.rpc.receivers.RPCMessageReceiver" </font>
        <font face="Courier New" color="#008080" size="2">/&gt;
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#008080" size="2">&lt;/</font>
        <font face="Courier New" color="#3f7f7f" size="2">operation</font>
        <font face="Courier New" color="#008080" size="2">&gt;
   <p>
      &lt;/
   </p></font>
        <font face="Courier New" color="#3f7f7f" size="2">service</font>
        <font face="Courier New" color="#008080" size="2">&gt;
   </font>
        <font face="Courier New" size="2">
          <p>
      To enable MTOM, we have to add a parameter for the service called enableMTOM and set
      its value to true. Note that MTOM is disabled by default.
   </p>
          <p>
      5. The next thing we have to do is package the service as a jar file but with a "aar"
      extension. You can do this several ways, but the easiest approach is to just use Eclipse's
      Export functionality. 
   </p>
          <p>
      6. Once you have the aar file, copy it under the axis2 deployment within Tomcat. This
      would be at TOMCAT_INSTALL\webapps\axis2\WEB-INF\services\
   </p>
          <p>
      7. Restart Tomcat.
   </p>
        </font>
        <font size="2">
          <b>
            <p>
      Create MTOM enabled Web Service Client
   </p>
          </b>
          <p>
      1. Before we can call the service, we need a proxy to the web service. Assuming Tomcat
      is running, browse to the following URL. 
   </p>
        </font>
        <a href="http://localhost:8080/axis2/services/TestService?wsdl">
          <u>
            <font color="#0000ff" size="2">http://localhost:8080/axis2/services/TestService?wsdl
   </font>
          </u>
        </a>
        <font size="2">
          <p>
      2. To create the proxy, save the WSDL file to the bin directory of the Axis2 installation.
      Name the file TestService.wsdl. Note that within this directory, you'll also have
      the WSDL2Java.bat file that we need to use to create the web service proxy.
   </p>
          <p>
      3. After you save the WSDL file, open a command prompt and execute 
   </p>
          <p>
      WSDL2JAVA -uri TestService.wsdl
   </p>
          <p>
      This should create the proxy files with a folder name src. 
   </p>
          <p>
      4. Now we need to create a java project within Eclipse for the web service client.
      Create a new Project and name it TestMTOMClient. 
   </p>
          <p>
      5. Add the Axis2 jar files to the classpath. 
   </p>
          <p>
      6. Copy the src folder from step 3 under the TestMTOMClient project and refresh the
      project in Eclipse.
   </p>
          <p>
      7. Now create a class to execute the web service. Name the class TestClient and paste
      the following in its place.
   </p>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      package
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> com.test;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> java.io.File;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> java.io.FileInputStream;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> java.io.IOException;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> java.io.InputStream;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> junit.framework.TestCase;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> org.apache.axiom.om.OMAbstractFactory;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> org.apache.axiom.om.OMElement;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> org.apache.axiom.om.OMFactory;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> org.apache.axiom.om.OMNamespace;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> org.apache.axiom.om.OMText;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> org.apache.axis2.Constants;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> org.apache.axis2.util.<strike>Base64</strike>;</font>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      import
   </p>
          </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> com.test.TestServiceStub.ReceiveMTOM;</font>
          <p>
            <font color="#000000">
            </font> 
   </p>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">
            <p>
      public
   </p>
          </font>
        </b>
        <font face="Courier New" color="#000000" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">class
   </font>
        </b>
        <font face="Courier New" color="#000000" size="2"> TestClient </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">extends
   </font>
        </b>
        <font face="Courier New" size="2">
          <font color="#000000"> TestCase</font>
          <p>
      {
   </p>
          <p>
          </p>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">private
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">static
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">final
   </font>
        </b>
        <font face="Courier New" size="2"> String </font>
        <i>
          <font face="Courier New" color="#0000c0" size="2">EPR
   </font>
        </i>
        <font face="Courier New" size="2"> = </font>
        <font face="Courier New" color="#2a00ff" size="2">"</font>
        <a href="http://localhost:9080/axis2/services/TestService">
          <u>
            <font face="Courier New" color="#0000ff" size="2">http://localhost:9080/axis2/services/TestService
   </font>
          </u>
        </a>
        <font face="Courier New" color="#2a00ff" size="2">"</font>
        <font face="Courier New" size="2">;
   <p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">private
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">static
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">final
   </font>
        </b>
        <font face="Courier New" size="2"> String </font>
        <i>
          <font face="Courier New" color="#0000c0" size="2">INPUT_FILE
   </font>
        </i>
        <font face="Courier New" size="2"> = </font>
        <font face="Courier New" color="#2a00ff" size="2">"C:\\HOLD\\small.pdf"</font>
        <font face="Courier New" size="2">;
   <p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">public
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">static
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">void
   </font>
        </b>
        <font face="Courier New" size="2"> main(String[] args) </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">throws
   </font>
        </b>
        <font face="Courier New" size="2"> Exception
   <p>
      {
   </p><p></p><p>
      }
   </p><p></p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">public
   </font>
        </b>
        <font face="Courier New" size="2">
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">void
   </font>
        </b>
        <font face="Courier New" size="2"> testMTOM()</font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">throws
   </font>
        </b>
        <font face="Courier New" size="2"> Exception
   <p>
      {
   </p><p>
      TestServiceStub stub = 
   </p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">new
   </font>
        </b>
        <font face="Courier New" size="2"> TestServiceStub(</font>
        <i>
          <font face="Courier New" color="#0000c0" size="2">EPR
   </font>
        </i>
        <font face="Courier New" size="2">);
   <p>
      stub._getServiceClient().getOptions().setProperty(
   </p><p>
      Constants.Configuration.
   </p></font>
        <i>
          <font face="Courier New" color="#0000c0" size="2">ENABLE_MTOM
   </font>
        </i>
        <font face="Courier New" size="2">, Constants.</font>
        <i>
          <font face="Courier New" color="#0000c0" size="2">VALUE_TRUE
   </font>
        </i>
        <font face="Courier New" size="2">);
   <p></p></font>
        <font face="Courier New" color="#3f5fbf" size="2">/**
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">set</font>
        <font face="Courier New" size="2">
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">timeout
   </font>
        <font face="Courier New" size="2">
          <p>
          </p>
        </font>
        <font face="Courier New" color="#3f5fbf" size="2">*/
   </font>
        <font face="Courier New" size="2">
          <p>
      stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(10000);
   </p>
          <p>
          </p>
          <p>
      String base64String = <strike>Base64</strike>.<i>encode</i>(<i>readFully</i>(
   </p>
        </font>
        <i>
          <font face="Courier New" color="#0000c0" size="2">INPUT_FILE
   </font>
        </i>
        <font face="Courier New" size="2">));
   <p></p><p>
      ReceiveMTOM rmtom = 
   </p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">new
   </font>
        </b>
        <font face="Courier New" size="2"> ReceiveMTOM();
   <p>
      OMFactory fac = OMAbstractFactory.<i>getOMFactory</i>();
   </p><p></p><p>
      OMText binaryNode =fac.createOMText(base64String,
   </p></font>
        <font face="Courier New" color="#2a00ff" size="2">"application/pdf"</font>
        <font face="Courier New" size="2">,</font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">true
   </font>
        </b>
        <font face="Courier New" size="2">);
   <p>
      OMNamespace omNs = fac.createOMNamespace(
   </p></font>
        <font face="Courier New" color="#2a00ff" size="2">"http://test.com"</font>
        <font face="Courier New" size="2">, </font>
        <font face="Courier New" color="#2a00ff" size="2">"ns0"</font>
        <font face="Courier New" size="2">);
   <p>
      OMElement method = fac.createOMElement(
   </p></font>
        <font face="Courier New" color="#2a00ff" size="2">"receiveMTOM"</font>
        <font face="Courier New" size="2">,
   omNs);
   <p>
      method.addChild(binaryNode);
   </p><p>
      rmtom.setElement(method);
   </p><p>
      stub.receiveMTOM(rmtom);
   </p><p></p><p>
      System.
   </p></font>
        <i>
          <font face="Courier New" color="#0000c0" size="2">out
   </font>
        </i>
        <font face="Courier New" size="2">.println(</font>
        <font face="Courier New" color="#2a00ff" size="2">"done
   calling service..."</font>
        <font face="Courier New" size="2">);
   <p>
      }
   </p><p>
      }
   </p></font>
        <font size="2">
          <p>
      The testMTOM() method creates a stub and sets the enableMTOM property. It then reads
      the a file and then does a base64 encoded on the file's contents. Finally, it calls
      the receiveMTOM() metod on the stub.
   </p>
        </font>
        <font face="Courier New" size="2"> Note that to</font>
        <font size="2"> call
   the web service, we need a sample file. The class above assumes there is a file named
   "small.pdf" at c:\hold\. So create a folder named hold in the root of the c:\ drive
   and copy a pdf file in that directory. Name the file small.pdf.
   <p>
      9. Before you call the service, start TCPMon so we can view the SOAP message that
      the client sends to the service so you can verify that the SOAP Message is really
      an MTOM enabled SOAP request. Configurre TCPMon so that the listen port is 9080 and
      the listener's Target port is 8080. Assuming that Tomcat is running on port 8080.
      Also realize that the client above is setup to call the service on 9080 so as long
      as we configure TCPMon correctly we should be okay. If you are not using TCPMon, change
      the EPR variable in the client class so that it points to port 8080 or whatever port
      your service is running on.
   </p><p>
      10. Assuming you did everything correctly, you should be able to send some MTOM SOAP
      messages to the service. When the service receives a request, it save the binary file
      to c:\hold\att.pdf. 
   </p><p>
       
   </p><b><p>
      References
   </p></b><p>
      1. Download Tomcat: 
   </p></font>
        <a href="http://tomcat.apache.org/download-55.cgi">
          <u>
            <font color="#0000ff" size="2">http://tomcat.apache.org/download-55.cgi
   </font>
          </u>
        </a>
        <font size="2">
          <p>
      2. Download Axis2 version 1.3: 
   </p>
        </font>
        <a href="http://ws.apache.org/axis2/download/1_3/download.cgi">
          <u>
            <font color="#0000ff" size="2">http://ws.apache.org/axis2/download/1_3/download.cgi
   </font>
          </u>
        </a>
        <font size="2">
          <p>
      3. Download TCPMonitor: 
   </p>
        </font>
        <a href="http://ws.apache.org/commons/tcpmon/download.cgi">
          <u>
            <font color="#0000ff" size="2">http://ws.apache.org/commons/tcpmon/download.cgi
   </font>
          </u>
        </a>
        <font size="2">
          <p>
      4. Using TCPMonitor: 
   </p>
        </font>
        <a href="http://wso2.org/project/wsas/java/2.1/docs/tools/tcpmonguide.html">
          <u>
            <font color="#0000ff" size="2">http://wso2.org/project/wsas/java/2.1/docs/tools/tcpmonguide.html
   </font>
          </u>
        </a>
        <font size="2">
          <p>
      5. A very good article on MTOM with Axis2: 
   </p>
        </font>
        <a href="http://ws.apache.org/axis2/1_1_1/mtom-guide.html">
          <u>
            <font color="#0000ff" size="2">http://ws.apache.org/axis2/1_1_1/mtom-guide.html
   </font>
          </u>
        </a>
        <font size="2">
          <p>
      6. Apache MTOM User Guide: 
   </p>
        </font>
        <a href="http://ws.apache.org/axis2/1_0/mtom-guide.html">
          <u>
            <font color="#0000ff" size="2">http://ws.apache.org/axis2/1_0/mtom-guide.html
   </font>
          </u>
        </a>
        <img width="0" height="0" src="http://www.sayedhashimi.com/aggbug.ashx?id=56ac3f2c-ba05-4ba3-83fa-9f54e3f5021f" />
      </div>
    </content>
  </entry>
  <entry>
    <title>WS-Security, Axis2 and Rampart</title>
    <link rel="alternate" type="text/html" href="http://www.sayedhashimi.com/PermaLink,guid,0511ea6b-35b0-4fce-998c-6cd42a6646ec.aspx" />
    <id>http://www.sayedhashimi.com/PermaLink,guid,0511ea6b-35b0-4fce-998c-6cd42a6646ec.aspx</id>
    <published>2007-10-09T05:00:29.569125-07:00</published>
    <updated>2007-10-09T05:00:29.569125-07:00</updated>
    <category term="Web Services" label="Web Services" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <font size="2">
          <p>
      One of the things that I don’t like about Java is that the community is not using
      the same foundational libraries. For example, there is not a standard J2EE application
      server. Instead there is a specification and hundreds of vendors. As a result, everyone
      seems to be using a different implementation of a specification, and thus finding
      answers to questions is a lot harder because the user community is spread across many
      many implementations. 
   </p>
          <p>
      Recently, I had to call a web service which was protected by WS-Security UsernameToken.
      I was able to quickly call the service with Axis 1.1 and WSS4J but when I tried to
      use Axis2 and Rampart I ran into exception after exception. After several days of
      struggling, I was eventually able to create a web service client that created the
      proper soap message. 
   </p>
          <p>
      This blog contains a step by step procedure to create a web service client to a web
      service which is protected by ws-security UsernameToken.
   </p>
          <p>
      I am assuming that you have already deployed the web service which is protected by
      ws-security and that you simply want to call the service using Axis2 version 1.3 and
      Rampart 1.3. Here are the steps:
   </p>
          <p>
      1) Download Axis2 version 1.3 from 
   </p>
        </font>
        <a href="http://ws.apache.org/axis2/">
          <u>
            <font color="#0000ff" size="2">http://ws.apache.org/axis2/
   </font>
          </u>
        </a>
        <font size="2">
          <p>
      2) Download Rampart 1.3 from 
   </p>
        </font>
        <a href="http://ws.apache.org/axis2/modules/index.html">
          <u>
            <font color="#0000ff" size="2">http://ws.apache.org/axis2/modules/index.html
   </font>
          </u>
        </a>
        <font size="2">
          <p>
      3) Add Axis2 JARs to your client application classpath--all JARs from the Axis2 distribution
      lib directory.
   </p>
          <p>
      3) Add the Rampart jars to your client application classpath--all jars from the Rampart
      distribution lib directory.
   </p>
          <p>
      4) Create a proxy to the web service that is protected by ws-security--using the WSDL2Java
      tool or batch file.
   </p>
          <p>
      5) Create an Axis2 client-configuration file which engages rampart and which has the
      ws-security parameter. Place this file within your client application project. For
      example, the standard is to create a folder called "conf" for this file.
   </p>
          <p>
      Here is an example file:
   </p>
          <p>
       
   </p>
          <font size="2">
            <p>
      &lt;axisconfig name="AxisJava2.0"&gt;
   </p>
            <p>
      &lt;!-- engage rampart --&gt;
   </p>
            <p>
      &lt;module ref="rampart" /&gt;
   </p>
            <p>
       
   </p>
            <p>
      &lt;!-- ws-security parameters: UsernameToken and PasswordText --&gt; 
   </p>
            <p>
      &lt;parameter name="OutflowSecurity"&gt;
   </p>
            <p>
      &lt;action&gt;
   </p>
            <p>
      &lt;items&gt;UsernameToken&lt;/items&gt;
   </p>
            <p>
      &lt;user&gt;myusername&lt;/user&gt;
   </p>
            <p>
      &lt;passwordCallbackClass&gt;com.mycomp.test.PWCBHandler&lt;/passwordCallbackClass&gt;
   </p>
            <p>
      &lt;passwordType&gt;PasswordText&lt;/passwordType&gt;
   </p>
            <p>
      &lt;/action&gt;
   </p>
            <p>
      &lt;/parameter&gt;
   </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;!-- Parameters --&gt;
   </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;parameter name="hotdeployment"&gt;true&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="hotupdate"&gt;false&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="enableMTOM"&gt;false&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="enableSwA"&gt;false&lt;/parameter&gt;
   </p>
            <p>
      &lt;!--Uncomment if you want to enable file caching for attachments --&gt;
   </p>
            <p>
      &lt;!--parameter name="cacheAttachments"&gt;true&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="attachmentDIR"&gt;&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="sizeThreshold"&gt;4000&lt;/parameter--&gt;
   </p>
            <p>
      &lt;!--This will give out the timout of the configuration contexts, in seconds--&gt;
   </p>
            <p>
      &lt;parameter name="ConfigContextTimeoutInterval"&gt;30&lt;/parameter&gt;
   </p>
            <p>
      &lt;!--During a fault, stacktrace can be sent with the fault message. The following
      flag will control --&gt;
   </p>
            <p>
      &lt;!--that behaviour.--&gt;
   </p>
            <p>
      &lt;parameter name="sendStacktraceDetailsWithFaults"&gt;false&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="DrillDownToRootCauseForFaultReason"&gt;false&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="userName"&gt;admin&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="password"&gt;axis2&lt;/parameter&gt;
   </p>
            <p>
      &lt;!--Set the flag to true if you want to enable transport level session mangment--&gt;
   </p>
            <p>
      &lt;parameter name="manageTransportSession"&gt;false&lt;/parameter&gt;
   </p>
            <p>
      &lt;!-- Following parameter will completely disable REST handling in Axis2--&gt;
   </p>
            <p>
      &lt;parameter name="disableREST" locked="true"&gt;false&lt;/parameter&gt;
   </p>
            <p>
            </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;!-- Message Receivers --&gt;
   </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;!--This is the Deafult Message Receiver for the system , if you want to have MessageReceivers
      for --&gt;
   </p>
            <p>
      &lt;!--all the other MEP implement it and add the correct entry to here , so that
      you can refer from--&gt;
   </p>
            <p>
      &lt;!--any operation --&gt;
   </p>
            <p>
      &lt;!--Note : You can ovride this for particular service by adding the same element
      with your requirement--&gt;
   </p>
            <p>
      &lt;messageReceivers&gt;
   </p>
            <p>
      &lt;messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
   </p>
            <p>
      class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/&gt;
   </p>
            <p>
      &lt;messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
   </p>
            <p>
      class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/&gt;
   </p>
            <p>
      &lt;/messageReceivers&gt;
   </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;!-- Message Formatter --&gt;
   </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;!--Following content type to message formatter mapping can be used to implement
      support for different message --&gt;
   </p>
            <p>
      &lt;!--format serialization in Axis2. These message formats are expected to be resolved
      based on the content type. --&gt;
   </p>
            <p>
      &lt;messageFormatters&gt;
   </p>
            <p>
      &lt;messageFormatter contentType="application/x-www-form-urlencoded"
   </p>
            <p>
      class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/&gt;
   </p>
            <p>
      &lt;messageFormatter contentType="application/xml"
   </p>
            <p>
      class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/&gt;
   </p>
            <p>
      &lt;messageFormatter contentType="text/xml"
   </p>
            <p>
      class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/&gt;
   </p>
            <p>
      &lt;messageFormatter contentType="application/echo+xml"
   </p>
            <p>
      class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/&gt;
   </p>
            <p>
      &lt;/messageFormatters&gt;
   </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;!-- Transport Ins --&gt;
   </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;transportReceiver name="http"
   </p>
            <p>
      class="org.apache.axis2.transport.http.SimpleHTTPServer"&gt;
   </p>
            <p>
      &lt;parameter name="port"&gt;6060&lt;/parameter&gt;
   </p>
            <p>
            </p>
            <p>
      &lt;/transportReceiver&gt;
   </p>
            <p>
            </p>
            <p>
      &lt;!--Uncomment this and configure as appropriate for JMS transport support, after
      setting up your JMS environment (e.g. ActiveMQ)
   </p>
            <p>
      &lt;transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener"&gt;
   </p>
            <p>
      &lt;parameter name="myTopicConnectionFactory"&gt;
   </p>
            <p>
      &lt;parameter name="java.naming.factory.initial"&gt;org.apache.activemq.jndi.ActiveMQInitialContextFactory&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="java.naming.provider.url"&gt;tcp://localhost:61616&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="transport.jms.ConnectionFactoryJNDIName"&gt;TopicConnectionFactory&lt;/parameter&gt;
   </p>
            <p>
      &lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="myQueueConnectionFactory"&gt;
   </p>
            <p>
      &lt;parameter name="java.naming.factory.initial"&gt;org.apache.activemq.jndi.ActiveMQInitialContextFactory&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="java.naming.provider.url"&gt;tcp://localhost:61616&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="transport.jms.ConnectionFactoryJNDIName"&gt;QueueConnectionFactory&lt;/parameter&gt;
   </p>
            <p>
      &lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="default"&gt;
   </p>
            <p>
      &lt;parameter name="java.naming.factory.initial"&gt;org.apache.activemq.jndi.ActiveMQInitialContextFactory&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="java.naming.provider.url"&gt;tcp://localhost:61616&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="transport.jms.ConnectionFactoryJNDIName"&gt;QueueConnectionFactory&lt;/parameter&gt;
   </p>
            <p>
      &lt;/parameter&gt;
   </p>
            <p>
      &lt;/transportReceiver&gt;--&gt;
   </p>
            <p>
            </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;!-- Transport Outs --&gt;
   </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;transportSender name="tcp"
   </p>
            <p>
      class="org.apache.axis2.transport.tcp.TCPTransportSender"/&gt;
   </p>
            <p>
      &lt;transportSender name="local"
   </p>
            <p>
      class="org.apache.axis2.transport.local.LocalTransportSender"/&gt;
   </p>
            <p>
      &lt;transportSender name="http"
   </p>
            <p>
      class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"&gt;
   </p>
            <p>
      &lt;parameter name="PROTOCOL"&gt;HTTP/1.1&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="Transfer-Encoding"&gt;chunked&lt;/parameter&gt;
   </p>
            <p>
            </p>
            <p>
      &lt;!-- If following is set to 'true', optional action part of the Content-Type will
      not be added to the SOAP 1.2 messages --&gt;
   </p>
            <p>
      &lt;!-- &lt;parameter name="OmitSOAP12Action"&gt;true&lt;/parameter&gt; --&gt;
   </p>
            <p>
      &lt;/transportSender&gt;
   </p>
            <p>
            </p>
            <p>
      &lt;transportSender name="https"
   </p>
            <p>
      class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"&gt;
   </p>
            <p>
      &lt;parameter name="PROTOCOL"&gt;HTTP/1.1&lt;/parameter&gt;
   </p>
            <p>
      &lt;parameter name="Transfer-Encoding"&gt;chunked&lt;/parameter&gt;
   </p>
            <p>
      &lt;/transportSender&gt;
   </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;!-- Global Modules --&gt;
   </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;!-- Comment this to disable Addressing --&gt;
   </p>
            <p>
      &lt;module ref="addressing"/&gt;
   </p>
            <p>
      &lt;!--Configuring module , providing parameters for modules whether they refer or
      not--&gt;
   </p>
            <p>
      &lt;!--&lt;moduleConfig name="addressing"&gt;--&gt;
   </p>
            <p>
      &lt;!--&lt;parameter name="addressingPara"&gt;N/A&lt;/parameter&gt;--&gt;
   </p>
            <p>
      &lt;!--&lt;/moduleConfig&gt;--&gt;
   </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;!-- Clustering --&gt;
   </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;!-- Configure and uncomment following for preparing Axis2 to a clustered environment
      --&gt;
   </p>
            <p>
      &lt;!-- 
   </p>
            <p>
      &lt;cluster class="org.apache.axis2.cluster.tribes.TribesClusterManager"&gt;
   </p>
            <p>
      &lt;parameter name="param1"&gt;value1&lt;/parameter&gt;
   </p>
            <p>
      &lt;/cluster&gt;
   </p>
            <p>
      --&gt;
   </p>
            <p>
            </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;!-- Phases --&gt;
   </p>
            <p>
      &lt;!-- ================================================= --&gt;
   </p>
            <p>
      &lt;phaseOrder type="InFlow"&gt;
   </p>
            <p>
      &lt;!-- System predefined phases --&gt;
   </p>
            <p>
      &lt;phase name="Transport"&gt;
   </p>
            <p>
      &lt;handler name="RequestURIBasedDispatcher"
   </p>
            <p>
      class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"&gt;
   </p>
            <p>
      &lt;order phase="Transport"/&gt;
   </p>
            <p>
      &lt;/handler&gt;
   </p>
            <p>
      &lt;handler name="SOAPActionBasedDispatcher"
   </p>
            <p>
      class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"&gt;
   </p>
            <p>
      &lt;order phase="Transport"/&gt;
   </p>
            <p>
      &lt;/handler&gt;
   </p>
            <p>
      &lt;/phase&gt;
   </p>
            <p>
      &lt;phase name="Addressing"&gt;
   </p>
            <p>
      &lt;handler name="AddressingBasedDispatcher"
   </p>
            <p>
      class="org.apache.axis2.dispatchers.AddressingBasedDispatcher"&gt;
   </p>
            <p>
      &lt;order phase="Addressing"/&gt;
   </p>
            <p>
      &lt;/handler&gt;
   </p>
            <p>
      &lt;/phase&gt;
   </p>
            <p>
      &lt;phase name="Security"/&gt;
   </p>
            <p>
      &lt;phase name="PreDispatch"/&gt;
   </p>
            <p>
      &lt;phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase"&gt;
   </p>
            <p>
      &lt;handler name="RequestURIBasedDispatcher"
   </p>
            <p>
      class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/&gt;
   </p>
            <p>
      &lt;handler name="SOAPActionBasedDispatcher"
   </p>
            <p>
      class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/&gt;
   </p>
            <p>
      &lt;handler name="RequestURIOperationDispatcher"
   </p>
            <p>
      class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/&gt;
   </p>
            <p>
      &lt;handler name="SOAPMessageBodyBasedDispatcher"
   </p>
            <p>
      class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/&gt;
   </p>
            <p>
      &lt;handler name="HTTPLocationBasedDispatcher"
   </p>
            <p>
      class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/&gt;
   </p>
            <p>
      &lt;/phase&gt;
   </p>
            <p>
      &lt;phase name="RMPhase"/&gt;
   </p>
            <p>
      &lt;!-- System predefined phases --&gt;
   </p>
            <p>
      &lt;!-- After Postdispatch phase module author or service author can add any phase
      he want --&gt;
   </p>
            <p>
      &lt;phase name="OperationInPhase"/&gt;
   </p>
            <p>
      &lt;phase name="soapmonitorPhase"/&gt;
   </p>
            <p>
      &lt;/phaseOrder&gt;
   </p>
            <p>
      &lt;phaseOrder type="OutFlow"&gt;
   </p>
            <p>
      &lt;!-- user can add his own phases to this area --&gt;
   </p>
            <p>
      &lt;phase name="soapmonitorPhase"/&gt;
   </p>
            <p>
      &lt;phase name="OperationOutPhase"/&gt;
   </p>
            <p>
      &lt;!--system predefined phase--&gt;
   </p>
            <p>
      &lt;!--these phase will run irrespective of the service--&gt;
   </p>
            <p>
      &lt;phase name="RMPhase"/&gt;
   </p>
            <p>
      &lt;phase name="PolicyDetermination"/&gt;
   </p>
            <p>
      &lt;phase name="MessageOut"/&gt;
   </p>
            <p>
      &lt;phase name="Security"/&gt;
   </p>
            <p>
      &lt;/phaseOrder&gt;
   </p>
            <p>
      &lt;phaseOrder type="InFaultFlow"&gt;
   </p>
            <p>
      &lt;phase name="Addressing"&gt;
   </p>
            <p>
      &lt;handler name="AddressingBasedDispatcher"
   </p>
            <p>
      class="org.apache.axis2.dispatchers.AddressingBasedDispatcher"&gt;
   </p>
            <p>
      &lt;order phase="Addressing"/&gt;
   </p>
            <p>
      &lt;/handler&gt;
   </p>
            <p>
      &lt;/phase&gt;
   </p>
            <p>
      &lt;phase name="Security"/&gt;
   </p>
            <p>
      &lt;phase name="PreDispatch"/&gt;
   </p>
            <p>
      &lt;phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase"&gt;
   </p>
            <p>
      &lt;handler name="RequestURIBasedDispatcher"
   </p>
            <p>
      class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/&gt;
   </p>
            <p>
      &lt;handler name="SOAPActionBasedDispatcher"
   </p>
            <p>
      class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/&gt;
   </p>
            <p>
      &lt;handler name="RequestURIOperationDispatcher"
   </p>
            <p>
      class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/&gt;
   </p>
            <p>
      &lt;handler name="SOAPMessageBodyBasedDispatcher"
   </p>
            <p>
      class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/&gt;
   </p>
            <p>
      &lt;handler name="HTTPLocationBasedDispatcher"
   </p>
            <p>
      class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/&gt;
   </p>
            <p>
      &lt;/phase&gt;
   </p>
            <p>
      &lt;phase name="RMPhase"/&gt;
   </p>
            <p>
      &lt;!-- user can add his own phases to this area --&gt;
   </p>
            <p>
      &lt;phase name="OperationInFaultPhase"/&gt;
   </p>
            <p>
      &lt;phase name="soapmonitorPhase"/&gt;
   </p>
            <p>
      &lt;/phaseOrder&gt;
   </p>
            <p>
      &lt;phaseOrder type="OutFaultFlow"&gt;
   </p>
            <p>
      &lt;!-- user can add his own phases to this area --&gt;
   </p>
            <p>
      &lt;phase name="soapmonitorPhase"/&gt;
   </p>
            <p>
      &lt;phase name="OperationOutFaultPhase"/&gt;
   </p>
            <p>
      &lt;phase name="RMPhase"/&gt;
   </p>
            <p>
      &lt;phase name="PolicyDetermination"/&gt;
   </p>
            <p>
      &lt;phase name="MessageOut"/&gt;
   </p>
            <p>
      &lt;/phaseOrder&gt;
   </p>
            <p>
      &lt;/axisconfig&gt;
   </p>
            <p>
       
   </p>
            <font size="2">
              <p>
      The configuration file above is a typical client config file with the rampart and
      ws-security configuration.
   </p>
              <p>
              </p>
              <p>
      6) When calling the web service through the web service stub, you'll have to give
      Axis the path to the Axis configuration file above. Moreover, for Axis to engage Rampart,
      you'll have to give Axis the path to the Axis respository folder. The repository folder
      needs to have a subdirectory called "modules" and within that directory, the Rampart
      1.3 "mar" file has to exist. Therefore, create a folder somewhere within your project
      called "repository". Then create a subdirectory called "modules". Finally, copy the
      "rampart-1.3.mar" file from the Rampart distributable.
   </p>
              <p>
      7) Now you are ready to make a service call. First create an instance of a custom
      configuration passing in the repository path and the axis configuration file path. 
   </p>
            </font>
            <font face="Courier New" size="2">
              <p>
      ConfigurationContext 
   </p>
            </font>
            <font face="Courier New" size="2">cxt</font>
            <font face="Courier New" size="2"> = 
   <p>
      ConfigurationContextFactory.<i>createConfigurationContextFromFileSystem</i>(
   </p></font>
            <i>
              <font face="Courier New" color="#0000c0" size="2">"c:\\folderpath\\repository"
   </font>
            </i>
          </font>
          <font face="Courier New" size="2">,</font>
          <i>
            <font face="Courier New" color="#0000c0" size="2">"c:\\path_to_axis_config_file.xml"
   </font>
          </i>
        </font>
        <font face="Courier New" size="2">);
   </font>
        <font face="Courier New" size="2">
          <p>
      8) Create a stub with the custom axis configuration instance.
   </p>
        </font>
        <font face="Courier New" size="2">
          <p>
      HelloServiceStub stub = 
   </p>
        </font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">new
   </font>
        </b>
        <font face="Courier New" size="2"> HelloServiceStub(ctx,</font>
        <font face="Courier New" size="2">"http://localhost:8080/services/HelloService"</font>
        <font face="Courier New" size="2">);
   <p></p><p>
      HelloServiceStub.Echo echoReq = 
   </p></font>
        <b>
          <font face="Courier New" color="#7f0055" size="2">new
   </font>
        </b>
        <font face="Courier New" size="2"> HelloServiceStub.Echo();
   <p>
      System.
   </p></font>
        <i>
          <font face="Courier New" color="#0000c0" size="2">out
   </font>
        </i>
        <font face="Courier New" size="2">.println(</font>
        <font face="Courier New" color="#2a00ff" size="2">"calling
   service..."</font>
        <font face="Courier New" size="2">);
   <p></p><p>
      HelloServiceStub.EchoResponse resp = stub.echo(echoReq);
   </p><p></p><p>
      System.
   </p></font>
        <i>
          <font face="Courier New" color="#0000c0" size="2">out
   </font>
        </i>
        <font face="Courier New" size="2">.println(</font>
        <font face="Courier New" color="#2a00ff" size="2">"done
   calling service..."</font>
        <font face="Courier New" size="2">);
   </font>
        <i>
          <p>
            <font face="Arial" size="2">The key to the whole process was 
      </font>
          </p>
        </i>ConfigurationContextFactory.<i>createConfigurationContextFromFileSystem. When
   calling this method, you need to make sure you pass the correct repository path and
   a proper Axis2 client configuration file. The path to the repository has to have a
   sub directory called "modules" and that has to contain the rampart "mar" file. If
   this is not correct, then Axis2 will not be able to engage Rampart.
   </i><img width="0" height="0" src="http://www.sayedhashimi.com/aggbug.ashx?id=0511ea6b-35b0-4fce-998c-6cd42a6646ec" /></div>
    </content>
  </entry>
  <entry>
    <title>How to add a start menu icon for your ClickOnce deployed application using MSBuild?</title>
    <link rel="alternate" type="text/html" href="http://www.sayedhashimi.com/PermaLink,guid,69129626-d919-4bf0-b8c0-c1207d4998df.aspx" />
    <id>http://www.sayedhashimi.com/PermaLink,guid,69129626-d919-4bf0-b8c0-c1207d4998df.aspx</id>
    <published>2006-10-11T06:20:56.265625-07:00</published>
    <updated>2006-10-11T06:20:56.265625-07:00</updated>
    <category term="ClickOnce" label="ClickOnce" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <div>
          <font face="Arial" size="2">
            <span class="384295712-11102006">If you have an automated
      build and deployment process using MSBuild, then you likely use the <font size="2"><a href="http://http://msdn2.microsoft.com/en-us/library/6wc2ccdc.aspx">GenerateApplicationManifest</a> and <font size="2"><a href="http://msdn2.microsoft.com/en-us/library/3k2t34e7.aspx">GenerateDeploymentManifest</a> tasks
      to create the ClickOnce application and deployment manifest, respectively. If you
      are using these tasks, you may have wondered how you can set an icon (under the
      start menu) for your application. To have an icon set, you have to do several
      things:</font></font></span>
          </font>
        </div>
        <div>
          <font face="Arial" size="2">
            <span class="384295712-11102006">
            </span>
          </font> 
   </div>
        <div>
          <font face="Arial" size="2">
            <span class="384295712-11102006">1) Package the icon
      with the deployment. The easiest way to do this is to add an icon file to your main
      project--that ensure that it gets deployed with the application.</span>
          </font>
        </div>
        <div>
          <font face="Arial" size="2">
            <span class="384295712-11102006">2) After you add
      the icon file, right click on the file in Visual Studio, and set the Build Action
      to Content.</span>
          </font>
        </div>
        <div>
          <font face="Arial" size="2">
            <span class="384295712-11102006">3) At deployment
      time, set the IconFile attribute on GenerateApplicationManifest to the icon file name
      (e.g., myapp.ico), you added in step (1).</span>
          </font>
        </div>
        <div>
          <font face="Arial" size="2">
            <span class="384295712-11102006">
            </span>
          </font> 
   </div>
        <div>
          <font face="Arial" size="2">
            <span class="384295712-11102006">The above will add
      an iconFile attribute to the assembly description element, e.g., &lt;description
      iconFile="myapp.ico" /&gt;, in the application manifest file (e.g., myapp.exe.manifest).
      When ClickOnce sees this attribute set, it will look in the ClickOnce deployment for
      the file and create a Start Menu Icon for your application. </span>
          </font>
        </div>
        <div>
          <font face="Arial" size="2">
            <span class="384295712-11102006">
            </span>
          </font> 
   </div>
        <div>
          <font face="Arial" size="2">
            <span class="384295712-11102006">An interesting thing
      to note is that the iconFile attribute is set in the application manifest and not
      in the deployment manifest. The reason for this is to allow you to change your
      application icons from one deployment to the next.</span>
          </font>
        </div>
        <div>
          <font face="Arial" size="2">
            <span class="384295712-11102006">
            </span>
          </font> 
   </div>
        <div>
          <font face="Arial" size="2">
            <span class="384295712-11102006">
            </span>
          </font> 
   </div>
        <div>
          <font face="Arial" size="2">
            <span class="384295712-11102006">If you are deploying
      your ClickOnce application using Visual Studio and need to set the Start Mneu icon,
      do steps (1) and (2), and then go to the Project | Properties and choose the Application
      tab. Under the Resources group box, set the application icon to the icon you added
      in step (1). ClickOnce should take care of the rest. You can find out more on this
      at <a title="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=170920&amp;SiteID=1" href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=170920&amp;SiteID=1"><font title="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=170920&amp;SiteID=1" face="Arial"><font title="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=170920&amp;SiteID=1" size="2">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=170920&amp;SiteID=1</font></font></a> .</span>
          </font>
        </div>
        <img width="0" height="0" src="http://www.sayedhashimi.com/aggbug.ashx?id=69129626-d919-4bf0-b8c0-c1207d4998df" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Application Block Internals: Demystifying the Object Builder</title>
    <link rel="alternate" type="text/html" href="http://www.sayedhashimi.com/PermaLink,guid,d05aed4f-a211-4969-893e-7ffea324a56c.aspx" />
    <id>http://www.sayedhashimi.com/PermaLink,guid,d05aed4f-a211-4969-893e-7ffea324a56c.aspx</id>
    <published>2006-09-07T10:13:52.439125-07:00</published>
    <updated>2006-09-07T10:13:52.439125-07:00</updated>
    <category term="ObjectBuilder" label="ObjectBuilder" scheme="dasBlog" />
    <content type="html">&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;strong&gt;Demystifying
   the ObjectBuilder&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;In
   my last post, I gave an introduction to ObjectBuilder. In this post, I take ObjectBuilder
   apart and talk about all of the hairy details. &lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;ObjectBuilder
   is used in the Enterprise Library, the CAB, and the Mobile framework MS just released.
   If you have to extend any of the above frameworks/libraries in a non-trivial way,
   you are going to need to understand what is going on under the covers. Under the covers
   of the above frameworks/libraries is ObjectBuilder--the dependency injection framework.&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;Unfortunately,
   there is not any documentation for the ObjectBuilder, so learning is a real nightmare.
   I was able to break it by going over the unittests that ship with the source code.&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;b&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Fundamental
   Classes in Object Builder&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;i&gt;&lt;u&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Strategy
   and Policies &lt;/span&gt;&lt;/u&gt;&lt;/i&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;- 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   is based upon policies and strategies. Strategies are chained (i.e. 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   implements the Chain of Responsability pattern on strategies) and get registered for
   a build stage.&amp;nbsp; Strategies use policies to figure out how to build an object.
   Policies are registered with 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   for types. A policy is defined for types (objects in 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   are defined by the type and ID). &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;i&gt;&lt;u&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Locator
   -&lt;/span&gt;&lt;/u&gt;&lt;/i&gt;&lt;span style="mso-bidi-font-family: Arial"&gt; locators in 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   are used to find registered objects. When an object is created, it gets registered
   with the locator (see CreationStrategy.RegisterObject).&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;i&gt;&lt;u&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;LifetimeContainer&lt;/span&gt;&lt;/u&gt;&lt;/i&gt;&lt;span style="mso-bidi-font-family: Arial"&gt; -
   objects managed by the object builder can have a lifetime associated with them. The
   thing that determines how long an object stays around is the container that the object
   is associated with. LifetimeContainers in 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   , maintain a list of objects. When the container is disposed off, the objects in it
   are also disposed.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;i&gt;&lt;u&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;BuilderContext- &lt;/span&gt;&lt;/u&gt;&lt;/i&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;an
   object that defines the context for the build-up&amp;nbsp;and tear-down of an object.
   BuilderContext holds the strategies, policies and locator for the given build-up or
   tear-down. It also provides a method to iterate the chain of strategies (see IBuilderContext
   and BuilderContext).&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;
   &lt;st1:place w:st="on"&gt;
      &lt;b&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;OB&lt;/span&gt;&lt;/b&gt;
   &lt;/st1:place&gt;
   &lt;b&gt;&lt;span style="mso-bidi-font-family: Arial"&gt; By Example&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;/**********Create
   A Singleton*************/&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   void CreateASingleton()&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // we need a locator, a strategy chain, and a list of policies.&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; Locator locator = new Locator();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; BuilderStrategyChain strategyChain = new BuilderStrategyChain();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; PolicyList policies = new PolicyList();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // in order to build a singleton, we have to&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // have a SingletonStrategy. The singleton strategy&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // in turn uses a SingletonPolicy.&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // add a SingletonStrategy to the strategy chain&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; strategyChain.Add(new SingletonStrategy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // add a CreationStrategy to the strategy chain&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; strategyChain.Add(new CreationStrategy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // SingletonStrategy requires a SingletonPolicy&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; policies.Set&amp;lt;ISingletonPolicy&amp;gt;(new SingletonPolicy(true),
   typeof(MyObject), null);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // we also need a creation policy&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; policies.SetDefault&amp;lt;ICreationPolicy&amp;gt;(new DefaultCreationPolicy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // in order to make singletons, we need a lifetime container in
   the locator&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; locator.Add(typeof(ILifetimeContainer), new LifetimeContainer());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // create the object 
   &lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; BuilderContext cxt = new BuilderContext(strategyChain, locator,
   policies);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // in order to properly track singletons, we have to give the instance
   an ID.&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; object myObj = strategyChain.Head.BuildUp(cxt, typeof(MyObject),
   "MyObject_Singleton", null);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; object myObj2 = strategyChain.Head.BuildUp(cxt, typeof(MyObject),
   "MyObject_Singleton", null);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; if (myObj == myObj2)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Got singleton in myObj2&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int J = 0;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;The
   example above demonstrates creating singleton objects with the 
   &lt;st1:place w:st="on"&gt;OB.&lt;/st1:place&gt;
   Most of the work simply sets up using the 
   &lt;st1:place w:st="on"&gt;OB.&lt;/st1:place&gt;
   For example, in order to create an object, we need to have a build context. A build
   context requires a locator, a strategy chain, and a policy list. There are several
   pieces that enable singletons, however. For example, utimately a strategy is the thing
   that will create an object in OB. Strategies rely on policies to determine how to
   create an object. To create a singleton, we have to have a SingletonStrategy in the
   strategy chain. The singleton strategy looks for a SingletonPolicy, registered for
   the object being created. Recall that policies are setup for types. &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;There
   are a few design aspects of 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   that we have to understand. 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   uses something called a Locator. A locator knows how to find registered objects. Locators
   can be nested (i.e., a locator can have a parent). Locators make use of something
   called a LifetimeContainer. LifetimeContainer puts a boundary around the lifetime
   of a created object. When a locator is asked to find an object it can look in the
   current locator and/or it's parent locator (if one exists). &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;It's
   important to know that when searching for singletons, 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   looks only at the current locator--the parent is not searched. The SingletonStrategy
   class in 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   is shown below for reinforcement of this.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   class SingletonStrategy : BuilderStrategy&lt;br&gt;
   &amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; public override object BuildUp(IBuilderContext context, Type typeToBuild,
   object existing, string idToBuild)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
   DependencyResolutionLocatorKey key = new DependencyResolutionLocatorKey(typeToBuild,
   idToBuild);&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
   if (context.Locator != null &amp;amp;&amp;amp; context.Locator.Contains(key, SearchMode.Local))&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TraceBuildUp(context,
   typeToBuild, idToBuild, "");&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return context.Locator.Get(key);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
   return base.BuildUp(context, typeToBuild, existing, idToBuild);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
   &amp;nbsp;}&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;As
   shown, the SingletonStrategy checks to see if the build context has a locator,and
   then&amp;nbsp;asks the locator to find the object using a SearchMode.Local. This tells
   the locator not to look in the parent locator for the object. This has obvious usage
   implications--if you don't create your singletons with the correct locator, then you'll
   end up breaking the singleton (TODO: more on this.).&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;Also
   note that we have put a CreationStrategy in the chain of strategies for our singleton
   object. The SingletonStrategy ensures that once we have an object, that object is
   returned on subseqent build-up requests. The CreationStrategy is needed to build-up
   the object the first time. Since the CreationStrategy is the strategy that builds
   the object, this strategy also registers the object with the locator/container so
   that it can be pulled out the next time. We can see this by looking at the CreationStrategy.&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;public
   class CreationStrategy : BuilderStrategy&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;public override object BuildUp(IBuilderContext context, Type typeToBuild,
   object existing, string idToBuild)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;if (existing != null)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BuildUpExistingObject(context, typeToBuild, existing, idToBuild);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;existing = BuildUpNewObject(context, typeToBuild, existing,
   idToBuild);&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return
   base.BuildUp(context, typeToBuild, existing, idToBuild);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&amp;nbsp;private
   void BuildUpExistingObject(IBuilderContext context, Type typeToBuild, object existing,
   string idToBuild)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;RegisterObject(context, typeToBuild, existing, idToBuild);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&amp;nbsp;[SecurityPermission(SecurityAction.Demand,
   Flags = SecurityPermissionFlag.SerializationFormatter)]&lt;br&gt;
   &amp;nbsp;&amp;nbsp;private object BuildUpNewObject(IBuilderContext context, Type typeToBuild,
   object existing, string idToBuild)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;ICreationPolicy policy = context.Policies.Get&amp;lt;ICreationPolicy&amp;gt;(typeToBuild,
   idToBuild);&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if
   (policy == null)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (idToBuild == null)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw new ArgumentException(String.Format(CultureInfo.CurrentCulture,&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Properties.Resources.MissingPolicyUnnamed, typeToBuild));&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw new ArgumentException(String.Format(CultureInfo.CurrentCulture,&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Properties.Resources.MissingPolicyNamed, typeToBuild,
   idToBuild));&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;try&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;existing = FormatterServices.GetSafeUninitializedObject(typeToBuild);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;catch (MemberAccessException exception)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw new ArgumentException(String.Format(CultureInfo.CurrentCulture,
   Properties.Resources.CannotCreateInstanceOfType, typeToBuild), exception);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;RegisterObject(context,
   typeToBuild, existing, idToBuild);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeObject(context, existing, idToBuild, policy);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;return existing;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&amp;nbsp;private
   void RegisterObject(IBuilderContext context, Type typeToBuild, object existing, string
   idToBuild)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;if (context.Locator != null)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ILifetimeContainer lifetime = context.Locator.Get&amp;lt;ILifetimeContainer&amp;gt;(typeof(ILifetimeContainer),
   SearchMode.Local);&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if
   (lifetime != null)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ISingletonPolicy singletonPolicy = context.Policies.Get&amp;lt;ISingletonPolicy&amp;gt;(typeToBuild,
   idToBuild);&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if
   (singletonPolicy != null &amp;amp;&amp;amp; singletonPolicy.IsSingleton)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;context.Locator.Add(new DependencyResolutionLocatorKey(typeToBuild,
   idToBuild), existing);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lifetime.Add(existing);&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font face=Arial&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if
   (TraceEnabled(context))&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TraceBuildUp(context, typeToBuild, idToBuild,
   Properties.Resources.SingletonRegistered);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;//...more methods ....&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;As
   shown above, the BuildUp method checks to see if it has to build-up a new object or
   an existing one. In our case, we are building up an object for the firsttime. In this
   case, the BuildUpNewObject method is called. This method looks on the build context
   for a ICreationPolicy for the required object. If it doesn't find one, it throws an
   exception--in other words, you have to have a policy registered for the object that
   tells 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   how to create the object. In our case, we are using the DefaultCreationPolicy. If
   there is a ICreationPolicy, then the method builds a bare-bones object (one that is
   not initialized) using&amp;nbsp; &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;existing
   = &lt;/font&gt;&lt;span style="COLOR: teal"&gt;FormatterServices&lt;/span&gt;&lt;font color=#000000&gt;.GetSafeUninitializedObject(typeToBuild);&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;and
   then calls RegisterObject(). This is where the singleton magic happens. As you can
   see from the code snippet above, the CreationStrategy looks for a lifetime container
   on the local locator and if one exists, it looks for a singleton policy registered
   for the required object. If it finds the singleton policy, it adds a key for the newly
   build object to the lifetime container. &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Thus,
   we can conclude that in order to create singleton objects with 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   , we need to have a SingletonStrategy and a SingletonPolicy. There are two aspects
   to creating a singleton: &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;ol type=1&gt;
   &lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;
      &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;When
      creating an object, you have to register it. &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
      &lt;o:p&gt;&lt;/o:p&gt;
      &lt;/span&gt;&lt;/font&gt;&lt;/font&gt; 
   &lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;
      &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;When
      creating an object, you have to check to see if one already exists.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
      &lt;o:p&gt;&lt;/o:p&gt;
      &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
   &lt;/li&gt;
&lt;/ol&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;The
   singleton policy, ensures that the object gets registered with the local locator's
   lifetime container and the singleton strategy ensures that the registered object gets
   returned on subsequent build-up operations.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;
   &lt;st1:place w:st="on"&gt;
      &lt;span style="mso-bidi-font-family: Arial"&gt;OB&lt;/span&gt;
   &lt;/st1:place&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt; is a glorified object factory and DI framework.
   To support DI, 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   ships with some strategies and policies. Lets investigate these now. [TODO: Correct
   this intro into DI via Properties]&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;b&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Injecting
   into&amp;nbsp;Properties&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;DI
   in 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   is achived at build-up. When you ask OB to build-up an object, 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   runs a chain of strategies. The idea is to inject dependencies into objects at build-up.
   To do that, you put a strategy object, an object&amp;nbsp;that knows how to do the proper
   injection, into the chain of strategies.&amp;nbsp;One of the strategies that knows how
   to inject dependencies is the PropertySetterStrategy. An example will help.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   void PropertyInjectionExample()&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;Locator locator = new Locator();&lt;br&gt;
   &amp;nbsp;LifetimeContainer container = new LifetimeContainer();&lt;br&gt;
   &amp;nbsp;locator.Add(typeof(ILifetimeContainer), container);&lt;br&gt;
   &amp;nbsp;// strategies ...&lt;br&gt;
   &amp;nbsp;BuilderStrategyChain chain = new BuilderStrategyChain();&lt;br&gt;
   &amp;nbsp;chain.Add(new CreationStrategy());&lt;br&gt;
   &amp;nbsp;chain.Add(new PropertySetterStrategy());&lt;br&gt;
   &amp;nbsp;// policies...&lt;br&gt;
   &amp;nbsp;PolicyList policies = new PolicyList();&lt;br&gt;
   &amp;nbsp;// Property setter policy for MyDAOObject's ConnectionString&lt;br&gt;
   &amp;nbsp;PropertySetterPolicy psp = new PropertySetterPolicy();&lt;br&gt;
   &amp;nbsp;// add a property for the ConnectionString property 
   &lt;br&gt;
   &amp;nbsp;psp.Properties.Add("ConnectionString", new PropertySetterInfo("ConnectionString",new
   ValueParameter&amp;lt;string&amp;gt;("the connection string value would be here")));&lt;br&gt;
   &amp;nbsp;policies.Set&amp;lt;IPropertySetterPolicy&amp;gt;(psp, typeof(MyDAOObject), null);&lt;br&gt;
   &amp;nbsp;policies.SetDefault&amp;lt;ICreationPolicy&amp;gt;(new DefaultCreationPolicy());&lt;br&gt;
   &amp;nbsp;// create build conetxt...&lt;br&gt;
   &amp;nbsp;BuilderContext cxt = new BuilderContext(chain, locator, policies);&lt;br&gt;
   &amp;nbsp;// build the object&lt;br&gt;
   &amp;nbsp;MyDAOObject obj = chain.Head.BuildUp(cxt, typeof(MyDAOObject), null, null) as
   MyDAOObject;&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;class
   MyDAOObject&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; private string connectionString;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; public string ConnectionString&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return connectionString;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; connectionString
   = value;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; public MyDAOObject():this(null) { }&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; public MyDAOObject(string conStr)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; connectionString = conStr;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;In
   our introduction, we mentioned that DI is achieved by injecting dependencies into
   properties or via constructors. The PropertySetterStrategy, as the name suggests,
   injects dependencies using properties. In order to get properties injected into your
   objects, you have to add a PropertySetterStrategy instance to the strategy chain (as
   shown above). The BuildUp method of this strategy is shown below.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   override object BuildUp(IBuilderContext context, Type typeToBuild, object existing,
   string idToBuild)&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;if (existing != null)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;InjectProperties(context, existing, idToBuild);&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;return
   base.BuildUp(context, typeToBuild, existing, idToBuild);&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;As
   you can see, the BuildUp method ensures that the object has been created and then
   it calls the InjectProperties method. Note the implication here--you have to make
   sure you have a strategy that creates the object ahead of the PropertySetterStrategy
   in the strategy chain. Otherwise, the strategy is effectively skipped because the
   base class's BuildUp is called to call the next strategy in the chain. Now lets have
   a look at the InjectProperties method (see below).&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;private
   void InjectProperties(IBuilderContext context, object obj, string id)&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;if (obj == null)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;return;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;Type
   type = obj.GetType();&lt;br&gt;
   &amp;nbsp;IPropertySetterPolicy policy = context.Policies.Get&amp;lt;IPropertySetterPolicy&amp;gt;(type,
   id);&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;if
   (policy == null)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;return;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;foreach
   (IPropertySetterInfo propSetterInfo in policy.Properties.Values)&lt;br&gt;
   &amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;PropertyInfo propInfo = propSetterInfo.SelectProperty(context, type, id);&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;if
   (propInfo != null)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;if (propInfo.CanWrite)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;object value = propSetterInfo.GetValue(context, type, id,
   propInfo);&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(
   value != null )&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Guard.TypeIsAssignableFromType(propInfo.PropertyType,
   value.GetType(), obj.GetType());&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if
   (TraceEnabled(context))&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TraceBuildUp(context, type, id, Properties.Resources.CallingProperty,
   propInfo.Name, propInfo.PropertyType.Name);&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;propInfo.SetValue(obj,
   value, null);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw new ArgumentException(String.Format(&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CultureInfo.CurrentCulture,&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Properties.Resources.CannotInjectReadOnlyProperty,&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;type, propInfo.Name));&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;}&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;The
   InjectProperties method checks to see if an object exists and then looks for an implementation
   of IPropertySetterPolicy registered for the type. If it finds an IPropertySetterPolicy
   for the type, it iterates over the list properties that need to be injected. The list
   of properties that need to be injected and the values that need to be injected into
   these properties are defined by IPropertySetterPolicy.&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;public
   interface IPropertySetterPolicy : IBuilderPolicy&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;Dictionary&amp;lt;string, IPropertySetterInfo&amp;gt; Properties { get; }&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;Every
   property that needs to be injected has to have an entry into this dictionary. Every
   property has a string key and an IPropertySetterInfo instance that defines the property
   and the value for that property. Therefore, in our example above, when we create the
   PropertySetterPolicy for MyObject, we added the following for the ConnectionString
   property.&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;psp.Properties.Add("ConnectionString",
   new PropertySetterInfo("ConnectionString",new ValueParameter&amp;lt;string&amp;gt;("the connection
   string value would be here")));&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;The
   Add method adds an entry with the key "ConnectionString" and a new PropertySetterInfo
   for the ConnectionString property. If we go back to the InjectProperties method, we
   can see that the method iterates over the list of IPropertySetterInfo objects. For
   each property configured for injection, it calls the SelectProperty method on the
   IPropertySetterInfo object. The default implementation of this interface (PropertySetterInfo)
   looks at the type&amp;nbsp;to see if it has a property with given name and if it finds
   one, it returns a PropertyInfo for that type. Note that when we created the PropertySetterInfo
   object for the property, we gave it the name of the property along with the ValueParameter
   instance in the constructor of PropertySetterInfo. The IPropertySetterInfo interface
   defines the SelectProperty method, mentioned above, and the GetValue method (see below).
   The GetValue method returns the value that has to be injected into the property. &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   interface IPropertySetterInfo&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;object GetValue(IBuilderContext context, Type type, string id, PropertyInfo
   propInfo);&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;PropertyInfo
   SelectProperty(IBuilderContext context, Type type, string id);&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;After
   the InjectProperty method gets the PropertyInfo object for the property, it checks
   to see if the property can be written to (i.e., if it has a setter), and then calls
   the GetValue method on the IPropertySetterInfo implementation. The default implementation
   of this interface calls the GetValue method on the IParameter. In our example, we
   passed in an&amp;nbsp;ValueParameter instance, which is an implementation of IParameter
   that stores the value in the class and returns it when needed. Once the value for
   the property is obtained, the InjectProperties method checks to make sure that the
   value of the property can be assigned to the property and then it&amp;nbsp;calls PropertyInfo.SetValue. &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font face=Arial color=#000000&gt;That's the
   details on&amp;nbsp;DI via properties. With this much detail, it is easy to lose focus
   on the big picture, so lets understand the design of this aspect of the 
   &lt;st1:place w:st="on"&gt;OB.&lt;/st1:place&gt;
   The figure below dipicts the design of DI via properties in 
   &lt;st1:place w:st="on"&gt;OB.&lt;/st1:place&gt;
   &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   &lt;img src="http://www.sayedhashimi.com/content/binary/one.JPG" border=0&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;As
   shown, there are really three core&amp;nbsp;interfaces involved in the design, IPropertySetterPolicy,
   IPropertySetterStrategy, and IPropertySetterInfo. The strategy class looks for a registered
   IPropertySetterPolicy at build-up for a given type. If the policy is registered for
   the type, the strategy iterates the properties that require injection. Every injection
   property is represented by an IPropertySetterInfo. IPropertySetterInfo encapsulates
   two things about the property: what the property is and how to get a value for the
   property.&amp;nbsp;&lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   provides an implementation of this interface, PropertySetterInfo, that operates on
   an IParameter&amp;nbsp;abstraction (see PropertySetterInfo class below). &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   class PropertySetterInfo : IPropertySetterInfo&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;string name = null;&lt;br&gt;
   &amp;nbsp;PropertyInfo prop = null;&lt;br&gt;
   &amp;nbsp;IParameter value = null;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;public
   PropertySetterInfo(string name, IParameter value)&lt;br&gt;
   &amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;this.name = name;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;this.value = value;&lt;br&gt;
   &amp;nbsp;}&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;public
   PropertySetterInfo(PropertyInfo propInfo, IParameter value)&lt;br&gt;
   &amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;this.prop = propInfo;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;this.value = value;&lt;br&gt;
   &amp;nbsp;}&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;public
   PropertyInfo SelectProperty(IBuilderContext context, Type type, string id)&lt;br&gt;
   &amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;if (prop != null)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;return prop;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;return
   type.GetProperty(name);&lt;br&gt;
   &amp;nbsp;}&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;public
   object GetValue(IBuilderContext context, Type type, string id, PropertyInfo propInfo)&lt;br&gt;
   &amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;return value.GetValue(context);&lt;br&gt;
   &amp;nbsp;}&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;As
   shown, at a minimum, you need to&amp;nbsp;know two things to get a value injected into
   a property: 1) the name of the property and 2) how to get the value for the property.
   IParameter provides an abstraction to obtaining, and customizing, how the PropertySetterStrategy
   obtains the value to assign to the property. In our example earlier, for example,&amp;nbsp;we
   used a ValueParameter extension that stored the value of the ConnectionString in the
   class and returned it when the strategy asked for it. The design of DI via properties
   also shows that 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   provides a number of other IParameter extensions. For example, the LookupParameter
   implementation of IParameter looks in the build-context to find the value of the parameter.
   Here is an example using LookupParameter.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font color=#000000&gt;&lt;font face=Arial&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font face=Arial&gt;&lt;font color=#000000&gt;public
   void LookupParameterExample()&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; Locator locator = new Locator();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; LifetimeContainer container = new LifetimeContainer();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; locator.Add(typeof(ILifetimeContainer), container);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; BuilderStrategyChain chain = new BuilderStrategyChain();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; PolicyList policies = new PolicyList();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // put the connection string in the context&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; locator.Add("ConnectionString", "connection string goes here");&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // add strategies&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; chain.Add(new CreationStrategy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; chain.Add(new PropertySetterStrategy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // add policies&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; policies.SetDefault&amp;lt;ICreationPolicy&amp;gt;(new DefaultCreationPolicy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; PropertySetterPolicy psp = new PropertySetterPolicy();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // configure the property value to be pulled from the 
   &lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // build context&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; psp.Properties.Add("CS",new PropertySetterInfo("ConnectionString",new
   LookupParameter("ConnectionString")));&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // set the policy for the type MyDAOObject&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; policies.Set&amp;lt;IPropertySetterPolicy&amp;gt;(psp, typeof(MyDAOObject),
   null);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // create build context 
   &lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; BuilderContext cxt = new BuilderContext(chain, locator, policies);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // build-up object&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; MyDAOObject obj = chain.Head.BuildUp(cxt, typeof(MyDAOObject),
   null, null) as MyDAOObject;&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;First
   notice that we add an item to the locator named "ConnectionString". Second, when we
   add a property registration to the PropertySetterPolicy, we use a LookupParameter.
   Finally, when we create the LookupParameter, we give the key to use when looking up
   the parameter's value.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Now
   lets talk about DI via constructors.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;b&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Injecting
   into&amp;nbsp;Constructors&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Similar
   to how we inject into properties, we can inject into constructors. &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Locator
   locator = new Locator();&lt;br&gt;
   // add connection string to the locator&lt;br&gt;
   locator.Add("ConnectionString", "connection string goes here...");&lt;br&gt;
   LifetimeContainer container = new LifetimeContainer();&lt;br&gt;
   locator.Add(typeof(ILifetimeContainer), container);&lt;br&gt;
   BuilderStrategyChain chain = new BuilderStrategyChain();&lt;br&gt;
   PolicyList policies = new PolicyList();&lt;br&gt;
   // add strategies&lt;br&gt;
   chain.Add(new CreationStrategy());&lt;br&gt;
   // add policies&lt;br&gt;
   ConstructorPolicy cp = new ConstructorPolicy();&lt;br&gt;
   // use a lookup parameter to get the connection string from&lt;br&gt;
   // the local locator&lt;br&gt;
   cp.AddParameter(new LookupParameter("ConnectionString"));&lt;br&gt;
   policies.Set&amp;lt;ICreationPolicy&amp;gt;(cp, typeof(MyDAOObject), null);&lt;br&gt;
   BuilderContext cxt = new BuilderContext(chain, locator, policies);&lt;br&gt;
   // buildup&lt;br&gt;
   MyDAOObject obj = chain.Head.BuildUp(cxt, typeof(MyDAOObject), null, null) as MyDAOObject;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;The
   goal of this excercise is to inject the connection string into MyDAOObject via the
   constructor at build-up. Recall from our definition of MyDAOObject above that the
   class defined two constructors: a zero argument constructor and one that took a string
   parameter (i.e. the connection string). Our objective is to have the connection string
   picked up from the locator and injected into the object when the object is build-up.
   To do that, we first do the usual stuff. We create a locator,&amp;nbsp;lifetime container,
   a strategy chain and a policy list.&amp;nbsp;We add strategies and set policies and then
   do build-up.&amp;nbsp;The difference, as always, is in what strategies and policies we're
   using. One way to have injection occur, for constructors, is to use a CreationStrategy
   combined with a ConstructorPolicy. The ConstructorPolicy class is an ICreationPolicy
   that determines the constructor to call based on the parameters added to its policy.
   In our scenario, for example, we've added the connection string parameter using a
   LookupParameter. Recall that when the CreationStrategy.BuildUp is called, it gets
   the ICreationPolicy for the type and the calls SelectConstructor. When this method
   is called on the ConstructorPolicy, it reflects on the type and finds the constructor
   that matches the list of parameters added to its parameter list (see SelectConstructor
   below).&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   ConstructorInfo SelectConstructor(IBuilderContext context, Type type, string id)&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;if (constructor != null)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;return constructor;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;List&amp;lt;Type&amp;gt;
   types = new List&amp;lt;Type&amp;gt;();&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;foreach
   (IParameter parm in parameters)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;types.Add(parm.GetParameterType(context));&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;return
   type.GetConstructor(types.ToArray());&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;After
   the correct constructor is selected, CreationStrategy then asks the ICreationPolicy
   to get the parameters for the constructor. Similarly, ConstructorPolicy then looks
   at the list of parameters added to it, and creates an object array of values passed
   for the parameters. The method is shown below.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   object[] GetParameters(IBuilderContext context, Type type, string id, ConstructorInfo
   constructor)&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;List&amp;lt;object&amp;gt; results = new List&amp;lt;object&amp;gt;();&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;foreach
   (IParameter parm in parameters)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;results.Add(parm.GetValue(context));&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;return
   results.ToArray();&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Recall
   that LookupParameter.GetValue looks on the locator to get the value.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;That's
   the fundementals of injected dependencies via properties and constructor parameters.
   In the next section, we'll extend this discussion and talk about DI using the Dependency
   attribute. As you'll see, you can decorate your objects properties and constructor
   parameters with [Dependency] and have them injected.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;b&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Injection
   into Methods by Method Execution&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Thus
   far you've seen that 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   can inject dependencies&amp;nbsp;via properties and constructors. 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   can also inject depdencies into methods by executing methods at build-up. The example
   below demonstrates this.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   class MyDAOObject&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private string username, password;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void Credentials(string userName,
   string passWord)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.username =
   userName;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.password =
   passWord;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   void ExecuteMethodExample()&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; Locator locator = new Locator();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; LifetimeContainer container = new LifetimeContainer();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; locator.Add(typeof(ILifetimeContainer), container);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; BuilderStrategyChain chain = new BuilderStrategyChain();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; PolicyList policies = new PolicyList();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // add strategies&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; chain.Add(new CreationStrategy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; chain.Add(new MethodExecutionStrategy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // add policies&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; policies.SetDefault&amp;lt;ICreationPolicy&amp;gt;(new DefaultCreationPolicy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // add a method policy for MyDAOObject&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; MethodPolicy mp = new MethodPolicy();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; IMethodCallInfo methodInfo = new MethodCallInfo("Credentials",
   new object[] {"myUserName","myPassword" });&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; mp.Methods.Add("credentials", methodInfo);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; policies.Set&amp;lt;IMethodPolicy&amp;gt;(mp, typeof(MyDAOObject), null);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // create context&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; BuilderContext cxt = new BuilderContext(chain, locator, policies);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // build up&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; MyDAOObject obj = chain.Head.BuildUp(cxt, typeof(MyDAOObject),
   null, null) as MyDAOObject;&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;As
   you can see, we've added another method, Credentials,&amp;nbsp;to our MyDAOObject class.
   The method takes two string parameters: the username and password. The purpose of
   the example is to build an instance of MyDAOObject and then execute the Credentials
   method on it. To do that, we ask use the MethodExecutionStrategy along with a IMethodPolicy
   implementation. &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;The
   example, by now, is self explanatory--add a MethodExecutionStrategy after the CreationStrategy
   and then setup a IMethodPolicy to register the Credentials method, with the specific
   parameters, on the MyDAOObject and then call BuildUp.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;This
   is probably a good time to stop and make a point about 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   's build-up process. If you think of dependency injection with properties and constructors
   and then compare that to dependency injection via method execution, you can see that
   there is a difference in semantics. This leads to several questions. &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Why
   would you ever want to inject dependencies via methods? Isn't enough to just inject
   via properties and/or constructors? It seems to make more sense if you go with properties/constructors.
   For example, it makes perfect sense to inject the dependencies of an object when you
   create the object (via constructors). Setting properties on the object can be considered
   an extension of constructing an object, so its okay to inject dependencies after you
   call the constructor. But injecting the dependencies of an object by calling a method
   on it, seems a bit dirty. Why? Is it because an object may not have public properties
   or a visible constructor? For example, we may have a static class that only defines
   a static method. The answer to why 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   supports DI via method execution has to do with the intended use of the build-up process. &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Objects
   in 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   can be build-up more than once. In fact, objects in 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   are build-up repeatedly. This doesn't mean that objects are "re-instantiated". It
   just means that&amp;nbsp;objects are run through the&amp;nbsp;chain of strategies again and
   again.&amp;nbsp;If you look at one of the definitions of IBuilder.BuildUp, we can see
   hints of this.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;object
   BuildUp(IReadWriteLocator locator, Type typeToBuild, string idToBuild, object existing,&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; params PolicyList[] transientPolicies);&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;As
   shown, one of the parameters to BuildUp is an existing (created) instance of the object
   that needs to be build-up. If an object already exists, then 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   runs the stratetgy chain on the existing object. This enables some interesting solutions
   to be built on top of 
   &lt;st1:place w:st="on"&gt;OB.&lt;/st1:place&gt;
   The CAB, for example, has built several interesting solutions on the principal that
   we can execute methods as part of the build-up process. CAB has implemented a publish-subscribe
   pattern and a command pattern on top of 
   &lt;st1:place w:st="on"&gt;OB.&lt;/st1:place&gt;
   The fact that 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   can execute methods, and injection dependencies doing so, enables these features to
   be built. We'll talk about CAB's extensions later. For now, know that if it were not
   for these facilities in OB, then 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   would simply be an object factory.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;b&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Metadata
   Driven 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   &lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font face=Arial color=#000000&gt;The examples
   we've covered thus far demonstrate the basics of 
   &lt;st1:place w:st="on"&gt;OB.&lt;/st1:place&gt;
   The real-world applications and application&amp;nbsp;blocks built using OB make use of
   the metadata-driven facilities provided by 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   , which build upon the strategies we've talked about thus far. Metadata-driven&amp;nbsp;&lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   is driven by decorating objects with attributes. When you ask OB for an object, 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   inspects the metadata on the object, hooks up&amp;nbsp;policies, injects dependencies
   and then returns an instance. All of this happens at runtime when you build-up an
   object. At the heart of all of this is a strategy base class named ReflectionStrategy,
   which is extended by the&amp;nbsp;three reflection based classes PropertyReflectionStrategy,
   ConstructorReflectionStrategy, and MethodReflectionStrategy, and a host of attribute
   classes. Namely, CreateNew, Dependency, InjectionConstructor, InjectionMethod, and
   InjectionParameter (see figure below). &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   &lt;img src="http://www.sayedhashimi.com/content/binary/three.JPG" border=0&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Lets
   get started with an example using ConstructorReflectionStrategy and [Dependency].&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   class MyDAOObject2&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; private string connectionString = null;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; public MyDAOObject2([Dependency(Name = "ConnectionString", SearchMode
   = SearchMode.Local, NotPresentBehavior = NotPresentBehavior.Throw)]string connectionString)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.connectionString = connectionString;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
   }&lt;br&gt;
   public void ConstructorInjectionExample()&lt;br&gt;
   {&lt;br&gt;
   Locator locator = new Locator();&lt;br&gt;
   LifetimeContainer container = new LifetimeContainer();&lt;br&gt;
   locator.Add(typeof(ILifetimeContainer), container);&lt;br&gt;
   // add connection string to the context&lt;br&gt;
   locator.Add(new DependencyResolutionLocatorKey(typeof(string), "ConnectionString"),
   "connection string goes here");&lt;br&gt;
   BuilderStrategyChain chain = new BuilderStrategyChain();&lt;br&gt;
   PolicyList policies = new PolicyList();&lt;br&gt;
   // add strategies&lt;br&gt;
   chain.Add(new ConstructorReflectionStrategy());&lt;br&gt;
   chain.Add(new CreationStrategy());&lt;br&gt;
   // add policies&lt;br&gt;
   policies.SetDefault&amp;lt;ICreationPolicy&amp;gt;(new DefaultCreationPolicy());&lt;br&gt;
   // create context&lt;br&gt;
   BuilderContext cxt = new BuilderContext(chain, locator, policies);&lt;br&gt;
   MyDAOObject2 obj2 = chain.Head.BuildUp(cxt, typeof(MyDAOObject2), null, null) as MyDAOObject2;&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;As
   shown, we have a class named MyDAOObject2, which has a constructor that takes the
   connection string. The interesting thing here is that we have decorated the constructor
   parameter with the Dependency attribute. This effectively tells 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   that the class has a dependency on the defined parameter and to inject the parameter
   at build-up. Note that we have supplied some values to several properties defined
   on the Dependency attribute class for the connection string parameter. Specifically,&amp;nbsp;we
   have supplied the Name, SearchMode and NotPresentBehavior property values. When 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   has to inject the dependency, it looks at these values to determine where to look
   for the value and what to do if the value cannot be found. In our example, we are&amp;nbsp;telling 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   to look in the current locator for the connection string value and if it cannot find
   the value, then throw an exception.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;As
   usual, we create a locator, a strategy chain and a policy list. Note that we add the
   connection string to the locator using DependencyResolutionLocatorKey. In order for 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   to&amp;nbsp;interpret the&amp;nbsp;[Dependency], we&amp;nbsp;put an instance of ConstructorReflectionStrategy
   into the strategy chain. As always, strategies use polices, and so we&amp;nbsp;set the
   default creation policy to DefaultCreationPolicy. When we call BuildUp, 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   resolves the dependency and creates the object correctly. So where is the magic happening?
   Where does 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   pick the Dependency attribute and at what point, and how is the value for the dependency
   obtained? &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Most
   of the magic happens in the base class&amp;nbsp;of ConstructorReflectionStrategy: ReflectionStrategy.
   The essentials of ReflectionStrategy is shown below.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   abstract class ReflectionStrategy&amp;lt;TMemberInfo&amp;gt; : BuilderStrategy&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; protected abstract IEnumerable&amp;lt;IReflectionMemberInfo&amp;lt;TMemberInfo&amp;gt;&amp;gt;
   GetMembers(IBuilderContext context, Type typeToBuild, object existing, string idToBuild);&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
   protected abstract void AddParametersToPolicy(IBuilderContext context, Type typeToBuild,
   string idToBuild,&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IReflectionMemberInfo&amp;lt;TMemberInfo&amp;gt;
   member, IEnumerable&amp;lt;IParameter&amp;gt; parameters);&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
   protected abstract bool MemberRequiresProcessing(IReflectionMemberInfo&amp;lt;TMemberInfo&amp;gt;
   member);&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;public
   override object BuildUp(IBuilderContext context, Type typeToBuild, object existing,
   string idToBuild)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;foreach (IReflectionMemberInfo&amp;lt;TMemberInfo&amp;gt; member in GetMembers(context,
   typeToBuild, existing, idToBuild))&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (MemberRequiresProcessing(member))&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IEnumerable&amp;lt;IParameter&amp;gt; parameters = GenerateIParametersFromParameterInfos(member.GetParameters());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;AddParametersToPolicy(context, typeToBuild, idToBuild,
   member, parameters);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return
   base.BuildUp(context, typeToBuild, existing, idToBuild);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;...&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;ReflectionStrategy
   is the base class for metadata-driven injection processors. ReflectionStrategy defines
   three protected abstract methods that are used to define&amp;nbsp;the template for consuming
   attributes on properties, constructors, and methods.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;The
   BuildUp method in ReflectionStrategy defines the template for consuming injection
   attributes. Derived classes don't implement BuildUp--their job is to just provide
   implementation for th abstract methods. The BuildUp method calls the GetMembers abstract
   method to get the list of members that have to be considered for injection attributes
   and then iterate over each member, asking the derived class if the member needs to
   be processed. If so, then policies are added to the context&amp;nbsp;for the injection
   parameters. &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Lets
   now take a deeper look at the extension of ReflectionStrategy in turn. We'll start
   with ConstructorReflectionStrategy.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;b&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Dependency
   Injection using ConstructorReflectionStrategy&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;In
   our ConstructorReflectionStrategy example, we decorated the constructor parameter
   of MyDAOObject2 with&amp;nbsp;[Dependency]. Lets see how the dependency is resolved and
   injected into the constructor. &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;As
   mentioned earlier, the process of resolving&amp;nbsp;injection parameters is templatized
   by ReflectionStrategy.BuildUp. Thus, we have to look at the implementation of the
   three abstract methods in ConstructorReflectionStrategy&amp;nbsp;to see what happens when
   injection attributes are placed on constructor parameters. ConstructorReflectionStrategy
   is shown below.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;public
   class ConstructorReflectionStrategy : ReflectionStrategy&amp;lt;ConstructorInfo&amp;gt;&lt;br&gt;
   &amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;protected override IEnumerable&amp;lt;IReflectionMemberInfo&amp;lt;ConstructorInfo&amp;gt;&amp;gt;
   GetMembers(IBuilderContext context, Type typeToBuild, object existing, string idToBuild)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;List&amp;lt;IReflectionMemberInfo&amp;lt;ConstructorInfo&amp;gt;&amp;gt; result
   = new List&amp;lt;IReflectionMemberInfo&amp;lt;ConstructorInfo&amp;gt;&amp;gt;();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;ICreationPolicy existingPolicy = context.Policies.Get&amp;lt;ICreationPolicy&amp;gt;(typeToBuild,
   idToBuild);&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if
   (existing == null &amp;amp;&amp;amp; (existingPolicy == null || existingPolicy is DefaultCreationPolicy))&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ConstructorInfo injectionCtor = null;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ConstructorInfo[] ctors = typeToBuild.GetConstructors();&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if
   (ctors.Length == 1)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;injectionCtor = ctors[0];&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach (ConstructorInfo ctor in ctors)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (Attribute.IsDefined(ctor, typeof(InjectionConstructorAttribute)))&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Multiple decorated constructors aren't
   valid&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (injectionCtor != null)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw new InvalidAttributeException();&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;injectionCtor
   = ctor;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if
   (injectionCtor != null)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result.Add(new ReflectionMemberInfo&amp;lt;ConstructorInfo&amp;gt;(injectionCtor));&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return
   result;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; protected override void AddParametersToPolicy(IBuilderContext context,
   Type typeToBuild, string idToBuild, IReflectionMemberInfo&amp;lt;ConstructorInfo&amp;gt; member,
   IEnumerable&amp;lt;IParameter&amp;gt; parameters)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;ConstructorPolicy policy = new ConstructorPolicy();&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach
   (IParameter parameter in parameters)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;policy.AddParameter(parameter);&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;context.Policies.Set&amp;lt;ICreationPolicy&amp;gt;(policy,
   typeToBuild, idToBuild);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;protected override bool MemberRequiresProcessing(IReflectionMemberInfo&amp;lt;ConstructorInfo&amp;gt;
   member)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;return true;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;}&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Recall
   that GetMembers has to return an IEnumerable for the list of members, for the type,
   that need injection attribute processing. ConstructorReflectionStrategy has to return
   the constructor that has [InjectionConstructor] defined. This attribute is used to
   tell ConstructorReflectionStrategy, which constructor to use for attribute-based dependency
   injection, if you have more than one constructor defined. Notice that we didn't put
   this attribute on our constructor definition of MyDAOObject2, which means that [InjectionConstructor]&amp;nbsp;is
   optional if only one constructor has injection attributes. The GetMembers method for
   ConstructorReflectionStrategy checks to see if only one constructor is defined, and
   if so, it takes that constructor as the injection constructor. If more than one constructor
   is defined, it looks for the [InjectionConstructor]. Note that multiple constructors
   decorated with&amp;nbsp;[InjectionConstructor] is invalid.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;So
   ConstructorReflectionStrategy.GetMembers, returns a ReflectionMemberInfo for the [InjectionConstructor].
   ReflectionMemberInfo, is a wrapper for&amp;nbsp;items that need injection attribute processing.
   In the case of ConstructorReflectionStrategy, this is a wrapper around the constructor
   that has [InjectionConstructor]. We'll see a bit later, how ReflectionMemberInfo also
   wraps properties and methods.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;After
   ReflectionStrategy get the list of members that need injection attribute processing,
   the next thing it has to do is add appropriate policies to the context&amp;nbsp;for each
   parameter. Recall from our earlier discussion&amp;nbsp;where we injected a dependency
   using ConstructorPolicy. Using ConstructorPolicy and a ValueParameter, we manually
   established where and how to resolve the dependency. Using ConstructorReflectionStrategy
   and [Dependecy], effectively takes this manual step our of the picture because ConstructorReflectionStrategy
   creates a ConstructorPolicy and adds an&amp;nbsp;IParameter for each parameter for you.
   Note that AddParametersToPolicy iterates over the list of parameters and then adds
   that to the ConstructorPolicy. After which, it sets the ICreationPolicy, for the type,
   to the created constructor policy. Since this is a ConstructorReflectionStrategy,
   the type that needs to be build has not been constructed when this code executes.
   Which means that if the client is using the defualt creation strategy (CreationStrategy),
   and if the default creation policy (DefaultCreationPolicy) was set (which is the case
   in our ConstructorReflectionStrategy example above), that policy gets overriden by
   the&amp;nbsp;newly created&amp;nbsp;ConstructorPolicy. So, when CreationStrategy.InitializeObject
   runs, the correct constructor is selected and the proper values are passed into the
   constructor.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Now
   lets see how this is done with properties are decorated with attributes.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;b&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Dependency
   Injection using PropertyReflectionStrategy&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;PropertyReflectionStrategy
   extends ReflectionStrategy to support injection attributes on properties. The example
   below demonstrates using this extension.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   class MyDAOObject3&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; private string connectionString;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; 
   &lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; [Dependency(Name = "ConnectionString", SearchMode = SearchMode.Local,&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NotPresentBehavior = NotPresentBehavior.Throw)]&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; public string ConnectionString&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return connectionString;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; connectionString
   = value;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
   }&lt;br&gt;
   public void PropertyReflectionStrategyExample()&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; Locator locator = new Locator();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; LifetimeContainer container = new LifetimeContainer();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; locator.Add(typeof(ILifetimeContainer), container);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // add connection string to locator&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; locator.Add(new DependencyResolutionLocatorKey(typeof(string),
   "ConnectionString"), "connection string goes here");&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; BuilderStrategyChain chain = new BuilderStrategyChain();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; PolicyList policies = new PolicyList();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // add strategies&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; chain.Add(new PropertyReflectionStrategy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; chain.Add(new CreationStrategy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; chain.Add(new PropertySetterStrategy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // add policies&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; policies.SetDefault&amp;lt;ICreationPolicy&amp;gt;(new DefaultCreationPolicy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // create context&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; BuilderContext cxt = new BuilderContext(chain, locator, policies);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // do buildUp&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; MyDAOObject3 obj = chain.Head.BuildUp(cxt, typeof(MyDAOObject3),
   null, null) as MyDAOObject3;&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;In
   the code snippet above, we've created a class named MyDAOObject3 which has a single
   property named ConnectionString. This property is decorated with the same [Dependency]
   that was previously set on the constructor of MyDAOObject2. The obvious idea is to
   have 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   inject this propety at build-up. To have 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   interpret the metadata on the ConnectionString property, we have to add a few strategies
   to the strategy chain. In the last section, all we had was a ConstructorReflectionStrategy.
   Here, we see two new strategies: PropertyReflectionStrategy and PropertySetterStrategy.
   Note that the usual CreationStrategy sit in between these two. Why? In the section
   we had a ConstructorReflectionStrategy precede CreationStrategy because the strategy
   needed to resolve which constructor to call, prior to instantiating the object. With
   properties, however, we have to wait for the object to be instantiated prior to calling
   properties. Thus, we use the PropertyReflectionStrategy to [TODO] and the PropertySetterStrategy
   to assign property values.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;As
   before, the magic lies in the PropertyReflectionStrategy implementations of the three
   abstract methods defined in ReflectionStrategy (see below).&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   class PropertyReflectionStrategy : ReflectionStrategy&amp;lt;PropertyInfo&amp;gt;&lt;br&gt;
   &amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;protected override IEnumerable&amp;lt;IReflectionMemberInfo&amp;lt;PropertyInfo&amp;gt;&amp;gt;
   GetMembers(IBuilderContext context, Type typeToBuild, object existing, string idToBuild)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;foreach (PropertyInfo propInfo in typeToBuild.GetProperties())&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;yield return new PropertyReflectionMemberInfo(propInfo);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; protected override void AddParametersToPolicy(IBuilderContext context,
   Type typeToBuild, string idToBuild, IReflectionMemberInfo&amp;lt;PropertyInfo&amp;gt; member,
   IEnumerable&amp;lt;IParameter&amp;gt; parameters)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;PropertySetterPolicy result = context.Policies.Get&amp;lt;IPropertySetterPolicy&amp;gt;(typeToBuild,
   idToBuild) as PropertySetterPolicy;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if
   (result == null)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result = new PropertySetterPolicy();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;context.Policies.Set&amp;lt;IPropertySetterPolicy&amp;gt;(result,
   typeToBuild, idToBuild);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach
   (IParameter parameter in parameters)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (!result.Properties.ContainsKey(member.Name))&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result.Properties.Add(member.Name, new PropertySetterInfo(member.MemberInfo,
   parameter));&lt;br&gt;
   &amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;protected override bool MemberRequiresProcessing(IReflectionMemberInfo&amp;lt;PropertyInfo&amp;gt;
   member)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;return (member.GetCustomAttributes(typeof(ParameterAttribute), true).Length
   &amp;gt; 0);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;...&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;The
   GetMembers method is now returning an IEnumerable for the list of properties on the
   type. Recall from ReflectionStrategy.BuildUp that as each member is iterated, a call
   is made to MemberRequiresProcessing to see if that property needs to be processed.
   Since GetMembers returns all of the properties, MemberRequiresProcessing is used to
   ensure that the property being considered has at least one&amp;nbsp;custom property which
   extends [Parameter]. From the defintion of MyDAOObject3, we know that ConnectionString
   is decorated with [Dependeny], and [Dependency]does extend [Parameter]. &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;After
   the property is determined to be processable, ReflectionStrategy.BuildUp calls AddParametersToPolicy
   to add the property to the policy. In ConstructorReflectionStrategy.AddParametersToPolicy
   we saw that a new ConstructorPolicy was created for the constructor and the parameters
   for the constructor were added to that policy and the policy was set on the context
   for the type. Here, the method is looking for the appropriate policy to be on the
   context. Why? Recall that ConstructorReflectionStrategy enforced that only one constructor
   could have the [InjectionConstructor] decoration. Here, more than one property can
   have an extension of [Parameter] and because you have one policy for a given policy
   interface, for a type, we can create the policy ahead&amp;nbsp;of time and set it&amp;nbsp;prior
   to build-up. Note that if the PropertySetterPolicy is not on the context, which is
   our case, the method creates one and adds it to the context.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;After
   all of the properties have been preprocessed, the object is created, and then PropertySetterStrategy
   is executed to do the actual injection of values into the properties.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;b&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Dependency
   Injection using MethodReflectionStrategy&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;MethodReflectionStrategy
   is also an extension of ReflectionStrategy. This extension strategy is used to support
   calling methods which have been docorated with an [InjectionMethod] and have [Dependency]
   parameters. The code snippet below demonstrates this.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   class MyDAOObject3&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private string connectionString;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private string username, password;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
   [Dependency(Name = "ConnectionString", SearchMode = SearchMode.Local,&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NotPresentBehavior = NotPresentBehavior.Throw)]&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string ConnectionString&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return
   connectionString;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; connectionString
   = value;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [InjectionMethod]&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void Credentials([Dependency(Name = "DBUserName",
   SearchMode = SearchMode.Local,&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NotPresentBehavior = NotPresentBehavior.Throw)]string
   userName, 
   &lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Dependency(Name = "DBPassword",
   SearchMode = SearchMode.Local,&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NotPresentBehavior = NotPresentBehavior.Throw)]string
   password)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.username = userName;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.password = password;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial&gt;&lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   void MethodReflectionStrategyExample()&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; Locator locator = new Locator();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; LifetimeContainer container = new LifetimeContainer();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; locator.Add(typeof(ILifetimeContainer), container);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // add username and password to the locator&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; locator.Add(new DependencyResolutionLocatorKey(typeof(string),
   "DBUserName"), "sa");&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; locator.Add(new DependencyResolutionLocatorKey(typeof(string),
   "DBPassword"), "fairoza");&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; BuilderStrategyChain chain = new BuilderStrategyChain();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; PolicyList policies = new PolicyList();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // add strategies&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; chain.Add(new MethodReflectionStrategy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; chain.Add(new CreationStrategy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; chain.Add(new MethodExecutionStrategy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // add policies&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; policies.SetDefault&amp;lt;ICreationPolicy&amp;gt;(new DefaultCreationPolicy());&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; // create context and buildup&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; BuilderContext cxt = new BuilderContext(chain, locator, policies);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; MyDAOObject3 obj = chain.Head.BuildUp(cxt, typeof(MyDAOObject3),
   null, null) as MyDAOObject3;&lt;br&gt;
   }&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;You
   can see that we've added a method to MyDAOObject3 which is decorated with [InjectionMethod].
   You can also see that the two parameters to the method are decorated with the [Dependency].
   As far as build-up goes, the pattern looks very similar to our previous example--we
   have two method related strategies sandwiching the CreationStrategy. MethodReflectionStrategy
   is responsible for identifying the methods on the type that have the [InjectionMethod]
   decoration (or a derived class of InjectionMethod). MethodExecutionStrategy is responsible
   for executing the methods with proper values for the method parameters. MethodReflectionStrategy
   is shown below (we've already discussed MethodExecutionStrategy).&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;public
   class MethodReflectionStrategy : ReflectionStrategy&amp;lt;MethodInfo&amp;gt;&lt;br&gt;
   {&lt;br&gt;
   &amp;nbsp;&amp;nbsp;protected override IEnumerable&amp;lt;IReflectionMemberInfo&amp;lt;MethodInfo&amp;gt;&amp;gt;
   GetMembers(IBuilderContext context, Type typeToBuild, object existing, string idToBuild)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;foreach (MethodInfo method in typeToBuild.GetMethods())&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;yield return new ReflectionMemberInfo&amp;lt;MethodInfo&amp;gt;(method);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;protected override void AddParametersToPolicy(IBuilderContext context,
   Type typeToBuild, string idToBuild,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IReflectionMemberInfo&amp;lt;MethodInfo&amp;gt;
   member, IEnumerable&amp;lt;IParameter&amp;gt; parameters)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;MethodPolicy result = context.Policies.Get&amp;lt;IMethodPolicy&amp;gt;(typeToBuild,
   idToBuild) as MethodPolicy;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if
   (result == null)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result = new MethodPolicy();&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;context.Policies.Set&amp;lt;IMethodPolicy&amp;gt;(result, typeToBuild,
   idToBuild);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font face=Arial color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;result.Methods.Add(member.Name,
   new MethodCallInfo(member.MemberInfo, parameters));&lt;br&gt;
   &amp;nbsp;&amp;nbsp;}&lt;br&gt;
   &amp;nbsp;&amp;nbsp;protected override bool MemberRequiresProcessing(IReflectionMemberInfo&amp;lt;MethodInfo&amp;gt;
   member)&lt;br&gt;
   &amp;nbsp;&amp;nbsp;{&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;return (member.GetCustomAttributes(typeof(InjectionMethodAttribute),
   true).Length &amp;gt; 0);&lt;br&gt;
   &amp;nbsp;&amp;nbsp;}&lt;br&gt;
   }&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sayedhashimi.com/aggbug.ashx?id=d05aed4f-a211-4969-893e-7ffea324a56c" /&gt;</content>
  </entry>
  <entry>
    <title>ObjectBuilder-Dependency Injection Framework</title>
    <link rel="alternate" type="text/html" href="http://www.sayedhashimi.com/PermaLink,guid,781fd534-ad87-45b9-b9f0-fe96116eaaf2.aspx" />
    <id>http://www.sayedhashimi.com/PermaLink,guid,781fd534-ad87-45b9-b9f0-fe96116eaaf2.aspx</id>
    <published>2006-09-07T09:58:22.751625-07:00</published>
    <updated>2006-09-07T09:58:22.751625-07:00</updated>
    <category term="ObjectBuilder" label="ObjectBuilder" scheme="dasBlog" />
    <content type="html">&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;b&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Some
   Notes on Object Builder&lt;/span&gt;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;b&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Over
   the past few weeks I have been looking over the ObjectBuilder (Dependecy Injection)
   framework. I have taken a bunch of notes and will start to write some blog entries
   on it. This is the first....so an introduction is in order.&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;b&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;b&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Introduction
   to Object Builder&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Most
   software developers today&amp;nbsp;understand classes and object-oriented programming.
   One of the basic pillars of OO is to encapsulate concepts in objects. Thus, when writing
   OO based software, you end up with (potentially)&amp;nbsp;lots of classes. A common problem
   that arises with having a bunch of classes/components is how do you decouple some
   of the major components of your software so that you can maintain them independently.
   The solution is to use a loose coupling design.&amp;nbsp;Dependency Injection (DI) is
   a design pattern that promotes loose coupling. Specifically, DI addresses the following:&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;ol type=1&gt;
   &lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l1 level1 lfo1; tab-stops: list .5in"&gt;
      &lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font face=Arial&gt;If
      you have a collection of classes/components/services that rely on each other, then
      what's the best way to hook these objects together, so that you minimize coupling?&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt; 
      &lt;o:p&gt;&lt;/o:p&gt;
      &lt;/span&gt;&lt;/font&gt; 
   &lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l1 level1 lfo1; tab-stops: list .5in"&gt;
      &lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font face=Arial&gt;If
      you have objects that depend on each other, then how do you resolve the order in which
      these objects/components/services are created?&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt; 
      &lt;o:p&gt;&lt;/o:p&gt;
      &lt;/span&gt;&lt;/font&gt; 
   &lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l1 level1 lfo1; tab-stops: list .5in"&gt;
      &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;If
      you have objects that depend on other objects, then how do objects find their dependencies?&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
      &lt;o:p&gt;&lt;/o:p&gt;
      &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
   &lt;/li&gt;
&lt;/ol&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;In
   order for an implementation to support a mechanism where objects declare their dependencies
   and somehow their dependencies are made available, while taking into account that&amp;nbsp;the&amp;nbsp;dependency
   itself may also have dependencies, requires&amp;nbsp;a container for objects. So DI is
   a pattern that requires a container. The container maintains the created objects.
   When an object says it has a dependency on another object, the DI implementation looks
   in it's container for the object and if it exists, it uses the object, otherwise,
   it creates it and puts it&amp;nbsp;in the container (note that this is a simplified example).&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;The
   benefits of using a dependency injection&amp;nbsp;framework are:&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;ol type=1&gt;
   &lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo2; tab-stops: list .5in"&gt;
      &lt;font color=#000000&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font face=Arial&gt;The
      dependencies of your components are loosely coupled. By using DI you say that you
      depend on a component, and it's up to the DI container to deliver that component to
      you. Your component has no knowledge of how&amp;nbsp;the&amp;nbsp;dependency was created or
      where the implementation lives.&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt; 
      &lt;o:p&gt;&lt;/o:p&gt;
      &lt;/span&gt;&lt;/font&gt; 
   &lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo2; tab-stops: list .5in"&gt;
      &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Because
      your loosely coupled to your dependencies, you can swap implementations of your components.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
      &lt;o:p&gt;&lt;/o:p&gt;
      &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
   &lt;/li&gt;
&lt;/ol&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;&lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;Object
   builder&amp;nbsp;is a framework that can be used to implement a&amp;nbsp;DI&amp;nbsp;system. 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   is based upon policies and strategies. Strategies are chained and get registered for
   a build stage.&amp;nbsp; Strategies use policies. Policies are registered with 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   for types. A policy is defined for types (objects in 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   are defined by the type and ID). Some examples of policies in 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   include:&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;ITypeMappingPolicy&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;ICreationPolicy&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;ISingletonPolicy&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;With 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   you can define default policies. You can, for example, say that all objects with a
   given ID have to be a singleton. &lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;//
   create a new builder container&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Builder
   builder = new Builder();&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;//
   tell the builder that all of the objects in the container should be a singleton.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;builder.Policies.SetDefault&amp;lt;ISingletonPolicy&amp;gt;(new
   SingletonPolicy(true));&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;Note
   that the ID doesn't have to be unique because an object in 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   is defined by an ID and the type of the object. Thus, you can have many objects with
   the same ID.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;There
   are several ways you can have a&amp;nbsp;dependent service injected into an object. You
   can do it by requiring classes to write a constructor with the list of their dependencies.
   You can provided setter properties for your dependencies. And you can do for using
   attributes (i.e., decorate your class with your dependencies). 
   &lt;st1:place w:st="on"&gt;OB&lt;/st1:place&gt;
   supports all of these. As an example, you can define a property on a class with a
   dependency and then use the PropertySetterPolicy to set the dependency when the object
   is created. You can also define a constructor on class with it's dependencies and
   then use a CreationPolicy to have the dependency injected. Here are examples of how
   you can to this.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;1)
   Injection using a property&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;//
   create the PropertySetterPolicy&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;PropertySetterPolicy
   propPolicy = new PropertySetterPolicy();&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;//
   define the property that needs to be set--the dependency&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;propPolicy.Properties.Add("IConfigurationService",new
   PropertySetterInfo("IConfigurationService"),typeof(IConfigurationService),"MyConfigurationService",typeof(ConfigurationServiceImpl),NotPresentBehavior.CreateNew,SearchMode.Local)));&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;//
   add the policy for the object&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;builder.Policies.Set&amp;lt;IPropertySetterPolicy&amp;gt;(propPolicy,typeof(IEmailService),
   "MyEmailServiceID");&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;The
   above code creates a new PropertySetterPolicy and tells the dependency inject to inject
   the IConfigurationService into the IEmailService by calling it's IConfigurationService
   property. When the instance of IEmailService is created by the builder, it will run
   through it's policies and when the PropertySetterPolicy is executed, it will set the
   IConfigurationService property and thus inject the dependency. Note that by saying
   NotPresentBehavior.CreateNew tells the builder what to do if there is not an instance
   of IConfigurationService when the propery needs to be injected. In this case, it is
   saying to create a new one. Realize that if you have multiple instances of IEmailService,
   they will all get the same instance of IConfigurationService.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;2)
   Injection using a constructor&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;//
   injection via constructor is implemented by ICreationPolicy.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;ICreationPolicy
   createPolicy = new ConstructorPolicy(new ValueParameter&amp;lt;FileInfo&amp;gt;(new FileInfo("c:\\EmailGroupsFile.txt"));&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;builder.Policies.Set&amp;lt;ICreationPolicy&amp;gt;(createPolicy,typeof(EmailServiceImpl),"MyEmailServiceID");&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;span style="mso-bidi-font-family: Arial"&gt;The
   above code tells the builder to inject the path to the list of email groups (via the
   FileInfo) when&amp;nbsp;you create an object of type EmailServiceImpl and ID=MyEmailServiceID.&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;span style="mso-bidi-font-family: Arial"&gt;&lt;font face=Arial color=#000000&gt;We'll see
   alot more on this in later posts.&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sayedhashimi.com/aggbug.ashx?id=781fd534-ad87-45b9-b9f0-fe96116eaaf2" /&gt;</content>
  </entry>
  <entry>
    <title />
    <link rel="alternate" type="text/html" href="http://www.sayedhashimi.com/PermaLink,guid,11264fab-df5d-4e0a-8c81-cd0de941c164.aspx" />
    <id>http://www.sayedhashimi.com/PermaLink,guid,11264fab-df5d-4e0a-8c81-cd0de941c164.aspx</id>
    <published>2006-06-20T13:28:45.522625-07:00</published>
    <updated>2006-06-20T13:28:45.522625-07:00</updated>
    <category term="ClickOnce" label="ClickOnce" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <div>
          <font face="Arial" size="2">
            <span class="569593712-05062006">
              <font face="Arial">
                <font size="2">
                  <span class="992080013-05062006">
                    <font face="Arial" size="2">
                      <span class="992080013-05062006">A
      few days ago I was doing a demo on ClickOnce and was asked a few questions that I
      felt others could benefit from. The first one was with respect to the folders/files
      generated by Visual Studio when you do deployments and the other one worth mentioning
      deals with desktop icons and Clickonce.</span>
                    </font>
                  </span>
                </font>
              </font>
            </span>
          </font>
        </div>
        <div>
          <font face="Arial" size="2">
            <span class="569593712-05062006">
              <font face="Arial">
                <font size="2">
                  <span class="992080013-05062006">
                    <font face="Arial" size="2">
                      <span class="992080013-05062006">
                        <strong>
                        </strong>
                      </span>
                    </font>
                  </span>
                </font>
              </font>
            </span>
          </font> 
   </div>
        <div>
          <font face="Arial" size="2">
            <span class="569593712-05062006">
              <font face="Arial">
                <font size="2">
                  <span class="992080013-05062006">
                    <font face="Arial" size="2">
                      <span class="992080013-05062006">
                        <strong>When
      I publish my application using VS 2005, it puts each deployment in a separate folder.
      In addition, it creates a [APPLICATION]_[VERSION].application file for each version.
      Moreover, there is a [APPLICATION].application file too. What is the reasoning behind
      all of this? Especially, the [APPLICATION]_[VERSION].application files?</strong>
                      </span>
                    </font>
                  </span>
                </font>
              </font>
            </span>
          </font>
        </div>
        <div>
          <font face="Arial" size="2">
            <span class="569593712-05062006">
              <font face="Arial">
                <font size="2">
                  <span class="992080013-05062006">
                    <font face="Arial" size="2">
                      <span class="992080013-05062006">
                        <strong>
                        </strong>
                      </span>
                    </font>
                  </span>
                </font>
              </font>
            </span>
          </font> 
   </div>
        <div>
          <font face="Arial" size="2">
            <span class="569593712-05062006">
              <font face="Arial">
                <font size="2">
                  <span class="992080013-05062006">
                    <font face="Arial" size="2">
                      <span class="992080013-05062006">When
      you publish an application using VS 2005, VS creates a deployment folder and
      names it based on your application name and version. The deployment folder contains
      everything about a particular version. VS also creates a deployment manifest based
      on the application and version (e.g., MyApp_1_0_0_0.application). Moreover, the firsttime
      you publish your application, VS creates deployment manifest (e.g., MyApp.application)
      that is independent of any version. The idea behind these files is to achieve server
      side rollback. The scenario is for you to do a deployment and send your users the
      link to the MyApp.application file. This deployment manifest refers to the latest
      version of the deployment. If you need to do a rollback on the server side for any
      reason, you can simply delete the MyApp.application and rename the latest version
      to MyApp.application.</span>
                    </font>
                  </span>
                </font>
              </font>
            </span>
          </font>
        </div>
        <div>
          <font face="Arial" size="2">
            <span class="569593712-05062006">
              <font face="Arial">
                <font size="2">
                  <span class="992080013-05062006">
                    <font face="Arial" size="2">
                      <span class="992080013-05062006">
                      </span>
                    </font>
                  </span>
                </font>
              </font>
            </span>
          </font> 
   </div>
        <div>
          <font face="Arial" size="2">
            <span class="569593712-05062006">
              <font face="Arial">
                <font size="2">
                  <span class="992080013-05062006">
                    <font face="Arial" size="2">
                      <span class="992080013-05062006">
                        <div>
                          <font face="Arial" size="2">
                            <span class="569593712-05062006">
                              <font face="Arial">
                                <font size="2">
                                  <span class="992080013-05062006">
                                    <div>
                                      <font face="Arial" size="2">
                                        <span class="569593712-05062006">
                                          <strong>Desktop
            Shortcut and ClickOnce</strong>
                                        </span>
                                      </font>
                                    </div>
                                    <div>
                                      <font face="Arial" size="2">
                                        <span class="569593712-05062006">
                                        </span>
                                      </font> 
         </div>
                                    <div>
                                      <font face="Arial" size="2">
                                        <span class="569593712-05062006">ClickOnce does not
            support the automatic creation of desktop shortcuts. Microsoft actually says that
            in their research they found that users don't like their desktop cluttered with
            icons and so they decided not to support desktop shortcuts with ClickOnce. If you
            have played around with ClickOnce to even a small degree then you know that ClickOnce
            also has an API that you can use to customize/supplement your ClickOnce deployment.
            If your users start asking for a desktop shortcut and you start to look for a way
            to achieve this, you'll likely end up using the APIs to figure out if the application
            is running for the firsttime (after a ClickOnce deployment) and if so, then execute
            some code that will determine the path to the application executable and then create
            a desktop shortcut. There are a few pitfalls that you have to consider before you
            jump into using desktop shortcuts with ClickOnce.</span>
                                      </font>
                                      <font face="Arial" size="2">
                                        <span class="569593712-05062006">
                                        </span>
                                      </font>
                                    </div>
                                    <div>
                                      <font face="Arial" size="2">
                                        <span class="569593712-05062006">
                                        </span>
                                      </font> 
         </div>
                                    <div>
                                      <font face="Arial" size="2">
                                        <span class="569593712-05062006">a) Desktop shortcuts
            requires use of some COM APIs and thus your application needs to have Full-Trust.
            See <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/e6ac108b-15f6-4a54-891f-589e8b687ace.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/e6ac108b-15f6-4a54-891f-589e8b687ace.asp</a> or <a href="http://www.knowdotnet.com/articles/createshortcutondesktop.html">http://www.knowdotnet.com/articles/createshortcutondesktop.html</a> .
            If your application does not have full trust, you'll get a SecurityException.</span>
                                      </font>
                                    </div>
                                    <div>
                                      <font face="Arial" size="2">
                                        <span class="569593712-05062006">
                                        </span>
                                      </font> 
         </div>
                                    <div>
                                      <font face="Arial" size="2">
                                        <span class="569593712-05062006">b) </span>
                                      </font>
                                      <font face="Arial" size="2">
                                        <span class="569593712-05062006">If
            your application does not have Full-Trust, then you might be eager to tell your users
            to just drag the Program Files shortcut for your application onto their desktop and
            then use that when launching the application. I highly recommend against this and
            here's why. </span>
                                      </font>
                                      <font face="Arial" size="2">
                                        <span class="569593712-05062006">Lets
            say you deploy version 1 of your application and a user drags the shortcut from Program
            Files onto the desktop. <font face="Arial"><font size="2">You then publish version
            2 of your application<span class="992080013-05062006">. When the user goes to launch
            the application using the shortcut he created, he'll get a message that the application
            has an update and he will update and everything will be fine. The next day when he
            comes in and executes the shortcut again, he'll get a message that the application
            has an update and he will have to update again. This will continue, until there is
            version 3. When version 3 comes out, the ClickOnce runtime will delete version 1 (ClickOnce
            maintaines only 2 versions of an application per user). When the user executes the
            shortcut again, he'll get a message that the shortcut points to a file that doesn't
            exist. </span></font></font><font face="Arial"><font size="2"><span class="992080013-05062006">The
            bottom line is that when the user drags the shortcut to the desktop on version 1,
            you have no way of updating the target of the shortcut when an update happens--ClickOnce
            updates the shortcut when you do an update so everything works with the Program Files
            shortcut.</span></font></font></span>
                                      </font>
                                    </div>
                                    <div>
                                      <font face="Arial" size="2">
                                        <span class="569593712-05062006">
                                          <font face="Arial">
                                            <font size="2">
                                              <span class="992080013-05062006">
                                              </span>
                                            </font>
                                          </font>
                                        </span>
                                      </font> 
         </div>
                                    <div>
                                      <font face="Arial" size="2">
                                        <span class="569593712-05062006">
                                          <font face="Arial">
                                            <font size="2">
                                              <span class="992080013-05062006">c) <font face="Arial" size="2"><span class="992080013-05062006">Another
            problem with desktop shortcuts is that you have no way of getting rid of them when
            your application is uninstalled.</span></font></span>
                                            </font>
                                          </font>
                                        </span>
                                      </font>
                                    </div>
                                  </span>
                                </font>
                              </font>
                            </span>
                          </font>
                        </div>
                      </span>
                    </font>
                  </span>
                </font>
              </font>
            </span>
          </font>
        </div>
        <img width="0" height="0" src="http://www.sayedhashimi.com/aggbug.ashx?id=11264fab-df5d-4e0a-8c81-cd0de941c164" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Forcing Application Updates</title>
    <link rel="alternate" type="text/html" href="http://www.sayedhashimi.com/PermaLink,guid,81b51158-ede5-42dd-ae5f-1ebb875678d1.aspx" />
    <id>http://www.sayedhashimi.com/PermaLink,guid,81b51158-ede5-42dd-ae5f-1ebb875678d1.aspx</id>
    <published>2006-03-21T12:40:48.376625-07:00</published>
    <updated>2006-03-21T12:40:48.376625-07:00</updated>
    <category term="ClickOnce" label="ClickOnce" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <strong>Forcing ClickOnce Updates</strong>
        </p>
        <p>
      One of the big selling points of ClickOnce is automatic updates. One of the common
      questions I get with regard to updates is "How can I force an update on the user?"
   </p>
        <p>
      There are three things to know with respect to <strong>forcing updates</strong> on
      users:
   </p>
        <p>
      1) If your application is an <strong>online</strong> application, your users will
      always run the latest version; online applications get downloaded everytime the application
      is accessed. Thus, with online applications, you get forced-updates by default. 
   </p>
        <p>
      2) If your application is an <strong>installed</strong> application, you can force
      updates by using the MinimumRequiredVersion attribute. If you publish your application
      using Visual Studio, you can set this property from the Updates Dialog.
   </p>
        <p>
      3) The last thing to note is that if your application is an <strong>installed</strong> application
      (and you have not set the <strong>MinimumRequiredVersion</strong> attribute) ClickOnce
      will prompt the user with an "Update Available" dialog ONLY if the user launches the
      application from the Start Menu shortcut. That is, if an application is an installed
      application and the user launches the application from a URL, ClickOnce forces the
      update.
   </p>
        <p>
       
   </p>
        <img width="0" height="0" src="http://www.sayedhashimi.com/aggbug.ashx?id=81b51158-ede5-42dd-ae5f-1ebb875678d1" />
      </div>
    </content>
  </entry>
  <entry>
    <title>URL Parameter Passing with a ClickOnce Application</title>
    <link rel="alternate" type="text/html" href="http://www.sayedhashimi.com/PermaLink,guid,a3dbdf22-a0e8-4776-9f75-3f236e59b120.aspx" />
    <id>http://www.sayedhashimi.com/PermaLink,guid,a3dbdf22-a0e8-4776-9f75-3f236e59b120.aspx</id>
    <published>2006-03-21T07:32:41.501625-07:00</published>
    <updated>2006-03-21T07:32:41.501625-07:00</updated>
    <category term="ClickOnce" label="ClickOnce" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      ClickOnce applications can have arguments passed to it via URL paramters (similar
      to how we pass paramters to web pages). An example URL looks like:
   </p>
        <p>
          <a href="http://mycompany.com/myapp.application?username=user&amp;pass=pwd">http://mycompany.com/myapp.application?username=user&amp;pass=pwd</a>
        </p>
        <p>
      If you are thinking of using this feature, there are a couple of things to keep in
      mind.
   </p>
        <p>
      1) URL Paramters are passed to your application only if your application is launched
      from a URL. This means that if you have an installed application and the user launches
      the application from the Start Menu shortcut, your application will not get URL paramters.
   </p>
        <p>
      2) This feature works well for online applications because online applications are
      always launched using the URL (i.e., online applications are not installed applications
      and thus do not get Start Menu shortcuts). 
   </p>
        <p>
      3) URL Parameter passing is not enabled by default. In Visual Studio 2005, you can
      enable it by checking the "Allow URL parameters to be passed to this application"
      checkbox. You can get to this by clicking on the "Options..." button from the Publish
      tab. If you are using the MAGE tool, you can do this when you create a deployment
      manifest by editing the "Deployment Options" UI. If you are using MSBuild to generate
      your ClickOnce application, you need to set the TrustUrlParameters<br />
      property on the <a href="http://msdn2.microsoft.com/en-us/library/ms172242.aspx">GenerateDeploymentManifest </a>task.
   </p>
        <p>
      4) Here is an example of a class that lets you get to the URL parameters collection
      of your ClickOnce application. Note that the application has to be deployed via ClickOnce
      for the class to return the URL parameters.
   </p>
        <p>
      using System;<br />
      using System.Collections.Generic;<br />
      using System.Windows.Forms;
   </p>
        <p>
      public sealed class DeploymentHelper<br />
      {<br />
          private static Dictionary&lt;string, string&gt; urlParms;
   </p>
        <p>
          static DeploymentHelper()<br />
          {<br />
              try<br />
              {<br />
                  Uri appUri = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.ActivationUri;<br />
                  if (appUri != null)<br />
                  {<br />
                     
      URLParameters = GetQueryStringParametersCollection();<br />
                  }<br />
              }<br />
              catch (Exception) { }<br />
          }
   </p>
        <p>
          public static Dictionary&lt;string, string&gt; URLParameters<br />
          {<br />
              get<br />
              {<br />
                  return urlParms;<br />
              }<br />
              private set<br />
              {<br />
                  urlParms = value;<br />
              }<br />
          }<br />
          
      <br />
          private static Dictionary&lt;string, string&gt; GetQueryStringParametersCollection()<br />
          {<br />
              Dictionary&lt;string, string&gt; nameValueTable
      = new Dictionary&lt;string, string&gt;();
   </p>
        <p>
              if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)<br />
              {<br />
                  string url = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.ActivationUri.AbsoluteUri;<br />
                  string queryString
      = (new Uri(url)).Query;<br />
                  string[] nameValuePairs
      = queryString.Split('&amp;');<br />
                  bool firstVar =
      true;<br />
                  foreach (string
      pair in nameValuePairs)<br />
                  {<br />
                     
      string[] vars = pair.Split('=');<br />
                     
      if (firstVar)<br />
                     
      {<br />
                         
      firstVar = false;<br />
                         
      if (vars[0].Contains("?"))<br />
                         
      {<br />
                             
      vars = new string[] { vars[0].Trim('?'), vars[1] };<br />
                         
      }<br />
                     
      }<br />
                     
      if (!nameValueTable.ContainsKey(vars[0]))<br />
                     
      {<br />
                         
      nameValueTable.Add(vars[0], vars[1]);<br />
                     
      }<br />
                  }<br />
              }
   </p>
        <p>
              return (nameValueTable);<br />
          }<br />
      }
   </p>
        <p>
      You can get to the URL parameters by using the static property URLParameters:
   </p>
        <p>
      Dictionary&lt;string,string&gt; urlParms = DeploymentHelper.URLParameters;
   </p>
        <p>
      Note that the core of the class is the static GetQueryStringParametersCollection()
      method. I copied most of this method from MSDN, however, the MSDN version has a bug
      in it so and I had to modify it. 
   </p>
        <p>
          <br />
       
   </p>
        <img width="0" height="0" src="http://www.sayedhashimi.com/aggbug.ashx?id=a3dbdf22-a0e8-4776-9f75-3f236e59b120" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Setting up CruiseControl.NET with MSBuild</title>
    <link rel="alternate" type="text/html" href="http://www.sayedhashimi.com/PermaLink,guid,c00defe4-f073-4e0e-98b6-70eabaf35f6a.aspx" />
    <id>http://www.sayedhashimi.com/PermaLink,guid,c00defe4-f073-4e0e-98b6-70eabaf35f6a.aspx</id>
    <published>2006-02-08T08:46:22.088375-08:00</published>
    <updated>2006-02-08T08:46:22.088375-08:00</updated>
    <category term="ClickOnce" label="ClickOnce" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Just setup CruiseControl.NET (CC.NET) on a fresh install of Windows 2003 server. It
      went pretty seamless. 
   </p>
        <p>
      For now, we are only doing continuous integration, but very soon we are going to set
      it up for NUnit and FxCop too. If you plan on using it, here are the steps I followed.
      Note that we are using Subversion for our source control and that the box had nothing
      on it.
   </p>
        <p>
      1. Download and install Subversion (<a href="http://subversion.tigris.org/project_packages.html">http://subversion.tigris.org/project_packages.html</a>).<br />
      2. Create a working directory and get latest from trunk.<br />
      3. Download CC.NET (<a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET">http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET</a>).<br />
      4. Download CC.NET Tray (<a href="http://confluence.public.thoughtworks.org/display/CCNET/CCTray">http://confluence.public.thoughtworks.org/display/CCNET/CCTray</a>).<br />
      5. Install CC.NET.<br />
      6. Modify CC.NET Server configuration file to monitor your source control working
      directory and to call MSBuild.<br />
      7. Modify CC.NET web dashboard configuration file to show MSBuild output.
   </p>
        <p>
      CC.NET can provide build updates via email notification or to a utility that you can
      install on your desktop (CCTray). We decided to go this route rather than have CC.NET
      email us. The cool thing about the tray utility is that it sits in your system tray
      and the icon will change when a build starts and the result of the build.
   </p>
        <p>
      If you have never used CC.NET or the Java version, note that CC.NET has a server application
      that can be run as an NT Service (named CruiseControl.NET Server). You can configure
      the service to start automatically via the service control MMC. CC.NET also has a
      web dashboard that is used to view build outputs. The dashboard application gets installed
      under Program Files\CruiseControl.NET\webdashboard\.  If you use configure CC.NET
      to call MSBuild, then you'll want to also add an entry to the dashboard.config file
      to include a link to the MSBuild output. 
   </p>
        <p>
      Most of the setup of CC.NET was easy, the only problem I had was that I working off
      of an old configuration file and that one was not configured for MSBuild. Here is
      the server configuration file (ccnet.config), followed by the dashboard config file.
   </p>
        <p>
      &lt;!-- ************************************************* --&gt;<br />
      &lt;cruisecontrol&gt;<br />
       &lt;project name="YourAppName"&gt;<br />
        &lt;!-- after a change is detected, wait 10 mins and then kick off the
      build--&gt;<br />
        &lt;schedule type="schedule" sleepSeconds="600" /&gt;<br />
        &lt;!--set the sourcecontrol type to subversion and point to the subversion
      exe--&gt;<br />
        &lt;sourcecontrol type="svn"&gt;<br />
         &lt;executable&gt;C:\Program Files\Subversion\bin\svn.exe&lt;/executable&gt;<br />
         &lt;workingDirectory&gt;D:\CruiseControl\yourapp\build\checkout&lt;/workingDirectory&gt;<br />
         &lt;trunkUrl&gt;svn://servername/Projects/yourapp/trunk/Source&lt;/trunkUrl&gt;<br />
         &lt;autoGetSource&gt;true&lt;/autoGetSource&gt;<br />
         &lt;username&gt;sayed&lt;/username&gt;<br />
         &lt;password&gt;password&lt;/password&gt;<br />
        &lt;/sourcecontrol&gt;<br />
        &lt;tasks&gt;<br />
         &lt;!-- Configure MSBuild to compile the updated files --&gt;<br />
         &lt;msbuild&gt;<br />
          &lt;executable&gt;C:\WINNT\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe&lt;/executable&gt;<br />
          &lt;workingDirectory&gt;D:\CruiseControl\YOURAPP\build\checkout\Solutions\YourSolution&lt;/workingDirectory&gt;<br />
          &lt;projectFile&gt;YourSolutionFileName.sln&lt;/projectFile&gt;<br />
          &lt;buildArgs&gt;/noconsolelogger /p:Configuration=Debug&lt;/buildArgs&gt;<br />
          &lt;targets&gt;&lt;/targets&gt;<br />
          &lt;timeout&gt;15&lt;/timeout&gt;<br />
          &lt;logger&gt;ThoughtWorks.CruiseControl.MsBuild.XmlLogger,ThoughtWorks.CruiseControl.MsBuild.dll&lt;/logger&gt;<br />
         &lt;/msbuild&gt;<br />
        &lt;/tasks&gt;<br />
        &lt;!--Publishers will be done after the build has completed--&gt;<br />
        &lt;publishers&gt;<br />
         &lt;xmllogger&gt;<br />
          &lt;logDir&gt;d:\cruisecontrol\yourapp\logs&lt;/logDir&gt;<br />
         &lt;/xmllogger&gt;<br />
         &lt;email from="<a href="mailto:alerts@sayedhashimi.com">alerts@sayedhashimi.com</a>"
      mailhost="yoursmtp.yourcompany.com" includeDetails="TRUE"&gt;<br />
          &lt;projectUrl&gt;http://yourservername/ccnet&lt;/projectUrl&gt;<br />
          &lt;users&gt;<br />
           &lt;user name="Sayed" group="developers" address="<a href="mailto:sayed@sayedhashimi.com&quot;/">sayed@sayedhashimi.com"/</a>&gt;<br />
          &lt;/users&gt;<br />
          &lt;groups&gt;<br />
           &lt;group name="developers" notification="always"&gt;<br />
          &lt;/groups&gt;<br />
         &lt;/email&gt;<br />
        &lt;/publishers&gt;<br />
        &lt;modificationDelaySeconds&gt;10&lt;/modificationDelaySeconds&gt;<br />
       &lt;/project&gt;
   </p>
        <p>
      &lt;/cruisecontrol&gt;<br />
      &lt;!-- ************************************************* --&gt;
   </p>
        <p>
      Here is the dashboard.config file I am using:
   </p>
        <p>
      &lt;!-- ************************************************* --&gt;<br />
      &lt;?xml version="1.0" encoding="utf-8" ?&gt; 
      <br />
      &lt;dashboard&gt;<br />
       &lt;remoteServices&gt;<br />
        &lt;servers&gt;<br />
         &lt;!-- Update this list to include all the servers you want to
      connect to. NB - each server name must be unique --&gt;<br />
         &lt;server name="local" url="tcp://localhost:21234/CruiseManager.rem"
      /&gt;<br />
        &lt;/servers&gt;<br />
       &lt;/remoteServices&gt;<br />
       &lt;plugins&gt;<br />
        &lt;farmPlugins&gt;<br />
         &lt;farmReportFarmPlugin /&gt;<br />
         &lt;cctrayDownloadPlugin /&gt;<br />
        &lt;/farmPlugins&gt;<br />
        &lt;serverPlugins&gt;<br />
         &lt;serverReportServerPlugin /&gt;<br />
         &lt;serverLogServerPlugin /&gt;<br />
         &lt;serverInformationServerPlugin /&gt;<br />
        &lt;/serverPlugins&gt;<br />
        &lt;projectPlugins&gt;<br />
         &lt;projectReportProjectPlugin /&gt;<br />
         &lt;latestBuildReportProjectPlugin /&gt;<br />
         &lt;viewAllBuildsProjectPlugin /&gt;<br />
        &lt;/projectPlugins&gt;<br />
        &lt;buildPlugins&gt;<br />
         &lt;buildReportBuildPlugin&gt;<br />
          &lt;xslFileNames&gt;<br />
           &lt;xslFile&gt;xsl\header.xsl&lt;/xslFile&gt;<br />
           &lt;xslFile&gt;xsl\modifications.xsl&lt;/xslFile&gt;<br />
           &lt;xslFile&gt;xsl\compile.xsl&lt;/xslFile&gt;<br />
           &lt;xslFile&gt;xsl\unittests.xsl&lt;/xslFile&gt;<br />
           &lt;xslFile&gt;xsl\MsTestSummary.xsl&lt;/xslFile&gt;<br />
           &lt;xslFile&gt;xsl\fxcop-summary.xsl&lt;/xslFile&gt;<br />
           &lt;xslFile&gt;xsl\NCoverSummary.xsl&lt;/xslFile&gt;<br />
           &lt;xslFile&gt;xsl\SimianSummary.xsl&lt;/xslFile&gt;<br />
          &lt;/xslFileNames&gt;<br />
         &lt;/buildReportBuildPlugin&gt;<br />
         &lt;buildLogBuildPlugin /&gt;<br />
         &lt;xslReportBuildPlugin description="MSBuild Output" actionName="MSBuildOutputBuildPlugin"
      xslFileName="xsl\msbuild.xsl" /&gt;<br />
         &lt;xslReportBuildPlugin description="NUnit Details" actionName="NUnitDetailsBuildReport"
      xslFileName="xsl\tests.xsl" /&gt;<br />
         &lt;xslReportBuildPlugin description="NUnit Timings" actionName="NUnitTimingsBuildReport"
      xslFileName="xsl\timing.xsl" /&gt;<br />
         &lt;xslReportBuildPlugin description="FxCop Report" actionName="FxCopBuildReport"
      xslFileName="xsl\FxCopReport.xsl" /&gt;<br />
         &lt;!--<br />
         &lt;xslReportBuildPlugin description="NAnt Output" actionName="NAntOutputBuildReport"
      xslFileName="xsl\Nant.xsl" /&gt;<br />
         &lt;xslReportBuildPlugin description="NAnt Timings" actionName="NAntTimingsBuildReport"
      xslFileName="xsl\NantTiming.xsl" /&gt;<br />
         &lt;xslReportBuildPlugin description="NCover Report" actionName="NCoverBuildReport"
      xslFileName="xsl\NCover.xsl" /&gt;<br />
         &lt;xslReportBuildPlugin description="Simian Report" actionName="SimianBuildReport"
      xslFileName="xsl\SimianReport.xsl"/&gt;<br />
         --&gt;<br />
         &lt;!-- This is an example of using Project-specific build plugins<br />
         &lt;xslReportBuildPlugin description="My Report" actionName="MyReport"
      xslFileName="xsl\MyReport.xsl"&gt;<br />
          &lt;includedProjects&gt;<br />
           &lt;projectName&gt;My Project&lt;/projectName&gt;<br />
          &lt;/includedProjects&gt;<br />
         &lt;/xslReportBuildPlugin&gt;<br />
         &lt;xslReportBuildPlugin description="My Other Report" actionName="MyOtherReport"
      xslFileName="xsl\MyOtherReport.xsl"&gt;<br />
          &lt;excludedProjects&gt;<br />
           &lt;projectName&gt;My Project&lt;/projectName&gt;<br />
          &lt;/excludedProjects&gt;<br />
         &lt;/xslReportBuildPlugin&gt;<br />
         --&gt;<br />
        &lt;/buildPlugins&gt;<br />
       &lt;/plugins&gt;<br />
      &lt;/dashboard&gt;<br />
      &lt;!-- ************************************************* --&gt;
   </p>
        <img width="0" height="0" src="http://www.sayedhashimi.com/aggbug.ashx?id=c00defe4-f073-4e0e-98b6-70eabaf35f6a" />
      </div>
    </content>
  </entry>
  <entry>
    <title>ClickOnce Updates of Data Files</title>
    <link rel="alternate" type="text/html" href="http://www.sayedhashimi.com/PermaLink,guid,f7a25991-4580-4417-a07a-2b8363455504.aspx" />
    <id>http://www.sayedhashimi.com/PermaLink,guid,f7a25991-4580-4417-a07a-2b8363455504.aspx</id>
    <published>2006-02-08T05:33:01.604-08:00</published>
    <updated>2006-02-08T05:33:01.604-08:00</updated>
    <category term="ClickOnce" label="ClickOnce" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      In my previous post, I talked about how ClickOnce udpates applications but forgot
      to mention something specific to data files. ClickOnce deployed applications might
      use files that need to be migrated from one version to another. For example, an access
      database. ClickOnce supports this but with respect to downloading updates, data files
      are always downloaded (and need to be synchronized with the version on the client).
      ClickOnce doesn't even look at the hash when it sees that a file is marked as a data
      file. 
   </p>
        <img width="0" height="0" src="http://www.sayedhashimi.com/aggbug.ashx?id=f7a25991-4580-4417-a07a-2b8363455504" />
      </div>
    </content>
  </entry>
  <entry>
    <title>ClickOnce Application Management</title>
    <link rel="alternate" type="text/html" href="http://www.sayedhashimi.com/PermaLink,guid,520010a7-6ce7-47ec-af0f-a57694bf3d41.aspx" />
    <id>http://www.sayedhashimi.com/PermaLink,guid,520010a7-6ce7-47ec-af0f-a57694bf3d41.aspx</id>
    <published>2006-02-07T05:17:41.338375-08:00</published>
    <updated>2006-02-07T05:17:41.338375-08:00</updated>
    <category term="ClickOnce" label="ClickOnce" scheme="dasBlog" />
    <content type="html">&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;I
   was recently asked a question concerning how the publisher of a ClickOnce application
   can force removal of an assembly after an update. Here is the question:&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;o:p&gt;
      &lt;font face=Arial color=#000000&gt;&amp;nbsp;&lt;/font&gt;
   &lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;strong&gt;Questions:&lt;/strong&gt; If my application
   no longer needs an assembly, does ClickOnce ensure that the file is deleted when I
   do an update? 
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;o:p&gt;
      &lt;font face=Arial color=#000000&gt;&amp;nbsp;&lt;/font&gt;
   &lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;&lt;strong&gt;Answer:&lt;/strong&gt; ClickOnce installs applications
   within the %userprofile% folder. At any time, ClickOnce will have up to two versions
   of an application for a given user. When ClickOnce has to do an update, it's smart
   enough to only download files that have changed, and not copy files that have been
   deleted. ClickOnce does updates using the files listed in the application manifest
   file, on the server, and the files that are in the existing application folder. So
   image for a second that we have an application with three files: an exe (myapp.exe),
   a supporting assembly (mysupport.dll) and another supporting assembly named "anothersupport.dll".
   Lets now assume that we have deployed version 1.0 to our clients. 
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;o:p&gt;
      &lt;font face=Arial color=#000000&gt;&amp;nbsp;&lt;/font&gt;
   &lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font color=#000000&gt;&lt;font face=Arial&gt;After deploying version 1.0, we decide that mysupport.dll
   is no longer needed because there is a major security flaw in it. In fact, we decide
   to purchase the same functionality from a 3rd party that doesn't have any security
   issues. What happens when we do an update? Does the assembly with the security flaw
   stay on the user's machine? 
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;o:p&gt;
      &lt;font face=Arial color=#000000&gt;&amp;nbsp;&lt;/font&gt;
   &lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
   &lt;font face=Arial color=#000000&gt;The answer is yes, but only until you do another update.
   We said earlier that ClickOnce maintain up to two version of an application for a
   given user. When you update your application, ClickOnce looks at the files you have
   listed in the application manifest and the files in the existing application folder
   on the client, to decide what to download and what not to download. ClickOnce does
   this to ensure that it doesn't download a file that was not modified. When ClickOnce
   sees that a file entry exists in the application manifest and does not exist in the
   existing application directory on the client, it knows that the file was added to
   the application and so it downloads the file. If it sees that a file is in the application
   manifest and is also in the existing application directory and the files have the
   same hash, then it just copies the file from the existing application directory to
   the new application directory. If a file exists in the application directory that
   is not in the application manifest, then ClickOnce leaves that file in the existing
   application directory. The reason it leaves the file is for rollback purposes. ClickOnce,
   supports "rollback to previous version" so it keeps the existing application just
   in case the user decides to go back to the old application. Can you get rid of the
   file manually? Technically you could, but the ClickOnce app store is not meant to
   be tampered with--ClickOnce manages the app store.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sayedhashimi.com/aggbug.ashx?id=520010a7-6ce7-47ec-af0f-a57694bf3d41" /&gt;</content>
  </entry>
  <entry>
    <title>Working towards an automated ClickOnce Deployment</title>
    <link rel="alternate" type="text/html" href="http://www.sayedhashimi.com/PermaLink,guid,2cfbae92-b944-4273-b6e0-368b69e46148.aspx" />
    <id>http://www.sayedhashimi.com/PermaLink,guid,2cfbae92-b944-4273-b6e0-368b69e46148.aspx</id>
    <published>2006-02-06T05:58:46.057125-08:00</published>
    <updated>2006-02-06T05:58:46.057125-08:00</updated>
    <category term="ClickOnce" label="ClickOnce" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      If you have an automated build process around a ClickOnce deployment, you should know
      how ClickOnce determines updates to files. Why is this important? Well, lets say that
      you are using MSBuild to do scheduled builds every day (say 3 times a day). Your build
      process starts out by getting the lastest code from your source control system and
      then builds all the projects and assemblies of your application. It then creates the
      application and deployment manifest (the ClickOnce manifest files) and then pushes
      updates to the deployment server.
   </p>
        <p>
      The potential problem with this approach is that if your build process rebuilds all
      of the assemblies used by your application, even if they were not modified, then ClickOnce
      will think the file has changed and will have to download the entire application again--just
      as if it were the initial install. This is an obvious problem and it has to do with
      how ClickOnce calculates a change to a file. 
   </p>
        <p>
      ClickOnce is driven by two manifest files: the application manifest and the deployment
      manifest. The application manifest has details about a particular version of an application.
      For example, the dependent assemblies of a particular version of an application. The
      deployment manifest has details about the application as a whole and not specific
      details about a particular version. The deployment manifest, for example, will have
      the update policy of the application. 
   </p>
        <p>
      Going back to our problem. I said that the application manifest has details about
      the files that comprise a specific version of an application. For example, if an application
      depends on an assembly called "MyCoolAssembly", then the application manifest will
      have an &lt;dependency&gt; tag for that assembly. Each file in the manifest has an
      associated hash that ClickOnce uses to determine if the file has changed. Actually,
      the hash is used for two things: 1) to determine changes to a file and, 2) to detect
      file tampering. 
   </p>
        <p>
      If your build process recreates assemblies, even if they were not modified, then ClickOnce
      will not know that the two files are identical. ClickOnce determines changes to files
      by comparing the file hash on client with what's on the server (in the application
      manifest). If the two files have the same hash, then ClickOnce doesn't download the
      file again, it simply copies the file from one directory to another.
   </p>
        <p>
      There are several things to think about when you start to build an automated ClickOnce
      deployment. 
   </p>
        <p>
      1. Identify any 3rd party assemblies and be sure not to rebuild these files; put these
      files in a well-known folder and have the build process copy them. 
      <br />
      2. If you have assemblies that you share across projects/solutions, establish a mechanism
      in your build process that will detect changes to files in these projects and will
      rebuild only when necessary.<br />
      3. The core of your application can be rebuild depending on how large the project
      is. 
   </p>
        <p>
      Generally, items 1) and 2) will make up a significant part of an application and needs
      to be addressed properly from the context of a ClickOnce deployment.
   </p>
        <img width="0" height="0" src="http://www.sayedhashimi.com/aggbug.ashx?id=2cfbae92-b944-4273-b6e0-368b69e46148" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Source Control Tutorial</title>
    <link rel="alternate" type="text/html" href="http://www.sayedhashimi.com/PermaLink,guid,0dcf422d-0c5e-4b8b-a00f-8682b19daaa4.aspx" />
    <id>http://www.sayedhashimi.com/PermaLink,guid,0dcf422d-0c5e-4b8b-a00f-8682b19daaa4.aspx</id>
    <published>2006-02-05T16:32:12.354-08:00</published>
    <updated>2006-02-05T16:32:12.354-08:00</updated>
    <category term="SCM" label="SCM" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Source-code management (SCM) is something we all deal with as developers. How we manage
      source code, however, is something we learn after entering the workforce. Developers
      are usually more interested in programming languages and tools, so they don’t pay
      too much attention to how will we protect our intellectual property. Recently I ran
      into an <a href="http://software.ericsink.com/scm/source_control.html">e-book</a> by
      one of the principals of <a href="http://www.sourcegear.com/vault">Vault</a> (a VSS
      like source-code management system) and was very impressed. It’s definitely worth
      a read.
   </p>
        <img width="0" height="0" src="http://www.sayedhashimi.com/aggbug.ashx?id=0dcf422d-0c5e-4b8b-a00f-8682b19daaa4" />
      </div>
    </content>
  </entry>
</feed>