Add String Service and Implement all of it's requirements as an xDashboard Package ...

This commit is contained in:
2025-11-04 18:09:54 +03:30
parent 83a9500f30
commit 5ea2b8e3b9
14 changed files with 1774 additions and 2 deletions
+82 -2
View File
@@ -1,3 +1,83 @@
namespace xStringService.DI {
public static class XDIHelperExtension { }
using System;
using Microsoft.Extensions.DependencyInjection;
using xExceptions.Constants;
using xCommons.Extensions;
using xStringService.Interfaces;
using xStringService.Providers;
namespace xStringService.DI
{
public static class XDIHelperExtension
{
/// <summary>
/// Register Module Provided Service on DI
/// </summary>
/// <param name="services"></param>
/// <param name="config"></param>
public static void AddXStringService(
this IServiceCollection services,
ServiceLifetime lifeTime
)
{
AddStringService(
services,
lifeTime
);
}
//
#region Private ...
/// <summary>
/// a LogTag for XStringService ...
/// </summary>
private static string XLogTag = "XStringService";
/// <summary>
/// print a log in Console ...
/// </summary>
/// <param name="message"></param>
private static void Log(string message)
{
Console.WriteLine($"{XLogTag} => {message}");
}
/// <summary>
/// Register Push Service ...
/// </summary>
/// <param name="services"></param>
/// <param name="lifeTime"></param>
private static void AddStringService(
IServiceCollection services,
ServiceLifetime lifeTime
)
{
//
var exception = XException.InvalidArgs.ToException(); ;
//
// Services ...
var isServicesExists = !services.IsNull();
if (!isServicesExists)
{
//
Log("AddStringService failed, services not provided ...");
throw exception;
}
//
// Lifetime ...
var isLifetimeExists = !lifeTime.IsNull();
if (!isLifetimeExists)
{
//
Log("AddStringService failed, lifetime not provided ...");
throw exception;
}
//
services.Add(new ServiceDescriptor(typeof(IXStringProvider), typeof(XStringProvider), lifeTime));
Log("AddStringService Succeed ...");
}
#endregion
}
}