// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using Microsoft.AspNetCore.Diagnostics.Elm; using Microsoft.Extensions.DependencyInjection.Extensions; namespace Microsoft.Extensions.DependencyInjection { /// /// Extension methods for setting up Elm services in an . /// public static class ElmServiceCollectionExtensions { /// /// Adds error logging middleware services to the specified . /// /// The to add services to. /// The so that additional calls can be chained. public static IServiceCollection AddElm(this IServiceCollection services) { if (services == null) { throw new ArgumentNullException(nameof(services)); } services.AddOptions(); services.TryAddSingleton(); services.TryAddSingleton(); return services; } /// /// Adds error logging middleware services to the specified . /// /// The to add services to. /// An to configure the provided . /// The so that additional calls can be chained. public static IServiceCollection AddElm(this IServiceCollection services, Action setupAction) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (setupAction == null) { throw new ArgumentNullException(nameof(setupAction)); } services.AddElm(); services.Configure(setupAction); return services; } } }