开发者

Using Unity without Prism

Im starting learning Silverlight (Im decent with WPF :P). Im always try to put something new when I start a new program. This time I want DI. I saw all the mtaulty videos about Prism & S开发者_开发知识库ilverlight but the regions thing, all that projects, when to use SL app or SL library, catalog... Seems difficult to me right now.

The thing is, I want to use Unity on a MVVM Light project. My question is simple:

How I register all my services? I mean "Where".

On Prism in every project with services you have an IModule implementation where register your services.

I just want a single project solution for ease.

Should I register all my services (including repositories) on App.xaml.cs?, Should I create some kind of class for Unity sake? or Should I be a man an read the entire prism4.pdf and do the things correctly? (Prism4.pdf seems to be a little unfriendly :P)

Thank you!


AFAIK, Unity and Prism don't need each other to work. Unity works perfectly fine without using Prism.
With Unity, you have to register your interfaces (services) in a config file, and load this config at the start of your program (App.xaml.cs is not a bad place). It is also possible to register the services using code, but this makes it more difficult to swap out dummy interfaces with real implementations for example. From here on you can use unityContainer.Resolve<T> to retrieve your services and interfaces.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜