views:

123

answers:

1

Given

public class Blah : IBlah 
{
    public Blah(decimal argument)
    {
    }
}

When

ForRequestedType<IBlah>()
    .TheDefault.Is.OfConcreteType<Blah>()
    .WithCtorArg("argument")
    .EqualToAppSetting("argument_app_setting_key")

Then StructureMap throws the following exception

No Default Instance defined for PluginFamily System.Decimal

Is there any way to use the EqualToAppSetting with non-string arguments ?

+1  A: 

I don't think you can do this with the EqualToAppSetting method. Could you not just reference System.Configuration and cast the app setting yourself? Like this...

      ForRequestedType<IBlah>()
        .TheDefault.Is.OfConcreteType<Blah>()
        .WithCtorArg("blah")
        .EqualTo(Convert.ToDecimal(ConfigurationManager.AppSettings["argument_app_setting_key"]));
thinkzig