在运行时指定对象定义到 spring.net XmlApplicationContext

发布于 2024-10-04 06:53:43 字数 461 浏览 0 评论 0原文

我是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪荡不羁 2024-10-11 06:53:44

您可以向容器询问先前注册的对象的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文