// 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.Hosting;
using Microsoft.AspNetCore.MiddlewareAnalysis;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Microsoft.Extensions.DependencyInjection
{
///
/// Extension methods for setting up diagnostic services in an .
///
public static class AnalysisServiceCollectionExtensions
{
///
/// Adds diagnostic services to the specified .
///
/// The to add services to.
public static IServiceCollection AddMiddlewareAnalysis(this IServiceCollection services)
{
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}
// Prevent registering the same implementation of IStartupFilter (AnalysisStartupFilter) multiple times.
// But allow multiple registrations of different implementation types.
services.TryAddEnumerable(ServiceDescriptor.Transient());
return services;
}
}
}