Skip to content

Commit

Permalink
pr-fix: update with additional xml code docs and guard messages
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnmoreels committed Sep 1, 2022
1 parent 54d0410 commit d70c373
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ public static class IServiceCollectionExtensions
/// Adds operation and transaction correlation to the application using the <see cref="DefaultCorrelationInfoAccessor"/>
/// </summary>
/// <param name="services">The services collection containing the dependency injection services.</param>
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="services"/> is <c>null</c>.</exception>
public static IServiceCollection AddCorrelation(this IServiceCollection services)
{
Guard.NotNull(services, nameof(services));
Guard.NotNull(services, nameof(services), "Requires a service collection to register the default correlation accessor to the application services");

return AddCorrelation<CorrelationInfo>(services);
}
Expand All @@ -42,11 +43,12 @@ public static IServiceCollection AddCorrelation(
/// </summary>
/// <typeparam name="TCorrelationInfo">The type of the <see cref="CorrelationInfo"/> model.</typeparam>
/// <param name="services">The services collection containing the dependency injection services.</param>
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="services"/> is <c>null</c>.</exception>
public static IServiceCollection AddCorrelation<TCorrelationInfo>(
this IServiceCollection services)
where TCorrelationInfo : CorrelationInfo
{
Guard.NotNull(services, nameof(services));
Guard.NotNull(services, nameof(services), "Requires a service collection to register the default correlation accessor to the application services");

return AddCorrelation<DefaultCorrelationInfoAccessor<TCorrelationInfo>, TCorrelationInfo>(
services,
Expand Down Expand Up @@ -118,13 +120,14 @@ public static IServiceCollection AddCorrelation<TAccessor>(
/// <typeparam name="TAccessor">The type of the <see cref="ICorrelationInfoAccessor"/> implementation.</typeparam>
/// <param name="services">The services collection containing the dependency injection services.</param>
/// <param name="createCustomCorrelationAccessor">The custom <see cref="ICorrelationInfoAccessor"/> implementation factory to retrieve the <see cref="CorrelationInfo"/>.</param>
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="services"/> or the <paramref name="createCustomCorrelationAccessor"/> is <c>null</c>.</exception>
public static IServiceCollection AddCorrelation<TAccessor>(
this IServiceCollection services,
Func<IServiceProvider, TAccessor> createCustomCorrelationAccessor)
where TAccessor : class, ICorrelationInfoAccessor
{
Guard.NotNull(services, nameof(services));
Guard.NotNull(createCustomCorrelationAccessor, nameof(createCustomCorrelationAccessor));
Guard.NotNull(services, nameof(services), "Requires a service collection to register the custom correlation accessor to the application services");
Guard.NotNull(createCustomCorrelationAccessor, nameof(createCustomCorrelationAccessor), "Requires a factory function to create a custom correlation accessor");

return AddCorrelation<TAccessor, CorrelationInfo>(services, createCustomCorrelationAccessor);
}
Expand Down Expand Up @@ -156,14 +159,15 @@ public static IServiceCollection AddCorrelation<TAccessor>(
/// <typeparam name="TCorrelationInfo">The type of the custom <see cref="CorrelationInfo"/> model.</typeparam>
/// <param name="services">The services collection containing the dependency injection services.</param>
/// <param name="createCustomCorrelationAccessor">The custom <see cref="ICorrelationInfoAccessor"/> implementation factory to retrieve the <see cref="CorrelationInfo"/>.</param>
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="services"/> or the <paramref name="createCustomCorrelationAccessor"/> is <c>null</c>.</exception>
public static IServiceCollection AddCorrelation<TAccessor, TCorrelationInfo>(
this IServiceCollection services,
Func<IServiceProvider, TAccessor> createCustomCorrelationAccessor)
where TAccessor : class, ICorrelationInfoAccessor<TCorrelationInfo>
where TCorrelationInfo : CorrelationInfo
{
Guard.NotNull(services, nameof(services));
Guard.NotNull(createCustomCorrelationAccessor, nameof(createCustomCorrelationAccessor));
Guard.NotNull(services, nameof(services), "Requires a service collection to register the custom correlation accessor to the application services");
Guard.NotNull(createCustomCorrelationAccessor, nameof(createCustomCorrelationAccessor), "Requires a factory function to create a custom correlation accessor");

services.AddScoped<ICorrelationInfoAccessor<TCorrelationInfo>>(createCustomCorrelationAccessor);
services.AddScoped<ICorrelationInfoAccessor>(serviceProvider =>
Expand Down

0 comments on commit d70c373

Please sign in to comment.