diff --git a/DigitalData.Core.Abstractions/DigitalData.Core.Abstractions.csproj b/DigitalData.Core.Abstractions/DigitalData.Core.Abstractions.csproj
index 87b3c31..c009a02 100644
--- a/DigitalData.Core.Abstractions/DigitalData.Core.Abstractions.csproj
+++ b/DigitalData.Core.Abstractions/DigitalData.Core.Abstractions.csproj
@@ -5,8 +5,7 @@
enable
enable
- WebCore.Abstractions
- 1.0.0
+ DigitalData.Core.Abstractions
Digital Data GmbH
Digital Data GmbH
DigitalData.Core.Abstractions
@@ -19,6 +18,7 @@
False
aa-DJ
Assets\icon.png
+ 1.0.0
diff --git a/DigitalData.Core.Application/Assets/icon.png b/DigitalData.Core.Application/Assets/icon.png
new file mode 100644
index 0000000..feac09f
Binary files /dev/null and b/DigitalData.Core.Application/Assets/icon.png differ
diff --git a/DigitalData.Core.Application/DIExtensions.cs b/DigitalData.Core.Application/DIExtensions.cs
index 3d4b7d4..270b058 100644
--- a/DigitalData.Core.Application/DIExtensions.cs
+++ b/DigitalData.Core.Application/DIExtensions.cs
@@ -81,6 +81,16 @@ namespace DigitalData.Core.Application
.AddScoped();
}
+ ///
+ /// Adds the JWT service to the .
+ ///
+ /// The type of the claim value used in the JWT token.
+ /// The to add the service to.
+ /// A function that takes a claim value of type and returns a used to configure the JWT token.
+ /// The original instance, allowing further configuration.
+ ///
+ /// This method adds the necessary services for handling JWT tokens. The function is used to generate the which is essential for creating the JWT tokens.
+ ///
public static IServiceCollection AddJWTService(this IServiceCollection services, Func tokenDescriptorFactory)
{
return services.AddScoped, JWTService>(provider => new (tokenDescriptorFactory));
diff --git a/DigitalData.Core.Application/DigitalData.Core.Application.csproj b/DigitalData.Core.Application/DigitalData.Core.Application.csproj
index 667b5ce..d528c5d 100644
--- a/DigitalData.Core.Application/DigitalData.Core.Application.csproj
+++ b/DigitalData.Core.Application/DigitalData.Core.Application.csproj
@@ -4,8 +4,25 @@
net7.0
enable
enable
+ True
+ 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.
+ DigitalData.Core.Application
+ Digital Data GmbH
+ Digital Data GmbH
+ DigitalData.Core.Application
+ Copyright 2024
+ icon.png
+ http://git.dd:3000/AppStd/WebCoreModules.git
+ digital data core application clean architecture
+
+
+ True
+ \
+
+
+
@@ -21,4 +38,11 @@
+
+
+ \
+ True
+
+
+
diff --git a/DigitalData.Core.Application/DirectorySearchOptions.cs b/DigitalData.Core.Application/DirectorySearchOptions.cs
index 9a1225c..97306d1 100644
--- a/DigitalData.Core.Application/DirectorySearchOptions.cs
+++ b/DigitalData.Core.Application/DirectorySearchOptions.cs
@@ -1,13 +1,28 @@
namespace DigitalData.Core.Application
{
+ ///
+ /// Represents the options for configuring directory search operations.
+ ///
public class DirectorySearchOptions
{
+ ///
+ /// Gets or initializes the name of the server to be used in the directory search.
+ ///
public string? ServerName { get; init; }
+ ///
+ /// Gets or initializes the root directory path for the search.
+ ///
public string? Root { get; init; }
-
+
+ ///
+ /// Gets or initializes the number of days before the user cache expires.
+ ///
public int UserCacheExpirationDays { get; init; }
-
+
+ ///
+ /// Gets or initializes the custom search filters to be applied during directory searches.
+ ///
public Dictionary CustomSearchFilters { get; init; } = new();
}
}
\ No newline at end of file
diff --git a/DigitalData.Core.Application/DirectorySearchService.cs b/DigitalData.Core.Application/DirectorySearchService.cs
index 516ee2d..188cdfa 100644
--- a/DigitalData.Core.Application/DirectorySearchService.cs
+++ b/DigitalData.Core.Application/DirectorySearchService.cs
@@ -18,6 +18,14 @@ namespace DigitalData.Core.Application
private readonly DateTimeOffset _userCacheExpiration;
public Dictionary CustomSearchFilters { get; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The options for directory search.
+ /// The memory cache.
+ ///
+ /// Thrown if the server name or root directory is not configured.
+ ///
public DirectorySearchService(IOptions options, IMemoryCache memoryCache)
{
_memoryCache = memoryCache;
@@ -39,12 +47,27 @@ namespace DigitalData.Core.Application
_userCacheExpiration = DateTimeOffset.Now.Date.AddDays(dayCounts);
}
+ ///
+ /// Validates the credentials of a directory entry.
+ ///
+ /// The directory entry username.
+ /// The directory entry password.
+ /// True if the credentials are valid; otherwise, false.
public bool ValidateCredentials(string dirEntryUsername, string dirEntryPassword)
{
using var context = new PrincipalContext(ContextType.Domain, ServerName, Root);
return context.ValidateCredentials(dirEntryUsername, dirEntryPassword);
}
+ ///
+ /// 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.
public DataResult> FindAll(DirectoryEntry searchRoot, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties)
{
List list = new();
@@ -74,10 +97,17 @@ namespace DigitalData.Core.Application
return Result.Success>(list);
}
+ ///
+ /// 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.
public DataResult> FindAllByUserCache(string username, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties)
{
- List 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);
}
+ ///
+ /// Sets the search root in the cache.
+ ///
+ /// The directory entry username.
+ /// The directory entry password.
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);
}
+
+ ///
+ /// Gets the search root from the cache.
+ ///
+ /// The directory entry username.
+ /// The cached if found; otherwise, null.
public DirectoryEntry? GetSearchRootCache(string dirEntryUsername)
{
_memoryCache.TryGetValue(dirEntryUsername, out DirectoryEntry? root);
diff --git a/DigitalData.Core.Client/Assets/icon.png b/DigitalData.Core.Client/Assets/icon.png
new file mode 100644
index 0000000..feac09f
Binary files /dev/null and b/DigitalData.Core.Client/Assets/icon.png differ
diff --git a/DigitalData.Core.Client/DigitalData.Core.Client.csproj b/DigitalData.Core.Client/DigitalData.Core.Client.csproj
index 51eb283..944e269 100644
--- a/DigitalData.Core.Client/DigitalData.Core.Client.csproj
+++ b/DigitalData.Core.Client/DigitalData.Core.Client.csproj
@@ -4,10 +4,35 @@
net7.0
enable
enable
+ 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.
+ DigitalData.Core.Client
+ 1.0.0
+ Digital Data GmbH
+ Digital Data GmbH
+ Digital Data GmbH
+ Copyright 2024
+
+ icon.png
+ http://git.dd:3000/AppStd/WebCoreModules.git
+ digital data core http client json serilization
+
+
+ True
+ \
+
+
+
+
+
+ \
+ True
+
+
+
diff --git a/DigitalData.Core.Client/HttpExtensions.cs b/DigitalData.Core.Client/HttpExtensions.cs
index efe9411..05ce43f 100644
--- a/DigitalData.Core.Client/HttpExtensions.cs
+++ b/DigitalData.Core.Client/HttpExtensions.cs
@@ -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 Text(this HttpResponseMessage response) => await response.Content.ReadAsStringAsync();
+ ///
+ /// Extension methods for HttpClient and HttpResponseMessage.
+ ///
+ public static class HttpExtensions
+ {
+ ///
+ /// Fetches data from the specified URL using the given HTTP method.
+ ///
+ /// The URL to fetch data from.
+ /// The HTTP method to use for the request. Defaults to GET.
+ /// A task representing the HTTP response message.
+ public static async Task 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 Json(this HttpResponseMessage response) => await response.Content.ReadFromJsonAsync();
+ ///
+ /// Reads the content of the HTTP response message as a string.
+ ///
+ /// The HTTP response message.
+ /// A task representing the response content as a string.
+ public static async Task Text(this HttpResponseMessage response) => await response.Content.ReadAsStringAsync();
- public static async Task Json(this HttpResponseMessage response)
- {
- string json = await response.Content.ReadAsStringAsync();
- return JsonConvert.DeserializeObject(json) ?? string.Empty;
- }
+ ///
+ /// Reads the content of the HTTP response message and deserializes it to a specified type.
+ ///
+ /// The type to deserialize the response content to.
+ /// The HTTP response message.
+ /// A task representing the deserialized response content.
+ public static async Task Json(this HttpResponseMessage response) => await response.Content.ReadFromJsonAsync();
- public static async Task> JsonList(this HttpResponseMessage response)
- {
- string json = await response.Content.ReadAsStringAsync();
- return JsonConvert.DeserializeObject(json) ?? string.Empty;
- }
+ ///
+ /// Reads the content of the HTTP response message and deserializes it to a dynamic object.
+ ///
+ /// The HTTP response message.
+ /// A task representing the deserialized response content as a dynamic object.
+ public static async Task Json(this HttpResponseMessage response)
+ {
+ string json = await response.Content.ReadAsStringAsync();
+ return JsonConvert.DeserializeObject(json) ?? string.Empty;
+ }
- public static async Task 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)),
- };
- }
+ ///
+ /// Reads the content of the HTTP response message and deserializes it to a list of dynamic objects.
+ ///
+ /// The HTTP response message.
+ /// A task representing the deserialized response content as a list of dynamic objects.
+ public static async Task> JsonList(this HttpResponseMessage response)
+ {
+ string json = await response.Content.ReadAsStringAsync();
+ return JsonConvert.DeserializeObject(json) ?? string.Empty;
+ }
- public static async void ThenAsync(this Task task, Action toDo)
- {
- var then = await task;
- toDo(then);
- }
+ ///
+ /// Fetches data from the specified URL using the given HTTP method and reads the response content as a string.
+ ///
+ /// The URL to fetch data from.
+ /// The HTTP method to use for the request. Defaults to GET.
+ /// A task representing the response content as a string.
+ public static async Task FetchText(this string url, Method method = Method.GET) => await url.Fetch(method: method).ThenAsync(Text);
- public static async Task ThenAsync(this Task task, Func toDo)
- {
- var then = await task;
- return toDo(then);
- }
+ ///
+ /// Fetches data from the specified URL using the given HTTP method and deserializes the response content to a specified type.
+ ///
+ /// The type to deserialize the response content to.
+ /// The URL to fetch data from.
+ /// The HTTP method to use for the request. Defaults to GET.
+ /// A task representing the deserialized response content.
+ public static async Task FetchJson(this string url, Method method = Method.GET) => await url.Fetch(method: method).ThenAsync(Json);
- public static async Task ThenAsync(this Task task, Func> toDoAsync)
- {
- var then = await task;
- return await toDoAsync(then);
- }
+ ///
+ /// Fetches data from the specified URL using the given HTTP method and deserializes the response content to a dynamic object.
+ ///
+ /// The URL to fetch data from.
+ /// The HTTP method to use for the request. Defaults to GET.
+ /// A task representing the deserialized response content as a dynamic object.
+ public static async Task FetchJson(this string url, Method method = Method.GET) => await url.Fetch(method: method).ThenAsync(Json);
- public static void ForEach(this IEnumerable values, Action action)
- {
- foreach (var value in values)
- action(value);
- }
- }
+ ///
+ /// Fetches data from the specified URL using the given HTTP method and deserializes the response content to a list of dynamic objects.
+ ///
+ /// The URL to fetch data from.
+ /// The HTTP method to use for the request. Defaults to GET.
+ /// A task representing the deserialized response content as a list of dynamic objects.
+ public static async Task> FetchJsonList(this string url, Method method = Method.GET) => await url.Fetch(method: method).ThenAsync(JsonList);
+
+ ///
+ /// Executes an action when a task is completed.
+ ///
+ /// The type of the task result.
+ /// The task to await.
+ /// The action to execute when the task is completed.
+ public static async void ThenAsync(this Task task, Action toDo)
+ {
+ var then = await task;
+ toDo(then);
+ }
+
+ ///
+ /// Executes a function when a task is completed and returns the result.
+ ///
+ /// The type of the task result.
+ /// The return type of the function.
+ /// The task to await.
+ /// The function to execute when the task is completed.
+ /// A task representing the result of the function.
+ public static async Task ThenAsync(this Task task, Func toDo)
+ {
+ var then = await task;
+ return toDo(then);
+ }
+
+ ///
+ /// Executes an asynchronous function when a task is completed and returns the result.
+ ///
+ /// The type of the task result.
+ /// The return type of the asynchronous function.
+ /// The task to await.
+ /// The asynchronous function to execute when the task is completed.
+ /// A task representing the result of the asynchronous function.
+ public static async Task ThenAsync(this Task task, Func> toDoAsync)
+ {
+ var then = await task;
+ return await toDoAsync(then);
+ }
+
+ ///
+ /// Executes an action for each element in an enumerable collection.
+ ///
+ /// The type of the elements in the collection.
+ /// The enumerable collection of elements.
+ /// The action to execute for each element.
+ public static void ForEach(this IEnumerable values, Action action)
+ {
+ foreach (var value in values)
+ action(value);
+ }
+ }
}
\ No newline at end of file
diff --git a/DigitalData.Core.Client/Method.cs b/DigitalData.Core.Client/Method.cs
new file mode 100644
index 0000000..a4ab8c4
--- /dev/null
+++ b/DigitalData.Core.Client/Method.cs
@@ -0,0 +1,7 @@
+namespace DigitalData.Core.Client
+{
+ public enum Method
+ {
+ GET
+ }
+}
\ No newline at end of file
diff --git a/DigitalData.Core.DTO/Assets/icon.png b/DigitalData.Core.DTO/Assets/icon.png
new file mode 100644
index 0000000..feac09f
Binary files /dev/null and b/DigitalData.Core.DTO/Assets/icon.png differ
diff --git a/DigitalData.Core.DTO/DIExtensions.cs b/DigitalData.Core.DTO/DIExtensions.cs
index 7d51b46..e852057 100644
--- a/DigitalData.Core.DTO/DIExtensions.cs
+++ b/DigitalData.Core.DTO/DIExtensions.cs
@@ -4,8 +4,19 @@ using System.Configuration;
namespace DigitalData.Core.DTO
{
+ ///
+ /// Provides extension methods for dependency injection.
+ ///
public static class DIExtensions
{
+ ///
+ /// Adds the to the service collection.
+ ///
+ /// The service collection to add the settings to.
+ /// The updated service collection.
+ ///
+ /// Thrown if the 'CookieConsentSettings' section is missing or improperly configured in appsettings.json.
+ ///
public static IServiceCollection AddCookieConsentSettings(this IServiceCollection services)
{
services.AddSingleton(sp =>
@@ -19,4 +30,4 @@ namespace DigitalData.Core.DTO
return services;
}
}
-}
+}
\ No newline at end of file
diff --git a/DigitalData.Core.DTO/DTOExtensions.cs b/DigitalData.Core.DTO/DTOExtensions.cs
index 5d3cb11..3940517 100644
--- a/DigitalData.Core.DTO/DTOExtensions.cs
+++ b/DigitalData.Core.DTO/DTOExtensions.cs
@@ -3,38 +3,84 @@ using System.Text;
namespace DigitalData.Core.DTO
{
+ ///
+ /// Provides extension methods for data transfer objects (DTOs).
+ ///
public static class DTOExtensions
{
+ ///
+ /// Adds a single message to the result.
+ ///
+ /// The type of the result.
+ /// The result to add the message to.
+ /// The message to add.
+ /// The updated result.
public static T Message(this T result, string message) where T : Result
{
result.Messages.Add(message);
return result;
}
+ ///
+ /// Adds multiple messages to the result.
+ ///
+ /// The type of the result.
+ /// The result to add the messages to.
+ /// The messages to add.
+ /// The updated result.
public static T Message(this T result, params string[] messages) where T : Result
{
result.Messages.AddRange(messages);
return result;
}
+ ///
+ /// Adds a collection of messages to the result.
+ ///
+ /// The type of the result.
+ /// The result to add the messages to.
+ /// The collection of messages to add.
+ /// The updated result.
public static T Message(this T result, IEnumerable messages) where T : Result
{
result.Messages.AddRange(messages);
return result;
}
+ ///
+ /// Adds a notice to the result.
+ ///
+ /// The type of the result.
+ /// The result to add the notice to.
+ /// The notice to add.
+ /// The updated result.
public static T Notice(this T result, Notice notice) where T : Result
{
result.Notices.Add(notice);
return result;
}
+ ///
+ /// Adds a collection of notices to the result.
+ ///
+ /// The type of the result.
+ /// The result to add the notices to.
+ /// The collection of notices to add.
+ /// The updated result.
public static T Notice(this T result, IEnumerable notices) where T : Result
{
result.Notices.AddRange(notices);
return result;
}
+ ///
+ /// Adds notices with a specific log level and flags to the result.
+ ///
+ /// The type of the result.
+ /// The result to add the notices to.
+ /// The log level of the notices.
+ /// The flags associated with the notices.
+ /// The updated result.
public static T Notice(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;
}
+ ///
+ /// Adds a notice with a specific log level, flag, and messages to the result.
+ ///
+ /// The type of the result.
+ /// The result to add the notice to.
+ /// The log level of the notice.
+ /// The flag associated with the notice.
+ /// The messages to add to the notice.
+ /// The updated result.
public static T Notice(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;
}
+ ///
+ /// Adds a notice with a specific log level and messages to the result.
+ ///
+ /// The type of the result.
+ /// The result to add the notice to.
+ /// The log level of the notice.
+ /// The messages to add to the notice.
+ /// The updated result.
public static T Notice(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;
}
+ ///
+ /// Checks if any notice has the specified flag.
+ ///
+ /// The collection of notices to check.
+ /// The flag to check for.
+ /// True if any notice has the specified flag; otherwise, false.
public static bool HasFlag(this IEnumerable notices, Enum flag) => notices.Any(n => n.Flag?.ToString() == flag.ToString());
+ ///
+ /// Checks if any notice has any of the specified flags.
+ ///
+ /// The collection of notices to check.
+ /// The flags to check for.
+ /// True if any notice has any of the specified flags; otherwise, false.
public static bool HasAnyFlag(this IEnumerable notices, params Enum[] flags) => flags.Any(f => notices.HasFlag(f));
+ ///
+ /// Executes a function based on the success or failure of the result.
+ ///
+ /// The type of the return value.
+ /// The result to evaluate.
+ /// The function to execute if the result is successful.
+ /// The function to execute if the result is a failure.
+ /// The result of the executed function.
public static I Then(this Result result, Func Success, Func, List, I> Fail)
{
return result.IsSuccess ? Success() : Fail(result.Messages, result.Notices);
}
+ ///
+ /// Asynchronously executes a function based on the success or failure of the result.
+ ///
+ /// The type of the return value.
+ /// The result to evaluate.
+ /// The asynchronous function to execute if the result is successful.
+ /// The function to execute if the result is a failure.
+ /// The result of the executed function.
public static async Task ThenAsync(this Result result, Func> SuccessAsync, Func, List, I> Fail)
{
return result.IsSuccess ? await SuccessAsync() : Fail(result.Messages, result.Notices);
}
+ ///
+ /// Executes a function based on the success or failure of the data result.
+ ///
+ /// The type of the data in the result.
+ /// The type of the return value.
+ /// The data result to evaluate.
+ /// The function to execute if the data result is successful.
+ /// The function to execute if the data result is a failure.
+ /// The result of the executed function.
public static I Then(this DataResult result, Func Success, Func, List, I> Fail)
{
return result.IsSuccess ? Success(result.Data) : Fail(result.Messages, result.Notices);
}
+ ///
+ /// Asynchronously executes a function based on the success or failure of the data result.
+ ///
+ /// The type of the data in the result.
+ /// The type of the return value.
+ /// The data result to evaluate.
+ /// The asynchronous function to execute if the data result is successful.
+ /// The function to execute if the data result is a failure.
+ /// The result of the executed function.
public static async Task ThenAsync(this DataResult result, Func> SuccessAsync, Func, List, I> Fail)
{
return result.IsSuccess ? await SuccessAsync(result.Data) : Fail(result.Messages, result.Notices);
}
+ ///
+ /// Asynchronously executes a function based on the success or failure of a task returning a result.
+ ///
+ /// The type of the return value.
+ /// The task returning a result to evaluate.
+ /// The function to execute if the result is successful.
+ /// The function to execute if the result is a failure.
+ /// The result of the executed function.
public static async Task ThenAsync(this Task tResult, Func Success, Func, List, I> Fail)
{
Result result = await tResult;
return result.IsSuccess ? Success() : Fail(result.Messages, result.Notices);
}
+ ///
+ /// Asynchronously executes a function based on the success or failure of a task returning a result.
+ ///
+ /// The type of the return value.
+ /// The task returning a result to evaluate.
+ /// The asynchronous function to execute if the result is successful.
+ /// The function to execute if the result is a failure.
+ /// The result of the executed function.
public static async Task ThenAsync(this Task tResult, Func> SuccessAsync, Func, List, I> Fail)
{
Result result = await tResult;
return result.IsSuccess ? await SuccessAsync() : Fail(result.Messages, result.Notices);
}
+ ///
+ /// Asynchronously executes a function based on the success or failure of a task returning a data result.
+ ///
+ /// The type of the data in the result.
+ /// The type of the return value.
+ /// The task returning a data result to evaluate.
+ /// The function to execute if the data result is successful.
+ /// The function to execute if the data result is a failure.
+ /// The result of the executed function.
public static async Task ThenAsync(this Task> tResult, Func Success, Func, List, I> Fail)
{
DataResult result = await tResult;
return result.IsSuccess ? Success(result.Data) : Fail(result.Messages, result.Notices);
}
+ ///
+ /// Asynchronously executes a function based on the success or failure of a task returning a data result.
+ ///
+ /// The type of the data in the result.
+ /// The type of the return value.
+ /// The task returning a data result to evaluate.
+ /// The asynchronous function to execute if the data result is successful.
+ /// The function to execute if the data result is a failure.
+ /// The result of the executed function.
public static async Task ThenAsync(this Task> tResult, Func> SuccessAsync, Func, List, I> Fail)
{
DataResult result = await tResult;
return result.IsSuccess ? await SuccessAsync(result.Data) : Fail(result.Messages, result.Notices);
}
+ ///
+ /// Joins the values into a single string with optional start, separator, and end strings.
+ ///
+ /// The type of the values.
+ /// The values to join.
+ /// The starting string.
+ /// The separator string.
+ /// The ending string.
+ /// The joined string.
public static string Join(this IEnumerable values, string start = "", string seperator = ". ", string end = ".")
=> new StringBuilder(start).Append(string.Join(seperator, values)).Append(end).ToString();
+ ///
+ /// Logs the notices using the specified logger.
+ ///
+ /// The logger to use.
+ /// The collection of notices to log.
+ /// The starting string for each notice.
+ /// The separator string for messages in each notice.
+ /// The ending string for each notice.
public static void LogNotice(this ILogger logger, IEnumerable notices, string start = ": ", string seperator = ". ", string end = ".\n")
{
foreach(LogLevel level in Enum.GetValues(typeof(LogLevel)))
@@ -142,11 +302,29 @@ namespace DigitalData.Core.DTO
}
}
+ ///
+ /// Logs the notices from a result using the specified logger.
+ ///
+ /// The logger to use.
+ /// The result containing the notices to log.
+ /// The starting string for each notice.
+ /// The separator string for messages in each notice.
+ /// The ending string for each notice.
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);
+ ///
+ /// Determines if the data result is right (true).
+ ///
+ /// The data result to evaluate.
+ /// True if the data result is true; otherwise, false.
public static bool IsRight(this DataResult bResult) => bResult.Data;
+ ///
+ /// Determines if the data result is wrong (false).
+ ///
+ /// The data result to evaluate.
+ /// True if the data result is false; otherwise, false.
public static bool IsWrong(this DataResult bResult) => !bResult.Data;
}
}
\ No newline at end of file
diff --git a/DigitalData.Core.DTO/DataResult.cs b/DigitalData.Core.DTO/DataResult.cs
index d5c592a..33f3699 100644
--- a/DigitalData.Core.DTO/DataResult.cs
+++ b/DigitalData.Core.DTO/DataResult.cs
@@ -2,11 +2,25 @@
namespace DigitalData.Core.DTO
{
+ ///
+ /// Represents a result of an operation that includes data, inheriting from .
+ ///
+ /// The type of the data included in the result.
public class DataResult : Result
{
+ ///
+ /// 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.
+ ///
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public required T Data { get; set; }
- public DataResult ToFail() => Fail().Message(Messages).Notice(Notices);
- }
+ ///
+ /// Converts the current to a failed ,
+ /// preserving the messages and notices.
+ ///
+ /// The type of the data in the new failed result.
+ /// A failed with the current messages and notices.
+ public DataResult ToFail() => Fail().Message(Messages).Notice(Notices);
+ }
}
\ No newline at end of file
diff --git a/DigitalData.Core.DTO/DigitalData.Core.DTO.csproj b/DigitalData.Core.DTO/DigitalData.Core.DTO.csproj
index 8a17f62..c55ab89 100644
--- a/DigitalData.Core.DTO/DigitalData.Core.DTO.csproj
+++ b/DigitalData.Core.DTO/DigitalData.Core.DTO.csproj
@@ -4,8 +4,26 @@
net7.0
enable
enable
+ 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.
+ True
+ DigitalData.Core.DTO
+ 1.0.0
+ Digital Data GmbH
+ Digital Data GmbH
+ DigitalData.Core.DTO
+ Copyright 2024
+ icon.png
+ http://git.dd:3000/AppStd/WebCoreModules.git
+ digital data core dto clean architecture result pattern
+
+
+ True
+ \
+
+
+
@@ -14,4 +32,11 @@
+
+
+ \
+ True
+
+
+
diff --git a/DigitalData.Core.DTO/Notice.cs b/DigitalData.Core.DTO/Notice.cs
index 5094f9b..847d271 100644
--- a/DigitalData.Core.DTO/Notice.cs
+++ b/DigitalData.Core.DTO/Notice.cs
@@ -2,10 +2,24 @@
namespace DigitalData.Core.DTO
{
+ ///
+ /// Represents a notice for logging purposes, containing a flag, log level, and associated messages.
+ ///
public class Notice
{
+ ///
+ /// Gets or sets an optional flag associated with the notice.
+ ///
public Enum? Flag { get; init; } = null;
+
+ ///
+ /// Gets or sets the log level for the notice.
+ ///
public LogLevel Level { get; init; } = LogLevel.None;
+
+ ///
+ /// Gets a list of messages associated with the notice.
+ ///
public List Messages { get; init; } = new();
}
}
\ No newline at end of file
diff --git a/DigitalData.Core.DTO/Result.cs b/DigitalData.Core.DTO/Result.cs
index 2168ad8..5d9cf6c 100644
--- a/DigitalData.Core.DTO/Result.cs
+++ b/DigitalData.Core.DTO/Result.cs
@@ -2,17 +2,39 @@
namespace DigitalData.Core.DTO
{
+ ///
+ /// Represents the result of an operation, containing information about its success or failure,
+ /// messages for the client, and notices for logging.
+ ///
public class Result
{
+ ///
+ /// Gets or sets a value indicating whether the operation was successful.
+ ///
public bool IsSuccess { get; set; } = false;
+ ///
+ /// Gets a value indicating whether the operation failed.
+ ///
public bool IsFailed => !IsSuccess;
+ ///
+ /// Gets a list of messages intended for the client.
+ ///
public List Messages { get; init; } = new();
-
+
+ ///
+ /// Gets a list of notices intended for logging purposes. This property is ignored during JSON serialization.
+ ///
[JsonIgnore]
public List Notices = new();
+ ///
+ /// Creates a with the specified data.
+ ///
+ /// The type of the data.
+ /// The data to include in the result.
+ /// A new instance.
public DataResult Data(T data) => new()
{
IsSuccess = IsSuccess,
@@ -21,20 +43,49 @@ namespace DigitalData.Core.DTO
Data = data
};
+ ///
+ /// Checks if any notice has the specified flag.
+ ///
+ /// The flag to check.
+ /// True if any notice has the specified flag; otherwise, false.
public bool HasFlag(Enum flag) => Notices.Any(n => n.Flag?.ToString() == flag.ToString());
- public bool HasAnyFlag(params Enum[] flags) => flags.Any(f => HasFlag(f));
+ ///
+ /// Checks if any notice has any of the specified flags.
+ ///
+ /// The flags to check.
+ /// True if any notice has any of the specified flags; otherwise, false.
+ public bool HasAnyFlag(params Enum[] flags) => flags.Any(HasFlag);
+ ///
+ /// Creates a new successful .
+ ///
+ /// A new successful .
public static Result Success() => new() { IsSuccess = true };
+ ///
+ /// Creates a new failed .
+ ///
+ /// A new failed .
public static Result Fail() => new() { IsSuccess = false };
+ ///
+ /// Creates a new successful with the specified data.
+ ///
+ /// The type of the data.
+ /// The data to include in the result.
+ /// A new successful with the specified data.
public static DataResult Success(T data) => new()
{
IsSuccess = true,
Data = data
};
+ ///
+ /// Creates a new failed with no data.
+ ///
+ /// The type of the data.
+ /// A new failed with no data.
#pragma warning disable CS8601 // Possible null reference assignment.
public static DataResult Fail() => new()
{
diff --git a/DigitalData.Core.Infrastructure/Assets/icon.png b/DigitalData.Core.Infrastructure/Assets/icon.png
new file mode 100644
index 0000000..feac09f
Binary files /dev/null and b/DigitalData.Core.Infrastructure/Assets/icon.png differ
diff --git a/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj b/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj
index 64f71e5..9c2f6b8 100644
--- a/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj
+++ b/DigitalData.Core.Infrastructure/DigitalData.Core.Infrastructure.csproj
@@ -4,8 +4,27 @@
net7.0
enable
enable
+ True
+ DigitalData.Core.Infrastructure
+ 1.0.0
+ Digital Data GmbH
+ Digital Data GmbH
+ DigitalData.Core.Infrastructure
+ 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.
+ Copyright 2024
+ icon.png
+ http://git.dd:3000/AppStd/WebCoreModules.git
+ digital data core abstractions clean architecture
+ digital data core infrastructure clean architecture
+
+
+ True
+ \
+
+
+
@@ -14,4 +33,11 @@
+
+
+ \
+ True
+
+
+