/// <summary> /// Adds a singleton component to a named service. /// </summary> /// <typeparam name="TComponent">The component service type.</typeparam> /// <param name="configurator">The named configurator which the component will be configured for.</param> /// <param name="factory">The factory used to create the component for the named service.</param> public static void ConfigureComponent <TComponent>(this INamedServiceConfigurator configurator, Func <IServiceProvider, string, TComponent> factory) where TComponent : class { configurator.ConfigureDelegate(services => { services.AddSingletonNamedService(configurator.Name, factory); }); }
/// <summary> /// Configures options for a named service. /// </summary> /// <param name="configurator"> /// The named service configurator. /// </param> /// <param name="configureOptions"> /// The options configuration delegate. /// </param> /// <typeparam name="TOptions"> /// The underlying options type. /// </typeparam> public static void Configure <TOptions>(this INamedServiceConfigurator configurator, Action <OptionsBuilder <TOptions> > configureOptions) where TOptions : class, new() { configurator.ConfigureDelegate(services => { configureOptions?.Invoke(services.AddOptions <TOptions>(configurator.Name)); services.ConfigureNamedOptionForLogging <TOptions>(configurator.Name); }); }