Enhance framework compatibility and code readability
Added preprocessor directives for .NET framework compatibility. Modified `using` directives to be framework-specific. Improved code formatting for better readability. Introduced obsolete attributes for deprecated methods, recommending `MediatR` as an alternative. Added XML documentation for clarity and maintainability.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
#if NET
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Configuration;
|
||||
|
||||
@@ -31,4 +32,5 @@ public static class DIExtensions
|
||||
});
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
#if NET
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application.DTO;
|
||||
@@ -19,7 +20,7 @@ public static class DTOExtensions
|
||||
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||
public static T Message<T>(this T result, string? message) where T : Result
|
||||
{
|
||||
if(message is not null)
|
||||
if (message is not null)
|
||||
result.Messages.Add(message);
|
||||
return result;
|
||||
}
|
||||
@@ -28,7 +29,7 @@ public static class DTOExtensions
|
||||
internal static IEnumerable<T> FilterNull<T>(this IEnumerable<T?> list)
|
||||
{
|
||||
foreach (var item in list)
|
||||
if(item is not null)
|
||||
if (item is not null)
|
||||
yield return item;
|
||||
}
|
||||
|
||||
@@ -328,7 +329,7 @@ public static class DTOExtensions
|
||||
/// <param name="end">The ending string.</param>
|
||||
/// <returns>The joined string.</returns>
|
||||
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||
public static string Join<T>(this IEnumerable<T> values, string start = "", string seperator = ". ", string end = ".")
|
||||
public static string Join<T>(this IEnumerable<T> values, string start = "", string seperator = ". ", string end = ".")
|
||||
=> new StringBuilder(start).Append(string.Join(seperator, values)).Append(end).ToString();
|
||||
|
||||
/// <summary>
|
||||
@@ -342,7 +343,7 @@ public static class DTOExtensions
|
||||
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||
public static void LogNotice(this ILogger logger, IEnumerable<Notice> notices, string start = ": ", string seperator = ". ", string end = ".\n")
|
||||
{
|
||||
foreach(LogLevel level in Enum.GetValues(typeof(LogLevel)))
|
||||
foreach (LogLevel level in Enum.GetValues(typeof(LogLevel)))
|
||||
{
|
||||
var logNotices = notices.Where(n => n.Level == level);
|
||||
|
||||
@@ -350,7 +351,7 @@ public static class DTOExtensions
|
||||
continue;
|
||||
|
||||
var sb = new StringBuilder();
|
||||
foreach(Notice notice in logNotices)
|
||||
foreach (Notice notice in logNotices)
|
||||
{
|
||||
if (notice.Flag is not null)
|
||||
sb.Append(notice.Flag);
|
||||
@@ -390,4 +391,5 @@ public static class DTOExtensions
|
||||
/// <returns>True if the data result is false; otherwise, false.</returns>
|
||||
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||
public static bool IsWrong(this DataResult<bool> bResult) => !bResult.Data;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
namespace DigitalData.Core.Abstraction.Application.DTO;
|
||||
#if NET
|
||||
namespace DigitalData.Core.Abstraction.Application.DTO;
|
||||
|
||||
/// <summary>
|
||||
/// Defines flags that indicate specific types of status or conditions in a service operation.
|
||||
@@ -47,4 +48,5 @@ public enum Flag
|
||||
/// This flag is used when the specified item or condition does not exist or is unavailable.
|
||||
/// </summary>
|
||||
NotFound
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
#if NET
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application.DTO;
|
||||
|
||||
@@ -25,4 +26,5 @@ public class Notice
|
||||
/// </summary>
|
||||
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||
public List<string> Messages { get; init; } = new();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text.Json.Serialization;
|
||||
#if NET
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application.DTO;
|
||||
|
||||
@@ -105,4 +106,5 @@ public class Result
|
||||
Data = default
|
||||
};
|
||||
#pragma warning restore CS8601 // Possible null reference assignment.
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user