diff --git a/GerstITS.Examples.Api/Common/Configurations/Extensions/IConfigurationExtensions.cs b/GerstITS.Examples.Api/Common/Configurations/Extensions/IConfigurationExtensions.cs index e5ca66e..8200f19 100644 --- a/GerstITS.Examples.Api/Common/Configurations/Extensions/IConfigurationExtensions.cs +++ b/GerstITS.Examples.Api/Common/Configurations/Extensions/IConfigurationExtensions.cs @@ -2,28 +2,27 @@ using System.Linq; using Microsoft.Extensions.Configuration; -namespace GerstITS.Examples.Api.Configurations +namespace GerstITS.Examples.Api.Configurations; + +public static class IConfigurationExtensions { - public static class IConfigurationExtensions + #region Methods + + public static TEnum GetFlaggedEnum(this IConfiguration configuration, string key) + where TEnum : struct, IConvertible { - #region Methods + ThrowsAnExceptionIfTypeIsNotAnEnumeration(); - public static TEnum GetFlaggedEnum(this IConfiguration configuration, string key) - where TEnum : struct, IConvertible - { - ThrowsAnExceptionIfTypeIsNotAnEnumeration(); - - return (TEnum)(object)(configuration.GetSection(key)? - .Get() ?? Enumerable.Empty()) - .Sum(i => (int)(object)i); - } - - private static void ThrowsAnExceptionIfTypeIsNotAnEnumeration() where TEnum : struct, IConvertible - { - if (!typeof(TEnum).IsEnum) - throw new InvalidOperationException($"{typeof(TEnum)} is not supported."); - } - - #endregion + return (TEnum)(object)(configuration.GetSection(key)? + .Get() ?? Enumerable.Empty()) + .Sum(i => (int)(object)i); } -} + + private static void ThrowsAnExceptionIfTypeIsNotAnEnumeration() where TEnum : struct, IConvertible + { + if (!typeof(TEnum).IsEnum) + throw new InvalidOperationException($"{typeof(TEnum)} is not supported."); + } + + #endregion +} \ No newline at end of file diff --git a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.EntityFrameworkMigration.cs b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.EntityFrameworkMigration.cs index 530307d..e8c4513 100644 --- a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.EntityFrameworkMigration.cs +++ b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.EntityFrameworkMigration.cs @@ -2,26 +2,25 @@ using GerstITS.System.Configurations; using Microsoft.Extensions.Configuration; -namespace GerstITS.Examples.Api.Configurations +namespace GerstITS.Examples.Api.Configurations; + +internal sealed class EntityFrameworkMigrationConfiguration : IEntityFrameworkMigrationConfiguration { - internal sealed class EntityFrameworkMigrationConfiguration : IEntityFrameworkMigrationConfiguration + #region Constructors + + public EntityFrameworkMigrationConfiguration(string parentPrefix, + Microsoft.Extensions.Configuration.IConfiguration configuration) { - #region Constructors + var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; - public EntityFrameworkMigrationConfiguration(string parentPrefix, - Microsoft.Extensions.Configuration.IConfiguration configuration) - { - var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; - - AutoMigrate = configuration.GetValue($"{prefix}:{nameof(AutoMigrate)}"); - } - - #endregion - - #region IMigrationConfiguration - - public bool AutoMigrate { get; } - - #endregion + AutoMigrate = configuration.GetValue($"{prefix}:{nameof(AutoMigrate)}"); } + + #endregion + + #region IMigrationConfiguration + + public bool AutoMigrate { get; } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenApiSecurityScheme.cs b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenApiSecurityScheme.cs index a619569..694e1c5 100644 --- a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenApiSecurityScheme.cs +++ b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenApiSecurityScheme.cs @@ -2,33 +2,32 @@ using Microsoft.Net.Http.Headers; using Microsoft.OpenApi.Models; -namespace GerstITS.Examples.Api.Configurations +namespace GerstITS.Examples.Api.Configurations; + +internal sealed class OpenApiSecuritySchemeConfiguration : IOpenApiSecuritySchemeConfiguration { - internal sealed class OpenApiSecuritySchemeConfiguration : IOpenApiSecuritySchemeConfiguration + #region Properties + + public bool AllowAnonymous { get; } + public string HttpHeaderKey { get; } + public string Scheme { get; } + public SecuritySchemeType SchemeType { get; } + public ParameterLocation ParameterLocation { get; } + public string Description { get; } + + #endregion + + #region Constructors + + public OpenApiSecuritySchemeConfiguration() { - #region Properties + AllowAnonymous = false; + HttpHeaderKey = HeaderNames.Authorization; + Scheme = "Bearer"; + SchemeType = SecuritySchemeType.Http; + ParameterLocation = ParameterLocation.Header; + Description = "Authorization header using the Bearer scheme (Value: Bearer {{access_token}})."; + } - public bool AllowAnonymous { get; } - public string HttpHeaderKey { get; } - public string Scheme { get; } - public SecuritySchemeType SchemeType { get; } - public ParameterLocation ParameterLocation { get; } - public string Description { get; } - - #endregion - - #region Constructors - - public OpenApiSecuritySchemeConfiguration() - { - AllowAnonymous = false; - HttpHeaderKey = HeaderNames.Authorization; - Scheme = "Bearer"; - SchemeType = SecuritySchemeType.Http; - ParameterLocation = ParameterLocation.Header; - Description = "Authorization header using the Bearer scheme (Value: Bearer {{access_token}})."; - } - - #endregion - } + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenId.Validation.cs b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenId.Validation.cs index b00032e..264b8e6 100644 --- a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenId.Validation.cs +++ b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenId.Validation.cs @@ -1,34 +1,33 @@ using GerstITS.Authentication.OpenId; using Microsoft.Extensions.Configuration; -namespace GerstITS.Examples.Api.Configurations +namespace GerstITS.Examples.Api.Configurations; + +internal class OpenIdValidationConfiguration : IOpenIdValidationConfiguration { - internal class OpenIdValidationConfiguration : IOpenIdValidationConfiguration + #region Constructors + + public OpenIdValidationConfiguration(string parentPrefix, + IConfiguration configuration) { - #region Constructors + var prefix = $"{parentPrefix}:Validate"; - public OpenIdValidationConfiguration(string parentPrefix, - IConfiguration configuration) - { - var prefix = $"{parentPrefix}:Validate"; - - Issuer = configuration.GetValue($"{prefix}:{nameof(Issuer)}"); - Audience = configuration.GetValue($"{prefix}:{nameof(Audience)}"); - RsaPublicKey = configuration.GetValue($"{prefix}:{nameof(RsaPublicKey)}"); - RequiredClaimType = configuration.GetValue($"{prefix}:{nameof(RequiredClaimType)}"); - ValidateLifetime = configuration.GetValue($"{prefix}:{nameof(ValidateLifetime)}"); - } - - #endregion - - #region IOpenIdValidationConfiguration - - public string Issuer { get; } - public string Audience { get; } - public string RsaPublicKey { get; } - public string RequiredClaimType { get; } - public bool ValidateLifetime { get; } - - #endregion + Issuer = configuration.GetValue($"{prefix}:{nameof(Issuer)}"); + Audience = configuration.GetValue($"{prefix}:{nameof(Audience)}"); + RsaPublicKey = configuration.GetValue($"{prefix}:{nameof(RsaPublicKey)}"); + RequiredClaimType = configuration.GetValue($"{prefix}:{nameof(RequiredClaimType)}"); + ValidateLifetime = configuration.GetValue($"{prefix}:{nameof(ValidateLifetime)}"); } + + #endregion + + #region IOpenIdValidationConfiguration + + public string Issuer { get; } + public string Audience { get; } + public string RsaPublicKey { get; } + public string RequiredClaimType { get; } + public bool ValidateLifetime { get; } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenId.cs b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenId.cs index d4e173b..8fdfebc 100644 --- a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenId.cs +++ b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenId.cs @@ -2,34 +2,33 @@ using GerstITS.System.Configurations; using Microsoft.Extensions.Configuration; -namespace GerstITS.Examples.Api.Configurations +namespace GerstITS.Examples.Api.Configurations; + +internal class OpenIdConfiguration : IOpenIdConfiguration { - internal class OpenIdConfiguration : IOpenIdConfiguration + #region Constructors + + public OpenIdConfiguration(string parentPrefix, + Microsoft.Extensions.Configuration.IConfiguration configuration) { - #region Constructors + var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; - public OpenIdConfiguration(string parentPrefix, - Microsoft.Extensions.Configuration.IConfiguration configuration) - { - var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; + Authority = configuration.GetValue($"{prefix}:{nameof(Authority)}"); + RequireHttpsMetadata = configuration.GetValue($"{prefix}:{nameof(RequireHttpsMetadata)}"); + SaveToken = configuration.GetValue($"{prefix}:{nameof(SaveToken)}"); - Authority = configuration.GetValue($"{prefix}:{nameof(Authority)}"); - RequireHttpsMetadata = configuration.GetValue($"{prefix}:{nameof(RequireHttpsMetadata)}"); - SaveToken = configuration.GetValue($"{prefix}:{nameof(SaveToken)}"); - - Validate = new OpenIdValidationConfiguration(prefix, configuration); - } + Validate = new OpenIdValidationConfiguration(prefix, configuration); + } - #endregion + #endregion - #region IOpenIdConfiguration + #region IOpenIdConfiguration - public string Authority { get; } - public bool RequireHttpsMetadata { get; } - public bool SaveToken { get; } + public string Authority { get; } + public bool RequireHttpsMetadata { get; } + public bool SaveToken { get; } - public IOpenIdValidationConfiguration Validate { get; } + public IOpenIdValidationConfiguration Validate { get; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Server.CorsPolicy.cs b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Server.CorsPolicy.cs index 7f42d0d..58e285b 100644 --- a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Server.CorsPolicy.cs +++ b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Server.CorsPolicy.cs @@ -2,31 +2,30 @@ using GerstITS.Web.Api.Builder; using Microsoft.Extensions.Configuration; -namespace GerstITS.Examples.Api.Configurations +namespace GerstITS.Examples.Api.Configurations; + +internal sealed class CorsPolicyConfiguration : ICorsPolicy, GerstITS.System.Configurations.IConfiguration { - internal sealed class CorsPolicyConfiguration : ICorsPolicy, GerstITS.System.Configurations.IConfiguration + #region Constructors + + public CorsPolicyConfiguration(string parentPrefix, Microsoft.Extensions.Configuration.IConfiguration configuration) { - #region Constructors + var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; - public CorsPolicyConfiguration(string parentPrefix, Microsoft.Extensions.Configuration.IConfiguration configuration) - { - var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; - - AllowCredentials = configuration.GetValue($"{prefix}:{nameof(AllowCredentials)}", false); - AllowedOrigins = configuration.GetSection($"{prefix}:{nameof(AllowedOrigins)}").Get() ?? new string[0]; - AllowedHeaders = configuration.GetSection($"{prefix}:{nameof(AllowedHeaders)}").Get() ?? new string[0]; - AllowedMethods = configuration.GetSection($"{prefix}:{nameof(AllowedMethods)}").Get() ?? new string[0]; - } - - #endregion - - #region ICorsPolicy - - public bool AllowCredentials { get; } - public string[] AllowedOrigins { get; set; } - public string[] AllowedHeaders { get; set; } - public string[] AllowedMethods { get; set; } - - #endregion + AllowCredentials = configuration.GetValue($"{prefix}:{nameof(AllowCredentials)}", false); + AllowedOrigins = configuration.GetSection($"{prefix}:{nameof(AllowedOrigins)}").Get() ?? new string[0]; + AllowedHeaders = configuration.GetSection($"{prefix}:{nameof(AllowedHeaders)}").Get() ?? new string[0]; + AllowedMethods = configuration.GetSection($"{prefix}:{nameof(AllowedMethods)}").Get() ?? new string[0]; } + + #endregion + + #region ICorsPolicy + + public bool AllowCredentials { get; } + public string[] AllowedOrigins { get; set; } + public string[] AllowedHeaders { get; set; } + public string[] AllowedMethods { get; set; } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Server.Headers.cs b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Server.Headers.cs index a1a874a..01b5061 100644 --- a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Server.Headers.cs +++ b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Server.Headers.cs @@ -3,28 +3,27 @@ using GerstITS.Web.Api.Builder; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.HttpOverrides; -namespace GerstITS.Examples.Api.Configurations +namespace GerstITS.Examples.Api.Configurations; + +internal sealed class WebApiHeadersConfiguration : IHeaderConfiguration, IConfiguration { - internal sealed class WebApiHeadersConfiguration : IHeaderConfiguration, IConfiguration + #region Constructors + + public WebApiHeadersConfiguration(string parentPrefix, Microsoft.Extensions.Configuration.IConfiguration configuration) { - #region Constructors + var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; - public WebApiHeadersConfiguration(string parentPrefix, Microsoft.Extensions.Configuration.IConfiguration configuration) + ForwardedHeaders = new ForwardedHeadersOptions { - var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; - - ForwardedHeaders = new ForwardedHeadersOptions - { - ForwardedHeaders = configuration.GetFlaggedEnum($"{prefix}:{nameof(ForwardedHeadersOptions)}:{nameof(ForwardedHeadersOptions.ForwardedHeaders)}") - }; - } - - #endregion - - #region IHeaderConfiguration - - public ForwardedHeadersOptions ForwardedHeaders { get; } - - #endregion + ForwardedHeaders = configuration.GetFlaggedEnum($"{prefix}:{nameof(ForwardedHeadersOptions)}:{nameof(ForwardedHeadersOptions.ForwardedHeaders)}") + }; } + + #endregion + + #region IHeaderConfiguration + + public ForwardedHeadersOptions ForwardedHeaders { get; } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Server.cs b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Server.cs index 2a4fd28..fd41a4e 100644 --- a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Server.cs +++ b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Server.cs @@ -2,34 +2,33 @@ using GerstITS.Web.Api.Builder; using Microsoft.Extensions.Configuration; -namespace GerstITS.Examples.Api.Configurations +namespace GerstITS.Examples.Api.Configurations; + +internal sealed class ServerConfiguration : IServerConfiguration { - internal sealed class ServerConfiguration : IServerConfiguration + #region Constructors + + public ServerConfiguration(string parentPrefix, Microsoft.Extensions.Configuration.IConfiguration configuration) { - #region Constructors + var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; - public ServerConfiguration(string parentPrefix, Microsoft.Extensions.Configuration.IConfiguration configuration) - { - var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; + UseHttpsRedirection = configuration.GetValue($"{prefix}:{nameof(UseHttpsRedirection)}"); + UseHsts = configuration.GetValue($"{prefix}:{nameof(UseHsts)}"); + UseCors = configuration.GetValue($"{prefix}:{nameof(UseCors)}"); - UseHttpsRedirection = configuration.GetValue($"{prefix}:{nameof(UseHttpsRedirection)}"); - UseHsts = configuration.GetValue($"{prefix}:{nameof(UseHsts)}"); - UseCors = configuration.GetValue($"{prefix}:{nameof(UseCors)}"); - - Headers = new WebApiHeadersConfiguration(prefix, configuration); - CorsPolicy = new CorsPolicyConfiguration(prefix, configuration); - } - - #endregion - - #region IServerConfiguration - - public bool UseHttpsRedirection { get; } - public bool UseHsts { get; } - public bool UseCors { get; } - public IHeaderConfiguration Headers { get; } - public ICorsPolicy CorsPolicy { get; } - - #endregion + Headers = new WebApiHeadersConfiguration(prefix, configuration); + CorsPolicy = new CorsPolicyConfiguration(prefix, configuration); } + + #endregion + + #region IServerConfiguration + + public bool UseHttpsRedirection { get; } + public bool UseHsts { get; } + public bool UseCors { get; } + public IHeaderConfiguration Headers { get; } + public ICorsPolicy CorsPolicy { get; } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Swagger.License.cs b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Swagger.License.cs index 45a1660..236e029 100644 --- a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Swagger.License.cs +++ b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Swagger.License.cs @@ -3,27 +3,26 @@ using GerstITS.System.Configurations; using GerstITS.Web.Api.Swagger; using Microsoft.Extensions.Configuration; -namespace GerstITS.Examples.Api.Configurations +namespace GerstITS.Examples.Api.Configurations; + +internal sealed class LicenseConfiguration : ILicense, System.Configurations.IConfiguration { - internal sealed class LicenseConfiguration : ILicense, System.Configurations.IConfiguration + #region Constructors + + public LicenseConfiguration(string parentPrefix, Microsoft.Extensions.Configuration.IConfiguration configuration) { - #region Constructors + var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; - public LicenseConfiguration(string parentPrefix, Microsoft.Extensions.Configuration.IConfiguration configuration) - { - var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; - - Name = configuration.GetValue($"{prefix}:{nameof(Name)}"); - Url = configuration.GetValue($"{prefix}:{nameof(Url)}"); - } + Name = configuration.GetValue($"{prefix}:{nameof(Name)}"); + Url = configuration.GetValue($"{prefix}:{nameof(Url)}"); + } - #endregion + #endregion - #region ILicence + #region ILicence - public string Name { get; } - public Uri Url { get; } + public string Name { get; } + public Uri Url { get; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Swagger.cs b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Swagger.cs index fd18ea6..da44c8b 100644 --- a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Swagger.cs +++ b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Swagger.cs @@ -4,42 +4,41 @@ using GerstITS.System.Configurations; using GerstITS.Web.Api.Swagger; using Microsoft.Extensions.Configuration; -namespace GerstITS.Examples.Api.Configurations +namespace GerstITS.Examples.Api.Configurations; + +internal sealed class SwaggerConfiguration : ISwaggerConfiguration { - internal sealed class SwaggerConfiguration : ISwaggerConfiguration + #region Constructors + + public SwaggerConfiguration(string parentPrefix, + Microsoft.Extensions.Configuration.IConfiguration configuration) { - #region Constructors + var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; - public SwaggerConfiguration(string parentPrefix, - Microsoft.Extensions.Configuration.IConfiguration configuration) - { - var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; + var currentAssembly = typeof(WebApiConfiguration).Assembly; + var fileVersionInfo = FileVersionInfo.GetVersionInfo(currentAssembly.Location); - var currentAssembly = typeof(WebApiConfiguration).Assembly; - var fileVersionInfo = FileVersionInfo.GetVersionInfo(currentAssembly.Location); + Name = fileVersionInfo.ProductName; + Company = fileVersionInfo.CompanyName; + SupportEMail = configuration.GetValue($"{prefix}:{nameof(SupportEMail)}"); + TermsOfService = configuration.GetValue($"{prefix}:{nameof(TermsOfService)}"); - Name = fileVersionInfo.ProductName; - Company = fileVersionInfo.CompanyName; - SupportEMail = configuration.GetValue($"{prefix}:{nameof(SupportEMail)}"); - TermsOfService = configuration.GetValue($"{prefix}:{nameof(TermsOfService)}"); - - Release = currentAssembly.GetName().Version; - License = new LicenseConfiguration(prefix, configuration); - Security = new OpenApiSecuritySchemeConfiguration(); - } - - #endregion - - #region ISwaggerConfiguration - - public string Name { get; } - public string Company { get; } - public string SupportEMail { get; } - public Uri TermsOfService { get; } - public Version Release { get; } - public ILicense License { get; } - public IOpenApiSecuritySchemeConfiguration Security { get; } - - #endregion + Release = currentAssembly.GetName().Version; + License = new LicenseConfiguration(prefix, configuration); + Security = new OpenApiSecuritySchemeConfiguration(); } + + #endregion + + #region ISwaggerConfiguration + + public string Name { get; } + public string Company { get; } + public string SupportEMail { get; } + public Uri TermsOfService { get; } + public Version Release { get; } + public ILicense License { get; } + public IOpenApiSecuritySchemeConfiguration Security { get; } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.cs b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.cs index 9ef7723..1b98792 100644 --- a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.cs +++ b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.cs @@ -4,31 +4,30 @@ using GerstITS.System.Configurations; using GerstITS.Web.Api.Builder; using GerstITS.Web.Api.Swagger; -namespace GerstITS.Examples.Api.Configurations +namespace GerstITS.Examples.Api.Configurations; + +internal sealed class WebApiConfiguration : IConfiguration { - internal sealed class WebApiConfiguration : IConfiguration + #region Properties + + public IServerConfiguration Server { get; } + public IOpenIdConfiguration OpenId { get; } + public ISwaggerConfiguration Swagger { get; set; } + public IEntityFrameworkMigrationConfiguration EntityFrameworkMigration { get; set; } + + #endregion + + #region Constructors + + public WebApiConfiguration(Microsoft.Extensions.Configuration.IConfiguration configuration) { - #region Properties + var prefix = this.ToConfigurationPrefix(); - public IServerConfiguration Server { get; } - public IOpenIdConfiguration OpenId { get; } - public ISwaggerConfiguration Swagger { get; set; } - public IEntityFrameworkMigrationConfiguration EntityFrameworkMigration { get; set; } - - #endregion - - #region Constructors - - public WebApiConfiguration(Microsoft.Extensions.Configuration.IConfiguration configuration) - { - var prefix = this.ToConfigurationPrefix(); - - EntityFrameworkMigration = new EntityFrameworkMigrationConfiguration(prefix, configuration); - OpenId = new OpenIdConfiguration(prefix, configuration); - Server = new ServerConfiguration(prefix, configuration); - Swagger = new SwaggerConfiguration(prefix, configuration); - } - - #endregion + EntityFrameworkMigration = new EntityFrameworkMigrationConfiguration(prefix, configuration); + OpenId = new OpenIdConfiguration(prefix, configuration); + Server = new ServerConfiguration(prefix, configuration); + Swagger = new SwaggerConfiguration(prefix, configuration); } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/EntityNotFoundExceptionTransformation.cs b/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/EntityNotFoundExceptionTransformation.cs index 40ef533..db60277 100644 --- a/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/EntityNotFoundExceptionTransformation.cs +++ b/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/EntityNotFoundExceptionTransformation.cs @@ -2,18 +2,17 @@ using GerstITS.Data; using GerstITS.Web.Api.ExceptionHandling; -namespace GerstITS.Examples.Api.ExceptionHandling +namespace GerstITS.Examples.Api.ExceptionHandling; + +public class EntityNotFoundExceptionTransformation : ExceptionTransformationBase { - public class EntityNotFoundExceptionTransformation : ExceptionTransformationBase + protected override ExceptionTransformationInfo CreateExceptionTransformationInfo(EntityNotFoundException exception, string ticketId) { - protected override ExceptionTransformationInfo CreateExceptionTransformationInfo(EntityNotFoundException exception, string ticketId) + return new ExceptionTransformationInfo { - return new ExceptionTransformationInfo - { - StatusCode = HttpStatusCode.NotFound, - ReasonPhrase = "Enitity nicht gefunden", - Details = exception.Message - }; - } + StatusCode = HttpStatusCode.NotFound, + ReasonPhrase = "Enitity nicht gefunden", + Details = exception.Message + }; } -} +} \ No newline at end of file diff --git a/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/ValidationExceptionTransformation.cs b/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/ValidationExceptionTransformation.cs index c04002e..36f3853 100644 --- a/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/ValidationExceptionTransformation.cs +++ b/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/ValidationExceptionTransformation.cs @@ -2,22 +2,21 @@ using System.Net; using GerstITS.Web.Api.ExceptionHandling; -namespace GerstITS.Examples.Api.ExceptionHandling -{ - internal sealed class ValidationExceptionTransformation : ExceptionTransformationBase - { - #region Methods +namespace GerstITS.Examples.Api.ExceptionHandling; - protected override ExceptionTransformationInfo CreateExceptionTransformationInfo(ValidationException exception, string ticketId) +internal sealed class ValidationExceptionTransformation : ExceptionTransformationBase +{ + #region Methods + + protected override ExceptionTransformationInfo CreateExceptionTransformationInfo(ValidationException exception, string ticketId) + { + return new ExceptionTransformationInfo { - return new ExceptionTransformationInfo - { - StatusCode = HttpStatusCode.BadRequest, - ReasonPhrase = "Validierungsfehler", - Details = exception.Message - }; - } + StatusCode = HttpStatusCode.BadRequest, + ReasonPhrase = "Validierungsfehler", + Details = exception.Message + }; + } - #endregion - } -} + #endregion +} \ No newline at end of file diff --git a/GerstITS.Examples.Api/Common/StartupTasks/ExampleStartupTask.cs b/GerstITS.Examples.Api/Common/StartupTasks/ExampleStartupTask.cs index 786ab98..7aef036 100644 --- a/GerstITS.Examples.Api/Common/StartupTasks/ExampleStartupTask.cs +++ b/GerstITS.Examples.Api/Common/StartupTasks/ExampleStartupTask.cs @@ -3,37 +3,36 @@ using GerstITS.Examples.Logic.Example; using GerstITS.IoC; using GerstITS.System.Json; -namespace GerstITS.Examples.Api.StartupTasks +namespace GerstITS.Examples.Api.StartupTasks; + +internal class ExampleStartupTask : IStartupTask { - internal class ExampleStartupTask : IStartupTask + #region Fields# + + private readonly IExampleProvider _provider; + private readonly IJsonConvert _jsonConvert; + + #endregion + + #region Construtcors + + public ExampleStartupTask(IExampleProvider provider, + IJsonConvert jsonConvert) { - #region Fields# - - private readonly IExampleProvider _provider; - private readonly IJsonConvert _jsonConvert; - - #endregion - - #region Construtcors - - public ExampleStartupTask(IExampleProvider provider, - IJsonConvert jsonConvert) - { - _jsonConvert = jsonConvert; - _provider = provider; - } - - #endregion - - #region IStartupTask - - public StartupPriorities Priority => StartupPriorities.Normal; - - public void Execute() - { - Debug.WriteLine($"---> {nameof(ExampleStartupTask)}: {_jsonConvert.Serialize(_provider.GetById(123))}"); - } - - #endregion + _jsonConvert = jsonConvert; + _provider = provider; } -} + + #endregion + + #region IStartupTask + + public StartupPriorities Priority => StartupPriorities.Normal; + + public void Execute() + { + Debug.WriteLine($"---> {nameof(ExampleStartupTask)}: {_jsonConvert.Serialize(_provider.GetById(123))}"); + } + + #endregion +} \ No newline at end of file diff --git a/GerstITS.Examples.Api/Common/Versioning/Versions.cs b/GerstITS.Examples.Api/Common/Versioning/Versions.cs index 14522f3..0feca3b 100644 --- a/GerstITS.Examples.Api/Common/Versioning/Versions.cs +++ b/GerstITS.Examples.Api/Common/Versioning/Versions.cs @@ -1,12 +1,11 @@ -namespace GerstITS.Examples.Api.Versioning +namespace GerstITS.Examples.Api.Versioning; + +public static class Versions { - public static class Versions - { - #region Versions + #region Versions - public const string _1_0 = "1.0"; - public const string _1_1 = "1.1"; + public const string _1_0 = "1.0"; + public const string _1_1 = "1.1"; - #endregion - } + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Controllers/1.0/ExampleController.cs b/GerstITS.Examples.Api/Controllers/1.0/ExampleController.cs index 28df7a0..3678c84 100644 --- a/GerstITS.Examples.Api/Controllers/1.0/ExampleController.cs +++ b/GerstITS.Examples.Api/Controllers/1.0/ExampleController.cs @@ -5,48 +5,47 @@ using GerstITS.Web.Api; using GerstITS.Web.Api.FluentApi; using Microsoft.AspNetCore.Mvc; -namespace GerstITS.Examples.Api.Controllers +namespace GerstITS.Examples.Api.Controllers; + +/// +/// Controller is deprecated use newer version. +/// +[ApiController, + ApiVersion(Versions._1_0, Deprecated = true), + Route(ApplicationEnvironment.WebApi.ControllerRouteTemplate)] +public class ExampleController : FluentApiControllerBase { - /// - /// Controller is deprecated use newer version. - /// - [ApiController, - ApiVersion(Versions._1_0, Deprecated = true), - Route(ApplicationEnvironment.WebApi.ControllerRouteTemplate)] - public class ExampleController : FluentApiControllerBase - { - #region Fields + #region Fields - private readonly IExampleProvider _provider; + private readonly IExampleProvider _provider; - #endregion + #endregion - #region Constructors + #region Constructors - public ExampleController(IExampleProvider provider, - IValidator validator) - : base(validator) - { - _provider = provider; - } - - #endregion - - #region Methods - - /// - /// Gets the example data by id. - /// - /// - /// Returns Example data. - [HttpGet, - Route("{id}")] - public IActionResult Get(int id) - { - return Api().Use(id) - .Get(_provider.GetById); - } - - #endregion + public ExampleController(IExampleProvider provider, + IValidator validator) + : base(validator) + { + _provider = provider; } -} + + #endregion + + #region Methods + + /// + /// Gets the example data by id. + /// + /// + /// Returns Example data. + [HttpGet, + Route("{id}")] + public IActionResult Get(int id) + { + return Api().Use(id) + .Get(_provider.GetById); + } + + #endregion +} \ No newline at end of file diff --git a/GerstITS.Examples.Api/Controllers/1.1/ExampleController.cs b/GerstITS.Examples.Api/Controllers/1.1/ExampleController.cs index e18791b..7e57907 100644 --- a/GerstITS.Examples.Api/Controllers/1.1/ExampleController.cs +++ b/GerstITS.Examples.Api/Controllers/1.1/ExampleController.cs @@ -5,48 +5,47 @@ using GerstITS.Web.Api; using GerstITS.Web.Api.FluentApi; using Microsoft.AspNetCore.Mvc; -namespace GerstITS.Examples.Api.Controllers._1._1 +namespace GerstITS.Examples.Api.Controllers._1._1; + +/// +/// Is responsible to get employee organization assignment examples. +/// +[ApiController, + ApiVersion(Versions._1_1), + Route(ApplicationEnvironment.WebApi.ControllerRouteTemplate)] +public class ExampleController : FluentApiControllerBase { - /// - /// Is responsible to get employee organization assignment examples. - /// - [ApiController, - ApiVersion(Versions._1_1), - Route(ApplicationEnvironment.WebApi.ControllerRouteTemplate)] - public class ExampleController : FluentApiControllerBase - { - #region Fields + #region Fields - private readonly IExampleProvider _provider; + private readonly IExampleProvider _provider; - #endregion + #endregion - #region Constructors + #region Constructors - public ExampleController(IExampleProvider provider, - IValidator validator) - : base(validator) - { - _provider = provider; - } - - #endregion - - #region Methods - - /// - /// Gets a employee organization assignment by specified id. - /// - /// Id of the employee organization assignment. - /// Returns an employee organization assignment - [HttpGet, - Route("{id}")] - public IActionResult Get(int id) - { - return Api().Use(id) - .Get(_provider.GetById_v1_1); - } - - #endregion + public ExampleController(IExampleProvider provider, + IValidator validator) + : base(validator) + { + _provider = provider; } -} + + #endregion + + #region Methods + + /// + /// Gets a employee organization assignment by specified id. + /// + /// Id of the employee organization assignment. + /// Returns an employee organization assignment + [HttpGet, + Route("{id}")] + public IActionResult Get(int id) + { + return Api().Use(id) + .Get(_provider.GetById_v1_1); + } + + #endregion +} \ No newline at end of file diff --git a/GerstITS.Examples.Api/Module.Configurations.cs b/GerstITS.Examples.Api/Module.Configurations.cs index 7f7c915..fb61f02 100644 --- a/GerstITS.Examples.Api/Module.Configurations.cs +++ b/GerstITS.Examples.Api/Module.Configurations.cs @@ -1,22 +1,21 @@ using GerstITS.Examples.Api.Configurations; using Microsoft.Extensions.DependencyInjection; -namespace GerstITS.Examples.Api +namespace GerstITS.Examples.Api; + +public sealed partial class Module { - public sealed partial class Module + #region Methods + + private static void RegisterConfigurations(IServiceCollection container) { - #region Methods + container.AddSingleton(); - private static void RegisterConfigurations(IServiceCollection container) - { - container.AddSingleton(); - - container.AddSingleton(c => c.GetService().EntityFrameworkMigration); - container.AddSingleton(c => c.GetService().OpenId); - container.AddSingleton(c => c.GetService().Server); - container.AddSingleton(c => c.GetService().Swagger); - } - - #endregion + container.AddSingleton(c => c.GetService().EntityFrameworkMigration); + container.AddSingleton(c => c.GetService().OpenId); + container.AddSingleton(c => c.GetService().Server); + container.AddSingleton(c => c.GetService().Swagger); } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Module.ExceptionHandling.cs b/GerstITS.Examples.Api/Module.ExceptionHandling.cs index 4a60561..da951a7 100644 --- a/GerstITS.Examples.Api/Module.ExceptionHandling.cs +++ b/GerstITS.Examples.Api/Module.ExceptionHandling.cs @@ -2,17 +2,16 @@ using GerstITS.Web.Api.ExceptionHandling.Extensions; using Microsoft.Extensions.DependencyInjection; -namespace GerstITS.Examples.Api +namespace GerstITS.Examples.Api; + +public sealed partial class Module { - public sealed partial class Module + #region Methods + + private static void RegisterExceptionHandling(IServiceCollection container) { - #region Methods - - private static void RegisterExceptionHandling(IServiceCollection container) - { - container.RegisterExceptionTransformationsOf(); - } - - #endregion + container.RegisterExceptionTransformationsOf(); } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Module.Mvc.cs b/GerstITS.Examples.Api/Module.Mvc.cs index 92a9f82..3ae7880 100644 --- a/GerstITS.Examples.Api/Module.Mvc.cs +++ b/GerstITS.Examples.Api/Module.Mvc.cs @@ -1,21 +1,20 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; -namespace GerstITS.Examples.Api +namespace GerstITS.Examples.Api; + +public sealed partial class Module { - public sealed partial class Module + #region Methods + + private static void RegisterMvc(IServiceCollection container) { - #region Methods + //container.AddTransient, ApiMvcOptions>(); + //container.AddTransient, MvcJsonOptions>(); - private static void RegisterMvc(IServiceCollection container) - { - //container.AddTransient, ApiMvcOptions>(); - //container.AddTransient, MvcJsonOptions>(); - - container.AddMvc() - .AddNewtonsoftJson(); - } - - #endregion + container.AddMvc() + .AddNewtonsoftJson(); } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Module.StartupTasks.cs b/GerstITS.Examples.Api/Module.StartupTasks.cs index 7295fd7..bd1d687 100644 --- a/GerstITS.Examples.Api/Module.StartupTasks.cs +++ b/GerstITS.Examples.Api/Module.StartupTasks.cs @@ -2,17 +2,16 @@ using GerstITS.IoC.DotNetCore; using Microsoft.Extensions.DependencyInjection; -namespace GerstITS.Examples.Api +namespace GerstITS.Examples.Api; + +public sealed partial class Module { - public sealed partial class Module + #region Methods + + private static void RegisterStartupTasks(IServiceCollection container) { - #region Methods - - private static void RegisterStartupTasks(IServiceCollection container) - { - container.RegisterStartupTasksOf(); - } - - #endregion + container.RegisterStartupTasksOf(); } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Module.cs b/GerstITS.Examples.Api/Module.cs index f166407..5c44be6 100644 --- a/GerstITS.Examples.Api/Module.cs +++ b/GerstITS.Examples.Api/Module.cs @@ -1,20 +1,19 @@ using GerstITS.IoC; using Microsoft.Extensions.DependencyInjection; -namespace GerstITS.Examples.Api +namespace GerstITS.Examples.Api; + +public sealed partial class Module : IIoCModule { - public sealed partial class Module : IIoCModule + #region IIoCModule + + public void RegisterComponents(IServiceCollection container) { - #region IIoCModule - - public void RegisterComponents(IServiceCollection container) - { - RegisterConfigurations(container); - RegisterExceptionHandling(container); - RegisterMvc(container); - RegisterStartupTasks(container); - } - - #endregion + RegisterConfigurations(container); + RegisterExceptionHandling(container); + RegisterMvc(container); + RegisterStartupTasks(container); } -} + + #endregion +} \ No newline at end of file diff --git a/GerstITS.Examples.Api/Program.cs b/GerstITS.Examples.Api/Program.cs index 162368d..87b0f28 100644 --- a/GerstITS.Examples.Api/Program.cs +++ b/GerstITS.Examples.Api/Program.cs @@ -1,23 +1,22 @@ using GerstITS.Logging.Serilog; using GerstITS.Web.Api.Hosting; -namespace GerstITS.Examples.Api +namespace GerstITS.Examples.Api; + +public class Program : ProgramBase { - public class Program : ProgramBase + #region Methods + + public static void Main(string[] args) { - #region Methods - - public static void Main(string[] args) - { - BootstrapLogContext.Execute(_ => Run(args)); - } - - protected override void ConfigureWebHost(IWebHostBuilder webHostBuilder) - { - webHostBuilder.UseLogging() - .UseStartup(); - } - - #endregion + BootstrapLogContext.Execute(_ => Run(args)); } -} + + protected override void ConfigureWebHost(IWebHostBuilder webHostBuilder) + { + webHostBuilder.UseLogging() + .UseStartup(); + } + + #endregion +} \ No newline at end of file diff --git a/GerstITS.Examples.Api/Startup.cs b/GerstITS.Examples.Api/Startup.cs index 8ae7cd2..35fdf4a 100644 --- a/GerstITS.Examples.Api/Startup.cs +++ b/GerstITS.Examples.Api/Startup.cs @@ -4,31 +4,30 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; -namespace GerstITS.Examples.Api +namespace GerstITS.Examples.Api; + +public class Startup : BootstrapperStartupBase { - public class Startup : BootstrapperStartupBase + #region Methods + + protected override void ConfigureApplication(IApplicationBuilder applicationBuilder, IWebHostEnvironment webHostEnvironment) { - #region Methods + if (webHostEnvironment.IsProduction()) + applicationBuilder.UsePreconfiguredHsts(); + else + applicationBuilder.UseDeveloperExceptionPage() + .UseSwagger(); - protected override void ConfigureApplication(IApplicationBuilder applicationBuilder, IWebHostEnvironment webHostEnvironment) - { - if (webHostEnvironment.IsProduction()) - applicationBuilder.UsePreconfiguredHsts(); - else - applicationBuilder.UseDeveloperExceptionPage() - .UseSwagger(); - - applicationBuilder.UsePreconfiguredCors() - .UsePreconfiguredForwardedHeaders() - .UsePreconfiguredHttpsRedirection() - .UseAuthentication() - .UseAuthorization() - .UseRouting() - .UseEndpoints(endpoints => endpoints.MapControllers()) - .UseRewriteUnknownPathsToIndexSite(ApplicationEnvironment.WebApi.BaseUrl) - .UseSystemIndependentStaticFiles(); - } - - #endregion + applicationBuilder.UsePreconfiguredCors() + .UsePreconfiguredForwardedHeaders() + .UsePreconfiguredHttpsRedirection() + .UseAuthentication() + .UseAuthorization() + .UseRouting() + .UseEndpoints(endpoints => endpoints.MapControllers()) + .UseRewriteUnknownPathsToIndexSite(ApplicationEnvironment.WebApi.BaseUrl) + .UseSystemIndependentStaticFiles(); } -} + + #endregion +} \ No newline at end of file diff --git a/GerstITS.Examples.Jobs.SayHelloWorld/Configurations/SayHelloWorldJobConfiguration.cs b/GerstITS.Examples.Jobs.SayHelloWorld/Configurations/SayHelloWorldJobConfiguration.cs index c95e031..a5d1cb3 100644 --- a/GerstITS.Examples.Jobs.SayHelloWorld/Configurations/SayHelloWorldJobConfiguration.cs +++ b/GerstITS.Examples.Jobs.SayHelloWorld/Configurations/SayHelloWorldJobConfiguration.cs @@ -1,16 +1,15 @@ using GerstITS.Job.Scheduling; -namespace GerstITS.Examples.Jobs.SayHelloWorld.Configurations -{ - public class SayHelloWorldJobConfiguration : JobSchedulingConfigurationBase - { - #region Constructors +namespace GerstITS.Examples.Jobs.SayHelloWorld.Configurations; - public SayHelloWorldJobConfiguration(Microsoft.Extensions.Configuration.IConfiguration configuration) - : base(configuration) - { - } +public class SayHelloWorldJobConfiguration : JobSchedulingConfigurationBase +{ + #region Constructors + + public SayHelloWorldJobConfiguration(Microsoft.Extensions.Configuration.IConfiguration configuration) + : base(configuration) + { + } - #endregion - } + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Jobs.SayHelloWorld/Jobs/SayHelloWorldJob.cs b/GerstITS.Examples.Jobs.SayHelloWorld/Jobs/SayHelloWorldJob.cs index 18e53f5..9ca3838 100644 --- a/GerstITS.Examples.Jobs.SayHelloWorld/Jobs/SayHelloWorldJob.cs +++ b/GerstITS.Examples.Jobs.SayHelloWorld/Jobs/SayHelloWorldJob.cs @@ -6,40 +6,39 @@ using GerstITS.Job; using GerstITS.System.Environment; using Quartz; -namespace GerstITS.Examples.Jobs.SayHelloWorld.Jobs +namespace GerstITS.Examples.Jobs.SayHelloWorld.Jobs; + +[DisallowConcurrentExecution] +public class SayHelloWorldJob : JobBase { - [DisallowConcurrentExecution] - public class SayHelloWorldJob : JobBase + #region Fields + + private readonly SayHelloWorldJobConfiguration _configuration; + private readonly Stopwatch _stopWatch; + + #endregion + + #region Cosntructors + + public SayHelloWorldJob(SayHelloWorldJobConfiguration configuration, + ISystemClock systemClock) { - #region Fields - - private readonly SayHelloWorldJobConfiguration _configuration; - private readonly Stopwatch _stopWatch; - - #endregion - - #region Cosntructors - - public SayHelloWorldJob(SayHelloWorldJobConfiguration configuration, - ISystemClock systemClock) - { - _configuration = configuration; - _stopWatch = new Stopwatch(); - } - - #endregion - - #region Methods - - protected override void Execute() - { - _stopWatch.Restart(); - Thread.Sleep(4000); - - _stopWatch.Stop(); - Debug.WriteLine($"---> Say hello to world from {_configuration.Name}, Duration: {_stopWatch.ElapsedMilliseconds / 1000}s"); - } - - #endregion + _configuration = configuration; + _stopWatch = new Stopwatch(); } + + #endregion + + #region Methods + + protected override void Execute() + { + _stopWatch.Restart(); + Thread.Sleep(4000); + + _stopWatch.Stop(); + Debug.WriteLine($"---> Say hello to world from {_configuration.Name}, Duration: {_stopWatch.ElapsedMilliseconds / 1000}s"); + } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Jobs.SayHelloWorld/Module.cs b/GerstITS.Examples.Jobs.SayHelloWorld/Module.cs index 0a506d7..f1a6a02 100644 --- a/GerstITS.Examples.Jobs.SayHelloWorld/Module.cs +++ b/GerstITS.Examples.Jobs.SayHelloWorld/Module.cs @@ -4,17 +4,16 @@ using GerstITS.IoC; using GerstITS.Job.Scheduling; using Microsoft.Extensions.DependencyInjection; -namespace GerstITS.Examples.Jobs.SayHelloWorld -{ - public sealed class Module : IIoCModule - { - #region IIoCModule +namespace GerstITS.Examples.Jobs.SayHelloWorld; - public void RegisterComponents(IServiceCollection container) - { - container.RegisterJob(); - } +public sealed class Module : IIoCModule +{ + #region IIoCModule + + public void RegisterComponents(IServiceCollection container) + { + container.RegisterJob(); + } - #endregion - } -} + #endregion +} \ No newline at end of file diff --git a/GerstITS.Examples.Logic/Example/Contracts/Example.cs b/GerstITS.Examples.Logic/Example/Contracts/Example.cs index b1151e0..fd8d71d 100644 --- a/GerstITS.Examples.Logic/Example/Contracts/Example.cs +++ b/GerstITS.Examples.Logic/Example/Contracts/Example.cs @@ -1,13 +1,12 @@ -namespace GerstITS.Examples.Logic.Example -{ - public class Example - { - #region Properties +namespace GerstITS.Examples.Logic.Example; - public string FirstName { get; set; } - public string LastName { get; set; } - public string Description { get; set; } +public class Example +{ + #region Properties + + public string FirstName { get; set; } + public string LastName { get; set; } + public string Description { get; set; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Logic/Example/Contracts/IExampleProvider.cs b/GerstITS.Examples.Logic/Example/Contracts/IExampleProvider.cs index e97a562..b72f616 100644 --- a/GerstITS.Examples.Logic/Example/Contracts/IExampleProvider.cs +++ b/GerstITS.Examples.Logic/Example/Contracts/IExampleProvider.cs @@ -1,8 +1,7 @@ -namespace GerstITS.Examples.Logic.Example +namespace GerstITS.Examples.Logic.Example; + +public interface IExampleProvider { - public interface IExampleProvider - { - Example GetById(int id); - Example GetById_v1_1(int id); - } -} + Example GetById(int id); + Example GetById_v1_1(int id); +} \ No newline at end of file diff --git a/GerstITS.Examples.Logic/Example/ExampleProvider.cs b/GerstITS.Examples.Logic/Example/ExampleProvider.cs index e986db0..599de51 100644 --- a/GerstITS.Examples.Logic/Example/ExampleProvider.cs +++ b/GerstITS.Examples.Logic/Example/ExampleProvider.cs @@ -1,51 +1,50 @@ using AutoMapper; using GerstITS.Data; -namespace GerstITS.Examples.Logic.Example +namespace GerstITS.Examples.Logic.Example; + +internal sealed class ExampleProvider : IExampleProvider { - internal sealed class ExampleProvider : IExampleProvider + #region Fields + + private readonly IMapper _mapper; + + #endregion + + #region Constructors + + public ExampleProvider(IMapper mapper) { - #region Fields - - private readonly IMapper _mapper; - - #endregion - - #region Constructors - - public ExampleProvider(IMapper mapper) - { - _mapper = mapper; - } - - #endregion - - #region IExampleProvider - - public Example GetById(int id) - { - ThrowsAnExceptionIfEntityIsNotFound(id); - - return _mapper.Map(id); - } - - public Example GetById_v1_1(int id) - { - ThrowsAnExceptionIfEntityIsNotFound(id); - - return _mapper.Map(id); - } - - #endregion - - #region Methods - - private static void ThrowsAnExceptionIfEntityIsNotFound(int id) - { - if (id % 2 == 0) - throw new EntityNotFoundException($"Example mit der Id '{id}' nicht gefunden."); - } - - #endregion + _mapper = mapper; } + + #endregion + + #region IExampleProvider + + public Example GetById(int id) + { + ThrowsAnExceptionIfEntityIsNotFound(id); + + return _mapper.Map(id); + } + + public Example GetById_v1_1(int id) + { + ThrowsAnExceptionIfEntityIsNotFound(id); + + return _mapper.Map(id); + } + + #endregion + + #region Methods + + private static void ThrowsAnExceptionIfEntityIsNotFound(int id) + { + if (id % 2 == 0) + throw new EntityNotFoundException($"Example mit der Id '{id}' nicht gefunden."); + } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Logic/Example/Mappings/IntegerMapping.cs b/GerstITS.Examples.Logic/Example/Mappings/IntegerMapping.cs index 8c87a6a..32badda 100644 --- a/GerstITS.Examples.Logic/Example/Mappings/IntegerMapping.cs +++ b/GerstITS.Examples.Logic/Example/Mappings/IntegerMapping.cs @@ -1,19 +1,18 @@ using AutoMapper; -namespace GerstITS.Examples.Logic.Example +namespace GerstITS.Examples.Logic.Example; + +internal sealed class IntegerMapping : Profile { - internal sealed class IntegerMapping : Profile + #region Construtcors + + public IntegerMapping() { - #region Construtcors - - public IntegerMapping() - { - CreateMap() - .ForMember(x => x.FirstName, m => m.MapFrom((s, _) => $"First Name {s}")) - .ForMember(x => x.LastName, m => m.MapFrom((s, _) => $"Last Name {s}")) - .ForMember(x => x.Description, m => m.MapFrom((s, _) => $"Useful description for id '{s}'")); - } - - #endregion + CreateMap() + .ForMember(x => x.FirstName, m => m.MapFrom((s, _) => $"First Name {s}")) + .ForMember(x => x.LastName, m => m.MapFrom((s, _) => $"Last Name {s}")) + .ForMember(x => x.Description, m => m.MapFrom((s, _) => $"Useful description for id '{s}'")); } -} + + #endregion +} \ No newline at end of file diff --git a/GerstITS.Examples.Logic/Module.Example.cs b/GerstITS.Examples.Logic/Module.Example.cs index 39e997a..b53388f 100644 --- a/GerstITS.Examples.Logic/Module.Example.cs +++ b/GerstITS.Examples.Logic/Module.Example.cs @@ -2,19 +2,18 @@ using GerstITS.Mapping.AutoMapper; using Microsoft.Extensions.DependencyInjection; -namespace GerstITS.Examples.Logic +namespace GerstITS.Examples.Logic; + +public sealed partial class Module { - public sealed partial class Module + #region Methods + + private static void RegisterExample(IServiceCollection container) { - #region Methods + container.RegisterMappingsOf(); - private static void RegisterExample(IServiceCollection container) - { - container.RegisterMappingsOf(); + container.AddScoped(); + } - container.AddScoped(); - } - - #endregion - } + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Logic/Module.Shared.cs b/GerstITS.Examples.Logic/Module.Shared.cs index 59c9c4f..6e7b4b2 100644 --- a/GerstITS.Examples.Logic/Module.Shared.cs +++ b/GerstITS.Examples.Logic/Module.Shared.cs @@ -4,19 +4,18 @@ using GerstITS.Search; using GerstITS.Validation; using Microsoft.Extensions.DependencyInjection; -namespace GerstITS.Examples.Logic +namespace GerstITS.Examples.Logic; + +public sealed partial class Module { - public sealed partial class Module + #region Methods + + private static void RegisterShared(IServiceCollection container) { - #region Methods + container.RegisterValidationRulesOf(); - private static void RegisterShared(IServiceCollection container) - { - container.RegisterValidationRulesOf(); + container.AddScoped(); + } - container.AddScoped(); - } - - #endregion - } + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Logic/Module.cs b/GerstITS.Examples.Logic/Module.cs index 7732508..01ca2e8 100644 --- a/GerstITS.Examples.Logic/Module.cs +++ b/GerstITS.Examples.Logic/Module.cs @@ -1,18 +1,17 @@ using GerstITS.IoC; using Microsoft.Extensions.DependencyInjection; -namespace GerstITS.Examples.Logic -{ - public sealed partial class Module : IIoCModule - { - #region IIoCModule +namespace GerstITS.Examples.Logic; - public void RegisterComponents(IServiceCollection container) - { - RegisterExample(container); - RegisterShared(container); - } +public sealed partial class Module : IIoCModule +{ + #region IIoCModule + + public void RegisterComponents(IServiceCollection container) + { + RegisterExample(container); + RegisterShared(container); + } - #endregion - } -} + #endregion +} \ No newline at end of file diff --git a/GerstITS.Examples.Logic/Shared/Extensions/IReadOnlyRepositoryExtensions.cs b/GerstITS.Examples.Logic/Shared/Extensions/IReadOnlyRepositoryExtensions.cs index fbd48de..0345dea 100644 --- a/GerstITS.Examples.Logic/Shared/Extensions/IReadOnlyRepositoryExtensions.cs +++ b/GerstITS.Examples.Logic/Shared/Extensions/IReadOnlyRepositoryExtensions.cs @@ -4,28 +4,27 @@ using System.Linq.Expressions; using GerstITS.Common; using GerstITS.Data; -namespace GerstITS.Examples.Logic.Shared +namespace GerstITS.Examples.Logic.Shared; + +internal static class ISearchEngineExtensions { - internal static class ISearchEngineExtensions + #region Methods + + public static TEntity QueryBy(this IReadOnlyRepository repository, Expression> condition) + where TEntity : IEntity { - #region Methods - - public static TEntity QueryBy(this IReadOnlyRepository repository, Expression> condition) - where TEntity : IEntity - { - return repository.Query() - .Where(condition) - .FirstOrDefault(); - } - - public static TModel ThrowsAnExceptionIfNotFound(this TModel model, TKey id) - { - if (model.IsNull()) - throw new EntityNotFoundException($"{typeof(TModel).Name} with id '{id}' not found."); - - return model; - } - - #endregion + return repository.Query() + .Where(condition) + .FirstOrDefault(); } + + public static TModel ThrowsAnExceptionIfNotFound(this TModel model, TKey id) + { + if (model.IsNull()) + throw new EntityNotFoundException($"{typeof(TModel).Name} with id '{id}' not found."); + + return model; + } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Logic/Shared/Search/Sorting/ISortable.cs b/GerstITS.Examples.Logic/Shared/Search/Sorting/ISortable.cs index 5b5ab28..c4ad0e9 100644 --- a/GerstITS.Examples.Logic/Shared/Search/Sorting/ISortable.cs +++ b/GerstITS.Examples.Logic/Shared/Search/Sorting/ISortable.cs @@ -1,6 +1,5 @@ -namespace GerstITS.Examples.Logic.Shared.Search.Sorting +namespace GerstITS.Examples.Logic.Shared.Search.Sorting; + +internal interface ISortable { - internal interface ISortable - { - } -} +} \ No newline at end of file diff --git a/GerstITS.Examples.Logic/Shared/Search/Sorting/SortingProvider.cs b/GerstITS.Examples.Logic/Shared/Search/Sorting/SortingProvider.cs index 7c0d332..fc3d39d 100644 --- a/GerstITS.Examples.Logic/Shared/Search/Sorting/SortingProvider.cs +++ b/GerstITS.Examples.Logic/Shared/Search/Sorting/SortingProvider.cs @@ -5,46 +5,45 @@ using System.Reflection; using GerstITS.Common; using GerstITS.Search; -namespace GerstITS.Examples.Logic.Shared.Search.Sorting +namespace GerstITS.Examples.Logic.Shared.Search.Sorting; + +internal class SortingProvider : ISortingProvider { - internal class SortingProvider : ISortingProvider + #region ISortingProvider + + public bool CanSort(IQueryable query) { - #region ISortingProvider - - public bool CanSort(IQueryable query) - { - return typeof(TItem).IsAssignableTo(typeof(ISortable)); - } - - public IQueryable Sort(IQueryable query, ISorting sorting) - { - var propertyInfo = typeof(TItem).GetProperties() - .SingleOrDefault(i => string.Equals(i.Name, sorting.SortBy, StringComparison.InvariantCultureIgnoreCase)); - - if (!CanSort(query) || propertyInfo.IsNull()) - return query; - - var sortExpression = CreateSortExpression(propertyInfo); - - return (sorting.SortDirection == SortingDirections.Ascending - ? query.OrderBy(sortExpression) - : query.OrderByDescending(sortExpression)) - .AsQueryable(); - } - - #endregion - - #region Methods - - private static Expression> CreateSortExpression(MemberInfo propertyInfo) - { - var parameterExpression = Expression.Parameter(typeof(TItem), "x"); - var propertyExpression = Expression.Property(parameterExpression, propertyInfo.Name); - var convertExpression = Expression.Convert(propertyExpression, typeof(object)); - - return Expression.Lambda>(convertExpression, parameterExpression); - } - - #endregion + return typeof(TItem).IsAssignableTo(typeof(ISortable)); } -} + + public IQueryable Sort(IQueryable query, ISorting sorting) + { + var propertyInfo = typeof(TItem).GetProperties() + .SingleOrDefault(i => string.Equals(i.Name, sorting.SortBy, StringComparison.InvariantCultureIgnoreCase)); + + if (!CanSort(query) || propertyInfo.IsNull()) + return query; + + var sortExpression = CreateSortExpression(propertyInfo); + + return (sorting.SortDirection == SortingDirections.Ascending + ? query.OrderBy(sortExpression) + : query.OrderByDescending(sortExpression)) + .AsQueryable(); + } + + #endregion + + #region Methods + + private static Expression> CreateSortExpression(MemberInfo propertyInfo) + { + var parameterExpression = Expression.Parameter(typeof(TItem), "x"); + var propertyExpression = Expression.Property(parameterExpression, propertyInfo.Name); + var convertExpression = Expression.Convert(propertyExpression, typeof(object)); + + return Expression.Lambda>(convertExpression, parameterExpression); + } + + #endregion +} \ No newline at end of file diff --git a/GerstITS.Examples.Logic/Shared/Validation/IdValidationRule.cs b/GerstITS.Examples.Logic/Shared/Validation/IdValidationRule.cs index 9333325..add0662 100644 --- a/GerstITS.Examples.Logic/Shared/Validation/IdValidationRule.cs +++ b/GerstITS.Examples.Logic/Shared/Validation/IdValidationRule.cs @@ -1,19 +1,18 @@ using FluentValidation; using GerstITS.Validation; -namespace GerstITS.Examples.Logic.Shared.Validation -{ - internal sealed class IdValidationRule : ValidationRuleBase - { - #region Constructors - - public IdValidationRule() - { - RuleFor(x => x) - .GreaterThan(0) - .OverridePropertyName("id"); - } +namespace GerstITS.Examples.Logic.Shared.Validation; - #endregion - } -} +internal sealed class IdValidationRule : ValidationRuleBase +{ + #region Constructors + + public IdValidationRule() + { + RuleFor(x => x) + .GreaterThan(0) + .OverridePropertyName("id"); + } + + #endregion +} \ No newline at end of file diff --git a/GerstITS.Examples.WebClient.Console/Module.cs b/GerstITS.Examples.WebClient.Console/Module.cs index 2ae07ed..2967078 100644 --- a/GerstITS.Examples.WebClient.Console/Module.cs +++ b/GerstITS.Examples.WebClient.Console/Module.cs @@ -5,21 +5,20 @@ using GerstITS.IoC.DotNetCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace GerstITS.Examples.WebClient.Console +namespace GerstITS.Examples.WebClient.Console; + +public class Module : IIoCModule { - public class Module : IIoCModule + #region IIoCModule + + public void RegisterComponents(IServiceCollection container) { - #region IIoCModule + container.AddTransient(); - public void RegisterComponents(IServiceCollection container) - { - container.AddTransient(); - - container.AddTransient(c => new ConfigurationBuilder().SetBasePath(AppDomain.CurrentDomain.BaseDirectory) - .AddJsonFile("appsettings.json", false, true) - .Build()); - } - - #endregion + container.AddTransient(c => new ConfigurationBuilder().SetBasePath(AppDomain.CurrentDomain.BaseDirectory) + .AddJsonFile("appsettings.json", false, true) + .Build()); } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.WebClient.Console/Program.cs b/GerstITS.Examples.WebClient.Console/Program.cs index 5f7d531..bcffb95 100644 --- a/GerstITS.Examples.WebClient.Console/Program.cs +++ b/GerstITS.Examples.WebClient.Console/Program.cs @@ -1,31 +1,30 @@ using GerstITS.IoC.DotNetCore; -namespace GerstITS.Examples.WebClient.Console +namespace GerstITS.Examples.WebClient.Console; + +internal class Program { - internal class Program + #region Fields + + private static readonly DotNetCoreApplicationBootstrapper _bootstrapper; + + #endregion + + #region Constructors + + static Program() { - #region Fields - - private static readonly DotNetCoreApplicationBootstrapper _bootstrapper; - - #endregion - - #region Constructors - - static Program() - { - _bootstrapper = new DotNetCoreApplicationBootstrapper(); - } - - #endregion - - #region Methods - - private static void Main(string[] args) - { - _bootstrapper.Run(); - } - - #endregion + _bootstrapper = new DotNetCoreApplicationBootstrapper(); } -} + + #endregion + + #region Methods + + private static void Main(string[] args) + { + _bootstrapper.Run(); + } + + #endregion +} \ No newline at end of file diff --git a/GerstITS.Examples.WebClient.Console/Tests/TestRunner.cs b/GerstITS.Examples.WebClient.Console/Tests/TestRunner.cs index b7b1079..2b849d5 100644 --- a/GerstITS.Examples.WebClient.Console/Tests/TestRunner.cs +++ b/GerstITS.Examples.WebClient.Console/Tests/TestRunner.cs @@ -4,48 +4,47 @@ using GerstITS.Examples.WebClients.Examples.Api; using GerstITS.IoC.DotNetCore; using GerstITS.Web.WebClients; -namespace GerstITS.Examples.WebClient.Console.Tests +namespace GerstITS.Examples.WebClient.Console.Tests; + +internal sealed class TestRunner : IApplicationStart { - internal sealed class TestRunner : IApplicationStart + #region Fields + + private readonly IWebClient _webClient; + + #endregion + + #region Construtors + + public TestRunner(IWebClient webClient) { - #region Fields - - private readonly IWebClient _webClient; - - #endregion - - #region Construtors - - public TestRunner(IWebClient webClient) - { - _webClient = webClient; - } + _webClient = webClient; + } - #endregion + #endregion - #region ITestRunner + #region ITestRunner - public void Run() - { - var result1 = _webClient.Request() - .Execute(c => c.Search(new SearchCriteria - { SortBy = nameof(Country.Name), SortDirection = SortingDirections.Descending, Skip = 5, Take = 5})); + public void Run() + { + var result1 = _webClient.Request() + .Execute(c => c.Search(new SearchCriteria + { SortBy = nameof(Country.Name), SortDirection = SortingDirections.Descending, Skip = 5, Take = 5})); - var result2 = _webClient.Request() - .Execute(c => c.Get(result1.Value.Result.First().Id)); + var result2 = _webClient.Request() + .Execute(c => c.Get(result1.Value.Result.First().Id)); - var test3 = _webClient.Request() - .Execute(c => c.Create(new Country {Name = $"Country-{Guid.NewGuid()}"})); + var test3 = _webClient.Request() + .Execute(c => c.Create(new Country {Name = $"Country-{Guid.NewGuid()}"})); - test3.Value.Name += "_Renamed"; + test3.Value.Name += "_Renamed"; - var test4 = _webClient.Request() - .Execute(c => c.Update(test3.Value)); + var test4 = _webClient.Request() + .Execute(c => c.Update(test3.Value)); - var test5 = _webClient.Request() - .Execute(c => c.Delete(test3.Value.Id)); - } + var test5 = _webClient.Request() + .Execute(c => c.Delete(test3.Value.Id)); + } - #endregion - } + #endregion } \ No newline at end of file diff --git a/GerstITS.WebClients.Example.Api/Configurations/ExampleApiClientConfiguration.cs b/GerstITS.WebClients.Example.Api/Configurations/ExampleApiClientConfiguration.cs index c3d8606..1dea161 100644 --- a/GerstITS.WebClients.Example.Api/Configurations/ExampleApiClientConfiguration.cs +++ b/GerstITS.WebClients.Example.Api/Configurations/ExampleApiClientConfiguration.cs @@ -1,17 +1,16 @@ using GerstITS.Web.Rest.WebClients; using Microsoft.Extensions.Configuration; -namespace GerstITS.Examples.WebClients.Examples.Api.Configurations -{ - internal class ExampleApiClientConfiguration : RestWebServiceConfigurationBase - { - #region Constructors +namespace GerstITS.Examples.WebClients.Examples.Api.Configurations; - public ExampleApiClientConfiguration(IConfiguration configuration) - : base(configuration) - { - } +internal class ExampleApiClientConfiguration : RestWebServiceConfigurationBase +{ + #region Constructors + + public ExampleApiClientConfiguration(IConfiguration configuration) + : base(configuration) + { + } - #endregion - } -} + #endregion +} \ No newline at end of file diff --git a/GerstITS.WebClients.Example.Api/Contracts/ICountry.cs b/GerstITS.WebClients.Example.Api/Contracts/ICountry.cs index 173997b..b10ce07 100644 --- a/GerstITS.WebClients.Example.Api/Contracts/ICountry.cs +++ b/GerstITS.WebClients.Example.Api/Contracts/ICountry.cs @@ -1,27 +1,26 @@ using GerstITS.Web.WebClients; -namespace GerstITS.Examples.WebClients.Examples.Api +namespace GerstITS.Examples.WebClients.Examples.Api; + +public interface ICountry : IWebService { - public interface ICountry : IWebService - { - [WebMethod(WebMethods.Get), - ResourceUrl("Country/{id}")] - Country Get(int id); + [WebMethod(WebMethods.Get), + ResourceUrl("Country/{id}")] + Country Get(int id); - [WebMethod(WebMethods.Get), - ResourceUrl("Country/Search")] - SearchResult Search(SearchCriteria criteria); + [WebMethod(WebMethods.Get), + ResourceUrl("Country/Search")] + SearchResult Search(SearchCriteria criteria); - [WebMethod(WebMethods.Post), - ResourceUrl("Country")] - Country Create(Country model); + [WebMethod(WebMethods.Post), + ResourceUrl("Country")] + Country Create(Country model); - [WebMethod(WebMethods.Put), - ResourceUrl("Country")] - void Update(Country model); + [WebMethod(WebMethods.Put), + ResourceUrl("Country")] + void Update(Country model); - [WebMethod(WebMethods.Delete), - ResourceUrl("Country/{id}")] - void Delete(int id); - } + [WebMethod(WebMethods.Delete), + ResourceUrl("Country/{id}")] + void Delete(int id); } \ No newline at end of file diff --git a/GerstITS.WebClients.Example.Api/Contracts/Serialization/Country.cs b/GerstITS.WebClients.Example.Api/Contracts/Serialization/Country.cs index cca6f8a..dca3174 100644 --- a/GerstITS.WebClients.Example.Api/Contracts/Serialization/Country.cs +++ b/GerstITS.WebClients.Example.Api/Contracts/Serialization/Country.cs @@ -1,12 +1,11 @@ -namespace GerstITS.Examples.WebClients.Examples.Api +namespace GerstITS.Examples.WebClients.Examples.Api; + +public class Country { - public class Country - { - #region Properties + #region Properties - public int Id { get; set; } - public string Name { get; set; } + public int Id { get; set; } + public string Name { get; set; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/GerstITS.WebClients.Example.Api/Contracts/Serialization/SearchCriteria.cs b/GerstITS.WebClients.Example.Api/Contracts/Serialization/SearchCriteria.cs index 5a1e789..912fb77 100644 --- a/GerstITS.WebClients.Example.Api/Contracts/Serialization/SearchCriteria.cs +++ b/GerstITS.WebClients.Example.Api/Contracts/Serialization/SearchCriteria.cs @@ -1,18 +1,17 @@ -namespace GerstITS.Examples.WebClients.Examples.Api +namespace GerstITS.Examples.WebClients.Examples.Api; + +public class SearchCriteria { - public class SearchCriteria - { - #region Properties + #region Properties - internal int Id { get; set; } - public string Name { get; set; } + internal int Id { get; set; } + public string Name { get; set; } - public int? Skip { get; set; } - public int? Take { get; set; } + public int? Skip { get; set; } + public int? Take { get; set; } - public string SortBy { get; set; } - public SortingDirections SortDirection { get; set; } + public string SortBy { get; set; } + public SortingDirections SortDirection { get; set; } - #endregion - } + #endregion } \ No newline at end of file diff --git a/GerstITS.WebClients.Example.Api/Contracts/Serialization/SearchResult.cs b/GerstITS.WebClients.Example.Api/Contracts/Serialization/SearchResult.cs index a930c9c..7d6b9d3 100644 --- a/GerstITS.WebClients.Example.Api/Contracts/Serialization/SearchResult.cs +++ b/GerstITS.WebClients.Example.Api/Contracts/Serialization/SearchResult.cs @@ -1,24 +1,23 @@ using System; using System.Collections.Generic; -namespace GerstITS.Examples.WebClients.Examples.Api +namespace GerstITS.Examples.WebClients.Examples.Api; + +public class SearchResult { - public class SearchResult + #region Properties + + public int TotalCount { get; set; } + public IEnumerable Result { get; set; } + + #endregion + + #region Constructors + + public SearchResult() { - #region Properties - - public int TotalCount { get; set; } - public IEnumerable Result { get; set; } - - #endregion - - #region Constructors - - public SearchResult() - { - Result = Array.Empty(); - } - - #endregion + Result = Array.Empty(); } + + #endregion } \ No newline at end of file diff --git a/GerstITS.WebClients.Example.Api/Contracts/Serialization/SortingDirections.cs b/GerstITS.WebClients.Example.Api/Contracts/Serialization/SortingDirections.cs index cfc3930..4e1b0ba 100644 --- a/GerstITS.WebClients.Example.Api/Contracts/Serialization/SortingDirections.cs +++ b/GerstITS.WebClients.Example.Api/Contracts/Serialization/SortingDirections.cs @@ -1,8 +1,7 @@ -namespace GerstITS.Examples.WebClients.Examples.Api +namespace GerstITS.Examples.WebClients.Examples.Api; + +public enum SortingDirections { - public enum SortingDirections - { - Ascending = 0, - Descending - } + Ascending = 0, + Descending } \ No newline at end of file diff --git a/GerstITS.WebClients.Example.Api/CreationRules/ExampleApiClientCreatingRule.cs b/GerstITS.WebClients.Example.Api/CreationRules/ExampleApiClientCreatingRule.cs index a91f5bb..0c98e56 100644 --- a/GerstITS.WebClients.Example.Api/CreationRules/ExampleApiClientCreatingRule.cs +++ b/GerstITS.WebClients.Example.Api/CreationRules/ExampleApiClientCreatingRule.cs @@ -2,24 +2,23 @@ using GerstITS.Examples.WebClients.Examples.Api.Configurations; using GerstITS.Web.Rest.WebClients; -namespace GerstITS.Examples.WebClients.Examples.Api.CreationRules +namespace GerstITS.Examples.WebClients.Examples.Api.CreationRules; + +internal sealed class ExampleApiClientCreatingRule : RestApiClientCreationRuleBase { - internal sealed class ExampleApiClientCreatingRule : RestApiClientCreationRuleBase + #region Properties + + protected override Type[] SupportedTypes => new[] { typeof(ICountry) }; + + #endregion + + #region Constructors + + public ExampleApiClientCreatingRule(ExampleApiClientConfiguration configuration, + Func restWebServiceClientFactory) + : base(configuration, restWebServiceClientFactory) { - #region Properties - - protected override Type[] SupportedTypes => new[] { typeof(ICountry) }; - - #endregion - - #region Constructors - - public ExampleApiClientCreatingRule(ExampleApiClientConfiguration configuration, - Func restWebServiceClientFactory) - : base(configuration, restWebServiceClientFactory) - { - } + } - #endregion - } + #endregion } \ No newline at end of file diff --git a/GerstITS.WebClients.Example.Api/Module.Configurations.cs b/GerstITS.WebClients.Example.Api/Module.Configurations.cs index c128521..47e74b2 100644 --- a/GerstITS.WebClients.Example.Api/Module.Configurations.cs +++ b/GerstITS.WebClients.Example.Api/Module.Configurations.cs @@ -1,17 +1,16 @@ using GerstITS.Examples.WebClients.Examples.Api.Configurations; using Microsoft.Extensions.DependencyInjection; -namespace GerstITS.Examples.WebClients.Examples.Api +namespace GerstITS.Examples.WebClients.Examples.Api; + +public sealed partial class Module { - public sealed partial class Module + #region Methods + + private static void RegisterConfigurations(IServiceCollection container) { - #region Methods - - private static void RegisterConfigurations(IServiceCollection container) - { - container.AddSingleton(); - } - - #endregion + container.AddSingleton(); } + + #endregion } \ No newline at end of file diff --git a/GerstITS.WebClients.Example.Api/Module.CreationRules.cs b/GerstITS.WebClients.Example.Api/Module.CreationRules.cs index 92a0042..18412fb 100644 --- a/GerstITS.WebClients.Example.Api/Module.CreationRules.cs +++ b/GerstITS.WebClients.Example.Api/Module.CreationRules.cs @@ -2,17 +2,16 @@ using GerstITS.Web.WebClients; using Microsoft.Extensions.DependencyInjection; -namespace GerstITS.Examples.WebClients.Examples.Api +namespace GerstITS.Examples.WebClients.Examples.Api; + +public sealed partial class Module { - public sealed partial class Module + #region Methods + + private static void RegisterCreationRules(IServiceCollection container) { - #region Methods - - private static void RegisterCreationRules(IServiceCollection container) - { - container.AddTransient(); - } - - #endregion + container.AddTransient(); } + + #endregion } \ No newline at end of file diff --git a/GerstITS.WebClients.Example.Api/Module.cs b/GerstITS.WebClients.Example.Api/Module.cs index afb5a61..241bcd8 100644 --- a/GerstITS.WebClients.Example.Api/Module.cs +++ b/GerstITS.WebClients.Example.Api/Module.cs @@ -1,18 +1,17 @@ using GerstITS.IoC; using Microsoft.Extensions.DependencyInjection; -namespace GerstITS.Examples.WebClients.Examples.Api +namespace GerstITS.Examples.WebClients.Examples.Api; + +public sealed partial class Module : IIoCModule { - public sealed partial class Module : IIoCModule + #region IIoCModule + + public void RegisterComponents(IServiceCollection container) { - #region IIoCModule - - public void RegisterComponents(IServiceCollection container) - { - RegisterConfigurations(container); - RegisterCreationRules(container); - } - - #endregion + RegisterConfigurations(container); + RegisterCreationRules(container); } + + #endregion } \ No newline at end of file