在 WCF 服务引用之间共享类型并仍然自动生成 INotifyPropertyChanged

发布于 2025-01-03 18:06:50 字数 372 浏览 3 评论 0原文

我有两个 WCF 服务需要彼此共享类型(即 service1 的输出需要作为 service2 的输入)。我熟悉 Visual Studio 中的“重用引用程序集中的类型”选项,这将使我的场景发挥作用。

也就是说,直到我提到我错过了 svcutil.exe(通过 Visual Studio)通常会给我的自动生成的代码。我缺少在所有属性上自动实现 INotifyPropertyChanged,将 IEnumerable 对象放入 ObservableCollections 等。

有没有办法在两个服务之间重用类型,同时也获得所有自动生成的优点,特别是 INotifyPropertyChanged?我不想在驻留在服务器端的当前非常小的类中手动编写所有代码。

使用.Net 4.0。

I have two WCF services that need to share types between each other (i.e The output of service1 needs to be the input to service2). I am familiar with the option in Visual Studio to "Reuse Types in Referenced Assemblies" and this would make my scenario work.

That is, until I mention that I am missing out on the auto-generated code that svcutil.exe (via Visual Studio) would typically give me. I'm missing the auto-implementing of INotifyPropertyChanged on all properties, making IEnumerable objects into ObservableCollections, etc.

Is there a way to reuse types between two services but also get all of that auto-generated goodness, most specifically the INotifyPropertyChanged? I do not want to write all that code by hand within the currently very small classes which reside on the server side.

Using .Net 4.0.

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

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

发布评论

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

评论(1

烟若柳尘 2025-01-10 18:06:50

您可以将消息类型放入它们自己的程序集中,然后从客户端和服务引用该程序集。当服务不在您手中时,自动生成的代码非常有用。

You could put the message types in their own assembly and then reference this assembly from client and service. The autogenerated code is useful, when the service is not in your hands.

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