如何在 silverlight 和 mvc3 应用程序之间共享代码
我的任务是构建一个同时具有 silverlight UI(为了丰富)和 MVC3 JQueryUI(为了覆盖)的应用程序。
我当然希望在它们之间共享尽可能多的代码和单元测试。在我看来,“两个应用程序”之间的唯一区别是 UI 和交互模型 - 业务逻辑和验证规则等完全相同。
我真的很喜欢 MVVM 模式,但确实了解 MVC 不具备 XAML 所具有的数据绑定级别。
我认为我仍然可以使用视图模型,在这两种情况下都可以进行命令?在 silverlight 情况下,它“正常工作”。在 MVC 情况下,控制器只不过是通往 ViewModel 的管道,所有“真实代码”都在其中,而视图将使用视图模型作为“模型”。
- 这合理吗?
- 我还可以在 mvc 中使用一些 MVVM 灯光功能吗?特别是从控制器向视图模型发出命令?
- 有更好的办法吗?
I have been tasked with building an application that has both a silverlight UI (for richness) and an MVC3 JQueryUI (for reach).
I would of course like to share as much code and unit tests between them as possible. It seems to me the only difference between the "two apps" is the UI and interaction models- the business logic and validation rules etc are exactly the same.
I REALLY like the MVVM pattern, but do understand that MVC does not have the level of data binding that XAML has.
Im thinking that I can still use view models, with commanding in both cases? In the silverlight case, it "just works". In the MVC case, the controllers would become nothing more than conduits over to the ViewModels, where all the "real code" is, and the views would use the view model as the "model".
- is this reasonable?
- can I still use some of MVVM lights functionality in mvc? in particular, commanding from the controller to the view model?
- is there a better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将面临的问题是 Silverlight 在不同的 .Net 框架(基本上是 .Net 的精简版本)上运行。最好的选择是使用可移植类库 (MS网站链接)。这些允许您在不同的 .Net 框架之间共享代码。
这将让您共享一些代码。
The issue you'll face is that Silverlight runs on a different .Net framework (basically a cut-down version of .Net). Your best bet is to use Portable Class Libraries (MS web site link). These allow you to share code between different .Net frameworks.
This will let you share some code.