在运行时指定对象定义到 spring.net XmlApplicationContext
我是 Spring.Net 的新手,直到现在我都在定义 xml 文件,在其中定义了所有对象的定义,然后创建了 XMLApplicationContext。现在我必须支持可以插入 XMLApplicationContext 的插件。我尝试了以下操作,
context.ConfigureObject (inObject, inName);
(context as XmlApplicationContext).ObjectFactory.RegisterSingleton (inName, inObject);
使用此对象在运行时将其注册到上下文中,但是我无法提供可以指定对象属性及其引用的对象定义。这里的引用是一个对象 ID,它位于用于创建 XMLApplicationContext 的通用配置 xml 中。这可能吗?
还有什么方法可以在创建 XMLApplicationContext 之后将其扩展为新的配置 xml?
I am new to Spring.Net, until now I was defining the xml file where I had defined all the object's definition and then created the XMLApplicationContext. Now I have to support plugins which can be inserted into XMLApplicationContext. I tried the following,
context.ConfigureObject (inObject, inName);
(context as XmlApplicationContext).ObjectFactory.RegisterSingleton (inName, inObject);
using this the object is registered into the context at runtime, however I am not able to provide the object definition where I can specify objects properties and its ref. The ref here is to an object id which is in common config xml which was used to create XMLApplicationContext. Is this possible?
Also is there any way that after creating the XMLApplicationContext we can extend it for new config xml?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以向容器询问先前注册的对象的 ObjectDefinition,从中您应该能够收集 xml 注册的对象 id 供您用作参考信息。
You can ask the container for the previously-registered object's ObjectDefinition and from that you should be able to gather the xml-registered object id for you to the use as your ref info.