When I started to learn about开发者_C百科 WPF and MVVM recently, I came across some sort of framework or technology in .NET that made it really easy to request a service of some kind. In my particular case, I've got an assembly that handles writing application preferences to an XML file, and I want to let all of my assemblies in the larger application use this to write their own set of preferences to the same file.
I thought it was Unity, but when I looked it up, it didn't seem to be what I read about. The only clue I have for you is that I think it's called a service (it's NOT WCF), and you can request the service two ways: one way gives you the same service each time, like a singleton, and the other way gives you a new instance each time.
Please help to jog my poor memory. :)
My guess is that you're referring to Microsoft's Common Service Locator.
Although you might just be talking about Dependency Injection in general, of which Unity is one such library. There are many other DI libraries including AutoFac, Ninject, StructureMap, and Castle Windsor. The CSL is just a way of abstracting the DI library itself, which is useful when you're a framework/library designer and want to use DI without depending on a specific implementation.
精彩评论