Rich Newman

XML Configuration File – Unity

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" />
  </configSections>
  <unity>
    <containers>
      <container>
        <types>
          <type type="MovieFinderTestUnityXML.Movie, MovieFinderTestUnityXML" name="AndreiRublevMovie" >
            <typeConfig extensionType="Microsoft.Practices.Unity.Configuration.TypeInjectionElement, Microsoft.Practices.Unity.Configuration">
              <constructor>
                <param name="title" parameterType="System.String, mscorlib">
                  <value value="Andrei Rublev"/>
                </param>
                <param name="director" parameterType="System.String, mscorlib">
                  <value value="Andrei Tarkovsky"/>
                </param>
              </constructor>
            </typeConfig>
          </type>
 
          <type type="MovieFinderTestUnityXML.IMovieFinder, MovieFinderTestUnityXML"
                mapTo="MovieFinderTestUnityXML.SimpleMovieFinder, MovieFinderTestUnityXML"
                name="SimpleMovieFinder" >
            <typeConfig extensionType="Microsoft.Practices.Unity.Configuration.TypeInjectionElement, Microsoft.Practices.Unity.Configuration">
              <constructor>
                <param name="message" parameterType="System.String, mscorlib">
                  <value value="Test test"/>
                </param>
              </constructor>
            </typeConfig>
          </type>
          <type type="MovieFinderTestUnityXML.MovieLister, MovieFinderTestUnityXML" name="SimpleMovieLister">
            <lifetime type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager, Microsoft.Practices.Unity"/>
            <typeConfig>
              <constructor>
                <param name="finder" parameterType="MovieFinderTestUnityXML.IMovieFinder, MovieFinderTestUnityXML">
                  <dependency name="SimpleMovieFinder"/>
                </param>
              </constructor>
            </typeConfig>
          </type>
 
          <type type="MovieFinderTestUnityXML.IMovieFinder, MovieFinderTestUnityXML"
        mapTo="MovieFinderTestUnityXML.ColonDelimitedMovieFinder, MovieFinderTestUnityXML"
        name="ColonDelimitedMovieFinder" >
          </type>
          <type type="MovieFinderTestUnityXML.MovieLister, MovieFinderTestUnityXML" name="ColonDelimitedMovieLister">
            <typeConfig>
              <constructor />
              <property name="Finder" propertyType="MovieFinderTestUnityXML.IMovieFinder, MovieFinderTestUnityXML">
                <dependency name="ColonDelimitedMovieFinder"/>
              </property>
            </typeConfig>
          </type>
        </types>
 
        <!--Can't use this - can't specify the delegate that's needed in XML 
        <extensions>
          <add type="Microsoft.Practices.Unity.StaticFactory.StaticFactoryExtension, Microsoft.Practices.Unity.StaticFactory"/>
        </extensions>-->
      </container>
    </containers>
  </unity>
</configuration>

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: