Last Works on Webinar ...

This commit is contained in:
2025-11-05 05:07:24 +03:30
parent 330201023b
commit 0b0083a479
12 changed files with 1380 additions and 19 deletions
+115 -1
View File
@@ -1,3 +1,117 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using xCommons.Extensions;
using xExceptions.Constants;
using xWebinarService.Interfaces;
using xWebinarService.Interfaces.Entities;
using xWebinarService.Providers;
namespace xWebinarService.DI {
public static class XDIHelperExtension { }
public static class XDIHelperExtension
{
/// <summary>
/// Register Module Provided Service on DI
/// </summary>
/// <param name="services"></param>
/// <param name="config"></param>
public static void AddXWebinarService(
this IServiceCollection services,
ServiceLifetime lifeTime
)
{
//
AddWebinarService(
services,
lifeTime
);
}
//
#region Private ...
/// <summary>
/// a LogTag for XWebinarService ...
/// </summary>
private static string XLogTag = "XWebinarService";
/// <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 AddWebinarService(
IServiceCollection services,
ServiceLifetime lifeTime
)
{
//
var exception = XException.InvalidArgs.ToException(); ;
//
// Services ...
var isServicesExists = !services.IsNull();
if (!isServicesExists)
{
//
Log("AddWebinarService failed, services not provided ...");
throw exception;
}
//
// Lifetime ...
var isLifetimeExists = !lifeTime.IsNull();
if (!isLifetimeExists)
{
//
Log("AddWebinarService failed, lifetime not provided ...");
throw exception;
}
//
// Check String Repository Exists ...
var isWebinarRepositoryExists = !services
.GetRegisteredService<IXWebinarRepository>()
.IsNull() &&
!services.GetRegisteredService<IXWebinarSubscriberRepository>()
.IsNull();
if (!isWebinarRepositoryExists)
{
//
Log("AddWebinarService failed, IXWebinarRepository or IXWebinarSubscriberRepository not provided ...");
throw exception;
}
//
// Check WEBRTC Hub Exists ...
var isWebRTCHubExists = !services.GetRegisteredService<XWebinarHub>().IsNull();
if (!isWebRTCHubExists)
{
//
Log("AddWebinarService failed, XWebinarHub 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("AddWebinarService Succeed ...");
}
#endregion
}
}