public IEnumerator <KeyValuePair <TKey, TValue> > GetEnumerator() { foreach (var service in GetServices()) { yield return(new KeyValuePair <TKey, TValue>((TKey)service.ServiceKey, (TValue)context.ResolveService(GetService((TKey)service.ServiceKey)))); } }
///<summary></summary> public TValue this[TKey key] { get { return((TValue)_context.ResolveService(GetService(key))); } }
private static TResult Resolve <TResult>(object target, IComponentContext ls, IEnumerable <Parameter> parameterCollection) { object obj2; if (target is Service) { obj2 = ls.ResolveService((Service)target, parameterCollection); } else { obj2 = ls.ResolveComponent((IComponentRegistration)target, parameterCollection); } return((TResult)obj2); }
static TResult Resolve <TResult>(object target, IComponentContext ls, IEnumerable <Parameter> parameterCollection) { object resolved; if (target is Service) { resolved = ls.ResolveService((Service)target, parameterCollection); } else { var ts = new TypedService(typeof(TResult)); resolved = ls.ResolveComponent(ts, (IComponentRegistration)target, parameterCollection); } return((TResult)resolved); }
/// <summary> /// Retrieve a service from the context. /// </summary> /// <param name="context">The context from which to resolve the service.</param> /// <param name="parameters">Parameters for the service.</param> /// <param name="service">The service to resolve.</param> /// <returns> /// The component instance that provides the service. /// </returns> /// <exception cref="ComponentNotRegisteredException"/> /// <exception cref="DependencyResolutionException"/> public static object ResolveService(this IComponentContext context, Service service, params Parameter[] parameters) { return(context.ResolveService(service, (IEnumerable <Parameter>)parameters)); }
public TValue this[TKey key] => (TValue)_context.ResolveService(GetService(key));
public static object Resolve(this IComponentContext context, Type serviceType, IEnumerable <Parameter> parameters) { return(context.ResolveService(new TypedService(serviceType), parameters)); }
public static object ResolveService(this IComponentContext context, Service service) { return(context.ResolveService(service, NoParameters)); }
public static object ResolveNamed(this IComponentContext context, string serviceName, Type serviceType, IEnumerable <Parameter> parameters) { return(context.ResolveService(new KeyedService(serviceName, serviceType), parameters)); }
public static TService ResolveNamed <TService>(this IComponentContext context, string serviceName, IEnumerable <Parameter> parameters) { return((TService)context.ResolveService(new KeyedService(serviceName, typeof(TService)), parameters)); }