Additional attributes on type definition

Feb 14, 2008 at 11:13 PM
Edited Feb 14, 2008 at 11:14 PM
I would like to add additional attributes to the type definition and map those to properties of my concrete object. In the example below I would like the value of the "connectionName" attribute to be injected into MySqlDataStore.ConnectionName. I have a working PoC using a ContainerExtension and BuilderStrategy, but it requires my own configuration block which I would like to avoid. Is this a feature that makes sense to include in a future release?

<container>

<types>
<type
name="MyType1"
type="Custom.IMyDataStore"
mapTo="Custom.MySqlDataStore"
lifetime="Transient"
connectionName="MySqlDataStoreConnectionName"/>
</types>

</container>

In my PoC, I modify Unity.Configuration.UnityTypeElement to override ConfigurationElement.OnDeserializeUnrecognizedAttribute and put all unrecognized attributes into a NameValueCollection that I can then access in my BuilderStrategy and map to properties of MySqlDataStore using reflection.