how to change web.config?

Jul 14, 2010 at 8:55 AM

Hello guys:

            I'm using unity 2.0,and I want to change the following config of unity 1.0:what can i do ?

      <type type="IControllerFactory" mapTo="Microsoft.Web.Mvc.Resources.ResourceControllerFactory,Microsoft.Web.Mvc">
            <typeConfig extensionType="Microsoft.Practices.Unity.Configuration.TypeInjectionElement,Microsoft.Practices.Unity.Configuration">
              <constructor>
                <param name="inner" parameterType="IControllerFactory">
                  <dependency type="TownHallControllerFactory"/>
                </param>
              </constructor>
            </typeConfig>
          </type>
Jul 14, 2010 at 10:18 AM

Here's the 2.0 version of your config:

<register type="IControllerFactory" mapTo="Microsoft.Web.Mvc.Resources.ResourceControllerFactory,Microsoft.Web.Mvc">
      <constructor>
        <param name="inner" type="IControllerFactory" dependencyType="TownHallControllerFactory" />
      </constructor>
</register>

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jul 14, 2010 at 7:23 PM

Actually, you can make it even shorter if there's no overloads on the constructor. There's no need to specify parameter types as long as the names aren't ambiguous. So if you have multiple constructor overloads with the same named parameters but different types, you need the type, otherwise you just need the name.

<register type="IControllerFactory" mapTo="Microsoft.Web.Mvc.Resources.ResourceControllerFactory,Microsoft.Web.Mvc">
      <constructor>
        <param name="inner" dependencyType="TownHallControllerFactory" />
      </constructor>
</register>