如何在 Spring.NET 构造函数中使用复杂类型参数
我正在尝试将 Spring.NET 与 C# 应用程序一起使用来填充复杂类型的参数数组(params 关键字)构造函数参数(称之为 SecretCode,它恰好是枚举类型。)
有人可以帮我指出文档来配置 XML 文件来执行此操作?
作为参考,以下是相关代码片段:
public class MyValueSet<T> where T: struct
{
public MyValueSet(params T[] values) {...}
}
public class DerivedClass : MyValueSet<SecretCode> {...}
public enum SecretCode {...}
我尝试用 Spring.NET 配置文件替换的硬编码代码是(足够接近):
var something = new DerivedClass(SecretCode.One, SecretCode.Two, SecretCode.Fifty-Two);
想法?
I am trying to use Spring.NET with a C# application to populate a parameter array (params keyword) constructor argument that is of a complex Type (call it SecretCode, which happens to be an enumerated type.)
Can someone help point me to the documentation to configure the XML file to do this?
For reference, here are relevant code snippets:
public class MyValueSet<T> where T: struct
{
public MyValueSet(params T[] values) {...}
}
public class DerivedClass : MyValueSet<SecretCode> {...}
public enum SecretCode {...}
The hard-coded code I am trying replace with the Spring.NET configuration file is (close enough to) this:
var something = new DerivedClass(SecretCode.One, SecretCode.Two, SecretCode.Fifty-Two);
Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发布这个问题是为了分享我得出的答案,并看看是否有更深入了解 Spring.NET 的人有更好的答案。
我最终得到的配置是这样的:
I posted the question in order to share the answer I came up with, and to see if anyone who knows Spring.NET more thoroughly had a better answer.
The configuration I ended up with is this: