Add Entity Hub and also Implement DI Extensions for Register Service ...
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using xCommons.Extensions;
|
||||
using xExceptions.Constants;
|
||||
using xTagService.Interfaces.Entities;
|
||||
|
||||
namespace xTagService.DI
|
||||
{
|
||||
public static class XDIHelperExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Register Module Provided Service on DI
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <param name="config"></param>
|
||||
public static void AddXTagService(
|
||||
this IServiceCollection services,
|
||||
ServiceLifetime lifeTime
|
||||
)
|
||||
{
|
||||
//
|
||||
AddTagService(
|
||||
services,
|
||||
lifeTime
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
#region Private ...
|
||||
/// <summary>
|
||||
/// a LogTag for XTagService ...
|
||||
/// </summary>
|
||||
private static string XLogTag = "XTagService";
|
||||
|
||||
/// <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 AddTagService(
|
||||
IServiceCollection services,
|
||||
ServiceLifetime lifeTime
|
||||
)
|
||||
{
|
||||
//
|
||||
var exception = XException.InvalidArgs.ToException(); ;
|
||||
|
||||
//
|
||||
// Services ...
|
||||
var isServicesExists = !services.IsNull();
|
||||
if (!isServicesExists)
|
||||
{
|
||||
//
|
||||
Log("AddTagService failed, services not provided ...");
|
||||
throw exception;
|
||||
}
|
||||
|
||||
//
|
||||
// Lifetime ...
|
||||
var isLifetimeExists = !lifeTime.IsNull();
|
||||
if (!isLifetimeExists)
|
||||
{
|
||||
//
|
||||
Log("AddTagService failed, lifetime not provided ...");
|
||||
throw exception;
|
||||
}
|
||||
|
||||
//
|
||||
// Check String Repository Exists ...
|
||||
var isRepositoryExists = !services
|
||||
.GetRegisteredService<IXTagRepository>()
|
||||
.IsNull();
|
||||
if (!isRepositoryExists)
|
||||
{
|
||||
//
|
||||
Log("AddTagService failed, IXTagRepository not provided ...");
|
||||
throw exception;
|
||||
}
|
||||
|
||||
//
|
||||
// Register Resource Providers ...
|
||||
// services.Add(new ServiceDescriptor(typeof(IXWebinarTitleResourceProvider), typeof(XWebinarTitleResourceProvider), lifeTime));
|
||||
// services.Add(new ServiceDescriptor(typeof(IXWebinarDescriptionResourceProvider), typeof(XWebinarDescriptionResourceProvider), lifeTime));
|
||||
|
||||
//
|
||||
// Register Main Provider ...
|
||||
// services.Add(new ServiceDescriptor(typeof(IXWebinarProvider), typeof(XWebinarProvider), lifeTime));
|
||||
|
||||
//
|
||||
Log("AddTagService Succeed ...");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xPushService.Base;
|
||||
using xTagService.Models.Entities;
|
||||
|
||||
namespace xTagService.Hubs
|
||||
{
|
||||
public class XTagEntityHub : XBaseEntityHub<XTag, int>
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public XTagEntityHub(ILogger<XBaseHub> logger) : base(logger)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user