开发者

Silverlight: How to consume a REST API?

I'm building a Silverlight app that I want to be hosted in Azure and use Azure table storage.开发者_JAVA百科

I have a class that represents the main data entity, ExpenseInfo. It has many data annotations for RIA validation, such as [Required].

I am following this tutorial to set up the REST service for access from SL. It wants there to be a class in my web role for data serialization. This class would contain all the same data as ExpenseInfo.

So, where do I want ExpenseInfo to be? Do I want separate classes in each project? Put it in one project, and instantiate it in both? Is it weird to have a class with all those data annotations in the server side web role?

Thanks, I'm new to SL and Azure.


The pattern you're looking for here is the Data Transfer Object (DTO) pattern. Here's a good article on the pros and cons of that pattern. Personally, I don't mind the additional classes that a DTO and/or and Adapter pattern brings (you will see adapter type patterns used all over the place, MVVM is a hot one right now). I have a strong dislike for sharing business logic in assemblies across a trust boundary, so I generally use DTO/Adapter in my architectures.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜