String -> String type conversion

Jun 25, 2009 at 4:01 PM


There is a following  configuration :
<type type="IDbStorage"
    <lifetime type="singleton"/>
            <param name="connectionString"  parameterType="System.String">
                <value value="cacheDb"

Value of the connectionString is the name of the connection string in app.config. I would like the DbStorage constructor to receive not the name of the connection string, but it's value taken from the app.config. 
Unfortunately, the specified converter is NOT called, hence the provided value is a string by itself. Is it possible to solve this somehow?


Jun 26, 2009 at 2:47 PM

There is another post regarding a similar issue with the same cause ( In a nutshell, if the value type is a string, Unity never attempts to call the TypeConverter you specified.

I also posted my solution creating a new configuration element allowing you to specify values indirectly by referencing an appSetting key. I have created similar code for connectionString's. I will let you do the exercise of implementing that -- it should be pretty easy starting from that posting.


Jun 26, 2009 at 4:01 PM

Thanks! I've also found this post and did that way :) It's very frustrating that Unity is very poorly documented. I thought of switching to it from Spring.NET, where I coould solve all of the issues easely. But now I don't even know what to do, hence basic configuration settings takes that long