Beispiel #1
0
 /// <summary>
 /// Retrieve a service from the context, or null if the service is not
 /// registered.
 /// </summary>
 /// <param name="context">The context from which to resolve the service.</param>
 /// <param name="service">The service.</param>
 /// <param name="parameters">Parameters for the service.</param>
 /// <returns>
 /// The component instance that provides the service, or null.
 /// </returns>
 /// <exception cref="DependencyResolutionException"/>
 public static object ResolveOptionalService(this IComponentContext context, Service service, params Parameter[] parameters)
 {
     return(context.ResolveOptionalService(service, (IEnumerable <Parameter>)parameters));
 }
Beispiel #2
0
 /// <summary>
 /// Retrieve a service from the context, or null if the service is not
 /// registered.
 /// </summary>
 /// <param name="context">The context from which to resolve the service.</param>
 /// <param name="parameters">Parameters for the service.</param>
 /// <typeparam name="TService">The service to resolve.</typeparam>
 /// <returns>
 /// The component instance that provides the service, or null.
 /// </returns>
 /// <exception cref="DependencyResolutionException"/>
 public static TService?ResolveOptional <TService>(this IComponentContext context, IEnumerable <Parameter> parameters)
     where TService : struct
 {
     return((TService?)context.ResolveOptionalService(new TypedService(typeof(TService)), parameters));
 }
Beispiel #3
0
 public static TService ResolveOptionalKeyed <TService>(this IComponentContext context, object serviceKey, IEnumerable <Parameter> parameters) where TService : class
 {
     return((TService)context.ResolveOptionalService(new KeyedService(serviceKey, typeof(TService)), parameters));
 }
Beispiel #4
0
 public static object ResolveOptionalService(this IComponentContext context, Service service)
 {
     return(context.ResolveOptionalService(service, NoParameters));
 }
Beispiel #5
0
 public static object ResolveOptional(this IComponentContext context, Type serviceType, IEnumerable <Parameter> parameters)
 {
     return(context.ResolveOptionalService(new TypedService(serviceType), parameters));
 }