diff --git a/DigitalData.Core.Abstraction.Application/DTO/DIExtensions.cs b/DigitalData.Core.Abstraction.Application/DTO/DIExtensions.cs index d04d8fe..89eba58 100644 --- a/DigitalData.Core.Abstraction.Application/DTO/DIExtensions.cs +++ b/DigitalData.Core.Abstraction.Application/DTO/DIExtensions.cs @@ -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; } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/DigitalData.Core.Abstraction.Application/DTO/DTOExtensions.cs b/DigitalData.Core.Abstraction.Application/DTO/DTOExtensions.cs index 39271be..971d5cc 100644 --- a/DigitalData.Core.Abstraction.Application/DTO/DTOExtensions.cs +++ b/DigitalData.Core.Abstraction.Application/DTO/DTOExtensions.cs @@ -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(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 FilterNull(this IEnumerable 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 /// The ending string. /// The joined string. [Obsolete("Use DigitalData.Core.Exceptions and .Middleware")] - public static string Join(this IEnumerable values, string start = "", string seperator = ". ", string end = ".") + public static string Join(this IEnumerable values, string start = "", string seperator = ". ", string end = ".") => new StringBuilder(start).Append(string.Join(seperator, values)).Append(end).ToString(); /// @@ -342,7 +343,7 @@ public static class DTOExtensions [Obsolete("Use DigitalData.Core.Exceptions and .Middleware")] public static void LogNotice(this ILogger logger, IEnumerable 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 /// True if the data result is false; otherwise, false. [Obsolete("Use DigitalData.Core.Exceptions and .Middleware")] public static bool IsWrong(this DataResult bResult) => !bResult.Data; -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/DigitalData.Core.Abstraction.Application/DTO/Flag.cs b/DigitalData.Core.Abstraction.Application/DTO/Flag.cs index 6010183..611a1b2 100644 --- a/DigitalData.Core.Abstraction.Application/DTO/Flag.cs +++ b/DigitalData.Core.Abstraction.Application/DTO/Flag.cs @@ -1,4 +1,5 @@ -namespace DigitalData.Core.Abstraction.Application.DTO; +#if NET +namespace DigitalData.Core.Abstraction.Application.DTO; /// /// 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. /// NotFound -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/DigitalData.Core.Abstraction.Application/DTO/Notice.cs b/DigitalData.Core.Abstraction.Application/DTO/Notice.cs index 326ee85..fc3f379 100644 --- a/DigitalData.Core.Abstraction.Application/DTO/Notice.cs +++ b/DigitalData.Core.Abstraction.Application/DTO/Notice.cs @@ -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 /// [Obsolete("Use DigitalData.Core.Exceptions and .Middleware")] public List Messages { get; init; } = new(); -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/DigitalData.Core.Abstraction.Application/DTO/Result.cs b/DigitalData.Core.Abstraction.Application/DTO/Result.cs index 2c36047..7313bce 100644 --- a/DigitalData.Core.Abstraction.Application/DTO/Result.cs +++ b/DigitalData.Core.Abstraction.Application/DTO/Result.cs @@ -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. -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/DigitalData.Core.Abstraction.Application/EntityExtensions.cs b/DigitalData.Core.Abstraction.Application/EntityExtensions.cs index d1d0677..ba5fbe5 100644 --- a/DigitalData.Core.Abstraction.Application/EntityExtensions.cs +++ b/DigitalData.Core.Abstraction.Application/EntityExtensions.cs @@ -1,4 +1,5 @@ -namespace DigitalData.Core.Abstraction.Application; +#if NET +namespace DigitalData.Core.Abstraction.Application; /// /// Provides extension methods for retrieving the value of an 'Id' property from objects. @@ -91,4 +92,5 @@ public static class EntityExtensions #pragma warning restore CS8601 return id is not null; } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/DigitalData.Core.Abstraction.Application/IBasicCRUDService.cs b/DigitalData.Core.Abstraction.Application/IBasicCRUDService.cs index 290b9ce..c2b91bb 100644 --- a/DigitalData.Core.Abstraction.Application/IBasicCRUDService.cs +++ b/DigitalData.Core.Abstraction.Application/IBasicCRUDService.cs @@ -1,4 +1,5 @@ -namespace DigitalData.Core.Abstraction.Application +#if NET +namespace DigitalData.Core.Abstraction.Application { /// /// Implements a simplified CRUD service interface that uses a single Data Transfer Object (DTO) type for all CRUD operations, @@ -18,4 +19,5 @@ where TDto : class where TEntity : class { } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/DigitalData.Core.Abstraction.Application/ICRUDService.cs b/DigitalData.Core.Abstraction.Application/ICRUDService.cs index 6b53fe8..12bc3a6 100644 --- a/DigitalData.Core.Abstraction.Application/ICRUDService.cs +++ b/DigitalData.Core.Abstraction.Application/ICRUDService.cs @@ -1,25 +1,26 @@ -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 : IReadService + where TCreateDto : class where TReadDto : class where TEntity : class { - [Obsolete("Use MediatR")] - public interface ICRUDService : IReadService - where TCreateDto : class where TReadDto : class where TEntity : class - { - /// - /// Asynchronously creates a new entity based on the provided and returns the identifier of the created entity wrapped in a . - /// The contains the identifier of the newly created entity on success or an error message on failure. - /// - /// The data transfer object containing the information for the new entity. - /// A task representing the asynchronous operation, with a containing the identifier of the created entity or an error message. - Task> CreateAsync(TCreateDto createDto); + /// + /// Asynchronously creates a new entity based on the provided and returns the identifier of the created entity wrapped in a . + /// The contains the identifier of the newly created entity on success or an error message on failure. + /// + /// The data transfer object containing the information for the new entity. + /// A task representing the asynchronous operation, with a containing the identifier of the created entity or an error message. + Task> CreateAsync(TCreateDto createDto); - /// - /// Updates an existing entity based on the provided updateDTO and returns the result wrapped in an IServiceMessage, - /// indicating the success or failure of the operation, including the error messages on failure. - /// - /// The updateDTO with updated values for the entity. - /// An Result indicating the outcome of the update operation, with an appropriate message. - Task UpdateAsync(TUpdateDto updateDto); - } -} \ No newline at end of file + /// + /// Updates an existing entity based on the provided updateDTO and returns the result wrapped in an IServiceMessage, + /// indicating the success or failure of the operation, including the error messages on failure. + /// + /// The updateDTO with updated values for the entity. + /// An Result indicating the outcome of the update operation, with an appropriate message. + Task UpdateAsync(TUpdateDto updateDto); +} +#endif \ No newline at end of file diff --git a/DigitalData.Core.Abstraction.Application/IDirectorySearchService.cs b/DigitalData.Core.Abstraction.Application/IDirectorySearchService.cs index 5ae1504..5d00c43 100644 --- a/DigitalData.Core.Abstraction.Application/IDirectorySearchService.cs +++ b/DigitalData.Core.Abstraction.Application/IDirectorySearchService.cs @@ -1,94 +1,96 @@ -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 ServerName { get; } - public string Root { get; } + public string Root { get; } - string SearchRootPath { get; } + string SearchRootPath { get; } - Dictionary CustomSearchFilters { get; } + Dictionary CustomSearchFilters { get; } - /// - /// Creates the connections to the server and returns a Boolean value that specifies - /// whether the specified username and password are valid. - /// - /// The username that is validated on the server. See the Remarks section - /// for more information on the format of userName. - /// The password that is validated on the server. - /// True if the credentials are valid; otherwise, false. - bool ValidateCredentials(string userName, string password); + /// + /// Creates the connections to the server and returns a Boolean value that specifies + /// whether the specified username and password are valid. + /// + /// The username that is validated on the server. See the Remarks section + /// for more information on the format of userName. + /// The password that is validated on the server. + /// True if the credentials are valid; otherwise, false. + bool ValidateCredentials(string userName, string password); - /// - /// Creates the connections to the server asynchronously and returns a Boolean value that specifies - /// whether the specified username and password are valid. - /// - /// The username that is validated on the server. See the Remarks section - /// for more information on the format of userName. - /// The password that is validated on the server. - /// True if the credentials are valid; otherwise, false. - Task ValidateCredentialsAsync(string userName, string password); + /// + /// Creates the connections to the server asynchronously and returns a Boolean value that specifies + /// whether the specified username and password are valid. + /// + /// The username that is validated on the server. See the Remarks section + /// for more information on the format of userName. + /// The password that is validated on the server. + /// True if the credentials are valid; otherwise, false. + Task ValidateCredentialsAsync(string userName, string password); - /// - /// Finds all directory entries matching the specified filter. - /// - /// The search root. - /// The search filter. - /// The search scope. - /// The size limit. - /// The properties to load. - /// A containing the results. - DataResult> FindAll(DirectoryEntry searchRoot, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties); + /// + /// Finds all directory entries matching the specified filter. + /// + /// The search root. + /// The search filter. + /// The search scope. + /// The size limit. + /// The properties to load. + /// A containing the results. + DataResult> FindAll(DirectoryEntry searchRoot, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties); - /// - /// Finds all directory entries matching the specified filter asynchronously. - /// - /// The search root. - /// The search filter. - /// The search scope. - /// The size limit. - /// The properties to load. - /// A containing the results. - Task>> FindAllAsync(DirectoryEntry searchRoot, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties); + /// + /// Finds all directory entries matching the specified filter asynchronously. + /// + /// The search root. + /// The search filter. + /// The search scope. + /// The size limit. + /// The properties to load. + /// A containing the results. + Task>> FindAllAsync(DirectoryEntry searchRoot, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties); - /// - /// Finds all directory entries matching the specified filter, using the user cache. - /// - /// The username. - /// The search filter. - /// The search scope. - /// The size limit. - /// The properties to load. - /// A containing the results. - DataResult> FindAllByUserCache(string username, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties); + /// + /// Finds all directory entries matching the specified filter, using the user cache. + /// + /// The username. + /// The search filter. + /// The search scope. + /// The size limit. + /// The properties to load. + /// A containing the results. + DataResult> FindAllByUserCache(string username, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties); - /// - /// Finds all directory entries matching the specified filter asynchronously, using the user cache. - /// - /// The username. - /// The search filter. - /// The search scope. - /// The size limit. - /// The properties to load. - /// A containing the results. - Task>> FindAllByUserCacheAsync(string username, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties); + /// + /// Finds all directory entries matching the specified filter asynchronously, using the user cache. + /// + /// The username. + /// The search filter. + /// The search scope. + /// The size limit. + /// The properties to load. + /// A containing the results. + Task>> FindAllByUserCacheAsync(string username, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties); - /// - /// Sets the search root in the cache. - /// - /// The directory entry username. - /// The directory entry password. - void SetSearchRootCache(string username, string password); + /// + /// Sets the search root in the cache. + /// + /// The directory entry username. + /// The directory entry password. + void SetSearchRootCache(string username, string password); - /// - /// Gets the search root from the cache. - /// - /// The directory entry username. - /// The cached if found; otherwise, null. - DirectoryEntry? GetSearchRootCache(string username); - } -} \ No newline at end of file + /// + /// Gets the search root from the cache. + /// + /// The directory entry username. + /// The cached if found; otherwise, null. + DirectoryEntry? GetSearchRootCache(string username); +} +#endif \ No newline at end of file diff --git a/DigitalData.Core.Abstraction.Application/IJWTService.cs b/DigitalData.Core.Abstraction.Application/IJWTService.cs index b5008e6..8ecc32e 100644 --- a/DigitalData.Core.Abstraction.Application/IJWTService.cs +++ b/DigitalData.Core.Abstraction.Application/IJWTService.cs @@ -1,41 +1,42 @@ -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; + +/// +/// Defines the operations for JWT service handling claims of type . +/// +public interface IJWTService { /// - /// Defines the operations for JWT service handling claims of type . + /// Generates a symmetric security key with the specified byte size. /// - public interface IJWTService + /// The size of the security key in bytes. Default is 32 bytes. + /// A new instance of . + public static SymmetricSecurityKey GenerateSecurityKey(int byteSize = 32) { - /// - /// Generates a symmetric security key with the specified byte size. - /// - /// The size of the security key in bytes. Default is 32 bytes. - /// A new instance of . - public static SymmetricSecurityKey GenerateSecurityKey(int byteSize = 32) - { - using var rng = RandomNumberGenerator.Create(); - var randomBytes = new byte[byteSize]; - rng.GetBytes(randomBytes); - var securityKey = new SymmetricSecurityKey(randomBytes); + using var rng = RandomNumberGenerator.Create(); + var randomBytes = new byte[byteSize]; + rng.GetBytes(randomBytes); + var securityKey = new SymmetricSecurityKey(randomBytes); - return securityKey; - } - - /// - /// Generates a token based on the specified claim value. - /// - /// The claim value to encode in the token. - /// A JWT as a string. - string GenerateToken(TClaimValue claimValue); - - /// - /// Reads and validates a security token from a string representation. - /// - /// The JWT to read. - /// A if the token is valid; otherwise, null. - JwtSecurityToken? ReadSecurityToken(string token); + return securityKey; } -} \ No newline at end of file + + /// + /// Generates a token based on the specified claim value. + /// + /// The claim value to encode in the token. + /// A JWT as a string. + string GenerateToken(TClaimValue claimValue); + + /// + /// Reads and validates a security token from a string representation. + /// + /// The JWT to read. + /// A if the token is valid; otherwise, null. + JwtSecurityToken? ReadSecurityToken(string token); +} +#endif \ No newline at end of file diff --git a/DigitalData.Core.Abstraction.Application/IReadService.cs b/DigitalData.Core.Abstraction.Application/IReadService.cs index ccc7ccd..4392299 100644 --- a/DigitalData.Core.Abstraction.Application/IReadService.cs +++ b/DigitalData.Core.Abstraction.Application/IReadService.cs @@ -1,39 +1,40 @@ -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 + where TReadDto : class where TEntity : class { - [Obsolete("Use MediatR")] - public interface IReadService - where TReadDto : class where TEntity : class - { - /// - /// 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. - /// - /// The identifier of the entity to retrieve. - /// An DataResult containing the readDTO representing the found entity or null, with an appropriate message. - Task> ReadByIdAsync(TId id); + /// + /// 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. + /// + /// The identifier of the entity to retrieve. + /// An DataResult containing the readDTO representing the found entity or null, with an appropriate message. + Task> ReadByIdAsync(TId id); - /// - /// Retrieves all entities and returns their readDTO representations wrapped in an IServiceResult, - /// including a collection of readDTOs on success or an error message on failure. - /// - /// An DataResult containing a collection of readDTOs representing all entities or an error message. - Task>> ReadAllAsync(); - - /// - /// Deletes an entity by its identifier and returns the result wrapped in an IServiceMessage, - /// indicating the success or failure of the operation, including the error messages on failure. - /// - /// The identifier of the entity to delete. - /// An Result indicating the outcome of the delete operation, with an appropriate message. - Task DeleteAsyncById(TId id); + /// + /// Retrieves all entities and returns their readDTO representations wrapped in an IServiceResult, + /// including a collection of readDTOs on success or an error message on failure. + /// + /// An DataResult containing a collection of readDTOs representing all entities or an error message. + Task>> ReadAllAsync(); - /// - /// Asynchronously checks if an entity with the specified identifier exists within the data store. - /// - /// The identifier of the entity to check. - /// A task that represents the asynchronous operation. The task result contains a boolean value indicating whether the entity exists. - Task HasEntity(TId id); - } -} \ No newline at end of file + /// + /// Deletes an entity by its identifier and returns the result wrapped in an IServiceMessage, + /// indicating the success or failure of the operation, including the error messages on failure. + /// + /// The identifier of the entity to delete. + /// An Result indicating the outcome of the delete operation, with an appropriate message. + Task DeleteAsyncById(TId id); + + /// + /// Asynchronously checks if an entity with the specified identifier exists within the data store. + /// + /// The identifier of the entity to check. + /// A task that represents the asynchronous operation. The task result contains a boolean value indicating whether the entity exists. + Task HasEntity(TId id); +} +#endif \ No newline at end of file diff --git a/DigitalData.Core.Abstraction.Application/Repository/ICRUDRepository.cs b/DigitalData.Core.Abstraction.Application/Repository/ICRUDRepository.cs index 281169e..8e874cb 100644 --- a/DigitalData.Core.Abstraction.Application/Repository/ICRUDRepository.cs +++ b/DigitalData.Core.Abstraction.Application/Repository/ICRUDRepository.cs @@ -1,4 +1,5 @@ -namespace DigitalData.Core.Abstraction.Application.Repository +#if NET +namespace DigitalData.Core.Abstraction.Application.Repository { /// /// Defines the contract for CRUD operations on a repository for entities of type TEntity. @@ -60,4 +61,5 @@ /// Task CountAsync(TId id); } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/DigitalData.Core.Abstraction.Application/Repository/IEntityMapper.cs b/DigitalData.Core.Abstraction.Application/Repository/IEntityMapper.cs index fd3bd5b..b5509ce 100644 --- a/DigitalData.Core.Abstraction.Application/Repository/IEntityMapper.cs +++ b/DigitalData.Core.Abstraction.Application/Repository/IEntityMapper.cs @@ -1,4 +1,7 @@ -namespace DigitalData.Core.Abstraction.Application.Repository +#if NETFRAMEWORK +using System.Collections.Generic; +#endif +namespace DigitalData.Core.Abstraction.Application.Repository { /// /// Defines methods for mapping between entities and Data Transfer Objects (DTOs).