如何使用 silverlight 应用程序中的遗留业务逻辑?

发布于 2024-07-28 23:55:28 字数 1138 浏览 8 评论 0原文

我有一个设计为 3 层应用程序的 XBap 系统。 XBap 客户端使用 netTcpBinding 通过 WCF 服务使用逻辑。

为了便于数据绑定并能够重用业务对象中内置的数据验证,我选择从 xBap 客户端引用业务对象库,而不是生成代理。

这些对象除了拥有基本的数据验证之外,不实现任何逻辑。 真正的业务逻辑是在我的 WCF 服务内部实现的。

现在我面临着一个巨大的挑战。 我需要将 xBap 移植到 silverlight,因此我需要我的 silverlight 应用程序。 使用相同的业务逻辑(winforms LOB 应用程序也使用它)。

出现的一些问题:

1) 无法从 silverlight 客户端应用程序引用业务对象库,因为它是编译为常规 dll 而不是 silverlight 的。

2)无法将其编译为 silverlight 库,因为我会失去很多功能,而且显然这不是一个好主意。 如果将来出现新的 .net 平台,我不保证修改后的 (silverlight) dll 能够正常工作。

当我发现 RIAServices 时,我抱有一些希望。 我在某处读到我可以实现服务并使用任何类型的 DAL。 (我有一个自定义的)但我没有找到任何示例来说明如何将 RIAServices 放在现有业务层之上。 值得一提的是,我们不使用(也不打算使用)LINQ。 我发现的每个示例都是从使用 RIAServices 开始,并使用 LINQ 从头开始​​编写业务逻辑。

RIAServices 生成数据绑定就绪的客户端代码,但我觉得我必须更改整个业务层,这将非常昂贵。

因此,解决方案似乎是继续使用 WCF,特别是现在 silverlight 3.0 支持新的二进制绑定,并使用代理而不是实际的业务对象。 问题是这些代理不包括数据验证、属性更改通知和更改跟踪,这三个方面是我的业务类执行的。

RIAServices 解决了这些和其他方面的问题,但它需要与 silverlight 项目配合使用。 WCF (SVCUtil.exe) 生成代理,但它们并不“完整”地满足我们的需求。 所以看来我必须开发自己的实用程序来生成那些以业务对象作为输入的代理。

在我开始这样做之前,我想知道是否有人已经遇到过这个问题并且能够以方便且无痛的方式解决它。

提前致谢,

贡萨洛

I have an XBap system designed as a 3-layer application. The XBap client consumes the logic through a WCF Service using netTcpBinding.

For easy of databinding and to be able to re use data validation built-in my business objects, I choosed to reference the business objects library from the xBap client instead of generating proxies.

These objects implement no logic other than they own basic data validation. The real business logic is implemented inside my WCF service.

Now I'm facing a big challenge. I need to port the xBap to silverlight, so I need my silverlight app. to consume the same business logic (which is also used by a winforms LOB application).

Some problems that arise:

1) Can't reference the business objects library from the silverlight client application because it's compiled as a regular dll and not a silverlight one.

2) Can't compile it as a silverlight library because I'd loose lots of functionallity and obviously is not a good idea anyway. If in the future a new .net platform arises I have no warranties that the modified (silverlight) dll will work.

I had some hope when I discovered RIAServices. I read somewhere I could implement a service and use any kind of DAL. (I have a custom one) but I found no example showing how to put RIAServices on top of an existing business layer. It's worth to say that we don't use (and we are not planning to) LINQ. Every example I found started using RIAServices and writing the business logic from scratch using LINQ.

RIAServices generates databinding-ready client code, but I feel I would have to change the entire business layer and that would be really expensive.

So, the solution seems to be to keep using WCF, specially now that silverlight 3.0 supports a new binary binding, and to work with proxies instead of the actual business objects.
The problem is that those proxies don't include data validation, property change notification and change tracking, three aspects that my business clasess perform.

RIAServices resolves these and other aspects but it requieres to work with silverlight proyects. WCF (SVCUtil.exe) generates proxies but they are not 'complete' for our needs. So It seems I'll have to develop my own utility for generating those proxies taking a business object as input.

Before I start doing so, I wish to know if anyone has already faced this problem and was able to resolve it in a convinient and painless way.

Thanks in advance,

Gonzalo

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

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

发布评论

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

评论(1

小矜持 2024-08-04 23:55:28

查看此博客文章和示例 - Silverlight 3 RTM 和 .NET RIA 服务的业务应用程序示例 7 月更新:第 8 部分:基于 WCF 的数据来源

它展示了使用 .NET RIA 服务编写 DomainService,该服务向 Silverlight 客户端公开操作和模型,然后针对 WCF 服务进行工作。

您不需要更改您的业务逻辑。 DomainService 作为一个层将重用它,如果您无法将业务逻辑/WCF 服务按原样公开给 Silverlight 客户端,那么这将是有意义的......

希望有所帮助。

Check this blog post and sample - Business Apps Example for Silverlight 3 RTM and .NET RIA Services July Update: Part 8: WCF Based Data Source.

It shows writing a DomainService using .NET RIA Services that exposes operations and a model to Silverlight client, and in turn works against a WCF service.

You shouldn't need to change your business logic. The DomainService as a layer would reuse that, and it would make sense if you can't expose your business logic/WCF services as-is to Silverlight clients ...

Hope that helps.

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