/// <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));
/// <summary> /// Exposes a singleton service type to ExpandR, so that plugins may provide multiple implementations. /// </summary> /// <typeparam name="TService">The service (interface) type.</typeparam> /// <typeparam name="TDefaultImpl">The default implementation type.</typeparam> public static void ExposeMultiSingleton <TService, TDefaultImpl>(this IExpandR expandr) => expandr.Expose <TService, TDefaultImpl>(ServiceLifetime.Singleton, true);
/// <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="defaultImpls">Default implementation(s) for the service.</param> public static void Expose <TService>(this IExpandR expandr, ServiceLifetime lifetime, bool multiple = false, params ExposedImplementation[] defaultImpls) => expandr.Expose(typeof(TService), lifetime, multiple, defaultImpls);
/// <summary> /// Exposes a singleton service type to ExpandR, so that plugins may provide multiple implementations. /// </summary> /// <typeparam name="TService">The service (interface) type.</typeparam> /// <param name="defaultImpls">Default implementations for the service.</param> public static void ExposeMultiSingleton <TService>(this IExpandR expandr, Func <IServiceProvider, TService> defaultFactory) => expandr.Expose <TService>(ServiceLifetime.Singleton, true, defaultFactory);
/// <summary> /// Exposes a singleton service type to ExpandR, so that plugins may provide multiple implementations. /// </summary> /// <typeparam name="TService">The service (interface) type.</typeparam> /// <param name="defaultInstance">Default instance implementations for the service.</param> public static void ExposeMultiSingleton <TService>(this IExpandR expandr, TService defaultInstance) => expandr.Expose <TService>(ServiceLifetime.Singleton, true, _ => defaultInstance);
/// <summary> /// Exposes a scoped service type to ExpandR, so that plugins may provide multiple implementations. /// </summary> /// <typeparam name="TService">The service (interface) type.</typeparam> /// <typeparam name="TDefaultImpl">The default implementation type.</typeparam> public static void ExposeMultiScoped <TService, TDefaultImpl>(this IExpandR expandr) => expandr.Expose <TService, TDefaultImpl>(ServiceLifetime.Scoped, true);
/// <summary> /// Exposes a singleton service type to ExpandR, so that plugins may provide multiple implementations. /// </summary> /// <typeparam name="TService">The service (interface) type.</typeparam> /// <param name="defaultImpls">Default implementations for the service.</param> public static void ExposeMultiSingleton <TService>(this IExpandR expandr, params ExposedImplementation[] defaultImpls) => expandr.Expose(typeof(TService), ServiceLifetime.Singleton, true, defaultImpls);
/// <summary> /// Exposes a transient service type to ExpandR, so that plugins may provide multiple implementations. /// </summary> /// <typeparam name="TService">The service (interface) type.</typeparam> /// <param name="defaultFactory">Default factory implementation for the service.</param> public static void ExposeMultiTransient <TService>(this IExpandR expandr, Func <IServiceProvider, TService> defaultFactory) => expandr.Expose <TService>(ServiceLifetime.Transient, true, defaultFactory);
/// <summary> /// Exposes a transient service type to ExpandR, so that plugins may provide multiple implementations. /// </summary> /// <typeparam name="TService">The service (interface) type.</typeparam> /// <typeparam name="TDefaultImpl">The default implementation type.</typeparam> public static void ExposeMultiTransient <TService, TDefaultImpl>(this IExpandR expandr) => expandr.Expose <TService, TDefaultImpl>(ServiceLifetime.Transient, true);
/// <summary> /// Exposes a singleton service type to ExpandR, so that plugins can implement it. /// </summary> /// <typeparam name="TService">The service (interface) type.</typeparam> /// <param name="multiple">Whether the service can have multiple implementations, or at most one.</param> /// <param name="defaultInstance">Default instance implementation for the service.</param> public static void ExposeSingleton <TService>(this IExpandR expandr, bool multiple, TService defaultInstance) => expandr.Expose <TService>(ServiceLifetime.Singleton, multiple, _ => defaultInstance);
/// <summary> /// Exposes a service type to ExpandR, so that plugins may provide multiple implementations. /// </summary> /// <typeparam name="TService">The service (interface) type.</typeparam> /// <param name="lifetime">The lifetime of the service.</param> /// <param name="defaultFactory">Default factory implementation for the service.</param> public static void ExposeMulti <TService>(this IExpandR expandr, ServiceLifetime lifetime, Func <IServiceProvider, TService> defaultFactory) => expandr.Expose <TService>(lifetime, true, defaultFactory);
/// <summary> /// Exposes a singleton 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="multiple">Whether the service can have multiple implementations, or at most one.</param> public static void ExposeSingleton <TService, TDefaultImpl>(this IExpandR expandr, bool multiple = false) => expandr.Expose <TService, TDefaultImpl>(ServiceLifetime.Singleton, multiple);
/// <summary> /// Exposes a singleton service type to ExpandR, so that plugins can implement it. /// </summary> /// <typeparam name="TService">The service (interface) type.</typeparam> /// <param name="multiple">Whether the service can have multiple implementations, or at most one.</param> /// <param name="defaultImpls">Default implementation(s) for the service.</param> public static void ExposeSingleton <TService>(this IExpandR expandr, bool multiple = false, params ExposedImplementation[] defaultImpls) => expandr.Expose <TService>(ServiceLifetime.Singleton, multiple, defaultImpls);
/// <summary> /// Exposes a scoped service type to ExpandR, so that plugins can implement it. /// </summary> /// <typeparam name="TService">The service (interface) type.</typeparam> /// <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 ExposeScoped <TService>(this IExpandR expandr, bool multiple, Func <IServiceProvider, TService> defaultFactory) => expandr.Expose <TService>(ServiceLifetime.Scoped, multiple, defaultFactory);
/// <summary> /// Exposes a transient 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="multiple">Whether the service can have multiple implementations, or at most one.</param> public static void ExposeTransient <TService, TDefaultImpl>(this IExpandR expandr, bool multiple = false) => expandr.Expose <TService, TDefaultImpl>(ServiceLifetime.Transient, multiple);
/// <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>());