Kommentare zur Dokumentation hinzugefügt und Pakete konfiguriert.
This commit is contained in:
parent
b7584a1632
commit
0ad92e7592
@ -5,8 +5,7 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<!-- NuGet Package Metadata -->
|
||||
<PackageId>WebCore.Abstractions</PackageId>
|
||||
<Version>1.0.0</Version>
|
||||
<PackageId>DigitalData.Core.Abstractions</PackageId>
|
||||
<Authors>Digital Data GmbH</Authors>
|
||||
<Company>Digital Data GmbH</Company>
|
||||
<Product>DigitalData.Core.Abstractions</Product>
|
||||
@ -19,6 +18,7 @@
|
||||
<PackAsTool>False</PackAsTool>
|
||||
<NeutralLanguage>aa-DJ</NeutralLanguage>
|
||||
<PackageIcon>Assets\icon.png</PackageIcon>
|
||||
<Version>1.0.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
BIN
DigitalData.Core.Application/Assets/icon.png
Normal file
BIN
DigitalData.Core.Application/Assets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1020 KiB |
@ -81,6 +81,16 @@ namespace DigitalData.Core.Application
|
||||
.AddScoped<IDirectorySearchService, DirectorySearchService>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the JWT service to the <see cref="IServiceCollection"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="TClaimValue">The type of the claim value used in the JWT token.</typeparam>
|
||||
/// <param name="services">The <see cref="IServiceCollection"/> to add the service to.</param>
|
||||
/// <param name="tokenDescriptorFactory">A function that takes a claim value of type <typeparamref name="TClaimValue"/> and returns a <see cref="SecurityTokenDescriptor"/> used to configure the JWT token.</param>
|
||||
/// <returns>The original <see cref="IServiceCollection"/> instance, allowing further configuration.</returns>
|
||||
/// <remarks>
|
||||
/// This method adds the necessary services for handling JWT tokens. The <paramref name="tokenDescriptorFactory"/> function is used to generate the <see cref="SecurityTokenDescriptor"/> which is essential for creating the JWT tokens.
|
||||
/// </remarks>
|
||||
public static IServiceCollection AddJWTService<TClaimValue>(this IServiceCollection services, Func<TClaimValue, SecurityTokenDescriptor> tokenDescriptorFactory)
|
||||
{
|
||||
return services.AddScoped<IJWTService<TClaimValue>, JWTService<TClaimValue>>(provider => new (tokenDescriptorFactory));
|
||||
|
||||
@ -4,8 +4,25 @@
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
<Description>This package provides implementations for application services within the DigitalData.Core.Abstractions library. It includes generic CRUD operations using Entity Framework Core, AutoMapper integration for object mapping, and additional services such as JWT handling and directory search functionality, adhering to Clean Architecture principles to ensure separation of concerns and maintainability.</Description>
|
||||
<PackageId>DigitalData.Core.Application</PackageId>
|
||||
<Authors>Digital Data GmbH</Authors>
|
||||
<Company>Digital Data GmbH</Company>
|
||||
<Product>DigitalData.Core.Application</Product>
|
||||
<Copyright>Copyright 2024</Copyright>
|
||||
<PackageIcon>icon.png</PackageIcon>
|
||||
<RepositoryUrl>http://git.dd:3000/AppStd/WebCoreModules.git</RepositoryUrl>
|
||||
<PackageTags>digital data core application clean architecture</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\DigitalData.Core.Abstractions\Assets\icon.png">
|
||||
<Pack>True</Pack>
|
||||
<PackagePath>\</PackagePath>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="7.0.0" />
|
||||
@ -21,4 +38,11 @@
|
||||
<ProjectReference Include="..\DigitalData.Core.Abstractions\DigitalData.Core.Abstractions.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Assets\icon.png">
|
||||
<PackagePath>\</PackagePath>
|
||||
<Pack>True</Pack>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -1,13 +1,28 @@
|
||||
namespace DigitalData.Core.Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the options for configuring directory search operations.
|
||||
/// </summary>
|
||||
public class DirectorySearchOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or initializes the name of the server to be used in the directory search.
|
||||
/// </summary>
|
||||
public string? ServerName { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or initializes the root directory path for the search.
|
||||
/// </summary>
|
||||
public string? Root { get; init; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or initializes the number of days before the user cache expires.
|
||||
/// </summary>
|
||||
public int UserCacheExpirationDays { get; init; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or initializes the custom search filters to be applied during directory searches.
|
||||
/// </summary>
|
||||
public Dictionary<string, string> CustomSearchFilters { get; init; } = new();
|
||||
}
|
||||
}
|
||||
@ -18,6 +18,14 @@ namespace DigitalData.Core.Application
|
||||
private readonly DateTimeOffset _userCacheExpiration;
|
||||
public Dictionary<string, string> CustomSearchFilters { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DirectorySearchService"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options">The options for directory search.</param>
|
||||
/// <param name="memoryCache">The memory cache.</param>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// Thrown if the server name or root directory is not configured.
|
||||
/// </exception>
|
||||
public DirectorySearchService(IOptions<DirectorySearchOptions> options, IMemoryCache memoryCache)
|
||||
{
|
||||
_memoryCache = memoryCache;
|
||||
@ -39,12 +47,27 @@ namespace DigitalData.Core.Application
|
||||
_userCacheExpiration = DateTimeOffset.Now.Date.AddDays(dayCounts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the credentials of a directory entry.
|
||||
/// </summary>
|
||||
/// <param name="dirEntryUsername">The directory entry username.</param>
|
||||
/// <param name="dirEntryPassword">The directory entry password.</param>
|
||||
/// <returns>True if the credentials are valid; otherwise, false.</returns>
|
||||
public bool ValidateCredentials(string dirEntryUsername, string dirEntryPassword)
|
||||
{
|
||||
using var context = new PrincipalContext(ContextType.Domain, ServerName, Root);
|
||||
return context.ValidateCredentials(dirEntryUsername, dirEntryPassword);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds all directory entries matching the specified filter.
|
||||
/// </summary>
|
||||
/// <param name="searchRoot">The search root.</param>
|
||||
/// <param name="filter">The search filter.</param>
|
||||
/// <param name="searchScope">The search scope.</param>
|
||||
/// <param name="sizeLimit">The size limit.</param>
|
||||
/// <param name="properties">The properties to load.</param>
|
||||
/// <returns>A <see cref="DataResult{T}"/> containing the results.</returns>
|
||||
public DataResult<IEnumerable<ResultPropertyCollection>> FindAll(DirectoryEntry searchRoot, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties)
|
||||
{
|
||||
List<ResultPropertyCollection> list = new();
|
||||
@ -74,10 +97,17 @@ namespace DigitalData.Core.Application
|
||||
return Result.Success<IEnumerable<ResultPropertyCollection>>(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds all directory entries matching the specified filter, using the user cache.
|
||||
/// </summary>
|
||||
/// <param name="username">The username.</param>
|
||||
/// <param name="filter">The search filter.</param>
|
||||
/// <param name="searchScope">The search scope.</param>
|
||||
/// <param name="sizeLimit">The size limit.</param>
|
||||
/// <param name="properties">The properties to load.</param>
|
||||
/// <returns>A <see cref="DataResult{T}"/> containing the results.</returns>
|
||||
public DataResult<IEnumerable<ResultPropertyCollection>> FindAllByUserCache(string username, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties)
|
||||
{
|
||||
List<ResultPropertyCollection> list = new();
|
||||
|
||||
_memoryCache.TryGetValue(username, out DirectoryEntry? searchRoot);
|
||||
|
||||
if (searchRoot is null)
|
||||
@ -86,6 +116,11 @@ namespace DigitalData.Core.Application
|
||||
return FindAll(searchRoot, filter, searchScope, sizeLimit, properties);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the search root in the cache.
|
||||
/// </summary>
|
||||
/// <param name="dirEntryUsername">The directory entry username.</param>
|
||||
/// <param name="dirEntryPassword">The directory entry password.</param>
|
||||
public void SetSearchRootCache(string dirEntryUsername, string dirEntryPassword)
|
||||
{
|
||||
if (_userCacheExpiration == default)
|
||||
@ -94,6 +129,12 @@ namespace DigitalData.Core.Application
|
||||
_memoryCache.Set(key: dirEntryUsername, new DirectoryEntry(path: SearchRootPath, username: dirEntryUsername, password: dirEntryPassword), absoluteExpiration: _userCacheExpiration);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the search root from the cache.
|
||||
/// </summary>
|
||||
/// <param name="dirEntryUsername">The directory entry username.</param>
|
||||
/// <returns>The cached <see cref="DirectoryEntry"/> if found; otherwise, null.</returns>
|
||||
public DirectoryEntry? GetSearchRootCache(string dirEntryUsername)
|
||||
{
|
||||
_memoryCache.TryGetValue(dirEntryUsername, out DirectoryEntry? root);
|
||||
|
||||
BIN
DigitalData.Core.Client/Assets/icon.png
Normal file
BIN
DigitalData.Core.Client/Assets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1020 KiB |
@ -4,10 +4,35 @@
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Description>This package provides HTTP client extension methods for the DigitalData.Core library, offering simplified and asynchronous methods for fetching and handling HTTP responses. It includes utility methods for sending GET requests, reading response content as text or JSON, and deserializing JSON into dynamic or strongly-typed objects using Newtonsoft.Json. These extensions facilitate efficient and easy-to-read HTTP interactions in client applications.</Description>
|
||||
<PackageId>DigitalData.Core.Client</PackageId>
|
||||
<Version>1.0.0</Version>
|
||||
<Authors>Digital Data GmbH</Authors>
|
||||
<Company>Digital Data GmbH</Company>
|
||||
<Product>Digital Data GmbH</Product>
|
||||
<Copyright>Copyright 2024</Copyright>
|
||||
<PackageProjectUrl></PackageProjectUrl>
|
||||
<PackageIcon>icon.png</PackageIcon>
|
||||
<RepositoryUrl>http://git.dd:3000/AppStd/WebCoreModules.git</RepositoryUrl>
|
||||
<PackageTags>digital data core http client json serilization</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\DigitalData.Core.Abstractions\Assets\icon.png">
|
||||
<Pack>True</Pack>
|
||||
<PackagePath>\</PackagePath>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Assets\icon.png">
|
||||
<PackagePath>\</PackagePath>
|
||||
<Pack>True</Pack>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -1,59 +1,150 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Json;
|
||||
using static System.Net.WebRequestMethods;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DigitalData.Core.Client
|
||||
{
|
||||
public static class HttpExtensions
|
||||
{
|
||||
public static async Task<string> Text(this HttpResponseMessage response) => await response.Content.ReadAsStringAsync();
|
||||
/// <summary>
|
||||
/// Extension methods for HttpClient and HttpResponseMessage.
|
||||
/// </summary>
|
||||
public static class HttpExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches data from the specified URL using the given HTTP method.
|
||||
/// </summary>
|
||||
/// <param name="url">The URL to fetch data from.</param>
|
||||
/// <param name="method">The HTTP method to use for the request. Defaults to GET.</param>
|
||||
/// <returns>A task representing the HTTP response message.</returns>
|
||||
public static async Task<HttpResponseMessage> Fetch(this string url, Method method = Method.GET)
|
||||
{
|
||||
using HttpClient client = new();
|
||||
return method switch
|
||||
{
|
||||
Method.GET => await client.GetAsync(url),
|
||||
_ => throw new NotImplementedException(nameof(method)),
|
||||
};
|
||||
}
|
||||
|
||||
public static async Task<T?> Json<T>(this HttpResponseMessage response) => await response.Content.ReadFromJsonAsync<T>();
|
||||
/// <summary>
|
||||
/// Reads the content of the HTTP response message as a string.
|
||||
/// </summary>
|
||||
/// <param name="response">The HTTP response message.</param>
|
||||
/// <returns>A task representing the response content as a string.</returns>
|
||||
public static async Task<string> Text(this HttpResponseMessage response) => await response.Content.ReadAsStringAsync();
|
||||
|
||||
public static async Task<dynamic> Json(this HttpResponseMessage response)
|
||||
{
|
||||
string json = await response.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<dynamic>(json) ?? string.Empty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Reads the content of the HTTP response message and deserializes it to a specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type to deserialize the response content to.</typeparam>
|
||||
/// <param name="response">The HTTP response message.</param>
|
||||
/// <returns>A task representing the deserialized response content.</returns>
|
||||
public static async Task<T?> Json<T>(this HttpResponseMessage response) => await response.Content.ReadFromJsonAsync<T>();
|
||||
|
||||
public static async Task<IEnumerable<dynamic>> JsonList(this HttpResponseMessage response)
|
||||
{
|
||||
string json = await response.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<dynamic>(json) ?? string.Empty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Reads the content of the HTTP response message and deserializes it to a dynamic object.
|
||||
/// </summary>
|
||||
/// <param name="response">The HTTP response message.</param>
|
||||
/// <returns>A task representing the deserialized response content as a dynamic object.</returns>
|
||||
public static async Task<dynamic> Json(this HttpResponseMessage response)
|
||||
{
|
||||
string json = await response.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<dynamic>(json) ?? string.Empty;
|
||||
}
|
||||
|
||||
public static async Task<HttpResponseMessage> Fetch(this string url, string method = Http.Get)
|
||||
{
|
||||
using HttpClient client = new();
|
||||
return method switch
|
||||
{
|
||||
Http.Get => await client.GetAsync(url),
|
||||
_ => throw new NotImplementedException(nameof(method)),
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// Reads the content of the HTTP response message and deserializes it to a list of dynamic objects.
|
||||
/// </summary>
|
||||
/// <param name="response">The HTTP response message.</param>
|
||||
/// <returns>A task representing the deserialized response content as a list of dynamic objects.</returns>
|
||||
public static async Task<IEnumerable<dynamic>> JsonList(this HttpResponseMessage response)
|
||||
{
|
||||
string json = await response.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<dynamic>(json) ?? string.Empty;
|
||||
}
|
||||
|
||||
public static async void ThenAsync<T>(this Task<T> task, Action<T> toDo)
|
||||
{
|
||||
var then = await task;
|
||||
toDo(then);
|
||||
}
|
||||
/// <summary>
|
||||
/// Fetches data from the specified URL using the given HTTP method and reads the response content as a string.
|
||||
/// </summary>
|
||||
/// <param name="url">The URL to fetch data from.</param>
|
||||
/// <param name="method">The HTTP method to use for the request. Defaults to GET.</param>
|
||||
/// <returns>A task representing the response content as a string.</returns>
|
||||
public static async Task<string> FetchText(this string url, Method method = Method.GET) => await url.Fetch(method: method).ThenAsync(Text);
|
||||
|
||||
public static async Task<I> ThenAsync<T, I>(this Task<T> task, Func<T, I> toDo)
|
||||
{
|
||||
var then = await task;
|
||||
return toDo(then);
|
||||
}
|
||||
/// <summary>
|
||||
/// Fetches data from the specified URL using the given HTTP method and deserializes the response content to a specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type to deserialize the response content to.</typeparam>
|
||||
/// <param name="url">The URL to fetch data from.</param>
|
||||
/// <param name="method">The HTTP method to use for the request. Defaults to GET.</param>
|
||||
/// <returns>A task representing the deserialized response content.</returns>
|
||||
public static async Task<T?> FetchJson<T>(this string url, Method method = Method.GET) => await url.Fetch(method: method).ThenAsync(Json<T>);
|
||||
|
||||
public static async Task<I> ThenAsync<T, I>(this Task<T> task, Func<T, Task<I>> toDoAsync)
|
||||
{
|
||||
var then = await task;
|
||||
return await toDoAsync(then);
|
||||
}
|
||||
/// <summary>
|
||||
/// Fetches data from the specified URL using the given HTTP method and deserializes the response content to a dynamic object.
|
||||
/// </summary>
|
||||
/// <param name="url">The URL to fetch data from.</param>
|
||||
/// <param name="method">The HTTP method to use for the request. Defaults to GET.</param>
|
||||
/// <returns>A task representing the deserialized response content as a dynamic object.</returns>
|
||||
public static async Task<dynamic> FetchJson(this string url, Method method = Method.GET) => await url.Fetch(method: method).ThenAsync(Json);
|
||||
|
||||
public static void ForEach<T>(this IEnumerable<T> values, Action<T> action)
|
||||
{
|
||||
foreach (var value in values)
|
||||
action(value);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Fetches data from the specified URL using the given HTTP method and deserializes the response content to a list of dynamic objects.
|
||||
/// </summary>
|
||||
/// <param name="url">The URL to fetch data from.</param>
|
||||
/// <param name="method">The HTTP method to use for the request. Defaults to GET.</param>
|
||||
/// <returns>A task representing the deserialized response content as a list of dynamic objects.</returns>
|
||||
public static async Task<IEnumerable<dynamic>> FetchJsonList(this string url, Method method = Method.GET) => await url.Fetch(method: method).ThenAsync(JsonList);
|
||||
|
||||
/// <summary>
|
||||
/// Executes an action when a task is completed.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the task result.</typeparam>
|
||||
/// <param name="task">The task to await.</param>
|
||||
/// <param name="toDo">The action to execute when the task is completed.</param>
|
||||
public static async void ThenAsync<T>(this Task<T> task, Action<T> toDo)
|
||||
{
|
||||
var then = await task;
|
||||
toDo(then);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a function when a task is completed and returns the result.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the task result.</typeparam>
|
||||
/// <typeparam name="I">The return type of the function.</typeparam>
|
||||
/// <param name="task">The task to await.</param>
|
||||
/// <param name="toDo">The function to execute when the task is completed.</param>
|
||||
/// <returns>A task representing the result of the function.</returns>
|
||||
public static async Task<I> ThenAsync<T, I>(this Task<T> task, Func<T, I> toDo)
|
||||
{
|
||||
var then = await task;
|
||||
return toDo(then);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes an asynchronous function when a task is completed and returns the result.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the task result.</typeparam>
|
||||
/// <typeparam name="I">The return type of the asynchronous function.</typeparam>
|
||||
/// <param name="task">The task to await.</param>
|
||||
/// <param name="toDoAsync">The asynchronous function to execute when the task is completed.</param>
|
||||
/// <returns>A task representing the result of the asynchronous function.</returns>
|
||||
public static async Task<I> ThenAsync<T, I>(this Task<T> task, Func<T, Task<I>> toDoAsync)
|
||||
{
|
||||
var then = await task;
|
||||
return await toDoAsync(then);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes an action for each element in an enumerable collection.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the elements in the collection.</typeparam>
|
||||
/// <param name="values">The enumerable collection of elements.</param>
|
||||
/// <param name="action">The action to execute for each element.</param>
|
||||
public static void ForEach<T>(this IEnumerable<T> values, Action<T> action)
|
||||
{
|
||||
foreach (var value in values)
|
||||
action(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
7
DigitalData.Core.Client/Method.cs
Normal file
7
DigitalData.Core.Client/Method.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace DigitalData.Core.Client
|
||||
{
|
||||
public enum Method
|
||||
{
|
||||
GET
|
||||
}
|
||||
}
|
||||
BIN
DigitalData.Core.DTO/Assets/icon.png
Normal file
BIN
DigitalData.Core.DTO/Assets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1020 KiB |
@ -4,8 +4,19 @@ using System.Configuration;
|
||||
|
||||
namespace DigitalData.Core.DTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides extension methods for dependency injection.
|
||||
/// </summary>
|
||||
public static class DIExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds the <see cref="CookieConsentSettings"/> to the service collection.
|
||||
/// </summary>
|
||||
/// <param name="services">The service collection to add the settings to.</param>
|
||||
/// <returns>The updated service collection.</returns>
|
||||
/// <exception cref="ConfigurationErrorsException">
|
||||
/// Thrown if the 'CookieConsentSettings' section is missing or improperly configured in appsettings.json.
|
||||
/// </exception>
|
||||
public static IServiceCollection AddCookieConsentSettings(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton(sp =>
|
||||
@ -19,4 +30,4 @@ namespace DigitalData.Core.DTO
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,38 +3,84 @@ using System.Text;
|
||||
|
||||
namespace DigitalData.Core.DTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides extension methods for data transfer objects (DTOs).
|
||||
/// </summary>
|
||||
public static class DTOExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds a single message to the result.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the result.</typeparam>
|
||||
/// <param name="result">The result to add the message to.</param>
|
||||
/// <param name="message">The message to add.</param>
|
||||
/// <returns>The updated result.</returns>
|
||||
public static T Message<T>(this T result, string message) where T : Result
|
||||
{
|
||||
result.Messages.Add(message);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds multiple messages to the result.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the result.</typeparam>
|
||||
/// <param name="result">The result to add the messages to.</param>
|
||||
/// <param name="messages">The messages to add.</param>
|
||||
/// <returns>The updated result.</returns>
|
||||
public static T Message<T>(this T result, params string[] messages) where T : Result
|
||||
{
|
||||
result.Messages.AddRange(messages);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a collection of messages to the result.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the result.</typeparam>
|
||||
/// <param name="result">The result to add the messages to.</param>
|
||||
/// <param name="messages">The collection of messages to add.</param>
|
||||
/// <returns>The updated result.</returns>
|
||||
public static T Message<T>(this T result, IEnumerable<string> messages) where T : Result
|
||||
{
|
||||
result.Messages.AddRange(messages);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a notice to the result.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the result.</typeparam>
|
||||
/// <param name="result">The result to add the notice to.</param>
|
||||
/// <param name="notice">The notice to add.</param>
|
||||
/// <returns>The updated result.</returns>
|
||||
public static T Notice<T>(this T result, Notice notice) where T : Result
|
||||
{
|
||||
result.Notices.Add(notice);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a collection of notices to the result.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the result.</typeparam>
|
||||
/// <param name="result">The result to add the notices to.</param>
|
||||
/// <param name="notices">The collection of notices to add.</param>
|
||||
/// <returns>The updated result.</returns>
|
||||
public static T Notice<T>(this T result, IEnumerable<Notice> notices) where T : Result
|
||||
{
|
||||
result.Notices.AddRange(notices);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds notices with a specific log level and flags to the result.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the result.</typeparam>
|
||||
/// <param name="result">The result to add the notices to.</param>
|
||||
/// <param name="level">The log level of the notices.</param>
|
||||
/// <param name="flags">The flags associated with the notices.</param>
|
||||
/// <returns>The updated result.</returns>
|
||||
public static T Notice<T>(this T result, LogLevel level, params Enum[] flags) where T : Result
|
||||
{
|
||||
var notices = flags.Select(flag => new Notice()
|
||||
@ -46,6 +92,15 @@ namespace DigitalData.Core.DTO
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a notice with a specific log level, flag, and messages to the result.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the result.</typeparam>
|
||||
/// <param name="result">The result to add the notice to.</param>
|
||||
/// <param name="level">The log level of the notice.</param>
|
||||
/// <param name="flag">The flag associated with the notice.</param>
|
||||
/// <param name="messages">The messages to add to the notice.</param>
|
||||
/// <returns>The updated result.</returns>
|
||||
public static T Notice<T>(this T result, LogLevel level, Enum flag, params string[] messages) where T : Result
|
||||
{
|
||||
result.Notices.Add(new Notice()
|
||||
@ -57,6 +112,14 @@ namespace DigitalData.Core.DTO
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a notice with a specific log level and messages to the result.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the result.</typeparam>
|
||||
/// <param name="result">The result to add the notice to.</param>
|
||||
/// <param name="level">The log level of the notice.</param>
|
||||
/// <param name="messages">The messages to add to the notice.</param>
|
||||
/// <returns>The updated result.</returns>
|
||||
public static T Notice<T>(this T result, LogLevel level, params string[] messages) where T : Result
|
||||
{
|
||||
result.Notices.Add(new Notice()
|
||||
@ -68,57 +131,154 @@ namespace DigitalData.Core.DTO
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if any notice has the specified flag.
|
||||
/// </summary>
|
||||
/// <param name="notices">The collection of notices to check.</param>
|
||||
/// <param name="flag">The flag to check for.</param>
|
||||
/// <returns>True if any notice has the specified flag; otherwise, false.</returns>
|
||||
public static bool HasFlag(this IEnumerable<Notice> notices, Enum flag) => notices.Any(n => n.Flag?.ToString() == flag.ToString());
|
||||
|
||||
/// <summary>
|
||||
/// Checks if any notice has any of the specified flags.
|
||||
/// </summary>
|
||||
/// <param name="notices">The collection of notices to check.</param>
|
||||
/// <param name="flags">The flags to check for.</param>
|
||||
/// <returns>True if any notice has any of the specified flags; otherwise, false.</returns>
|
||||
public static bool HasAnyFlag(this IEnumerable<Notice> notices, params Enum[] flags) => flags.Any(f => notices.HasFlag(f));
|
||||
|
||||
/// <summary>
|
||||
/// Executes a function based on the success or failure of the result.
|
||||
/// </summary>
|
||||
/// <typeparam name="I">The type of the return value.</typeparam>
|
||||
/// <param name="result">The result to evaluate.</param>
|
||||
/// <param name="Success">The function to execute if the result is successful.</param>
|
||||
/// <param name="Fail">The function to execute if the result is a failure.</param>
|
||||
/// <returns>The result of the executed function.</returns>
|
||||
public static I Then<I>(this Result result, Func<I> Success, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
return result.IsSuccess ? Success() : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously executes a function based on the success or failure of the result.
|
||||
/// </summary>
|
||||
/// <typeparam name="I">The type of the return value.</typeparam>
|
||||
/// <param name="result">The result to evaluate.</param>
|
||||
/// <param name="SuccessAsync">The asynchronous function to execute if the result is successful.</param>
|
||||
/// <param name="Fail">The function to execute if the result is a failure.</param>
|
||||
/// <returns>The result of the executed function.</returns>
|
||||
public static async Task<I> ThenAsync<I>(this Result result, Func<Task<I>> SuccessAsync, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
return result.IsSuccess ? await SuccessAsync() : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a function based on the success or failure of the data result.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the data in the result.</typeparam>
|
||||
/// <typeparam name="I">The type of the return value.</typeparam>
|
||||
/// <param name="result">The data result to evaluate.</param>
|
||||
/// <param name="Success">The function to execute if the data result is successful.</param>
|
||||
/// <param name="Fail">The function to execute if the data result is a failure.</param>
|
||||
/// <returns>The result of the executed function.</returns>
|
||||
public static I Then<T, I>(this DataResult<T> result, Func<T, I> Success, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
return result.IsSuccess ? Success(result.Data) : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously executes a function based on the success or failure of the data result.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the data in the result.</typeparam>
|
||||
/// <typeparam name="I">The type of the return value.</typeparam>
|
||||
/// <param name="result">The data result to evaluate.</param>
|
||||
/// <param name="SuccessAsync">The asynchronous function to execute if the data result is successful.</param>
|
||||
/// <param name="Fail">The function to execute if the data result is a failure.</param>
|
||||
/// <returns>The result of the executed function.</returns>
|
||||
public static async Task<I> ThenAsync<T, I>(this DataResult<T> result, Func<T, Task<I>> SuccessAsync, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
return result.IsSuccess ? await SuccessAsync(result.Data) : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously executes a function based on the success or failure of a task returning a result.
|
||||
/// </summary>
|
||||
/// <typeparam name="I">The type of the return value.</typeparam>
|
||||
/// <param name="tResult">The task returning a result to evaluate.</param>
|
||||
/// <param name="Success">The function to execute if the result is successful.</param>
|
||||
/// <param name="Fail">The function to execute if the result is a failure.</param>
|
||||
/// <returns>The result of the executed function.</returns>
|
||||
public static async Task<I> ThenAsync<I>(this Task<Result> tResult, Func<I> Success, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
Result result = await tResult;
|
||||
return result.IsSuccess ? Success() : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously executes a function based on the success or failure of a task returning a result.
|
||||
/// </summary>
|
||||
/// <typeparam name="I">The type of the return value.</typeparam>
|
||||
/// <param name="tResult">The task returning a result to evaluate.</param>
|
||||
/// <param name="SuccessAsync">The asynchronous function to execute if the result is successful.</param>
|
||||
/// <param name="Fail">The function to execute if the result is a failure.</param>
|
||||
/// <returns>The result of the executed function.</returns>
|
||||
public static async Task<I> ThenAsync<I>(this Task<Result> tResult, Func<Task<I>> SuccessAsync, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
Result result = await tResult;
|
||||
return result.IsSuccess ? await SuccessAsync() : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously executes a function based on the success or failure of a task returning a data result.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the data in the result.</typeparam>
|
||||
/// <typeparam name="I">The type of the return value.</typeparam>
|
||||
/// <param name="tResult">The task returning a data result to evaluate.</param>
|
||||
/// <param name="Success">The function to execute if the data result is successful.</param>
|
||||
/// <param name="Fail">The function to execute if the data result is a failure.</param>
|
||||
/// <returns>The result of the executed function.</returns>
|
||||
public static async Task<I> ThenAsync<T, I>(this Task<DataResult<T>> tResult, Func<T, I> Success, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
DataResult<T> result = await tResult;
|
||||
return result.IsSuccess ? Success(result.Data) : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously executes a function based on the success or failure of a task returning a data result.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the data in the result.</typeparam>
|
||||
/// <typeparam name="I">The type of the return value.</typeparam>
|
||||
/// <param name="tResult">The task returning a data result to evaluate.</param>
|
||||
/// <param name="SuccessAsync">The asynchronous function to execute if the data result is successful.</param>
|
||||
/// <param name="Fail">The function to execute if the data result is a failure.</param>
|
||||
/// <returns>The result of the executed function.</returns>
|
||||
public static async Task<I> ThenAsync<T, I>(this Task<DataResult<T>> tResult, Func<T, Task<I>> SuccessAsync, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
DataResult<T> result = await tResult;
|
||||
return result.IsSuccess ? await SuccessAsync(result.Data) : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Joins the values into a single string with optional start, separator, and end strings.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the values.</typeparam>
|
||||
/// <param name="values">The values to join.</param>
|
||||
/// <param name="start">The starting string.</param>
|
||||
/// <param name="separator">The separator string.</param>
|
||||
/// <param name="end">The ending string.</param>
|
||||
/// <returns>The joined string.</returns>
|
||||
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>
|
||||
/// Logs the notices using the specified logger.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger to use.</param>
|
||||
/// <param name="notices">The collection of notices to log.</param>
|
||||
/// <param name="start">The starting string for each notice.</param>
|
||||
/// <param name="separator">The separator string for messages in each notice.</param>
|
||||
/// <param name="end">The ending string for each notice.</param>
|
||||
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)))
|
||||
@ -142,11 +302,29 @@ namespace DigitalData.Core.DTO
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs the notices from a result using the specified logger.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger to use.</param>
|
||||
/// <param name="result">The result containing the notices to log.</param>
|
||||
/// <param name="start">The starting string for each notice.</param>
|
||||
/// <param name="separator">The separator string for messages in each notice.</param>
|
||||
/// <param name="end">The ending string for each notice.</param>
|
||||
public static void LogNotice(this ILogger logger, Result result, string start = ": ", string seperator = ". ", string end = ".\n")
|
||||
=> logger.LogNotice(notices: result.Notices, start: start, seperator: seperator, end: end);
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the data result is right (true).
|
||||
/// </summary>
|
||||
/// <param name="bResult">The data result to evaluate.</param>
|
||||
/// <returns>True if the data result is true; otherwise, false.</returns>
|
||||
public static bool IsRight(this DataResult<bool> bResult) => bResult.Data;
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the data result is wrong (false).
|
||||
/// </summary>
|
||||
/// <param name="bResult">The data result to evaluate.</param>
|
||||
/// <returns>True if the data result is false; otherwise, false.</returns>
|
||||
public static bool IsWrong(this DataResult<bool> bResult) => !bResult.Data;
|
||||
}
|
||||
}
|
||||
@ -2,11 +2,25 @@
|
||||
|
||||
namespace DigitalData.Core.DTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a result of an operation that includes data, inheriting from <see cref="Result"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the data included in the result.</typeparam>
|
||||
public class DataResult<T> : Result
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the data included in the result. This property is required.
|
||||
/// It will be ignored during JSON serialization if the value is null.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public required T Data { get; set; }
|
||||
|
||||
public DataResult<I> ToFail<I>() => Fail<I>().Message(Messages).Notice(Notices);
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts the current <see cref="DataResult{T}"/> to a failed <see cref="DataResult{I}"/>,
|
||||
/// preserving the messages and notices.
|
||||
/// </summary>
|
||||
/// <typeparam name="I">The type of the data in the new failed result.</typeparam>
|
||||
/// <returns>A failed <see cref="DataResult{I}"/> with the current messages and notices.</returns>
|
||||
public DataResult<I> ToFail<I>() => Fail<I>().Message(Messages).Notice(Notices);
|
||||
}
|
||||
}
|
||||
@ -4,8 +4,26 @@
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Description>This package provides Data Transfer Object (DTO) implementations and related utilities. It includes generic result handling, DTO extension methods, cookie consent settings management, and AutoMapper integration for robust object mapping, all adhering to Clean Architecture principles to ensure separation of concerns and maintainability.</Description>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
<PackageId>DigitalData.Core.DTO</PackageId>
|
||||
<Version>1.0.0</Version>
|
||||
<Authors>Digital Data GmbH</Authors>
|
||||
<Company>Digital Data GmbH</Company>
|
||||
<Product>DigitalData.Core.DTO</Product>
|
||||
<Copyright>Copyright 2024</Copyright>
|
||||
<PackageIcon>icon.png</PackageIcon>
|
||||
<RepositoryUrl>http://git.dd:3000/AppStd/WebCoreModules.git</RepositoryUrl>
|
||||
<PackageTags>digital data core dto clean architecture result pattern</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\DigitalData.Core.Abstractions\Assets\icon.png">
|
||||
<Pack>True</Pack>
|
||||
<PackagePath>\</PackagePath>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||
@ -14,4 +32,11 @@
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Assets\icon.png">
|
||||
<PackagePath>\</PackagePath>
|
||||
<Pack>True</Pack>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -2,10 +2,24 @@
|
||||
|
||||
namespace DigitalData.Core.DTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a notice for logging purposes, containing a flag, log level, and associated messages.
|
||||
/// </summary>
|
||||
public class Notice
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets an optional flag associated with the notice.
|
||||
/// </summary>
|
||||
public Enum? Flag { get; init; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the log level for the notice.
|
||||
/// </summary>
|
||||
public LogLevel Level { get; init; } = LogLevel.None;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of messages associated with the notice.
|
||||
/// </summary>
|
||||
public List<string> Messages { get; init; } = new();
|
||||
}
|
||||
}
|
||||
@ -2,17 +2,39 @@
|
||||
|
||||
namespace DigitalData.Core.DTO
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the result of an operation, containing information about its success or failure,
|
||||
/// messages for the client, and notices for logging.
|
||||
/// </summary>
|
||||
public class Result
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the operation was successful.
|
||||
/// </summary>
|
||||
public bool IsSuccess { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the operation failed.
|
||||
/// </summary>
|
||||
public bool IsFailed => !IsSuccess;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of messages intended for the client.
|
||||
/// </summary>
|
||||
public List<string> Messages { get; init; } = new();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of notices intended for logging purposes. This property is ignored during JSON serialization.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public List<Notice> Notices = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="DataResult{T}"/> with the specified data.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the data.</typeparam>
|
||||
/// <param name="data">The data to include in the result.</param>
|
||||
/// <returns>A new <see cref="DataResult{T}"/> instance.</returns>
|
||||
public DataResult<T> Data<T>(T data) => new()
|
||||
{
|
||||
IsSuccess = IsSuccess,
|
||||
@ -21,20 +43,49 @@ namespace DigitalData.Core.DTO
|
||||
Data = data
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Checks if any notice has the specified flag.
|
||||
/// </summary>
|
||||
/// <param name="flag">The flag to check.</param>
|
||||
/// <returns>True if any notice has the specified flag; otherwise, false.</returns>
|
||||
public bool HasFlag(Enum flag) => Notices.Any(n => n.Flag?.ToString() == flag.ToString());
|
||||
|
||||
public bool HasAnyFlag(params Enum[] flags) => flags.Any(f => HasFlag(f));
|
||||
/// <summary>
|
||||
/// Checks if any notice has any of the specified flags.
|
||||
/// </summary>
|
||||
/// <param name="flags">The flags to check.</param>
|
||||
/// <returns>True if any notice has any of the specified flags; otherwise, false.</returns>
|
||||
public bool HasAnyFlag(params Enum[] flags) => flags.Any(HasFlag);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new successful <see cref="Result"/>.
|
||||
/// </summary>
|
||||
/// <returns>A new successful <see cref="Result"/>.</returns>
|
||||
public static Result Success() => new() { IsSuccess = true };
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new failed <see cref="Result"/>.
|
||||
/// </summary>
|
||||
/// <returns>A new failed <see cref="Result"/>.</returns>
|
||||
public static Result Fail() => new() { IsSuccess = false };
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new successful <see cref="DataResult{T}"/> with the specified data.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the data.</typeparam>
|
||||
/// <param name="data">The data to include in the result.</param>
|
||||
/// <returns>A new successful <see cref="DataResult{T}"/> with the specified data.</returns>
|
||||
public static DataResult<T> Success<T>(T data) => new()
|
||||
{
|
||||
IsSuccess = true,
|
||||
Data = data
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new failed <see cref="DataResult{T}"/> with no data.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the data.</typeparam>
|
||||
/// <returns>A new failed <see cref="DataResult{T}"/> with no data.</returns>
|
||||
#pragma warning disable CS8601 // Possible null reference assignment.
|
||||
public static DataResult<T> Fail<T>() => new()
|
||||
{
|
||||
|
||||
BIN
DigitalData.Core.Infrastructure/Assets/icon.png
Normal file
BIN
DigitalData.Core.Infrastructure/Assets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1020 KiB |
@ -4,8 +4,27 @@
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
<PackageId>DigitalData.Core.Infrastructure</PackageId>
|
||||
<Version>1.0.0</Version>
|
||||
<Authors>Digital Data GmbH</Authors>
|
||||
<Company>Digital Data GmbH</Company>
|
||||
<Product>DigitalData.Core.Infrastructure</Product>
|
||||
<Description>This package provides implementations for data access and other low-level services within the DigitalData.Core.Abstractions library. It includes generic CRUD operations using Entity Framework Core, database context management, and other infrastructure-related functionalities, adhering to Clean Architecture principles to ensure separation of concerns and maintainability.</Description>
|
||||
<Copyright>Copyright 2024</Copyright>
|
||||
<PackageIcon>icon.png</PackageIcon>
|
||||
<RepositoryUrl>http://git.dd:3000/AppStd/WebCoreModules.git</RepositoryUrl>
|
||||
<RepositoryType>digital data core abstractions clean architecture</RepositoryType>
|
||||
<PackageTags>digital data core infrastructure clean architecture</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\DigitalData.Core.Abstractions\Assets\icon.png">
|
||||
<Pack>True</Pack>
|
||||
<PackagePath>\</PackagePath>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.16" />
|
||||
</ItemGroup>
|
||||
@ -14,4 +33,11 @@
|
||||
<ProjectReference Include="..\DigitalData.Core.Abstractions\DigitalData.Core.Abstractions.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Assets\icon.png">
|
||||
<PackagePath>\</PackagePath>
|
||||
<Pack>True</Pack>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user