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:
Developer 02 2025-09-30 17:33:51 +02:00
parent 07ab7f0c62
commit 74a625a863
13 changed files with 215 additions and 191 deletions

View File

@ -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

View File

@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
#if NET
using Microsoft.Extensions.Logging;
using System.Text;
namespace DigitalData.Core.Abstraction.Application.DTO;
@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,7 +1,8 @@
using DigitalData.Core.Abstraction.Application.DTO;
#if NET
using DigitalData.Core.Abstraction.Application.DTO;
namespace DigitalData.Core.Abstraction.Application;
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
@ -22,4 +23,4 @@ namespace DigitalData.Core.Abstraction.Application
/// <returns>An Result indicating the outcome of the update operation, with an appropriate message.</returns>
Task<Result> UpdateAsync<TUpdateDto>(TUpdateDto updateDto);
}
}
#endif

View File

@ -1,8 +1,10 @@
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 string ServerName { get; }
@ -91,4 +93,4 @@ namespace DigitalData.Core.Abstraction.Application
/// <returns>The cached <see cref="DirectoryEntry"/> if found; otherwise, null.</returns>
DirectoryEntry? GetSearchRootCache(string username);
}
}
#endif

View File

@ -1,9 +1,10 @@
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>
@ -38,4 +39,4 @@ namespace DigitalData.Core.Abstraction.Application
/// <returns>A <see cref="JwtSecurityToken"/> if the token is valid; otherwise, null.</returns>
JwtSecurityToken? ReadSecurityToken(string token);
}
}
#endif

View File

@ -1,7 +1,8 @@
using DigitalData.Core.Abstraction.Application.DTO;
#if NET
using DigitalData.Core.Abstraction.Application.DTO;
namespace DigitalData.Core.Abstraction.Application;
namespace DigitalData.Core.Abstraction.Application
{
[Obsolete("Use MediatR")]
public interface IReadService<TReadDto, TEntity, TId>
where TReadDto : class where TEntity : class
@ -36,4 +37,4 @@ namespace DigitalData.Core.Abstraction.Application
/// <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

View File

@ -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

View File

@ -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).