this is my first question to SO so i'll try not to disgrace myself.

What i'm doing right now is injecting two dependency objects to a MVC3 Controller's constructor.

But for the sake of the application logic, i need to change those objects with new ones sometime in the (runtime) future. Apperently the obvious case would be to get MVC to create a new controller with the new objects injected. All well, but how do i make MVC produce new controllers?

Here is the controller (if it is relevant, or just for visual recognition):

  public class RestoreController : Controller {
    private readonly StatusProvider statusProvider;
    private readonly AppHost appHost;

    public RestoreController(StatusProvider statusProvider, AppHost appHost){
        this.statusProvider = statusProvider;
        this.appHost = appHost;
    }

PS I considered some other solutions, but i wanted some folks to tell me for sure that this can't be done.

So can it?

I'll be happy to hear comments on my issue. Tnx, have a nice one.

有帮助吗?

解决方案

An instance of your controller is created everytime you try to access it (saying calling a view that depends on it). So if you're injecting that referenced objects at runtime, if they have changed (the instance value) you should get that change on the Controller

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top