Does the Alias, Register tag support the ConfigSource Attribute?

Topics: Building and extending application blocks, General discussion
Jun 29, 2011 at 8:09 AM

Hi,

With the developing continue, the Unity and the Container will getting bigger. Could I use the configsource attribute with the alias, register, unity tag?

such as:

<unity name="configsource">

        <alias configsource="interfacealias.config"/>

       <alias configsource="classalias.config"/>

 

       <register configsource="classregister.config"/>

</unity>

Jun 29, 2011 at 8:43 AM
Edited Jun 29, 2011 at 8:55 AM

Yes you can use the configsource with unity but not with alias and register. I'm not sure why you need to put the alias and register on a seperate config since it will only contains a type. The disadvantage of this is you will create a lot of configs which may later be hard to maintain. The code below is an example of using configsource in unity:

in your Main Config:

<configuration>
<configSections>
 <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" />
</configSections>
<unity configSource="Unity.config" />
</configuration>
 
in Unity.config 
 
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
    <container>
      <register type="DependencyInjection.Program+ISomeService, DependencyInjection" mapTo="DependencyInjection.Program+ImplementService, DependencyInjection">
        <constructor>
          <param name="myObj" value=""></param>
        </constructor>
      </register>
    </container>
  </unity>
 
Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com
Jun 30, 2011 at 9:40 AM

Thank you.