1
我有一个Web服务正在运行,它使用Spring.NET来实现它的IoCness。其中一个类需要在加载时执行一些操作(我正在使用AfterPropertiesSet
),“某些内容”涉及到ContextRegistry.GetContext()
的调用。问题是这样的代码在ContextRegistry
类:如何知道Spring.NET根上下文何时加载?
if (rootContextCurrentlyInCreation)
{
throw new InvalidOperationException("root context is currently in creation. You must not call ContextRegistry.GetContext() from e.g. constructors of your singleton objects");
}
我怎么能有这个对象注册自己一旦上下文完全创建通知?