using System; using Microsoft.Extensions.DependencyInjection; using xCommons.Extensions; using xExceptions.Constants; using xFileService.Interfaces; using xFileService.Providers; namespace xFileService.DI { public static class XDIHelperExtension { /// /// Register Module Provided Service on DI /// /// /// public static void AddXFileService( this IServiceCollection services, ServiceLifetime lifeTime ) { // AddFileService( services, lifeTime ); } // #region Private ... /// /// a LogTag for Service ... /// private static string XLogTag = "XFileService"; /// /// print a log in Console ... /// /// private static void Log(string message) { Console.WriteLine($"{XLogTag} => {message}"); } /// /// Register Push Service ... /// /// /// private static void AddFileService( IServiceCollection services, ServiceLifetime lifeTime ) { // var exception = XException.InvalidArgs.ToException(); ; // // Services ... var isServicesExists = !services.IsNull(); if (!isServicesExists) { // Log("AddFileService failed, services not provided ..."); throw exception; } // // Lifetime ... var isLifetimeExists = !lifeTime.IsNull(); if (!isLifetimeExists) { // Log("AddFileService failed, lifetime not provided ..."); throw exception; } // // Check String Repository Exists ... var isRepositoryExists = !services .GetRegisteredService() .IsNull(); if (!isRepositoryExists) { // Log("AddFileService failed, IXTagRepository not provided ..."); throw exception; } // // Register Main Provider ... services.Add(new ServiceDescriptor(typeof(IXFileProvider), typeof(XFileProvider), lifeTime)); // Log("AddFileService Succeed ..."); } #endregion } internal class IXTagRepository { } }