开发者

Dependency Injection / repository pattern with Silverlight 4 and WCF

we are creating a la开发者_如何学Pythonrge Silverlight Application. We already created our Domain Model including interfaces for our repositories. Now with WPF I'd just add a reference to the domain project, register all the dependencies (i.e. repositories) via a DI container and inject the repositories into the view models. With Silverlight, I have to communicate via a WCF service for all my database needs. So basically my repository interfaces are useless in the Silverlight project. The way I see it I have to do all the dependency injection in the WCF service and wrap all the repository functionality again for my Silverlight application. Am I correct?


That's basically correct. I suppose you could, in theory, link to your server-side repository interface files from the Silverlight client, using the WCF service as the actual data source for your client-side implementation of IRepository. But if you did this, you'd have to make all your interface methods asynchronous, not to mention coding them very carefully to allow for slight differences in environment and object models. In the end, it would quite likely be more of a pain that it's worth. You might experiment, however, and see if that's accurate.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜