Class ServiceProviderExtensions
- Namespace
- Cuemon.Extensions.AspNetCore.Diagnostics
- Assembly
- Cuemon.Extensions.AspNetCore.dll
Extension methods for the IServiceProvider interface.
public static class ServiceProviderExtensions
- Inheritance
-
ServiceProviderExtensions
Examples
The following example demonstrates how to retrieve all registered IHttpExceptionDescriptorResponseFormatter services from the service provider.
using System;
using System.Collections.Generic;
using Cuemon.AspNetCore.Diagnostics;
using Cuemon.Extensions.AspNetCore.Diagnostics;
using Microsoft.Extensions.DependencyInjection;
namespace Examples;
public class ExceptionFormatterResolver
{
public IEnumerable<IHttpExceptionDescriptorResponseFormatter> ResolveFormatters(IServiceProvider provider)
{
return provider.GetExceptionResponseFormatters();
}
}
Methods
GetExceptionResponseFormatters(IServiceProvider)
Retrieves a sequence of IHttpExceptionDescriptorResponseFormatter services from the specified provider.
public static IEnumerable<IHttpExceptionDescriptorResponseFormatter> GetExceptionResponseFormatters(this IServiceProvider provider)
Parameters
providerIServiceProviderThe IServiceProvider to extend.
Returns
- IEnumerable<IHttpExceptionDescriptorResponseFormatter>
A sequence of IHttpExceptionDescriptorResponseFormatter services.
Exceptions
- ArgumentNullException
providercannot be null.