1

I'm building a library for conversational natural language processing. In many ways it acts much like MVC3 in that it has Controllers and Action Methods. It also uses dependency injection in much the same way as MVC3 does when instantiating constructors for the Controller classes. The main differences being that an English sentence replaces both the URL and the form values of HTTP; routing is based on matching sentence structure; and the parameters passed in are the meanings of words and phrases used in the English sentence.

Currently it uses Autofac for Dependency Injection but I'd like to remove that dependency and allow callers to use any DI container.

If I use the P&P / Codeplex Common Service Locator project in my solution then callers would still need to provide their own implementations of IServiceLocator against the instance of that interface exposed by my engine. If I use IDependencyResolver from MVC3 instead there are at least existing implementations of the mapping from the various DI container to that interface.

Should I:-

  1. use the Common Service Locator and force callers to implement the mapping classes.
  2. use the MVC 3 IDependencyResolver interface which already has mappings to other containers.
  3. accept a object as the dependency resolver and duck type it to get the one method I need from it so I can use the MVC3 interface without even taking a dependency on ASP.NET MVC3.
  4. other?
4

1 に答える 1

0

Common Service Locatorは、定義上、変更されることはなく、特定のバージョンを必要としないインターフェイスアセンブリです。

さらに、すべての共通IOCライブラリに、CommonServiceLocatorに接続するための実装が追加されました。

したがって、オプション1が最良のオプションであり、CommonServiceLocatorの新しいリリースで破損するリスクは事実上ゼロです。

これに答えるのを手伝ってくれたPhilipLaureanoに感謝します。

于 2012-01-05T21:06:39.837 に答える