Skip to content

Commit

Permalink
Add post configure variants to options builder extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewTriesToCode committed Dec 22, 2023
1 parent 488cffd commit 6d4527c
Showing 1 changed file with 155 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,161 @@ public static OptionsBuilder<TOptions> ConfigurePerTenant<TOptions, TDep1, TDep2

return optionsBuilder;
}

public static OptionsBuilder<TOptions> PostConfigurePerTenant<TOptions, TTenantInfo>(
this OptionsBuilder<TOptions> optionsBuilder, Action<TOptions, TTenantInfo> configureOptions)
where TOptions : class
where TTenantInfo : class, ITenantInfo, new()
{
FinbuckleServiceCollectionExtensions.ConfigurePerTenantReqs<TOptions>(optionsBuilder.Services);

optionsBuilder.Services.AddTransient<IPostConfigureOptions<TOptions>>(sp =>
new PostConfigureOptions<TOptions, TTenantInfo?>(

Check warning on line 179 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (6.0.x, ubuntu-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep' in the generic type or method 'PostConfigureOptions<TOptions, TDep>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 179 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (6.0.x, macos-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep' in the generic type or method 'PostConfigureOptions<TOptions, TDep>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 179 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (8.0.x, macos-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep' in the generic type or method 'PostConfigureOptions<TOptions, TDep>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 179 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (7.0.x, ubuntu-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep' in the generic type or method 'PostConfigureOptions<TOptions, TDep>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 179 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (8.0.x, ubuntu-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep' in the generic type or method 'PostConfigureOptions<TOptions, TDep>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 179 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (7.0.x, macos-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep' in the generic type or method 'PostConfigureOptions<TOptions, TDep>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 179 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (8.0.x, windows-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep' in the generic type or method 'PostConfigureOptions<TOptions, TDep>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 179 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (7.0.x, windows-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep' in the generic type or method 'PostConfigureOptions<TOptions, TDep>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.
optionsBuilder.Name,
sp.GetService<TTenantInfo>(),
(options, dep) =>
{
if (dep is not null)
configureOptions(options, dep);
}));

return optionsBuilder;
}

public static OptionsBuilder<TOptions> PostConfigurePerTenant<TOptions, TDep, TTenantInfo>(
this OptionsBuilder<TOptions> optionsBuilder, Action<TOptions, TDep, TTenantInfo> configureOptions)
where TOptions : class
where TDep : class
where TTenantInfo : class, ITenantInfo, new()
{
FinbuckleServiceCollectionExtensions.ConfigurePerTenantReqs<TOptions>(optionsBuilder.Services);

optionsBuilder.Services.AddTransient<IPostConfigureOptions<TOptions>>(sp =>
new PostConfigureOptions<TOptions, TDep, TTenantInfo?>(

Check warning on line 200 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (6.0.x, ubuntu-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep2' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 200 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (6.0.x, macos-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep2' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 200 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (8.0.x, macos-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep2' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 200 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (7.0.x, ubuntu-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep2' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 200 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (8.0.x, ubuntu-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep2' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 200 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (7.0.x, macos-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep2' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 200 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (8.0.x, windows-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep2' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.
optionsBuilder.Name,
sp.GetRequiredService<TDep>(),
sp.GetService<TTenantInfo>(),
(options, dep, tenantInfo) =>
{
if (tenantInfo is not null)
configureOptions(options, dep, tenantInfo);
}));

return optionsBuilder;
}

public static OptionsBuilder<TOptions> PostConfigurePerTenant<TOptions, TDep1, TDep2, TTenantInfo>(
this OptionsBuilder<TOptions> optionsBuilder, Action<TOptions, TDep1, TDep2, TTenantInfo> configureOptions)
where TOptions : class
where TDep1 : class
where TDep2 : class
where TTenantInfo : class, ITenantInfo, new()
{
FinbuckleServiceCollectionExtensions.ConfigurePerTenantReqs<TOptions>(optionsBuilder.Services);

optionsBuilder.Services.AddTransient<IPostConfigureOptions<TOptions>>(sp =>
new PostConfigureOptions<TOptions, TDep1, TDep2, TTenantInfo?>(

Check warning on line 223 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (6.0.x, ubuntu-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep3' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 223 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (6.0.x, macos-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep3' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 223 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (8.0.x, macos-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep3' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 223 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (7.0.x, ubuntu-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep3' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 223 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (8.0.x, ubuntu-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep3' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 223 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (7.0.x, macos-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep3' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 223 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (8.0.x, windows-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep3' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.
optionsBuilder.Name,
sp.GetRequiredService<TDep1>(),
sp.GetRequiredService<TDep2>(),
sp.GetService<TTenantInfo>(),
(options, dep1, dep2, tenantInfo) =>
{
if (tenantInfo is not null)
configureOptions(options, dep1, dep2, tenantInfo);
}));

return optionsBuilder;
}

public static OptionsBuilder<TOptions> PostConfigurePerTenant<TOptions, TDep1, TDep2, TDep3, TTenantInfo>(
this OptionsBuilder<TOptions> optionsBuilder,
Action<TOptions, TDep1, TDep2, TDep3, TTenantInfo> configureOptions)
where TOptions : class
where TDep1 : class
where TDep2 : class
where TDep3 : class
where TTenantInfo : class, ITenantInfo, new()
{
FinbuckleServiceCollectionExtensions.ConfigurePerTenantReqs<TOptions>(optionsBuilder.Services);

optionsBuilder.Services.AddTransient<IPostConfigureOptions<TOptions>>(sp =>
new PostConfigureOptions<TOptions, TDep1, TDep2, TDep3, TTenantInfo?>(

Check warning on line 249 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (6.0.x, ubuntu-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep4' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3, TDep4>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 249 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (6.0.x, macos-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep4' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3, TDep4>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 249 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (8.0.x, macos-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep4' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3, TDep4>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 249 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (8.0.x, ubuntu-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep4' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3, TDep4>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 249 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (7.0.x, macos-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep4' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3, TDep4>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.
optionsBuilder.Name,
sp.GetRequiredService<TDep1>(),
sp.GetRequiredService<TDep2>(),
sp.GetRequiredService<TDep3>(),
sp.GetService<TTenantInfo>(),
(options, dep1, dep2, dep3, tenantInfo) =>
{
if (tenantInfo is not null)
configureOptions(options, dep1, dep2, dep3, tenantInfo);
}));

return optionsBuilder;
}

public static OptionsBuilder<TOptions> PostConfigurePerTenant<TOptions, TDep1, TDep2, TDep3, TDep4, TTenantInfo>(
this OptionsBuilder<TOptions> optionsBuilder,
Action<TOptions, TDep1, TDep2, TDep3, TDep4, TTenantInfo> configureOptions)
where TOptions : class
where TDep1 : class
where TDep2 : class
where TDep3 : class
where TDep4 : class
where TTenantInfo : class, ITenantInfo, new()
{
FinbuckleServiceCollectionExtensions.ConfigurePerTenantReqs<TOptions>(optionsBuilder.Services);

optionsBuilder.Services.AddTransient<IPostConfigureOptions<TOptions>>(sp =>
new PostConfigureOptions<TOptions, TDep1, TDep2, TDep3, TDep4, TTenantInfo?>(

Check warning on line 277 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (6.0.x, ubuntu-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep5' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3, TDep4, TDep5>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 277 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (6.0.x, macos-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep5' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3, TDep4, TDep5>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 277 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (8.0.x, macos-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep5' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3, TDep4, TDep5>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 277 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (8.0.x, ubuntu-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep5' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3, TDep4, TDep5>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.

Check warning on line 277 in src/Finbuckle.MultiTenant/DependencyInjection/OptionsBuilderExtensions.cs

View workflow job for this annotation

GitHub Actions / build-and-test (7.0.x, macos-latest)

The type 'TTenantInfo?' cannot be used as type parameter 'TDep5' in the generic type or method 'PostConfigureOptions<TOptions, TDep1, TDep2, TDep3, TDep4, TDep5>'. Nullability of type argument 'TTenantInfo?' doesn't match 'class' constraint.
optionsBuilder.Name,
sp.GetRequiredService<TDep1>(),
sp.GetRequiredService<TDep2>(),
sp.GetRequiredService<TDep3>(),
sp.GetRequiredService<TDep4>(),
sp.GetService<TTenantInfo>(),
(options, dep1, dep2, dep3, dep4, tenantInfo) =>
{
if (tenantInfo is not null)
configureOptions(options, dep1, dep2, dep3, dep4, tenantInfo);
}));

return optionsBuilder;
}

public static OptionsBuilder<TOptions> PostConfigurePerTenant<TOptions, TDep1, TDep2, TDep3, TDep4, TDep5, TTenantInfo>(
this OptionsBuilder<TOptions> optionsBuilder,
Action<TOptions, TDep1, TDep2, TDep3, TDep4, TDep5, TTenantInfo> configureOptions)
where TOptions : class
where TDep1 : class
where TDep2 : class
where TDep3 : class
where TDep4 : class
where TDep5 : class
where TTenantInfo : class, ITenantInfo, new()
{
FinbuckleServiceCollectionExtensions.ConfigurePerTenantReqs<TOptions>(optionsBuilder.Services);

optionsBuilder.Services.AddTransient<IPostConfigureOptions<TOptions>>(sp =>
{
var tenantInfo = sp.GetService<TTenantInfo>();
return new PostConfigureOptions<TOptions, TDep1, TDep2, TDep3, TDep4, TDep5>(
optionsBuilder.Name,
sp.GetRequiredService<TDep1>(),
sp.GetRequiredService<TDep2>(),
sp.GetRequiredService<TDep3>(),
sp.GetRequiredService<TDep4>(),
sp.GetRequiredService<TDep5>(),
(options, dep1, dep2, dep3, dep4, dep5) =>
{
if (tenantInfo is not null)
configureOptions(options, dep1, dep2, dep3, dep4, dep5, tenantInfo);
});
});

return optionsBuilder;
}
}
//
// /// <summary>
Expand Down

0 comments on commit 6d4527c

Please sign in to comment.