I am having difficulty using StructureMap for services, where the constructor has an argument with a null value. I.e
public JustGivingService(IRestClient restClient = null)
In my configuration with all the other services, I am usually able to get away with the minimum, so the problem here is probably just a lack of understanding. I would do this:
container.For<IJustGivingService>().Use<JustGivingService>()
However, due to the nullable parameter, I will find that I will need to use this instead to make it work:
RestClient restClient = null; container.For<IJustGivingService>().Use<JustGivingService>() .Ctor<IRestClient>("restClient").Is(restClient);
However, for me this is a bit dirty, and I feel that this is probably a workaround for what I'm trying to achieve, and not a standard way to do it. If there is a better way to do this, the accompanying information on why this will be very helpful.
source share