From 9d66f1d19e8e5588ffcc969059bfd088d8755439 Mon Sep 17 00:00:00 2001 From: TekH Date: Thu, 26 Feb 2026 19:02:45 +0100 Subject: [PATCH] Remove BaseClass and logging utilities Deleted Base.cs and Logging.cs, removing BaseClass, logging configuration, logger classes, and related extension methods for enums and DataRow. These foundational and logging utilities are no longer part of the project. --- .../Jobs/Infrastructure/Base.cs | 63 ------------------- .../Jobs/Infrastructure/Logging.cs | 41 ------------ 2 files changed, 104 deletions(-) delete mode 100644 EnvelopeGenerator.ServiceHost/Jobs/Infrastructure/Base.cs delete mode 100644 EnvelopeGenerator.ServiceHost/Jobs/Infrastructure/Logging.cs diff --git a/EnvelopeGenerator.ServiceHost/Jobs/Infrastructure/Base.cs b/EnvelopeGenerator.ServiceHost/Jobs/Infrastructure/Base.cs deleted file mode 100644 index abccf9c5..00000000 --- a/EnvelopeGenerator.ServiceHost/Jobs/Infrastructure/Base.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.Data; -using DigitalData.Modules.Logging; - -namespace DigitalData.Modules.Base; - -public abstract class BaseClass -{ - protected BaseClass(LogConfig logConfig) - { - LogConfig = logConfig; - Logger = logConfig.GetLogger(); - } - - protected LogConfig LogConfig { get; } - protected Logger Logger { get; } -} - -public static class ObjectEx -{ - public static T ToEnum(object value) where T : struct, Enum - { - if (value is T enumValue) - { - return enumValue; - } - - if (value is string stringValue && Enum.TryParse(stringValue, true, out var parsed)) - { - return parsed; - } - - if (int.TryParse(Convert.ToString(value), out var intValue)) - { - return (T)Enum.ToObject(typeof(T), intValue); - } - - return default; - } -} - -public static class DataRowExtensions -{ - public static T ItemEx(this DataRow row, string columnName, T defaultValue) - { - if (!row.Table.Columns.Contains(columnName)) - { - return defaultValue; - } - - var value = row[columnName]; - if (value is DBNull or null) - { - return defaultValue; - } - - return (T)Convert.ChangeType(value, typeof(T)); - } - - public static string ItemEx(this DataRow row, string columnName, string defaultValue) - { - return ItemEx(row, columnName, defaultValue); - } -} diff --git a/EnvelopeGenerator.ServiceHost/Jobs/Infrastructure/Logging.cs b/EnvelopeGenerator.ServiceHost/Jobs/Infrastructure/Logging.cs deleted file mode 100644 index 1331db0e..00000000 --- a/EnvelopeGenerator.ServiceHost/Jobs/Infrastructure/Logging.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Globalization; - -namespace DigitalData.Modules.Logging; - -public class LogConfig -{ - public bool Debug { get; set; } - - public Logger GetLogger() => new(); -} - -public class Logger -{ - ILogger logger; - - public void LogDebug(string message, params object?[] args) => Write("DEBUG", message, args); - - public void LogInformation(string message, params object?[] args) => Write("INFO", message, args); - - public void LogWarning(string message, params object?[] args) => Write("WARN", message, args); - - public void LogWarning(Exception exception, string message, params object?[] args) => Write("WARN", message + " " + exception.Message, args); - - public void Error(Exception exception) => logger.LogError(exception, exception.Message); - - public void LogError(Exception exception, string message, params object?[] args) => Write("ERROR", message + " " + exception.Message, args); - - private static void Write(string level, string message, params object?[] args) - { - var formatted = args.Length > 0 ? string.Format(CultureInfo.InvariantCulture, message, args) : message; - Console.WriteLine($"[{level}] {formatted}"); - } -} - -public static class LoggerExtensions -{ - public static void LogError(this ILogger logger, Exception exception) - { - logger.LogError(exception, "{message}", exception.Message); - } -} \ No newline at end of file