How can I allow one of my string parameters to be an empty string?
I get this error when I try either nothing or a single space (names changed):
Could not resolve non-optional dependency for 'test.User' (MyNamespace.MyObject). Parameter 'userName' type 'System.String'
Turns out it's much easier, and likely more correct, to add a constructor that doesn't take the parameter(s) you want to leave blank.
container.Register(
Component.For<Foo>()
.DependsOn(new
{
someString = string.Empty
}));
but first of all, why do you want to set that dependency to empty string? It does feel like hacking to me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With