服务定位器(Service Locator) & 初始化 - IDependencyResolver 接口

优质
小牛编辑
128浏览
2023-12-01

[命名空间: Serenity.Abstractions, 程序集: Serenity.Core]

此接口通常定义依赖解析器(dependency resolvers)的契约,以使 IoC 容器处理服务(services)与提供者(providers)之间的映射。

  1. public interface IDependencyResolver
  2. {
  3. TService Resolve<TService>() where TService : class;
  4. TService Resolve<TService>(string name) where TService : class;
  5. TService TryResolve<TService>() where TService : class;
  6. TService TryResolve<TService>(string name) where TService : class;
  7. }

所有方法在功能上都等效于静态依赖类相应的方法。