-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dceac27
commit 7f45343
Showing
14 changed files
with
74 additions
and
61 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...Modules/Subscriptions/Features/Infrastructure/Configuration/SubscriptionsConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
...ubscriptions/Features/Infrastructure/Configuration/SubscriptionsConfigurationValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...dules/TenantIdentity/Features/Infrastructure/Configuration/TenantIdentityConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
...antIdentity/Features/Infrastructure/Configuration/TenantIdentityConfigurationValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Shared.Features.Configuration | ||
{ | ||
public class ConfigurationObject | ||
{ | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Source/Shared/Features/Configuration/ConfigurationObjectValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Shared.Features.Configuration | ||
{ | ||
public abstract class ConfigurationObjectValidator<TConfiguration> : IValidateOptions<TConfiguration> where TConfiguration : ConfigurationObject | ||
{ | ||
public abstract ValidateOptionsResult Validate(string name, TConfiguration options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Shared.Features.Configuration | ||
{ | ||
public static class Registrator | ||
{ | ||
public static IServiceCollection RegisterConfiguration<TConfiguration>(this IServiceCollection services, IConfiguration configuration) where TConfiguration : ConfigurationObject, new() | ||
{ | ||
services.AddScoped(sp => | ||
{ | ||
TConfiguration tc = new TConfiguration(); | ||
configuration.GetSection(typeof(TConfiguration).Name).Bind(tc); | ||
return tc; | ||
}); | ||
services.Configure<TConfiguration>(configuration.GetSection(nameof(TConfiguration))); | ||
|
||
return services; | ||
} | ||
|
||
public static IServiceCollection RegisterConfiguration<TConfiguration, TConfigurationValidator>(this IServiceCollection services, IConfiguration configuration) | ||
where TConfiguration : ConfigurationObject, new() | ||
where TConfigurationValidator : ConfigurationObjectValidator<TConfiguration>, new() | ||
{ | ||
services.AddScoped(sp => | ||
{ | ||
TConfiguration tc = new TConfiguration(); | ||
configuration.GetSection(typeof(TConfiguration).Name).Bind(tc); | ||
return tc; | ||
}); | ||
services.Configure<TConfiguration>(configuration.GetSection(nameof(TConfiguration))); | ||
services.AddSingleton<IValidateOptions<TConfiguration>, TConfigurationValidator>(); | ||
|
||
return services; | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
Source/Shared/Features/EFCore/Configuration/EFCoreConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
Source/Shared/Features/EFCore/Configuration/EFCoreConfigurationValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
Source/Shared/Features/Modules/Configuration/IModuleConfiguration.cs
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
Source/Shared/Features/Modules/Configuration/Registrator.cs
This file was deleted.
Oops, something went wrong.