/// <summary> /// Adds components of the Mappings actuator to Microsoft-DI /// </summary> /// <param name="services">Service collection to add actuator to</param> /// <param name="config">Application configuration (this actuator looks for settings starting with management:endpoints:dump)</param> public static void AddMappingsActuator(this IServiceCollection services, IConfiguration config) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (config == null) { throw new ArgumentNullException(nameof(config)); } services.TryAddEnumerable(ServiceDescriptor.Singleton <IManagementOptions>(new ActuatorManagementOptions(config))); var options = new MappingsEndpointOptions(config); services.TryAddSingleton <IMappingsOptions>(options); services.RegisterEndpointOptions(options); services.TryAddSingleton <IRouteMappings, RouteMappings>(); }
/// <summary> /// Adds components of the Mappings actuator to Microsoft-DI /// </summary> /// <param name="services">Service collection to add actuator to</param> /// <param name="config">Application configuration. Retrieved from the <see cref="IServiceCollection"/> if not provided (this actuator looks for a settings starting with management:endpoints:mappings)</param> public static void AddMappingsActuator(this IServiceCollection services, IConfiguration config = null) { if (services == null) { throw new ArgumentNullException(nameof(services)); } config ??= services.BuildServiceProvider().GetService <IConfiguration>(); if (config == null) { throw new ArgumentNullException(nameof(config)); } services.AddActuatorManagementOptions(config); var options = new MappingsEndpointOptions(config); services.TryAddSingleton <IMappingsOptions>(options); services.RegisterEndpointOptions(options); services.TryAddSingleton <IRouteMappings, RouteMappings>(); services.TryAddSingleton <MappingsEndpoint>(); }