last ...
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using xCommons.Extensions;
|
||||
using xDataService.DI;
|
||||
using xDataService.Models;
|
||||
using xMessageService.DI;
|
||||
using xServices.Configurations;
|
||||
using xServices.Constants;
|
||||
using xServices.Interfaces;
|
||||
using xServices.Providers;
|
||||
using xStorageService.DI;
|
||||
|
||||
namespace xServices.DI
|
||||
@@ -48,7 +54,7 @@ namespace xServices.DI
|
||||
}
|
||||
|
||||
//
|
||||
services.AddSingleton<XServicesConfiguration>(config);
|
||||
services.AddSingleton(config);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -68,18 +74,21 @@ namespace xServices.DI
|
||||
}
|
||||
|
||||
//
|
||||
services.AddSingleton<XServicesConfiguration>(configuration);
|
||||
services.AddSingleton(configuration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register Services ...
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <param name="configuration"></param>
|
||||
/// <param name="databases"></param>
|
||||
/// <param name="lifeTime"></param>
|
||||
public static void AddXServices(
|
||||
this IServiceCollection services,
|
||||
IConfiguration configuration,
|
||||
ServiceLifetime lifeTime = ServiceLifetime.Transient
|
||||
IEnumerable<XDatabaseDescriptor> databases = null,
|
||||
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -90,6 +99,7 @@ namespace xServices.DI
|
||||
config: config,
|
||||
services: services,
|
||||
lifeTime: lifeTime,
|
||||
databases: databases,
|
||||
configuration: configuration
|
||||
);
|
||||
}
|
||||
@@ -99,12 +109,15 @@ namespace xServices.DI
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <param name="configuration"></param>
|
||||
/// <param name="config"></param>
|
||||
/// <param name="databases"></param>
|
||||
/// <param name="lifeTime"></param>
|
||||
public static void AddXServices(
|
||||
this IServiceCollection services,
|
||||
IConfiguration configuration,
|
||||
XServicesConfiguration config,
|
||||
ServiceLifetime lifeTime = ServiceLifetime.Transient
|
||||
IEnumerable<XDatabaseDescriptor> databases = null,
|
||||
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -112,6 +125,7 @@ namespace xServices.DI
|
||||
config: config,
|
||||
services: services,
|
||||
lifeTime: lifeTime,
|
||||
databases: databases,
|
||||
configuration: configuration
|
||||
);
|
||||
}
|
||||
@@ -120,11 +134,35 @@ namespace xServices.DI
|
||||
/// Use All Required Middlewares ...
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
public static void UseXServices(this IApplicationBuilder app)
|
||||
/// <param name="databases"></param>
|
||||
/// <param name="isDevelopmentEnvironment"></param>
|
||||
public static void UseXServices(
|
||||
this IApplicationBuilder app,
|
||||
IEnumerable<XDatabaseDescriptor> databases = null,
|
||||
bool isDevelopmentEnvironment = false
|
||||
)
|
||||
{
|
||||
//
|
||||
// Use Storage Service ...
|
||||
app.UseXStorageService();
|
||||
|
||||
//
|
||||
#region Use Data Data Service ...
|
||||
if (databases.HasChild())
|
||||
{
|
||||
//
|
||||
databases
|
||||
.ToList()
|
||||
.ForEach(database =>
|
||||
{
|
||||
//
|
||||
app.UseXDatabase(
|
||||
descriptor: database,
|
||||
isDevelopmentEnvironment: isDevelopmentEnvironment
|
||||
);
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
//
|
||||
@@ -134,11 +172,14 @@ namespace xServices.DI
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <param name="config"></param>
|
||||
/// <param name="configuration"></param>
|
||||
/// <param name="databases"></param>
|
||||
/// <param name="lifeTime"></param>
|
||||
private static void AddServices(
|
||||
this IServiceCollection services,
|
||||
IConfiguration configuration,
|
||||
XServicesConfiguration config = null,
|
||||
IEnumerable<XDatabaseDescriptor> databases = null,
|
||||
ServiceLifetime lifeTime = ServiceLifetime.Transient
|
||||
)
|
||||
{
|
||||
@@ -156,6 +197,31 @@ namespace xServices.DI
|
||||
//
|
||||
// Message Service ...
|
||||
services.AddXMessageService(config: configuration);
|
||||
|
||||
//
|
||||
#region Register Data Service ...
|
||||
//
|
||||
if (databases.HasChild())
|
||||
{
|
||||
//
|
||||
databases
|
||||
.ToList()
|
||||
.ForEach(database =>
|
||||
{
|
||||
//
|
||||
// Register DataBase ...
|
||||
services.AddXDatabase(
|
||||
lifetime: lifeTime,
|
||||
descriptor: database,
|
||||
configuration: configuration
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
// Register Repository Services ...
|
||||
services.AddScoped<IXTestRepositoryService, XTestRepositoryService>();
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user