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.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
|
||||
Reference in New Issue
Block a user