开发者

ASP.NET MVC 3 RTM way of ServiceLocator

I'm a little confused with IServiceLocator, IMvcServiceLocator, IDependencyResolver, etc...

What is the ASP.NET MVC 3 RTM way of locating services?

All I need is to access something like

T Resolve<T>();
T Resolve<T>(string key);

from anywhere (including another assembly).

EDIT: example

My web app has a kind of modular architecture. Themes are one aspect of modules. Each theme is an individual class library. It's not possible to know what services a theme needs. E.g. some view might display a tag cloud widget and that widget needs an instance of TagRepository.

Currently I'm using Windsor for IoC and I could expose that container for modules. But I don't really want to make every module depend on Windsor. I would like to know if there's a solut开发者_JS百科ion in standard Mvc library since modules need a reference to that anyway.


Asp.net Mvc doesn't have it's own DI container. You would have to implement IDependencyResolver. Take a look at this question: Castle Windsor Dependency Resolver for MVC 3

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜