Exemple #1
0
 /// <summary>
 /// Exposes a service type to ExpandR, so that plugins can implement it.
 /// </summary>
 /// <typeparam name="TService">The service (interface) type.</typeparam>
 /// <typeparam name="TDefaultImpl">The default implementation type.</typeparam>
 /// <param name="lifetime">The lifetime of the service.</param>
 /// <param name="multiple">Whether the service can have multiple implementations, or at most one.</param>
 public static void Expose <TService, TDefaultImpl>(this IExpandR expandr, ServiceLifetime lifetime, bool multiple = false)
 => expandr.Expose(typeof(TService), lifetime, multiple, ExposedImplementation.FromType <TDefaultImpl>());
Exemple #2
0
 /// <summary>
 /// Exposes a service type to ExpandR, so that plugins can implement it.
 /// </summary>
 /// <typeparam name="TService">The service (interface) type.</typeparam>
 /// <param name="lifetime">The lifetime of the service.</param>
 /// <param name="multiple">Whether the service can have multiple implementations, or at most one.</param>
 /// <param name="defaultFactory">Default factory implementation for the service.</param>
 public static void Expose <TService>(this IExpandR expandr, ServiceLifetime lifetime, bool multiple, Func <IServiceProvider, TService> defaultFactory)
 => expandr.Expose(typeof(TService), lifetime, multiple, ExposedImplementation.FromFactory(defaultFactory));
Exemple #3
0
 internal ServiceDescriptor Implement(Type type, ExposedImplementation impl)
 => impl.Implement(type, Lifetime);