使用Spring.NET IoC容器可以這樣做嗎?我可以使用Spring.NET在創建的實例中注入依賴關係嗎?
MyClass instance = new MyClass();
ContextRegistry.GetContext().InjectDepenencies(instance);
// instance has the defined dependencies set
這會派上用場。我可以使用ContextRegistry.GetContext().Get("name")
,但是會創建一個定義對象的新實例。我需要設置已經創建的對象的依賴關係。
我知道這是可能的在Unity中,不知道Spring.NET。 – Konamiman