Constructor Injection

Jun 6, 2008 at 11:31 AM
Edited Jun 6, 2008 at 12:32 PM
Sorry to ask but the downloadable documentation is still not working (Page cannot be displayed error) and the MSDN documentation doesn't cover this....

I have two classes that inherits from a generic interface which I have in my config like so:

<typeAlias alias="IMessageQueueController" type="AnAssembly.IMessageQueueController, AnAssembly" />
<typeAlias alias="IMessageFormatter" type="System.Messaging.IMessageFormatter, System.Messaging" />

<typeAlias alias="BinaryMessageFormatter" type="System.Messaging.BinaryMessageFormatter, System.Messaging" />
<typeAlias alias="XmlMessageFormatter" type="System.Messaging.XmlMessageFormatter, System.Messaging" />

<type type="IMessageQueueController[[AnEntity]]" mapTo="MessageQueueController[[AnEntity]]">
    <lifetime type="Singleton"/>
    <typeConfig extensionType="Microsoft.Practices.Unity.Configuration.TypeInjectionElement, Microsoft.Practices.Unity.Configuration">
        
<constructor>
            <
param name="formatter" parameterType="IMessageFormatter">
                <
dependency />
            </
param>
            <
param name="queueSettingKey" parameterType="System.String">
                <
value value="queueName"/>
            </
param>
        </
constructor>
    </
typeConfig>
</
type>

<type type="IMessageQueueController[[AnotherEntity]]" mapTo="MessageQueueController[[AnotherEntity]]">
    <lifetime type="Singleton"/>
    <typeConfig extensionType="Microsoft.Practices.Unity.Configuration.TypeInjectionElement, Microsoft.Practices.Unity.Configuration">
        
<constructor>
            <
param name="formatter" parameterType="IMessageFormatter">
                <
dependency />
            </
param>
            <
param name="queueSettingKey" parameterType="System.String">
                <
value value="queueName"/>
            </
param>
        </
constructor>
    </
typeConfig>
</
type>

Couple of questions being

  • Have I set up the Generic portion correctly?
  • How do I reference the BinaryMessageFormatter in the AnEntity Generic type and the XmlMessageFormatter in the AnotherEntity Generic type?

Thanks if anyone has the time to answer... :)

 

Jun 6, 2008 at 4:48 PM
To fix the documentation,
1. Right-click the CHM file, and then click Properties.
2. Click Unblock.
3. Double-click the .chm file to open the file.

(This is from http://support.microsoft.com/kb/902225.)

I'll look at the config in a bit.

Jun 8, 2008 at 6:26 PM

Thanks ctavares,

Now i feel like a dumb one :)