Skip to content

Commit 96c2807

Browse files
style: reformat
1 parent ec07863 commit 96c2807

File tree

16 files changed

+112
-34
lines changed

16 files changed

+112
-34
lines changed

.csharpierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"printWidth": 140,
2+
"printWidth": 130,
33
"useTabs": false,
44
"tabWidth": 4,
55
"preprocessorSymbolSets": [

Core.Application/Pipelines/Authorization/AuthorizationBehavior.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ public AuthorizationBehavior(IHttpContextAccessor httpContextAccessor)
1717
_httpContextAccessor = httpContextAccessor;
1818
}
1919

20-
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
20+
public async Task<TResponse> Handle(
21+
TRequest request,
22+
RequestHandlerDelegate<TResponse> next,
23+
CancellationToken cancellationToken
24+
)
2125
{
2226
ICollection<string>? userRoleClaims = _httpContextAccessor.HttpContext.User.ClaimRoles();
2327

2428
if (userRoleClaims == null)
2529
throw new AuthorizationException("You are not authenticated.");
2630

2731
bool isNotMatchedAUserRoleClaimWithRequestRoles = userRoleClaims
28-
.FirstOrDefault(userRoleClaim => userRoleClaim == GeneralOperationClaims.Admin || request.Roles.Contains(userRoleClaim))
32+
.FirstOrDefault(userRoleClaim =>
33+
userRoleClaim == GeneralOperationClaims.Admin || request.Roles.Contains(userRoleClaim)
34+
)
2935
.IsNullOrEmpty();
3036
if (isNotMatchedAUserRoleClaimWithRequestRoles)
3137
throw new AuthorizationException("You are not authorized.");

Core.Application/Pipelines/Caching/CacheRemovingBehavior.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ public CacheRemovingBehavior(IDistributedCache cache, ILogger<CacheRemovingBehav
1818
_logger = logger;
1919
}
2020

21-
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
21+
public async Task<TResponse> Handle(
22+
TRequest request,
23+
RequestHandlerDelegate<TResponse> next,
24+
CancellationToken cancellationToken
25+
)
2226
{
2327
if (request.BypassCache)
2428
return await next();
@@ -31,7 +35,9 @@ public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TRe
3135
byte[]? cachedGroup = await _cache.GetAsync(request.CacheGroupKey[i], cancellationToken);
3236
if (cachedGroup != null)
3337
{
34-
HashSet<string> keysInGroup = JsonSerializer.Deserialize<HashSet<string>>(Encoding.Default.GetString(cachedGroup))!;
38+
HashSet<string> keysInGroup = JsonSerializer.Deserialize<HashSet<string>>(
39+
Encoding.Default.GetString(cachedGroup)
40+
)!;
3541
foreach (string key in keysInGroup)
3642
{
3743
await _cache.RemoveAsync(key, cancellationToken);

Core.Application/Pipelines/Caching/CachingBehavior.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,22 @@ public class CachingBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest,
1515
private readonly CacheSettings _cacheSettings;
1616
private readonly ILogger<CachingBehavior<TRequest, TResponse>> _logger;
1717

18-
public CachingBehavior(IDistributedCache cache, ILogger<CachingBehavior<TRequest, TResponse>> logger, IConfiguration configuration)
18+
public CachingBehavior(
19+
IDistributedCache cache,
20+
ILogger<CachingBehavior<TRequest, TResponse>> logger,
21+
IConfiguration configuration
22+
)
1923
{
2024
_cache = cache;
2125
_logger = logger;
2226
_cacheSettings = configuration.GetSection("CacheSettings").Get<CacheSettings>() ?? throw new InvalidOperationException();
2327
}
2428

25-
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
29+
public async Task<TResponse> Handle(
30+
TRequest request,
31+
RequestHandlerDelegate<TResponse> next,
32+
CancellationToken cancellationToken
33+
)
2634
{
2735
if (request.BypassCache)
2836
return await next();
@@ -81,10 +89,17 @@ private async Task addCacheKeyToGroup(TRequest request, TimeSpan slidingExpirati
8189
);
8290
int? cacheGroupCacheSlidingExpirationValue = null;
8391
if (cacheGroupCacheSlidingExpirationCache != null)
84-
cacheGroupCacheSlidingExpirationValue = Convert.ToInt32(Encoding.Default.GetString(cacheGroupCacheSlidingExpirationCache));
85-
if (cacheGroupCacheSlidingExpirationValue == null || slidingExpiration.TotalSeconds > cacheGroupCacheSlidingExpirationValue)
92+
cacheGroupCacheSlidingExpirationValue = Convert.ToInt32(
93+
Encoding.Default.GetString(cacheGroupCacheSlidingExpirationCache)
94+
);
95+
if (
96+
cacheGroupCacheSlidingExpirationValue == null
97+
|| slidingExpiration.TotalSeconds > cacheGroupCacheSlidingExpirationValue
98+
)
8699
cacheGroupCacheSlidingExpirationValue = Convert.ToInt32(slidingExpiration.TotalSeconds);
87-
byte[] serializeCachedGroupSlidingExpirationData = JsonSerializer.SerializeToUtf8Bytes(cacheGroupCacheSlidingExpirationValue);
100+
byte[] serializeCachedGroupSlidingExpirationData = JsonSerializer.SerializeToUtf8Bytes(
101+
cacheGroupCacheSlidingExpirationValue
102+
);
88103

89104
DistributedCacheEntryOptions cacheOptions =
90105
new() { SlidingExpiration = TimeSpan.FromSeconds(Convert.ToDouble(cacheGroupCacheSlidingExpirationValue)) };

Core.Application/Pipelines/Logging/LoggingBehavior.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ public LoggingBehavior(ILogger logger, IHttpContextAccessor httpContextAccessor)
1818
_httpContextAccessor = httpContextAccessor;
1919
}
2020

21-
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
21+
public async Task<TResponse> Handle(
22+
TRequest request,
23+
RequestHandlerDelegate<TResponse> next,
24+
CancellationToken cancellationToken
25+
)
2226
{
2327
List<LogParameter> logParameters = [new LogParameter { Type = request.GetType().Name, Value = request }];
2428

Core.Application/Pipelines/Performance/PerformanceBehavior.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ public PerformanceBehavior(ILogger<PerformanceBehavior<TRequest, TResponse>> log
1616
_stopwatch = stopwatch;
1717
}
1818

19-
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
19+
public async Task<TResponse> Handle(
20+
TRequest request,
21+
RequestHandlerDelegate<TResponse> next,
22+
CancellationToken cancellationToken
23+
)
2024
{
2125
string requestName = request.GetType().Name;
2226

Core.Application/Pipelines/Transaction/TransactionScopeBehavior.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ namespace NArchitecture.Core.Application.Pipelines.Transaction;
66
public class TransactionScopeBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
77
where TRequest : IRequest<TResponse>, ITransactionalRequest
88
{
9-
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
9+
public async Task<TResponse> Handle(
10+
TRequest request,
11+
RequestHandlerDelegate<TResponse> next,
12+
CancellationToken cancellationToken
13+
)
1014
{
1115
using TransactionScope transactionScope = new(TransactionScopeAsyncFlowOption.Enabled);
1216
TResponse response;

Core.Application/Pipelines/Validation/RequestValidationBehavior.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ public RequestValidationBehavior(IEnumerable<IValidator<TRequest>> validators)
1515
_validators = validators;
1616
}
1717

18-
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
18+
public async Task<TResponse> Handle(
19+
TRequest request,
20+
RequestHandlerDelegate<TResponse> next,
21+
CancellationToken cancellationToken
22+
)
1923
{
2024
ValidationContext<object> context = new(request);
2125
IEnumerable<ValidationExceptionModel> errors = _validators

Core.CrossCuttingConcerns.Logging/LogDetailWithException.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ public LogDetailWithException()
99
ExceptionMessage = string.Empty;
1010
}
1111

12-
public LogDetailWithException(string fullName, string methodName, string user, List<LogParameter> parameters, string exceptionMessage)
12+
public LogDetailWithException(
13+
string fullName,
14+
string methodName,
15+
string user,
16+
List<LogParameter> parameters,
17+
string exceptionMessage
18+
)
1319
: base(fullName, methodName, user, parameters)
1420
{
1521
ExceptionMessage = exceptionMessage;

Core.ElasticSearch/ElasticSearchManager.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public ElasticSearchManager(ElasticSearchConfig configuration)
2020
new JsonNetSerializer(
2121
builtInSerializer,
2222
connectionSettings,
23-
jsonSerializerSettingsFactory: () => new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }
23+
jsonSerializerSettingsFactory: () =>
24+
new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }
2425
)
2526
);
2627
}
@@ -61,7 +62,10 @@ public async Task<IElasticSearchResult> CreateNewIndexAsync(IndexModel indexMode
6162
public async Task<IElasticSearchResult> DeleteByElasticIdAsync(ElasticSearchModel model)
6263
{
6364
ElasticClient elasticClient = getElasticClient(model.IndexName);
64-
DeleteResponse? response = await elasticClient.DeleteAsync<object>(model.ElasticId, selector: x => x.Index(model.IndexName));
65+
DeleteResponse? response = await elasticClient.DeleteAsync<object>(
66+
model.ElasticId,
67+
selector: x => x.Index(model.IndexName)
68+
);
6569
return new ElasticSearchResult(
6670
response.IsValid,
6771
message: response.IsValid ? ElasticSearchMessages.Success : response.ServerError.Error.Reason

Core.Mailing.MailKit/MailKitMailService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ private void emailPrepare(Mail mail, out MimeMessage email, out SmtpClient smtp)
8484
private AsymmetricKeyParameter readPrivateKeyFromPemEncodedString()
8585
{
8686
AsymmetricKeyParameter result;
87-
string pemEncodedKey = "-----BEGIN RSA PRIVATE KEY-----\n" + _mailSettings.DkimPrivateKey + "\n-----END RSA PRIVATE KEY-----";
87+
string pemEncodedKey =
88+
"-----BEGIN RSA PRIVATE KEY-----\n" + _mailSettings.DkimPrivateKey + "\n-----END RSA PRIVATE KEY-----";
8889
using (StringReader stringReader = new(pemEncodedKey))
8990
{
9091
PemReader pemReader = new(stringReader);

Core.Persistence/Paging/Paginate.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ public Paginate()
4242

4343
public class Paginate<TSource, TResult> : IPaginate<TResult>
4444
{
45-
public Paginate(IEnumerable<TSource> source, Func<IEnumerable<TSource>, IEnumerable<TResult>> converter, int index, int size, int from)
45+
public Paginate(
46+
IEnumerable<TSource> source,
47+
Func<IEnumerable<TSource>, IEnumerable<TResult>> converter,
48+
int index,
49+
int size,
50+
int from
51+
)
4652
{
4753
if (from > index)
4854
throw new ArgumentException($"From: {from} > Index: {index}, must From <= Index");

Core.Persistence/Repositories/EfRepositoryBase.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
namespace NArchitecture.Core.Persistence.Repositories;
1111

12-
public class EfRepositoryBase<TEntity, TEntityId, TContext> : IAsyncRepository<TEntity, TEntityId>, IRepository<TEntity, TEntityId>
12+
public class EfRepositoryBase<TEntity, TEntityId, TContext>
13+
: IAsyncRepository<TEntity, TEntityId>,
14+
IRepository<TEntity, TEntityId>
1315
where TEntity : Entity<TEntityId>
1416
where TContext : DbContext
1517
{
@@ -352,7 +354,9 @@ private async Task setEntityAsSoftDeletedAsync(IEntityTimestamps entity)
352354
var navigations = Context
353355
.Entry(entity)
354356
.Metadata.GetNavigations()
355-
.Where(x => x is { IsOnDependent: false, ForeignKey.DeleteBehavior: DeleteBehavior.ClientCascade or DeleteBehavior.Cascade })
357+
.Where(x =>
358+
x is { IsOnDependent: false, ForeignKey.DeleteBehavior: DeleteBehavior.ClientCascade or DeleteBehavior.Cascade }
359+
)
356360
.ToList();
357361
foreach (INavigation? navigation in navigations)
358362
{
@@ -367,7 +371,8 @@ private async Task setEntityAsSoftDeletedAsync(IEntityTimestamps entity)
367371
if (navValue == null)
368372
{
369373
IQueryable query = Context.Entry(entity).Collection(navigation.PropertyInfo.Name).Query();
370-
navValue = await GetRelationLoaderQuery(query, navigationPropertyType: navigation.PropertyInfo.GetType()).ToListAsync();
374+
navValue = await GetRelationLoaderQuery(query, navigationPropertyType: navigation.PropertyInfo.GetType())
375+
.ToListAsync();
371376
if (navValue == null)
372377
continue;
373378
}
@@ -402,7 +407,9 @@ private void setEntityAsSoftDeleted(IEntityTimestamps entity)
402407
var navigations = Context
403408
.Entry(entity)
404409
.Metadata.GetNavigations()
405-
.Where(x => x is { IsOnDependent: false, ForeignKey.DeleteBehavior: DeleteBehavior.ClientCascade or DeleteBehavior.Cascade })
410+
.Where(x =>
411+
x is { IsOnDependent: false, ForeignKey.DeleteBehavior: DeleteBehavior.ClientCascade or DeleteBehavior.Cascade }
412+
)
406413
.ToList();
407414
foreach (INavigation? navigation in navigations)
408415
{
@@ -430,7 +437,8 @@ private void setEntityAsSoftDeleted(IEntityTimestamps entity)
430437
if (navValue == null)
431438
{
432439
IQueryable query = Context.Entry(entity).Reference(navigation.PropertyInfo.Name).Query();
433-
navValue = GetRelationLoaderQuery(query, navigationPropertyType: navigation.PropertyInfo.GetType()).FirstOrDefault();
440+
navValue = GetRelationLoaderQuery(query, navigationPropertyType: navigation.PropertyInfo.GetType())
441+
.FirstOrDefault();
434442
if (navValue == null)
435443
continue;
436444
}

Core.Security/JWT/JwtHelper.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ IList<OperationClaim<TOperationClaimId>> operationClaims
7171
return jwt;
7272
}
7373

74-
protected virtual IEnumerable<Claim> SetClaims(
75-
User<TUserId> user,
76-
IList<OperationClaim<TOperationClaimId>> operationClaims
77-
)
74+
protected virtual IEnumerable<Claim> SetClaims(User<TUserId> user, IList<OperationClaim<TOperationClaimId>> operationClaims)
7875
{
7976
List<Claim> claims = [];
8077
claims.AddNameIdentifier(user!.Id!.ToString()!);

Core.Test/Application/Helpers/MockRepositoryHelper.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,20 @@ public static void SetupAnyAsync<TRepository, TEntity, TEntityId>(Mock<TReposito
158158
{
159159
mockRepo
160160
.Setup(s =>
161-
s.AnyAsync(It.IsAny<Expression<Func<TEntity, bool>>>(), It.IsAny<bool>(), It.IsAny<bool>(), It.IsAny<CancellationToken>())
161+
s.AnyAsync(
162+
It.IsAny<Expression<Func<TEntity, bool>>>(),
163+
It.IsAny<bool>(),
164+
It.IsAny<bool>(),
165+
It.IsAny<CancellationToken>()
166+
)
162167
)
163168
.ReturnsAsync(
164-
(Expression<Func<TEntity, bool>> expression, bool withDeleted, bool enableTracking, CancellationToken cancellationToken) =>
169+
(
170+
Expression<Func<TEntity, bool>> expression,
171+
bool withDeleted,
172+
bool enableTracking,
173+
CancellationToken cancellationToken
174+
) =>
165175
{
166176
if (!withDeleted)
167177
entityList = entityList.Where(e => !e.DeletedDate.HasValue).ToList();

Core.Translation.AmazonTranslate.DependencyInjection/ServiceCollectionAmazonTranslateLocalizationExtension.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ namespace NArchitecture.Core.Translation.AmazonTranslate.DependencyInjection;
66

77
public static class ServiceCollectionAmazonTranslateLocalizationExtension
88
{
9-
public static IServiceCollection AddAmazonTranslation(this IServiceCollection services, AmazonTranslateConfiguration configuration)
9+
public static IServiceCollection AddAmazonTranslation(
10+
this IServiceCollection services,
11+
AmazonTranslateConfiguration configuration
12+
)
1013
{
11-
services.AddTransient<ITranslationService, AmazonTranslateLocalizationManager>(_ => new AmazonTranslateLocalizationManager(
12-
configuration
13-
));
14+
services.AddTransient<ITranslationService, AmazonTranslateLocalizationManager>(
15+
_ => new AmazonTranslateLocalizationManager(configuration)
16+
);
1417
return services;
1518
}
1619
}

0 commit comments

Comments
 (0)