Hi there,
I have an interface to resolve and one of the mapped object's dependencies has a property on it which I would like to set with a value that I only have available when I resolve the top level object.
There's no valid default value for the property. If its not set it should be null and it should only be set if the value that I have available at resolve time is not null.
Is this conditional property injection possible?
I tried this...
container.RegisterType<ProductInstanceValidatorBase, CartItemPurchaseTypeValidator>("CartItemPurchaseTypeValidator", new InjectionProperty("AccountEntity", null);
... but it said I couldn't use a null value!
I also tried this on the resolve...
container.Resolve<ProductInstanceValidatorBase>(new PropertyOverride("AccountEntity", value));
...but this throws an exception when the value is null. It says,
Parameter type inference does not work for null values. Indicate the parameter type explicitly using a properly configured instance of the InjectionParameter or InjectionParameter classes. Parameter name: parameterValue
Basically I'm looking to register a property that is only set with an override and then only if the override value is non-null. Any ideas? Surely from a semantic point of view, property injection should be optional.
Cheers, Ian.