views:

189

answers:

1

I am creating an instance with StructureMap in code, and the constructor takes in a string. In the configuration I use a placeholder for the parameter. I am trying to create the object with the parameter value of null. When I get the object back from the ObjectFactory the value of the parameter is equal to the placeholder, not null.

here is my configuration for the object:

<DefaultInstance PluginType="Blah.NDQA.Core.Data.IUserManagementRepository,Blah.NDQA.Core" PluggedType="Blah.NDQA.Data.MySql.MySqlUserManagementRepository,Blah.NDQA.Data" companyID="placeholder"/>

here is how I am creating it:

IUserRightsRepository rightsRepo = ObjectFactory.With("companyID").EqualTo(null).GetInstance<IUserRightsRepository>();

in the particular case companyID = null and the value in the instance is equal to "placeholder".

Any information on how I can actually create the object with the value of companyID = null instead of the placeholder value would be appreciated....

+1  A: 

Try:

ObjectFactory.With<string>(null).GetInstance<IUserRightsRepository>();
Joshua Flanagan
@Joshua Flanagan - Hi Josh. what happens if you have to strings, and you only want one of them to be null? does the above code set all string properties to null?
Pure.Krome