Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
namespace Framework.Application.Events;

public record EventModel(Type DomainType, ImmutableArray<Guid> DomainObjectIdents, EventOperation EventOperation, long? Revision);

Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ public interface IEventSystem

Task ForceEventAsync(EventModel eventModel, CancellationToken cancellationToken = default);
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ public interface IFinancialYearCalculator

bool IsStartFinancialYearDate(DateTime dateTime);
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ public interface IFinancialYearService
{
Period GetCurrentFinancialYear();
}

Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using Framework.Database;
using Anch.SecuritySystem;

using Anch.SecuritySystem;
using Framework.Database;

namespace Framework.Application;

public interface IServiceEvaluator<out TService>
{
Task<TResult> EvaluateAsync<TResult>(DBSessionMode sessionMode, UserCredential? userCredential, Func<TService, Task<TResult>> getResult);
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ public interface IJobMiddlewareFactory
{
IScopedEvaluatorMiddleware Create<TService>(bool withRootLogging);
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ public static async Task EvaluateAsync<TService>(this IJobServiceEvaluator<TServ
where TService : notnull =>
await jobServiceEvaluator.EvaluateAsync(executeAsync.ToDefaultTask());
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ public interface INamedLockService
{
Task LockAsync(NamedLock namedLock, LockRole lockRole, CancellationToken cancellationToken = default);
}

Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ private class WithMiddleware(IScopedEvaluatorMiddleware middleware, IScopedEvalu
public async Task<TResult> EvaluateAsync<TResult>(Func<Task<TResult>> getResult) => await otherMiddleware.EvaluateAsync(async () => await middleware.EvaluateAsync(async () => await getResult()));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ public interface IGenericRepository<TDomainObject, in TIdent>

Task LockAsync(TDomainObject domainObject, LockRole lockRole, CancellationToken cancellationToken = default);
}

Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ public interface IRepository<TDomainObject>

Task LockAsync(TDomainObject domainObject, LockRole lockRole, CancellationToken cancellationToken = default);
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ public interface ITemplateGenericRepositoryFactory<out TRepository, TDomainObjec

TRepository Create(ISecurityProvider<TDomainObject> securityProvider);
}

Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using Anch.Core;
using Anch.SecuritySystem;

using Framework.Database;

using Anch.SecuritySystem;

namespace Framework.Application;

public static class ServiceEvaluatorExtensions
Expand Down Expand Up @@ -36,3 +35,4 @@ public TResult Evaluate<TResult>(DBSessionMode sessionMode, UserCredential? cust
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ public async Task<TResult> EvaluateAsync<TResult>(DBSessionMode sessionMode, Fun
return await sessionMiddleware.EvaluateAsync(async () => await getResult(scope.ServiceProvider));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ public async Task RemoveAsync<TDomainObject>(TDomainObject data, CancellationTok
await dal.RemoveAsync(data, cancellationToken);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ public IQueryable<TDomainObject> GetQueryable<TDomainObject>()
where TDomainObject : class =>
serviceProvider.GetRequiredService<IAsyncDal<TDomainObject, Guid>>().GetQueryable();
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ public static async Task Send(
.CreateGenericMethod(domainObjectType)
.Invoke<Task>(sender, [domainObject, domainObjectEvent]);
}

Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using Framework.Core;


namespace Framework.Application.FinancialYear;

public class FinancialYearCalculator (FinancialYearServiceSettings settings) : IFinancialYearCalculator
public class FinancialYearCalculator(FinancialYearServiceSettings settings) : IFinancialYearCalculator
{
private const int MinMonthValue = 1;

Expand Down Expand Up @@ -37,3 +36,4 @@ public int GetFinancialYear(int year, int month)

public bool IsStartFinancialYearDate(DateTime dateTime) => dateTime.Day == 1 && dateTime.Month == settings.StartMonth;
}

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Framework.Core;


namespace Framework.Application.FinancialYear;

public class FinancialYearService(TimeProvider timeProvider, IFinancialYearCalculator financialYearCalculator) : IFinancialYearService
{
public Period GetCurrentFinancialYear() => financialYearCalculator.GetFinancialYearPeriod(timeProvider.GetLocalNow().DateTime);
}

Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ public async Task<TResult> EvaluateAsync<TResult>(Func<Task<TResult>> getResult)
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ protected virtual IEnumerable<IScopedEvaluatorMiddleware> GetMiddlewares<TServic
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ public async Task<TResult> EvaluateAsync<TResult>(Func<TService, Task<TResult>>
.EvaluateAsync(async () => await executeAsync(service));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
namespace Framework.Application.Lock;

public record GenericNamedLockTypeInfo<TGenericNamedLock>(Expression<Func<TGenericNamedLock, string>> NamePath);

Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
namespace Framework.Application.Lock;

public interface INamedLockInitializer : IInitializer;

Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using Anch.Core;
using Anch.GenericQueryable;
using Anch.SecuritySystem.Attributes;

using Framework.Application.Repository;
using Framework.Core;

using Anch.GenericQueryable;

using Anch.SecuritySystem.Attributes;

namespace Framework.Application.Lock;

public class NamedLockInitializer<TGenericNamedLock>(
Expand Down Expand Up @@ -36,3 +34,4 @@ public async Task Initialize(CancellationToken cancellationToken)
}
}
}

Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using Anch.Core;
using Anch.GenericQueryable;
using Anch.SecuritySystem.Attributes;

using Framework.Application.Repository;
using Framework.Database;

using Anch.GenericQueryable;

using Anch.SecuritySystem.Attributes;

namespace Framework.Application.Lock;

public class NamedLockService<TGenericNamedLock>(
Expand All @@ -22,3 +20,4 @@ public async Task LockAsync(NamedLock namedLock, LockRole lockRole, Cancellation
await namedLockRepository.LockAsync(genericNamedLock, lockRole, cancellationToken);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ public class NamedLockTypeContainerSource(Type typeInfo) : INamedLockSource
{
public IReadOnlyList<NamedLock> NamedLocks { get; } = typeInfo.GetStaticPropertyValueList<NamedLock>().ToList();
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace Framework.Application.Lock;

public class RootNamedLockSource([FromKeyedServices(RootNamedLockSource.ElementsKey)]IEnumerable<INamedLockSource> elements) : INamedLockSource
public class RootNamedLockSource([FromKeyedServices(RootNamedLockSource.ElementsKey)] IEnumerable<INamedLockSource> elements) : INamedLockSource
{
public const string ElementsKey = "Elements";

public IReadOnlyList<NamedLock> NamedLocks { get; } = elements.SelectMany(el => el.NamedLocks).ToList();
}

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Microsoft.Extensions.DependencyInjection;

using Anch.SecuritySystem;
using Anch.SecuritySystem;
using Anch.SecuritySystem.Services;

using Microsoft.Extensions.DependencyInjection;

namespace Framework.Application.Middleware;

public class ImpersonateEvaluatorMiddleware(IServiceProvider scopedServiceProvider, UserCredential customUserCredential) : IScopedEvaluatorMiddleware
Expand All @@ -14,3 +14,4 @@ public async Task<TResult> EvaluateAsync<TResult>(Func<Task<TResult>> getResult)
return await impersonateService.WithImpersonateAsync(customUserCredential, getResult);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ public async Task<TResult> EvaluateAsync<TResult>(Func<Task<TResult>> getResult)
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ public class TryCloseSessionEvaluatorMiddleware(IDBSessionManager dbSessionManag
{
public async Task<TResult> EvaluateAsync<TResult>(Func<Task<TResult>> getResult) => await dbSessionManager.EvaluateAsync(getResult);
}

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Framework.Database;

using Anch.SecuritySystem;
using Anch.SecuritySystem;
using Anch.SecuritySystem.AccessDenied;
using Anch.SecuritySystem.DomainServices;

using Framework.Database;

namespace Framework.Application.Repository.Default;

public class EditRepository<TDomainObject>(
Expand All @@ -15,3 +15,4 @@ public class EditRepository<TDomainObject>(
accessDeniedExceptionService,
domainSecurityService.GetSecurityProvider(SecurityRule.Edit))
where TDomainObject : class;

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Framework.Application.Repository.Generic;
using Framework.Database;

using Anch.SecuritySystem.AccessDenied;
using Anch.SecuritySystem.AccessDenied;
using Anch.SecuritySystem.Providers;

using Framework.Application.Repository.Generic;
using Framework.Database;

namespace Framework.Application.Repository.Default;

public class Repository<TDomainObject>(
Expand All @@ -13,3 +13,4 @@ public class Repository<TDomainObject>(
: GenericRepository<TDomainObject, Guid>(dal, accessDeniedExceptionService, securityProvider),
IRepository<TDomainObject>
where TDomainObject : class;

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Anch.Core;

using Anch.SecuritySystem.DomainServices;

namespace Framework.Application.Repository.Default;
Expand All @@ -11,3 +10,4 @@ public class RepositoryFactory<TDomainObject>(IServiceProxyFactory serviceProxyF
TDomainObject>(serviceProxyFactory, domainSecurityService),
IRepositoryFactory<TDomainObject>
where TDomainObject : class;

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Framework.Database;

using Anch.SecuritySystem;
using Anch.SecuritySystem;
using Anch.SecuritySystem.AccessDenied;
using Anch.SecuritySystem.DomainServices;

using Framework.Database;

namespace Framework.Application.Repository.Default;

public class ViewRepository<TDomainObject>(
Expand All @@ -15,3 +15,4 @@ public class ViewRepository<TDomainObject>(
accessDeniedExceptionService,
domainSecurityService.GetSecurityProvider(SecurityRule.View))
where TDomainObject : class;

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Anch.Core;

using Framework.Database;

using Anch.SecuritySystem.AccessDenied;
using Anch.SecuritySystem.Providers;

using Framework.Database;

namespace Framework.Application.Repository.Generic;

public class GenericRepository<TDomainObject, TIdent>(
Expand Down Expand Up @@ -53,3 +52,4 @@ public async Task RefreshAsync(TDomainObject domainObject, CancellationToken can

public async Task LockAsync(TDomainObject domainObject, LockRole lockRole, CancellationToken cancellationToken) => await dal.LockAsync(domainObject, lockRole, cancellationToken);
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Anch.Core;

using Anch.SecuritySystem.DomainServices;

namespace Framework.Application.Repository.Generic;
Expand All @@ -11,3 +10,4 @@ public class GenericRepositoryFactory<TDomainObject, TIdent>(IServiceProxyFactor
TDomainObject>(serviceProxyFactory, domainSecurityService),
IGenericRepositoryFactory<TDomainObject, TIdent>
where TDomainObject : class;

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Anch.Core;

using Anch.SecuritySystem;
using Anch.SecuritySystem.DomainServices;
using Anch.SecuritySystem.Providers;
Expand All @@ -21,3 +20,4 @@ public TRepository Create(SecurityRule securityRule) =>
public TRepository Create(ISecurityProvider<TDomainObject> securityProvider) =>
serviceProxyFactory.Create<TRepository, TRepositoryImpl>(securityProvider);
}

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Framework.Application.Middleware;
using Anch.SecuritySystem;

using Framework.Application.Middleware;
using Framework.Database;

using Microsoft.Extensions.DependencyInjection;

using Anch.SecuritySystem;

namespace Framework.Application;

public class ServiceEvaluator<TService>(IServiceProvider rootServiceProvider) : IServiceEvaluator<TService>
Expand Down Expand Up @@ -32,3 +32,4 @@ private static IEnumerable<IScopedEvaluatorMiddleware> GetMiddlewares(IServicePr
}
}
}

1 change: 1 addition & 0 deletions src/Application/Framework.Application.Tests/PeriodTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ public void GetFinancialYear_YearOutOfRange_ThrowArgumentOutOfRangeException(int
Assert.IsType<ArgumentOutOfRangeException>(ex);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ private void AddService<TService, TListener>(IServiceCollection services)
where TService : class =>
services.AddScopedFromLazyInterfaceImplement<TService, TListener>(false);
}

Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ public void Initialize(IServiceCollection services)
this.elementsInitAction.ForEach(a => a(services));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ public interface IDALListenerSetup
IDALListenerSetup Add<TListener>()
where TListener : class, IDALListener;
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ IGenericNamedLockSetup SetNameLockType<TGenericNamedLock>(Expression<Func<TGener

IGenericNamedLockSetup AddManual(Type domainType) => this.AddManual(new NamedLock(domainType));
}

Loading
Loading