diff --git a/src/CSharp/EasyMicroservices.Cores.AspCore.Tests/Fixtures/BaseFixture.cs b/src/CSharp/EasyMicroservices.Cores.AspCore.Tests/Fixtures/BaseFixture.cs index 6588b9e..ad1dd20 100644 --- a/src/CSharp/EasyMicroservices.Cores.AspCore.Tests/Fixtures/BaseFixture.cs +++ b/src/CSharp/EasyMicroservices.Cores.AspCore.Tests/Fixtures/BaseFixture.cs @@ -2,6 +2,7 @@ using EasyMicroservices.Cores.AspCoreApi.Managers; using EasyMicroservices.Cores.AspEntityFrameworkCoreApi; using EasyMicroservices.Cores.Database.Interfaces; +using EasyMicroservices.Cores.Database.Logics; using EasyMicroservices.Cores.Database.Managers; using EasyMicroservices.Cores.Models; using EasyMicroservices.Cores.Relational.EntityFrameworkCore.Intrerfaces; @@ -20,6 +21,7 @@ public static async Task Init(int port, int? whiteLabelPort, A app.Services.AddTransient(serviceProvider => new MyTestContext(serviceProvider.GetService())); app.Services.AddTransient(); app.Services.AddSingleton(service => new WhiteLabelManager(service)); + app.Services.AddSingleton(); app.Services.AddSingleton((provider) => { return new DefaultUniqueIdentityManager(provider.GetService().CurrentWhiteLabel); diff --git a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs index 37f8bad..9f07ab9 100644 --- a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs +++ b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs @@ -9,10 +9,12 @@ using EasyMicroservices.Cores.Database.Interfaces; using EasyMicroservices.Cores.Database.Logics; using EasyMicroservices.Cores.Database.Managers; +using EasyMicroservices.Cores.Database.Widgets; using EasyMicroservices.Cores.Interfaces; using EasyMicroservices.Cores.Models; using EasyMicroservices.Cores.Relational.EntityFrameworkCore; using EasyMicroservices.Cores.Relational.EntityFrameworkCore.Builders; +using EasyMicroservices.Cores.Widgets; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Cors.Infrastructure; @@ -77,6 +79,8 @@ public static IServiceCollection Builder(this IServiceCollection servi services.AddHttpContextAccessor(); services.AddScoped(service => new UnitOfWork(service)); services.AddScoped(); + services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(service => new WhiteLabelManager(service)); services.AddSingleton((provider) => { @@ -369,6 +373,9 @@ public static async Task Use(this WebApplication webAp using (var scope = webApplication.Services.CreateAsyncScope()) { + var init = scope.ServiceProvider.GetService(); + if (init != null) + init.Build(); var dbbuilder = new DatabaseCreator(); using var context = scope.ServiceProvider.GetRequiredService(); dbbuilder.Initialize(context); diff --git a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/UnitOfWork.cs b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/UnitOfWork.cs index c52e97d..ee460f8 100644 --- a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/UnitOfWork.cs +++ b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/UnitOfWork.cs @@ -109,13 +109,21 @@ public virtual IDatabase GetDatabase() } #region ContractLogic + LogicOptions? _defaultLogicOptions; /// /// /// - public virtual void SetDefaultLogicOptions(LogicOptions logicOptions) + public LogicOptions? LogicOptions { - _defaultLogicOptions = logicOptions; + get + { + return _defaultLogicOptions; + } + set + { + _defaultLogicOptions = value; + } } LogicOptions GetLogicOptions(LogicOptions logicOptions) @@ -596,5 +604,14 @@ public virtual ServiceAddressInfo GetServiceAddress(string name) ?.Where(x => x.Name.HasValue()) .FirstOrDefault(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); } + + /// + /// + /// + /// + public IDatabaseWidgetManager GetDatabaseWidgetManager() + { + return GetService(); + } } } diff --git a/src/CSharp/EasyMicroservices.Cores.Contracts/Models/LogicOptions.cs b/src/CSharp/EasyMicroservices.Cores.Contracts/Models/LogicOptions.cs index 84693d7..7030420 100644 --- a/src/CSharp/EasyMicroservices.Cores.Contracts/Models/LogicOptions.cs +++ b/src/CSharp/EasyMicroservices.Cores.Contracts/Models/LogicOptions.cs @@ -20,6 +20,10 @@ public LogicOptions() /// /// /// + public bool DoStopReporting { get; set; } + /// + /// + /// public UniqueIdentityStrategy UniqueIdentityStrategy { get diff --git a/src/CSharp/EasyMicroservices.Cores.Database/Database/Interfaces/IDatabaseWidget.cs b/src/CSharp/EasyMicroservices.Cores.Database/Database/Interfaces/IDatabaseWidget.cs new file mode 100644 index 0000000..bf9ede7 --- /dev/null +++ b/src/CSharp/EasyMicroservices.Cores.Database/Database/Interfaces/IDatabaseWidget.cs @@ -0,0 +1,22 @@ +using EasyMicroservices.Cores.Interfaces; +using System.Threading.Tasks; + +namespace EasyMicroservices.Cores.Database.Interfaces; +/// +/// +/// +public interface IDatabaseWidget : IWidget +{ + /// + /// + /// + bool CanProcess(IBaseUnitOfWork baseUnitOfWork); + /// + /// + /// + /// + /// + /// + /// + Task Process(IDatabaseWidgetManager databaseWidgetManager, IBaseUnitOfWork baseUnitOfWork, T contract); +} diff --git a/src/CSharp/EasyMicroservices.Cores.Database/Database/Interfaces/IDatabaseWidgetManager.cs b/src/CSharp/EasyMicroservices.Cores.Database/Database/Interfaces/IDatabaseWidgetManager.cs new file mode 100644 index 0000000..f411417 --- /dev/null +++ b/src/CSharp/EasyMicroservices.Cores.Database/Database/Interfaces/IDatabaseWidgetManager.cs @@ -0,0 +1,19 @@ +using EasyMicroservices.Cores.Interfaces; +using EasyMicroservices.Database.Interfaces; +using System.Threading.Tasks; + +namespace EasyMicroservices.Cores.Database.Interfaces; +/// +/// +/// +public interface IDatabaseWidgetManager : IWidgetManager +{ + /// + /// + /// + /// + /// + /// + /// + Task Add(IBaseUnitOfWork baseUnitOfWork, T contract); +} diff --git a/src/CSharp/EasyMicroservices.Cores.Database/Database/Interfaces/IWritableLogic.cs b/src/CSharp/EasyMicroservices.Cores.Database/Database/Interfaces/IWritableLogic.cs index e9dde22..262d549 100644 --- a/src/CSharp/EasyMicroservices.Cores.Database/Database/Interfaces/IWritableLogic.cs +++ b/src/CSharp/EasyMicroservices.Cores.Database/Database/Interfaces/IWritableLogic.cs @@ -101,6 +101,7 @@ public interface IContractWritableLogic /// /// + [Obsolete] Task> AddEntity(TEntity entity, CancellationToken cancellationToken = default); /// diff --git a/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs b/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs index c51176d..1690aa9 100644 --- a/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs +++ b/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs @@ -598,7 +598,7 @@ private async Task> InternalUpdateBulk(IEa { if (uniqueIdentityManager.UpdateUniqueIdentity(currentUserUniqueIdentity, easyWritableQueryable.Context, entityEntry.Entity)) { - FixUniqueIdentity(easyWritableQueryable.Context,typeof(TEntity), [entityEntry]); + FixUniqueIdentity(easyWritableQueryable.Context, typeof(TEntity), [entityEntry]); } } } @@ -938,11 +938,13 @@ void FixUniqueIdentity(IContext context, Type entityType, IEntityEntry[] entityE /// /// /// + /// /// /// + /// /// /// - public async Task> Add(IEasyWritableQueryableAsync easyWritableQueryable, TEntity entity, CancellationToken cancellationToken = default) + internal async Task> Add(IEasyWritableQueryableAsync easyWritableQueryable, TEntity entity, TContract contract, CancellationToken cancellationToken = default) where TEntity : class { var result = await easyWritableQueryable.AddAsync(entity, cancellationToken); @@ -971,6 +973,8 @@ await InternalUpdate(easyWritableQueryable, result.Entity, false, true, true, tr await easyWritableQueryable.SaveChangesAsync(); } } + var widgetManager = _baseUnitOfWork.GetDatabaseWidgetManager(); + await widgetManager.Add(_baseUnitOfWork, contract); await ActivityChangeLogLogic.AddAsync(result.Entity, _baseUnitOfWork); return result.Entity; } @@ -1038,7 +1042,7 @@ public async Task> Add(IEasyWritabl where TEntity : class { var entity = await MapAsync(contract); - var result = await Add(easyWritableQueryable, entity, cancellationToken); + var result = await Add(easyWritableQueryable, entity, contract, cancellationToken); return result; } diff --git a/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseMappedLogicBase.cs b/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseMappedLogicBase.cs index 26d5ac2..1f7e7a2 100644 --- a/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseMappedLogicBase.cs +++ b/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseMappedLogicBase.cs @@ -149,9 +149,10 @@ public async Task> AddBulk(CreateBulkRequ /// /// /// + [Obsolete] public Task> AddEntity(TEntity entity, CancellationToken cancellationToken = default) { - return Add(_easyWriteableQueryable, entity, cancellationToken); + return Add(_easyWriteableQueryable, entity, entity, cancellationToken); } /// diff --git a/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/IdSchemaDatabaseMappedLogicBase.cs b/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/IdSchemaDatabaseMappedLogicBase.cs index 772c0b6..712828b 100644 --- a/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/IdSchemaDatabaseMappedLogicBase.cs +++ b/src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/IdSchemaDatabaseMappedLogicBase.cs @@ -244,9 +244,10 @@ public async Task> AddBulk(CreateBulkRequestContract /// /// + [Obsolete] public Task> AddEntity(TEntity entity, CancellationToken cancellationToken = default) { - return Add(_easyWriteableQueryable, entity, cancellationToken); + return Add(_easyWriteableQueryable, entity, entity, cancellationToken); } /// diff --git a/src/CSharp/EasyMicroservices.Cores.Database/Database/Managers/DatabaseWidgetManager.cs b/src/CSharp/EasyMicroservices.Cores.Database/Database/Managers/DatabaseWidgetManager.cs new file mode 100644 index 0000000..4527305 --- /dev/null +++ b/src/CSharp/EasyMicroservices.Cores.Database/Database/Managers/DatabaseWidgetManager.cs @@ -0,0 +1,31 @@ +using EasyMicroservices.Cores.Database.Interfaces; +using EasyMicroservices.Cores.Interfaces; +using EasyMicroservices.Cores.Widgets; +using System.Threading.Tasks; + +namespace EasyMicroservices.Cores.Database.Managers; + +/// +/// +/// +public class DatabaseWidgetManager : WidgetManager, IDatabaseWidgetManager +{ + /// + /// + /// + /// + /// + /// + /// + public async Task Add(IBaseUnitOfWork baseUnitOfWork, T contract) + { + var widgets = GetWidgetsByType(typeof(T)); + foreach (var widget in widgets) + { + if (widget is IDatabaseWidget databaseWidget && databaseWidget.CanProcess(baseUnitOfWork)) + { + await databaseWidget.Process(this, baseUnitOfWork, contract); + } + } + } +} \ No newline at end of file diff --git a/src/CSharp/EasyMicroservices.Cores.Database/Database/Widgets/DatabaseBuilderWidget.cs b/src/CSharp/EasyMicroservices.Cores.Database/Database/Widgets/DatabaseBuilderWidget.cs new file mode 100644 index 0000000..4ef4159 --- /dev/null +++ b/src/CSharp/EasyMicroservices.Cores.Database/Database/Widgets/DatabaseBuilderWidget.cs @@ -0,0 +1,34 @@ +using EasyMicroservices.Cores.Interfaces; +using System; +using System.Reflection.Emit; + +namespace EasyMicroservices.Cores.Database.Widgets; +/// +/// +/// +public abstract class DatabaseBuilderWidget : IWidget +{ + /// + /// + /// + public void Build() + { + + } + + /// + /// + /// + /// + /// + /// + public abstract void OnModelCreating(TModelBuilder modelBuilder, string suffix = "", string prefix = ""); + /// + /// + /// + /// + public Type GetObjectType() + { + return typeof(DatabaseBuilderWidget); + } +} diff --git a/src/CSharp/EasyMicroservices.Cores.Database/Database/Widgets/ReportingBuilderWidget.cs b/src/CSharp/EasyMicroservices.Cores.Database/Database/Widgets/ReportingBuilderWidget.cs new file mode 100644 index 0000000..bb66eed --- /dev/null +++ b/src/CSharp/EasyMicroservices.Cores.Database/Database/Widgets/ReportingBuilderWidget.cs @@ -0,0 +1,22 @@ +using EasyMicroservices.Cores.Interfaces; +using System; + +namespace EasyMicroservices.Cores.Database.Widgets; +/// +/// +/// +public abstract class ReportingBuilderWidget : IWidget +{ + /// + /// + /// + public abstract void Build(); + /// + /// + /// + /// + public Type GetObjectType() + { + return typeof(ReportingBuilderWidget); + } +} diff --git a/src/CSharp/EasyMicroservices.Cores.Database/Database/Widgets/SimpleReportingEntityWidget.cs b/src/CSharp/EasyMicroservices.Cores.Database/Database/Widgets/SimpleReportingEntityWidget.cs new file mode 100644 index 0000000..d218051 --- /dev/null +++ b/src/CSharp/EasyMicroservices.Cores.Database/Database/Widgets/SimpleReportingEntityWidget.cs @@ -0,0 +1,76 @@ +using EasyMicroservices.Cores.Database.Interfaces; +using EasyMicroservices.Cores.Interfaces; +using EasyMicroservices.ServiceContracts; +using System; +using System.Threading.Tasks; + +namespace EasyMicroservices.Cores.Widgets; + +/// +/// +/// +/// +/// +public class SimpleReportingEntityWidget : IDatabaseWidget + where TReportEntity : class + where TObjectContract : class +{ + /// + /// + /// + public void Build() + { + + } + + /// + /// + /// + public bool CanProcess(IBaseUnitOfWork baseUnitOfWork) + { + if (baseUnitOfWork.LogicOptions.HasValue) + return !baseUnitOfWork.LogicOptions.Value.DoStopReporting; + return true; + } + + /// + /// + /// + /// + public Type GetObjectType() + { + return typeof(TObjectContract); + } + + /// + /// + /// + /// + /// + public Task Initialize(params TObjectContract[] parameters) + { + return TaskHelper.GetCompletedTask(); + } + + /// + /// + /// + /// + /// + /// + /// + /// + public async Task Process(IDatabaseWidgetManager databaseWidgetManager, IBaseUnitOfWork baseUnitOfWork, TObjectContract contract) + { + var reportEntity = await baseUnitOfWork + .GetMapper() + .MapAsync(contract); + + await baseUnitOfWork.GetLogic(new Models.LogicOptions() + { + DoStopReporting = true + }) + .Add(reportEntity) + .AsCheckedResult(); + } +} diff --git a/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj b/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj index 1cf5042..ff610f9 100644 --- a/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj +++ b/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj @@ -31,6 +31,7 @@ + diff --git a/src/CSharp/EasyMicroservices.Cores.Database/Interfaces/IBaseUnitOfWork.cs b/src/CSharp/EasyMicroservices.Cores.Database/Interfaces/IBaseUnitOfWork.cs index cd97c4e..59ed533 100644 --- a/src/CSharp/EasyMicroservices.Cores.Database/Interfaces/IBaseUnitOfWork.cs +++ b/src/CSharp/EasyMicroservices.Cores.Database/Interfaces/IBaseUnitOfWork.cs @@ -23,11 +23,11 @@ public interface IBaseUnitOfWork : IDisposable /// /// ServiceAddressInfo GetServiceAddress(string name); + /// /// /// - /// - void SetDefaultLogicOptions(LogicOptions logicOptions); + LogicOptions? LogicOptions { get; set; } /// /// @@ -60,6 +60,11 @@ public interface IBaseUnitOfWork : IDisposable /// /// T GetService(); + /// + /// + /// + /// + IDatabaseWidgetManager GetDatabaseWidgetManager(); /// /// diff --git a/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EntityFrameworkCoreDatabaseBuilder.cs b/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EntityFrameworkCoreDatabaseBuilder.cs index 39b7b99..00bcefa 100644 --- a/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EntityFrameworkCoreDatabaseBuilder.cs +++ b/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EntityFrameworkCoreDatabaseBuilder.cs @@ -1,4 +1,7 @@ -using EasyMicroservices.Cores.Models; +using EasyMicroservices.Cores.Database.Interfaces; +using EasyMicroservices.Cores.Database.Widgets; +using EasyMicroservices.Cores.Interfaces; +using EasyMicroservices.Cores.Models; using EasyMicroservices.Cores.Relational.EntityFrameworkCore.Intrerfaces; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; @@ -16,6 +19,21 @@ public abstract class EntityFrameworkCoreDatabaseBuilder : IEntityFrameworkCoreD /// /// protected readonly IConfiguration Configuration; + /// + /// + /// + protected readonly IDatabaseWidgetManager WidgetManager; + /// + /// + /// + /// + /// + public EntityFrameworkCoreDatabaseBuilder(IConfiguration configuration, IDatabaseWidgetManager widgetManager) + { + Configuration = configuration; + WidgetManager = widgetManager; + } + /// /// /// @@ -50,4 +68,18 @@ public virtual List GetDatabases() { return Configuration?.GetSection("Databases")?.Get>(); } + + /// + /// + /// + /// + public virtual void OnWidgetBuilder(ModelBuilder modelBuilder) + { + if (WidgetManager is null) + return; + foreach (var widget in WidgetManager.GetWidgets>()) + { + widget.OnModelCreating(modelBuilder); + } + } } \ No newline at end of file diff --git a/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/Intrerfaces/IEntityFrameworkCoreDatabaseBuilder.cs b/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/Intrerfaces/IEntityFrameworkCoreDatabaseBuilder.cs index 6b62ebb..78e1ffb 100644 --- a/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/Intrerfaces/IEntityFrameworkCoreDatabaseBuilder.cs +++ b/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/Intrerfaces/IEntityFrameworkCoreDatabaseBuilder.cs @@ -14,5 +14,10 @@ public interface IEntityFrameworkCoreDatabaseBuilder /// /// void OnConfiguring(DbContextOptionsBuilder optionsBuilder); + /// + /// + /// + /// + void OnWidgetBuilder(ModelBuilder modelBuilder); } } diff --git a/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/RelationalCoreContext.cs b/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/RelationalCoreContext.cs index 680dfbd..f3fcee8 100644 --- a/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/RelationalCoreContext.cs +++ b/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/RelationalCoreContext.cs @@ -11,7 +11,8 @@ namespace EasyMicroservices.Cores.Relational.EntityFrameworkCore /// public class RelationalCoreContext : CoreContext { - IEntityFrameworkCoreDatabaseBuilder _builder; + readonly IEntityFrameworkCoreDatabaseBuilder _builder; + /// /// /// @@ -20,6 +21,7 @@ public RelationalCoreContext(IEntityFrameworkCoreDatabaseBuilder builder) { _builder = builder; } + /// /// /// @@ -34,8 +36,7 @@ public RelationalCoreContext() /// protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - if (_builder != null) - _builder.OnConfiguring(optionsBuilder); + _builder?.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder); } @@ -46,6 +47,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); + _builder?.OnWidgetBuilder(modelBuilder); new RelationalCoreModelBuilder().OnModelCreating(modelBuilder); } @@ -55,6 +57,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected virtual StringBuilder AutoModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); + _builder?.OnWidgetBuilder(modelBuilder); return new RelationalCoreModelBuilder().AutoModelCreating(modelBuilder); } } diff --git a/src/CSharp/EasyMicroservices.Cores.Tests/DatabaseLogics/LongIdMappedDatabaseLogicBaseTest.cs b/src/CSharp/EasyMicroservices.Cores.Tests/DatabaseLogics/LongIdMappedDatabaseLogicBaseTest.cs index a0d7d02..8b8071d 100644 --- a/src/CSharp/EasyMicroservices.Cores.Tests/DatabaseLogics/LongIdMappedDatabaseLogicBaseTest.cs +++ b/src/CSharp/EasyMicroservices.Cores.Tests/DatabaseLogics/LongIdMappedDatabaseLogicBaseTest.cs @@ -24,6 +24,11 @@ public void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseInMemoryDatabase("Test DB"); } + + public void OnWidgetBuilder(ModelBuilder modelBuilder) + { + + } } public class LongIdMappedDatabaseLogicBaseTest : IClassFixture, IClassFixture diff --git a/src/CSharp/EasyMicroservices.Cores.Tests/Fixtures/ServiceProviderFixture.cs b/src/CSharp/EasyMicroservices.Cores.Tests/Fixtures/ServiceProviderFixture.cs index 6b57dca..ec41e1c 100644 --- a/src/CSharp/EasyMicroservices.Cores.Tests/Fixtures/ServiceProviderFixture.cs +++ b/src/CSharp/EasyMicroservices.Cores.Tests/Fixtures/ServiceProviderFixture.cs @@ -2,6 +2,7 @@ using EasyMicroservices.Cores.AspEntityFrameworkCoreApi; using EasyMicroservices.Cores.AspEntityFrameworkCoreApi.Interfaces; using EasyMicroservices.Cores.Database.Interfaces; +using EasyMicroservices.Cores.Database.Logics; using EasyMicroservices.Cores.Database.Managers; using EasyMicroservices.Cores.Interfaces; using EasyMicroservices.Cores.Relational.EntityFrameworkCore; @@ -31,6 +32,7 @@ public async Task InitializeAsync() serviceCollection.AddTransient(serviceProvider => new MyTestContext(serviceProvider.GetService())); serviceCollection.AddTransient(); serviceCollection.AddSingleton(service => new WhiteLabelManager(service)); + serviceCollection.AddSingleton(); serviceCollection.AddSingleton((provider) => { return new DefaultUniqueIdentityManager(provider.GetService().CurrentWhiteLabel); diff --git a/src/CSharp/EasyMicroservices.Cores.sln b/src/CSharp/EasyMicroservices.Cores.sln index f4ff4f4..026aca6 100644 --- a/src/CSharp/EasyMicroservices.Cores.sln +++ b/src/CSharp/EasyMicroservices.Cores.sln @@ -15,9 +15,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyMicroservices.Cores.Asp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyMicroservices.Cores.Tests", "EasyMicroservices.Cores.Tests\EasyMicroservices.Cores.Tests.csproj", "{0EA879CC-3350-4B97-8517-DCE7DBD2C3CC}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DataAccess-Layer", "DataAccess-Layer", "{B9CFFFCB-64BC-4E3A-982B-C50FEFE6EA9B}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure-Layer", "Infrastructure-Layer", "{B9CFFFCB-64BC-4E3A-982B-C50FEFE6EA9B}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BusinessLogic-Layer", "BusinessLogic-Layer", "{5F639C59-EF1C-464B-85F1-FE01E4A9F81A}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Business-Layer", "Business-Layer", "{5F639C59-EF1C-464B-85F1-FE01E4A9F81A}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test-Layer", "Test-Layer", "{C2D086CC-9E2B-4152-B8F7-81E91032C17C}" EndProject @@ -27,7 +27,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyMicroservices.Cores.Asp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyMicroservices.Cores.AspCore.Tests", "EasyMicroservices.Cores.AspCore.Tests\EasyMicroservices.Cores.AspCore.Tests.csproj", "{243E15A6-5AD6-4304-8F91-D12666C59A0E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyMicroservices.Cores.Clients", "EasyMicroservices.Cores.Clients\EasyMicroservices.Cores.Clients.csproj", "{1F65B13F-F101-437C-80E7-BA4B54574D5F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyMicroservices.Cores.Clients", "EasyMicroservices.Cores.Clients\EasyMicroservices.Cores.Clients.csproj", "{1F65B13F-F101-437C-80E7-BA4B54574D5F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyMicroservices.Cores.Infrastructure", "EasyMicroservices.Cores.Infrastructure\EasyMicroservices.Cores.Infrastructure.csproj", "{37928D9D-11FD-40AB-9C4E-42C9B506D386}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -159,6 +161,18 @@ Global {1F65B13F-F101-437C-80E7-BA4B54574D5F}.Release|x64.Build.0 = Release|Any CPU {1F65B13F-F101-437C-80E7-BA4B54574D5F}.Release|x86.ActiveCfg = Release|Any CPU {1F65B13F-F101-437C-80E7-BA4B54574D5F}.Release|x86.Build.0 = Release|Any CPU + {37928D9D-11FD-40AB-9C4E-42C9B506D386}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {37928D9D-11FD-40AB-9C4E-42C9B506D386}.Debug|Any CPU.Build.0 = Debug|Any CPU + {37928D9D-11FD-40AB-9C4E-42C9B506D386}.Debug|x64.ActiveCfg = Debug|Any CPU + {37928D9D-11FD-40AB-9C4E-42C9B506D386}.Debug|x64.Build.0 = Debug|Any CPU + {37928D9D-11FD-40AB-9C4E-42C9B506D386}.Debug|x86.ActiveCfg = Debug|Any CPU + {37928D9D-11FD-40AB-9C4E-42C9B506D386}.Debug|x86.Build.0 = Debug|Any CPU + {37928D9D-11FD-40AB-9C4E-42C9B506D386}.Release|Any CPU.ActiveCfg = Release|Any CPU + {37928D9D-11FD-40AB-9C4E-42C9B506D386}.Release|Any CPU.Build.0 = Release|Any CPU + {37928D9D-11FD-40AB-9C4E-42C9B506D386}.Release|x64.ActiveCfg = Release|Any CPU + {37928D9D-11FD-40AB-9C4E-42C9B506D386}.Release|x64.Build.0 = Release|Any CPU + {37928D9D-11FD-40AB-9C4E-42C9B506D386}.Release|x86.ActiveCfg = Release|Any CPU + {37928D9D-11FD-40AB-9C4E-42C9B506D386}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -174,6 +188,7 @@ Global {2A012C31-966A-427B-B685-DCB95AC299E3} = {5F639C59-EF1C-464B-85F1-FE01E4A9F81A} {243E15A6-5AD6-4304-8F91-D12666C59A0E} = {C2D086CC-9E2B-4152-B8F7-81E91032C17C} {1F65B13F-F101-437C-80E7-BA4B54574D5F} = {B9CFFFCB-64BC-4E3A-982B-C50FEFE6EA9B} + {37928D9D-11FD-40AB-9C4E-42C9B506D386} = {B9CFFFCB-64BC-4E3A-982B-C50FEFE6EA9B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0E8382C1-722C-4F92-B66F-0354487C7F02}