Extension methods for configuring Application Insights telemetry.
public static class ApplicationInsightsExtensions
IServiceCollection AddCallingIdentityTelemetryInitializer(this IServiceCollection services)Summary: Registers telemetry initializers for enriching Application Insights telemetry with request context information.
Parameters:
services- The service collection.Returns: The service collection for method chaining.
Remarks: This method registers the following telemetry initializers:
Microsoft.ApplicationInsights.Extensibility.CallingIdentityTelemetryInitializer- Adds calling identity and request correlation IDs to telemetry.Microsoft.ApplicationInsights.Extensibility.Accept4xxResponseAsSuccessInitializer- Treats certain 4xx responses (BadRequest, NotFound) as successful requests.
Extension methods for configuring REST API services in the dependency injection container.
public static class RestApiExtensions
IServiceCollection AddRestApi(this IServiceCollection services)Summary: Registers REST API services with default configuration options.
Parameters:
services- The service collection.Returns: The service collection for method chaining.
IServiceCollection AddRestApi(this IServiceCollection services, RestApiOptions restApiOptions)Summary: Registers REST API services with default configuration options.
Parameters:
services- The service collection.Returns: The service collection for method chaining.
IServiceCollection AddRestApi(this IServiceCollection services, Action<IMvcBuilder> setupMvcAction, RestApiOptions restApiOptions)Summary: Registers REST API services with default configuration options.
Parameters:
services- The service collection.Returns: The service collection for method chaining.
Extension methods for Microsoft.Extensions.DependencyInjection.IServiceCollection to auto-register and validate service registrations.
public static class ServiceCollectionExtensions
void AutoRegistrateServices(this IServiceCollection services, Assembly interfaceAssembly, Assembly implementationAssembly)Summary: Automatically registers services by matching interfaces from one assembly with implementations from another.
Parameters:
services- The service collection.
interfaceAssembly- The assembly containing service interfaces.
implementationAssembly- The assembly containing service implementations.Remarks: This method scans both assemblies and registers each interface with its matching implementation as a transient service. Only the first matching implementation for each interface is registered.
void ValidateServiceRegistrations(this IServiceCollection services, Assembly apiAssembly)Summary: Validates that all interfaces in the specified assembly have been registered in the service collection.
Parameters:
services- The service collection.
apiAssembly- The assembly containing interfaces to validate.