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:
parent
07ab7f0c62
commit
74a625a863
@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
#if NET
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Configuration;
|
||||
|
||||
@ -32,3 +33,4 @@ 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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
@ -391,3 +392,4 @@ public static class DTOExtensions
|
||||
[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.
|
||||
@ -48,3 +49,4 @@ public enum Flag
|
||||
/// </summary>
|
||||
NotFound
|
||||
}
|
||||
#endif
|
||||
@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
#if NET
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application.DTO;
|
||||
|
||||
@ -26,3 +27,4 @@ public class Notice
|
||||
[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;
|
||||
|
||||
@ -106,3 +107,4 @@ public class Result
|
||||
};
|
||||
#pragma warning restore CS8601 // Possible null reference assignment.
|
||||
}
|
||||
#endif
|
||||
@ -1,4 +1,5 @@
|
||||
namespace DigitalData.Core.Abstraction.Application;
|
||||
#if NET
|
||||
namespace DigitalData.Core.Abstraction.Application;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods for retrieving the value of an 'Id' property from objects.
|
||||
@ -92,3 +93,4 @@ public static class EntityExtensions
|
||||
return id is not null;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,4 +1,5 @@
|
||||
namespace DigitalData.Core.Abstraction.Application
|
||||
#if NET
|
||||
namespace DigitalData.Core.Abstraction.Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements a simplified CRUD service interface that uses a single Data Transfer Object (DTO) type for all CRUD operations,
|
||||
@ -19,3 +20,4 @@
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,11 +1,12 @@
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
#if NET
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application
|
||||
{
|
||||
[Obsolete("Use MediatR")]
|
||||
public interface ICRUDService<TCreateDto, TReadDto, TEntity, TId> : IReadService<TReadDto, TEntity, TId>
|
||||
namespace DigitalData.Core.Abstraction.Application;
|
||||
|
||||
[Obsolete("Use MediatR")]
|
||||
public interface ICRUDService<TCreateDto, TReadDto, TEntity, TId> : IReadService<TReadDto, TEntity, TId>
|
||||
where TCreateDto : class where TReadDto : class where TEntity : class
|
||||
{
|
||||
{
|
||||
/// <summary>
|
||||
/// Asynchronously creates a new entity based on the provided <paramref name="createDto"/> and returns the identifier of the created entity wrapped in a <see cref="DataResult{TId}"/>.
|
||||
/// The <see cref="DataResult{TId}"/> contains the identifier of the newly created entity on success or an error message on failure.
|
||||
@ -21,5 +22,5 @@ namespace DigitalData.Core.Abstraction.Application
|
||||
/// <param name="updateDto">The updateDTO with updated values for the entity.</param>
|
||||
/// <returns>An Result indicating the outcome of the update operation, with an appropriate message.</returns>
|
||||
Task<Result> UpdateAsync<TUpdateDto>(TUpdateDto updateDto);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,10 +1,12 @@
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
#if NET
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using System.DirectoryServices;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application
|
||||
namespace DigitalData.Core.Abstraction.Application;
|
||||
|
||||
[Obsolete("Use DigitalData.ActiveDirectory")]
|
||||
public interface IDirectorySearchService
|
||||
{
|
||||
public interface IDirectorySearchService
|
||||
{
|
||||
public string ServerName { get; }
|
||||
|
||||
public string Root { get; }
|
||||
@ -90,5 +92,5 @@ namespace DigitalData.Core.Abstraction.Application
|
||||
/// <param name="username">The directory entry username.</param>
|
||||
/// <returns>The cached <see cref="DirectoryEntry"/> if found; otherwise, null.</returns>
|
||||
DirectoryEntry? GetSearchRootCache(string username);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,14 +1,15 @@
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
#if NET
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application
|
||||
namespace DigitalData.Core.Abstraction.Application;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the operations for JWT service handling claims of type <typeparamref name="TClaimValue"/>.
|
||||
/// </summary>
|
||||
public interface IJWTService<TClaimValue>
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the operations for JWT service handling claims of type <typeparamref name="TClaimValue"/>.
|
||||
/// </summary>
|
||||
public interface IJWTService<TClaimValue>
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates a symmetric security key with the specified byte size.
|
||||
/// </summary>
|
||||
@ -37,5 +38,5 @@ namespace DigitalData.Core.Abstraction.Application
|
||||
/// <param name="token">The JWT to read.</param>
|
||||
/// <returns>A <see cref="JwtSecurityToken"/> if the token is valid; otherwise, null.</returns>
|
||||
JwtSecurityToken? ReadSecurityToken(string token);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,11 +1,12 @@
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
#if NET
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application
|
||||
{
|
||||
[Obsolete("Use MediatR")]
|
||||
public interface IReadService<TReadDto, TEntity, TId>
|
||||
namespace DigitalData.Core.Abstraction.Application;
|
||||
|
||||
[Obsolete("Use MediatR")]
|
||||
public interface IReadService<TReadDto, TEntity, TId>
|
||||
where TReadDto : class where TEntity : class
|
||||
{
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves an entity by its identifier and returns its readDTO representation wrapped in an IServiceResult,
|
||||
/// including the readDTO on success or null and an error message on failure.
|
||||
@ -35,5 +36,5 @@ namespace DigitalData.Core.Abstraction.Application
|
||||
/// <param name="id">The identifier of the entity to check.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains a boolean value indicating whether the entity exists.</returns>
|
||||
Task<bool> HasEntity(TId id);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,4 +1,5 @@
|
||||
namespace DigitalData.Core.Abstraction.Application.Repository
|
||||
#if NET
|
||||
namespace DigitalData.Core.Abstraction.Application.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the contract for CRUD operations on a repository for entities of type TEntity.
|
||||
@ -61,3 +62,4 @@
|
||||
Task<int> CountAsync(TId id);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,4 +1,7 @@
|
||||
namespace DigitalData.Core.Abstraction.Application.Repository
|
||||
#if NETFRAMEWORK
|
||||
using System.Collections.Generic;
|
||||
#endif
|
||||
namespace DigitalData.Core.Abstraction.Application.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines methods for mapping between entities and Data Transfer Objects (DTOs).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user