Esempio n. 1
0
 protected sealed override object GetInstance(Type service, string key)
 {
     if (key != null)
     {
         return(ResolutionExtensions.ResolveNamed(this.Container, key, service));
     }
     return(ResolutionExtensions.Resolve(this.Container, service));
 }
Esempio n. 2
0
 /// <summary>
 /// Resolves the requested service instance.
 ///
 /// </summary>
 /// <param name="serviceType">Type of instance requested.</param><param name="key">Name of registered service you want. May be <see langword="null"/>.</param>
 /// <returns>
 /// The requested service instance.
 /// </returns>
 /// <exception cref="T:System.ArgumentNullException">Thrown if <paramref name="serviceType"/> is <see langword="null"/>.
 ///             </exception>
 protected override object DoGetInstance(Type serviceType, string key)
 {
     if (serviceType == null)
     {
         throw new ArgumentNullException("serviceType");
     }
     if (key == null)
     {
         return(ResolutionExtensions.Resolve(this._container, serviceType));
     }
     return(ResolutionExtensions.ResolveNamed(this._container, key, serviceType));
 }
Esempio n. 3
0
 protected T Resolve <T>(string name)
 {
     return(ResolutionExtensions.ResolveNamed <T>(this.Container, name));
 }
Esempio n. 4
0
 /// <summary>
 /// 按名称获取组件
 /// </summary>
 /// <typeparam name="TService">组件类型</typeparam>
 /// <param name="serviceName">组件名称</param>
 /// <returns>返回获取的组件</returns>
 public static TService ResolveNamed <TService>(string serviceName)
 {
     return(ResolutionExtensions.ResolveNamed <TService>(_container, serviceName));
 }
Esempio n. 5
0
 public static IRegistrationBuilder <TLimit, TReflectionActivatorData, TStyle> WithResolvedParameter <TLimit, TReflectionActivatorData, TStyle>(this IRegistrationBuilder <TLimit, TReflectionActivatorData, TStyle> registration, Type namedServiceType, string namedService) where TReflectionActivatorData : ReflectionActivatorData
 {
     return(RegistrationExtensions.WithParameter <TLimit, TReflectionActivatorData, TStyle>(registration, new ResolvedParameter((ParameterInfo pi, IComponentContext ctx) => pi.ParameterType == namedServiceType, (ParameterInfo pi, IComponentContext ctx) => ResolutionExtensions.ResolveNamed(ctx, namedService, namedServiceType))));
 }
Esempio n. 6
0
 public static T GetInstance <T>(string key, params object[] prms)
 {
     ServiceLocator.CheckReady();
     return(ResolutionExtensions.ResolveNamed <T>(ServiceLocator._container, key, from p in prms
                                                  select new TypedParameter(p.GetType(), p)));
 }
Esempio n. 7
0
 public static T GetInstance <T>(string key)
 {
     ServiceLocator.CheckReady();
     return(ResolutionExtensions.ResolveNamed <T>(ServiceLocator._container, key));
 }
Esempio n. 8
0
 public static object GetInstance(Type serviceType, string key)
 {
     ServiceLocator.CheckReady();
     return(ResolutionExtensions.ResolveNamed(ServiceLocator._container, key, serviceType));
 }