如何从 wsdl 生成在 Visual Studio 中设计时工作的类?

发布于 2024-12-10 18:04:34 字数 658 浏览 1 评论 0原文

我正在使用使用 Visual Studio 向导“添加服务引用”生成的模型类来执行 MVVM。

我正在尝试生成一些将出现在设计器中的设计时示例数据。

我面临的问题是集合成员没有被初始化,所以我将这行生成的代码更改

[System.Runtime.Serialization.OptionalFieldAttribute()]
private System.Collections.Generic.List<SDDM3.HylandService.ServiceKeyword> KeywordListField;

为: 这样

[System.Runtime.Serialization.OptionalFieldAttribute()]
private System.Collections.Generic.List<SDDM3.HylandService.ServiceKeyword> KeywordListField = new System.Collections.Generic.List<ServiceKeyword>();

做之后,VS 中的设计器没有抱怨。

我意识到当我重新生成代码时这些更改将会丢失。

有什么方法可以告诉代码生成器为我执行此操作吗?

I'm doing MVVM with model classes that are generated using the visual studio wizard for "Add Service Reference".

I'm trying to generate some design time sample data that will appear in the designer.

The problem I face is that collection members don't get initialized, so I changed this line of generated code:

[System.Runtime.Serialization.OptionalFieldAttribute()]
private System.Collections.Generic.List<SDDM3.HylandService.ServiceKeyword> KeywordListField;

to this:

[System.Runtime.Serialization.OptionalFieldAttribute()]
private System.Collections.Generic.List<SDDM3.HylandService.ServiceKeyword> KeywordListField = new System.Collections.Generic.List<ServiceKeyword>();

After doing that the designer in VS didn't complain.

I realize these changes will be lost when I re-generate the code.

Is there some way to tell the code generator to do this for me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文