简体   繁体   English

WCF行为配置为.NET Remoting

[英]WCF behaviour configuration as .NET Remoting

The Goal 目标

Run a local server (WCF) containing business logic that tracks information while the computer is powered on (ran when a user logs in as an ordinary process). 运行包含业务逻辑的本地服务器(WCF),该业务逻辑在计算机开机时(用户以普通过程登录时运行)跟踪信息。 The local client (WPF) containing presentation logic can connect to the readily-available local server to present the tracked information to the end-user. 包含呈现逻辑的本地客户端(WPF)可以连接到随时可用的本地服务器,以将跟踪的信息呈现给最终用户。 Everything is local and non critical, security is not an issue. 一切都在本地且非关键,安全性不是问题。

The Implementation 实施

Initially I wrote a local server based on the Remoting technology, which is considered to be legacy technology, and connected the local client to the local server. 最初,我基于Remoting技术编写了本地服务器,该技术被认为是传统技术,并将本地客户端连接到本地服务器。 Each shared object was shared remotely and could be called upon. 每个共享对象都已远程共享,可以被调用。

The Problem 问题

It was not possible to remote serialized Lambda expressions (refractor-enabled property name binding) and events. 远程序列化的Lambda表达式(启用了折射功能的属性名称绑定)和事件是不可能的。 I am aware events can be bound using a remote-enabled object and invoking that on the server, however, this breaks WPF data binding. 我知道可以使用支持远程的对象并在服务器上调用事件来绑定事件,但是,这会破坏WPF数据绑定。 Event-driven programming is important. 事件驱动的编程很重要。

What do I seek? 我要寻找什么?

An example to create the architecture I mentioned, or, a base sample that shows how to configure WCF to behave in a similar manner as Remoting does. 创建我提到的体系结构的一个示例,或一个基本示例,该示例显示了如何配置WCF以使其行为与Remoting相似。 Every online resource I could find, including MSDN articles, are written for .NET 2.0. 我可以找到的每个联机资源(包括MSDN文章)都是针对.NET 2.0编写的。 A lot has changed in WCF-world since .NET 2.0, and using .NET 4.0 is a requirement. 自.NET 2.0以来,WCF世界发生了许多变化,并且要求使用.NET 4.0。 Even links to samples, tutorials or articles for Remoting-like behaviour for WCF in .NET 4.0 is appreciated! 甚至链接到示例,教程或文章的链接,以获取.NET 4.0中WCF的类似Remoting的行为!

WCF is an excellent technology, howevery as others have commented, it sounds like you are trying to violate core principals of WCF. WCF是一项出色的技术,但是正如其他人所评论的那样,听起来您正在尝试违反WCF的核心原则。 I might be wrong here but it sounds like you want to send your viewmodels across the remoting boundary? 我在这里可能是错的,但听起来您想跨远程边界发送视图模型?

The reason why it is wrong to send viewmodels across the remoting boundary in my opinion is an architectual reason. 在我看来,跨远程范围发送视图模型是错误的,这是一个架构上的原因。 The reason being that I might have mutliple client apps, ie a web site and a wpf desktop app. 原因是我可能有多个客户端应用程序,即网站和wpf桌面应用程序。 That viewmodel is only relevant to the WPF app. 该视图模型仅与WPF应用相关。 It is largely platform specific (in most cases). 它在很大程度上是特定于平台的(在大多数情况下)。 Since viewmodels are platform specific they belong to the platform and not in your services. 由于视图模型是特定于平台的,因此它们属于平台而不属于您的服务。

Your DTO entities (ie service model classes) must be separate to your viewmodels, as your views requirements could change on any one client app, and your services might want to largely provide the same services as they were before. 您的DTO实体(即服务模型类)必须与视图模型分开,因为您的视图要求可能会在任何一个客户端应用程序上发生变化,并且您的服务可能希望在很大程度上提供与以前相同的服务。 It is fine for your client apps to have dependency on your model entities. 客户端应用程序对模型实体具有依赖性是很好的。 I usually put them in a common project that is common to my service project and my client app projects. 我通常将它们放在服务项目和客户应用程序项目共有的通用项目中。

This about it this way. 这种方式。 A good design should allow anyone to potentially consume it and do what they want with it. 一个好的设计应该允许任何人潜在地使用它并随心所欲地使用它。 A web service such as flikr,facebook or amazon doesn't tell you how or suggest what information you should display on your application, and neither should yours. 诸如flikr,facebook或amazon之类的Web服务不会告诉您如何或建议应在应用程序上显示哪些信息,您的信息也不应告诉您。 (Im not advocating to blindly follow their design, but it is a community example you can have a look at). (我不主张盲目地遵循他们的设计,但这是您可以看看的社区示例)。

Your viewmodels should defaultly be using bindable datatypes by implementing the INotifyPropertyChanged interface etc, so updating the data on a viewmodel should be a very easy thing to do. 默认情况下,您的视图模型应该通过实现INotifyPropertyChanged接口等来使用可绑定数据类型,因此更新视图模型上的数据应该非常容易。 The best thing to do when design an app is to think, if i did something which is not in my feature list how would I do it. 设计应用程序时,最好的办法就是思考,如果我做了一些功能列表中没有的内容,我将如何做。 Am I making it harder to say, expose my service to the public (even thought that is not my intent to do so). 我是否更难以说出来,将我的服务向公众公开(甚至认为这并非我的意图)。 That will keep your design robust, and in good shape for when clients change their mind in what they want. 这样可以使您的设计稳定可靠,并在客户改变主意时保持良好状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM