Windsor Castle - Null constructor argument

How to pass null constuctor argument using Castle Windsor? I thought the following would work

<parameters> <repository>null</repository> <message>null</message> </parameters>` 
+6
inversion-of-control castle-windsor
source share
3 answers

If you want them to be empty, that means they are non-essential dependencies. Having them as arguments to ctor, you suggest something else. You must redesign your class to have a different constructor that accepts only significant dependencies if you want them not to change throughout the entire life cycle of an object (read-only) or display them as properties.

In Windsor, you cannot force it to skip zeros for the reasons stated in another answer.

+5
source share

Wouldn't it be better just to have an additional public constructor that does not accept these parameters, then you will not need to register the parameters in the config?

+1
source share

This was discussed some time ago in the list of letters, and at that time I was looking at the code. Zero values ​​are intentionally filtered out (mainly due to the resolution of the complicating type type).

I could not find an easy way to make a special case to add them.

+1
source share

All Articles