/// <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>());
/// <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));
internal ServiceDescriptor Implement(Type type, ExposedImplementation impl) => impl.Implement(type, Lifetime);