开发者

how to share code between silverlight and mvc3 applications

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".

  1. is this reasonable?
  2. can I still use some of MVVM ligh开发者_StackOverflow中文版ts functionality in mvc? in particular, commanding from the controller to the view model?
  3. is there a better way?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜