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))));
     }
 }
Пример #2
0
 ///<summary></summary>
 public TValue this[TKey key]
 {
     get
     {
         return((TValue)_context.ResolveService(GetService(key)));
     }
 }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
 /// <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));
Пример #7
0
 public static object Resolve(this IComponentContext context, Type serviceType, IEnumerable <Parameter> parameters)
 {
     return(context.ResolveService(new TypedService(serviceType), parameters));
 }
Пример #8
0
 public static object ResolveService(this IComponentContext context, Service service)
 {
     return(context.ResolveService(service, NoParameters));
 }
Пример #9
0
 public static object ResolveNamed(this IComponentContext context, string serviceName, Type serviceType, IEnumerable <Parameter> parameters)
 {
     return(context.ResolveService(new KeyedService(serviceName, serviceType), parameters));
 }
Пример #10
0
 public static TService ResolveNamed <TService>(this IComponentContext context, string serviceName, IEnumerable <Parameter> parameters)
 {
     return((TService)context.ResolveService(new KeyedService(serviceName, typeof(TService)), parameters));
 }