I was wondering if it would be possible to allow null registrations -
i.e. that if I register null as User, constructors with a User
parameters will be considered for resolution, albeit with a null user
value.
When I have things that may or may not be registered (e.g. I have a
User object registered if someone is authenticated, but not for
anonymous web users) I have to create two constructors e.g.
public MyController(User user, ...) { _user = user; }
public MyController(...) this(null, ...) { }
in my Actions I check if the user is null to decide what to do. This
works OK, but once I create another null dependency I have to create
more constructors - in fact 2 ^ (number of null dependencies)
constructors to get all the combinations!
I can get round this by injecting the null object pattern, but I'm not
that keen on it - I like null meaning null!
--
You received this message because you are subscribed to the Google Groups "Autofac" group.
To post to this group, send email to aut...@googlegroups.com.
To unsubscribe from this group, send email to autofac+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/autofac?hl=en.