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.
This commit is contained in:
2026-02-26 19:02:45 +01:00
parent 14cef05d02
commit 9d66f1d19e
2 changed files with 0 additions and 104 deletions

View File

@@ -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<T>(object value) where T : struct, Enum
{
if (value is T enumValue)
{
return enumValue;
}
if (value is string stringValue && Enum.TryParse<T>(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<T>(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<string>(row, columnName, defaultValue);
}
}

View File

@@ -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<LogConfig> 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);
}
}