Unity: passing an instance of the model state to the injected dependency
I'm refactoring the controllers in a .net MVC app so I can inject thte dependencies using the unity container. There's this service that needs a reference to the controller's modelstate so I'm hitting a roadblock here. Is it possible to get a reference to the controllers's modelstate at the time of the injection? I'm currently registering the types by code (not using the configuration) so I was wondering if there was a way to do this using the InjectionConstructor ... something like:

    _container.RegisterType<ISportService, DBSportService>()
                .Configure<InjectedMembers>()
                .ConfigureInjectionFor<DBSportService>(new InjectionConstructor(new ModelStateWrapper(controller.ModelState)));
Unity: passing an instance of the model state to the injected dependency
===

I'm refactoring the controllers in a .net MVC app so I can inject thte dependencies using the unity container. There's this service that needs a reference to the controller's modelstate so I'm hitting a roadblock here. Is it possible to get a reference to the controllers's modelstate at the time of the injection? I'm currently registering the types by code (not using the configuration) so I was wondering if there was a way to do this using the InjectionConstructor ... something like:

    _container.RegisterType<ISportService, DBSportService>()
                .Configure<InjectedMembers>()
                .ConfigureInjectionFor<DBSportService>(new InjectionConstructor(new ModelStateWrapper(controller.ModelState)));