mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
eliminates region sections
This commit is contained in:
1 parent
705c02b90d
commit
405fc1ff9a
370 files changed
+47
-1618
No files matched your search
@@ -24,12 +24,9 @@ namespace Lumina.Presentation.Web.Common.Api;
|
||||
/// </summary>
|
||||
public class ApiHttpClient : IApiHttpClient
|
||||
{
|
||||
#region ================================================================== FIELD MEMBERS ================================================================================
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly JsonSerializerOptions _jsonOptions;
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiHttpClient"/> class.
|
||||
/// </summary>
|
||||
@@ -49,9 +46,7 @@ public class ApiHttpClient : IApiHttpClient
|
||||
Converters = { new JsonStringEnumConverter() }
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Sends a GET request to the specified <paramref name="endpoint"/> as an asynchronous operation and returns the result.
|
||||
/// </summary>
|
||||
@@ -208,5 +203,4 @@ public class ApiHttpClient : IApiHttpClient
|
||||
throw new ApiException(problemDetails, response.StatusCode);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -12,7 +12,6 @@ namespace Lumina.Presentation.Web.Common.Api;
|
||||
/// </summary>
|
||||
public interface IApiHttpClient
|
||||
{
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Sends a GET request to the specified <paramref name="endpoint"/> as an asynchronous operation and returns the result.
|
||||
/// </summary>
|
||||
@@ -75,5 +74,4 @@ public interface IApiHttpClient
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The deserialized response containing the result of the POST request.</returns>
|
||||
Task<TResponse> PostAsync<TResponse, TModel>(string endpoint, TModel data, string? token = null, CancellationToken cancellationToken = default);
|
||||
#endregion
|
||||
}
|
||||
-2
@@ -10,7 +10,6 @@ namespace Lumina.Presentation.Web.Common.DependencyInjection;
|
||||
/// </summary>
|
||||
internal static class PresentationWebLayerConfiguration
|
||||
{
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Extension method for registering the configuration options of the Lumina.Presentation.Web project into the Dependency Injection container.
|
||||
/// </summary>
|
||||
@@ -29,6 +28,5 @@ internal static class PresentationWebLayerConfiguration
|
||||
.ValidateOnStart();
|
||||
return serviceCollection;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Exceptions;
|
||||
using Lumina.Presentation.Web.Common.Filters;
|
||||
using Lumina.Presentation.Web.Common.Services;
|
||||
using Lumina.Presentation.Web.Core.Services.UI;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Polly;
|
||||
using Polly.CircuitBreaker;
|
||||
@@ -23,7 +22,6 @@ namespace Lumina.Presentation.Web.Common.DependencyInjection;
|
||||
/// </summary>
|
||||
public static class PresentationWebLayerServices
|
||||
{
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Registers the services of the Presentation Web layer into the dependency injection container.
|
||||
/// </summary>
|
||||
@@ -64,11 +62,9 @@ public static class PresentationWebLayerServices
|
||||
.AddPolicyHandler(retryPolicy)
|
||||
.AddPolicyHandler(circuitBreakerPolicy);
|
||||
|
||||
services.AddSingleton<ComboboxService>();
|
||||
services.AddScoped<INotificationService, NotificationService>();
|
||||
services.AddScoped<ApiExceptionFilter>();
|
||||
|
||||
return services;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -11,7 +11,6 @@ namespace Lumina.Presentation.Web.Common.Exceptions;
|
||||
/// </summary>
|
||||
public class ApiException : Exception
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the values of status codes defined for HTTP defined in RFC 2616 for HTTP 1.1.
|
||||
/// </summary>
|
||||
@@ -21,9 +20,7 @@ public class ApiException : Exception
|
||||
/// Gets or sets the problem details represented by this exception.
|
||||
/// </summary>
|
||||
public ProblemDetailsModel? ProblemDetails { get; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
||||
/// </summary>
|
||||
@@ -34,5 +31,4 @@ public class ApiException : Exception
|
||||
ProblemDetails = problemDetails;
|
||||
HttpStatusCode = httpStatusCode;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -21,7 +21,6 @@ namespace Lumina.Presentation.Web.Common.Filters;
|
||||
/// </summary>
|
||||
public class ApiExceptionFilter : IExceptionFilter
|
||||
{
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Called after an action has thrown an Exception.
|
||||
/// </summary>
|
||||
@@ -103,5 +102,4 @@ public class ApiExceptionFilter : IExceptionFilter
|
||||
task.Wait(); // run the task synchronously
|
||||
httpContext.Response.Cookies.Delete("Token");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -10,10 +10,8 @@ namespace Lumina.Presentation.Web.Common.Models.Common;
|
||||
[DebuggerDisplay("{Name}")]
|
||||
public class GenreModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the name of the genre element of the media item.
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
#endregion
|
||||
}
|
||||
@@ -10,7 +10,6 @@ namespace Lumina.Presentation.Web.Common.Models.Common;
|
||||
[DebuggerDisplay("{LanguageName}")]
|
||||
public class LanguageInfoModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the ISO 639-1 two-letter language code.
|
||||
/// </summary>
|
||||
@@ -25,5 +24,4 @@ public class LanguageInfoModel
|
||||
/// Gets an optional native name of the language.
|
||||
/// </summary>
|
||||
public string? NativeName { get; set; }
|
||||
#endregion
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Enums.Notifications;
|
||||
using System;
|
||||
#endregion
|
||||
@@ -11,4 +11,8 @@ namespace Lumina.Presentation.Web.Common.Models.Common;
|
||||
/// <param name="Id">The id of the notification.</param>
|
||||
/// <param name="Message">The message of the notification.</param>
|
||||
/// <param name="Type">The type of the notification.</param>
|
||||
public record struct NotificationModel(Guid Id, string Message, NotificationType Type);
|
||||
public record struct NotificationModel(
|
||||
Guid Id,
|
||||
string Message,
|
||||
NotificationType Type
|
||||
);
|
||||
@@ -13,7 +13,6 @@ namespace Lumina.Presentation.Web.Common.Models.Common;
|
||||
[DebuggerDisplay("{Title} ({Status})")]
|
||||
public class ProblemDetailsModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the URI reference that identifies the problem type.
|
||||
/// </summary>
|
||||
@@ -50,5 +49,4 @@ public class ProblemDetailsModel
|
||||
/// </summary>
|
||||
[JsonExtensionData]
|
||||
public IDictionary<string, JsonElement>? Extensions { get; set; }
|
||||
#endregion
|
||||
}
|
||||
@@ -10,7 +10,6 @@ namespace Lumina.Presentation.Web.Common.Models.Common;
|
||||
[DebuggerDisplay("{Value}/{MaxValue}")]
|
||||
public abstract class RatingModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the numeric value of the rating.
|
||||
/// </summary>
|
||||
@@ -25,5 +24,4 @@ public abstract class RatingModel
|
||||
/// Gets the optional number of votes or reviews this rating is based on.
|
||||
/// </summary>
|
||||
public int? VoteCount { get; set; }
|
||||
#endregion
|
||||
}
|
||||
@@ -11,7 +11,6 @@ namespace Lumina.Presentation.Web.Common.Models.Common;
|
||||
[DebuggerDisplay("{OriginalReleaseDate}")]
|
||||
public class ReleaseInfoModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the optional original release date of the media item.
|
||||
/// </summary>
|
||||
@@ -42,5 +41,4 @@ public class ReleaseInfoModel
|
||||
/// Gets the optional release version or edition. (e.g. "Original", "Director's Cut", "2.0")
|
||||
/// </summary>
|
||||
public string? ReleaseVersion { get; set; }
|
||||
#endregion
|
||||
}
|
||||
@@ -10,10 +10,8 @@ namespace Lumina.Presentation.Web.Common.Models.Common;
|
||||
[DebuggerDisplay("{Name}")]
|
||||
public class TagModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the name of the tag element of the media item.
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
#endregion
|
||||
}
|
||||
@@ -10,11 +10,8 @@ namespace Lumina.Presentation.Web.Common.Models.Configuration;
|
||||
[DebuggerDisplay("{SECTION_NAME}")]
|
||||
public class ServerConfigurationModel
|
||||
{
|
||||
#region ================================================================== FIELD MEMBERS ================================================================================
|
||||
public const string SECTION_NAME = "ServerConfiguration";
|
||||
#endregion
|
||||
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the remote API server path.
|
||||
/// </summary>
|
||||
@@ -29,5 +26,4 @@ public class ServerConfigurationModel
|
||||
/// Gets or sets the remote API server port.
|
||||
/// </summary>
|
||||
public required ushort Port { get; init; }
|
||||
#endregion
|
||||
}
|
||||
@@ -10,7 +10,6 @@ namespace Lumina.Presentation.Web.Common.Models.FileManagement;
|
||||
[DebuggerDisplay("{ContentType} (Data.Length)")]
|
||||
public class BlobDataModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the binary data as a byte array.
|
||||
/// </summary>
|
||||
@@ -20,5 +19,4 @@ public class BlobDataModel
|
||||
/// Gets or sets the content type (MIME type) of the blob data, such as "image/png" for an image or "application/pdf" for a PDF document.
|
||||
/// </summary>
|
||||
public string ContentType { get; set; } = null!;
|
||||
#endregion
|
||||
}
|
||||
@@ -11,10 +11,8 @@ namespace Lumina.Presentation.Web.Common.Models.FileManagement;
|
||||
[DebuggerDisplay("{Path}")]
|
||||
public class DirectoryModel : FileSystemItemModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the children items of the directory.
|
||||
/// </summary>
|
||||
public List<FileSystemItemModel> Items { get; set; } = [];
|
||||
#endregion
|
||||
}
|
||||
@@ -10,10 +10,8 @@ namespace Lumina.Presentation.Web.Common.Models.FileManagement;
|
||||
[DebuggerDisplay("{Path}")]
|
||||
public class FileModel : FileSystemItemModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the size of the file, in bytes
|
||||
/// </summary>
|
||||
public long Size { get; set; }
|
||||
#endregion
|
||||
}
|
||||
@@ -11,7 +11,6 @@ namespace Lumina.Presentation.Web.Common.Models.FileManagement;
|
||||
[DebuggerDisplay("{Path}")]
|
||||
public abstract class FileSystemItemModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the full path to the file system item.
|
||||
/// </summary>
|
||||
@@ -31,5 +30,4 @@ public abstract class FileSystemItemModel
|
||||
/// Gets or sets the modification date of the file system item.
|
||||
/// </summary>
|
||||
public DateTime DateModified { get; set; }
|
||||
#endregion
|
||||
}
|
||||
@@ -12,7 +12,6 @@ namespace Lumina.Presentation.Web.Common.Models.FileManagement;
|
||||
[DebuggerDisplay("{Path}")]
|
||||
public class FileSystemTreeNodeModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the full path of the file or directory.
|
||||
/// </summary>
|
||||
@@ -42,5 +41,4 @@ public class FileSystemTreeNodeModel
|
||||
/// Gets or sets the list of child nodes.
|
||||
/// </summary>
|
||||
public List<FileSystemTreeNodeModel> Children { get; set; } = [];
|
||||
#endregion
|
||||
}
|
||||
@@ -11,10 +11,8 @@ namespace Lumina.Presentation.Web.Common.Models.FileManagement;
|
||||
[DebuggerDisplay("{PlatformType}")]
|
||||
public class FileSystemTypeModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the file system platform type.
|
||||
/// </summary>
|
||||
public PlatformType PlatformType { get; set; }
|
||||
#endregion
|
||||
}
|
||||
@@ -10,10 +10,8 @@ namespace Lumina.Presentation.Web.Common.Models.FileManagement;
|
||||
[DebuggerDisplay("{Path}")]
|
||||
public class PathSegmentModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the returned path.
|
||||
/// </summary>
|
||||
public string Path { get; set; } = null!;
|
||||
#endregion
|
||||
}
|
||||
@@ -13,7 +13,6 @@ namespace Lumina.Presentation.Web.Common.Models.Libraries;
|
||||
[DebuggerDisplay("{Title}")]
|
||||
public class LibraryModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier of the library.
|
||||
/// </summary>
|
||||
@@ -33,5 +32,4 @@ public class LibraryModel
|
||||
/// Gets or sets the collection of directories that contain the library files.
|
||||
/// </summary>
|
||||
public List<string> Paths { get; set; } = [];
|
||||
#endregion
|
||||
}
|
||||
@@ -11,7 +11,6 @@ namespace Lumina.Presentation.Web.Common.Models.MediaContributors;
|
||||
[DebuggerDisplay("{Name}")]
|
||||
public class MediaContributorModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the name of the contributor.
|
||||
/// </summary>
|
||||
@@ -21,5 +20,4 @@ public class MediaContributorModel
|
||||
/// Gets the role of the contributor.
|
||||
/// </summary>
|
||||
public MediaContributorRoleModel? Role { get; set; }
|
||||
#endregion
|
||||
}
|
||||
-2
@@ -10,7 +10,6 @@ namespace Lumina.Presentation.Web.Common.Models.MediaContributors;
|
||||
[DebuggerDisplay("{DisplayName}")]
|
||||
public class MediaContributorNameModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the name by which the contributor is popularly known.
|
||||
/// </summary>
|
||||
@@ -20,5 +19,4 @@ public class MediaContributorNameModel
|
||||
/// Gets the legal name of the contributor.
|
||||
/// </summary>
|
||||
public string? LegalName { get; set; }
|
||||
#endregion
|
||||
}
|
||||
-2
@@ -10,7 +10,6 @@ namespace Lumina.Presentation.Web.Common.Models.MediaContributors;
|
||||
[DebuggerDisplay("{Name}")]
|
||||
public class MediaContributorRoleModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the value representing this object.
|
||||
/// </summary>
|
||||
@@ -20,5 +19,4 @@ public class MediaContributorRoleModel
|
||||
/// Gets the category of this object.
|
||||
/// </summary>
|
||||
public string? Category { get; set; }
|
||||
#endregion
|
||||
}
|
||||
@@ -11,7 +11,6 @@ namespace Lumina.Presentation.Web.Common.Models.UI;
|
||||
[DebuggerDisplay("{Text}")]
|
||||
public class ComboboxItem<TValue>
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the text of the item, that is visible to the user.
|
||||
/// </summary>
|
||||
@@ -26,5 +25,4 @@ public class ComboboxItem<TValue>
|
||||
/// Gets or sets the property indicating whether this element can be selected or not.
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
#endregion
|
||||
}
|
||||
-2
@@ -13,7 +13,6 @@ namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrar
|
||||
[DebuggerDisplay("{Title}")]
|
||||
public class BookModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the Id of the media item.
|
||||
/// </summary>
|
||||
@@ -204,5 +203,4 @@ public class BookModel
|
||||
/// Gets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? Updated { get; set; }
|
||||
#endregion
|
||||
}
|
||||
-2
@@ -12,10 +12,8 @@ namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrar
|
||||
[DebuggerDisplay("{Value}/{MaxValue}")]
|
||||
public class BookRatingModel : RatingModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the source of the book rating (e.g., a specific website or platform).
|
||||
/// </summary>
|
||||
public BookRatingSource? Source { get; set; }
|
||||
#endregion
|
||||
}
|
||||
-2
@@ -10,10 +10,8 @@ namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrar
|
||||
[DebuggerDisplay("{Title}")]
|
||||
public class BookSeriesModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the book series.
|
||||
/// </summary>
|
||||
public string? Title { get; set; }
|
||||
#endregion
|
||||
}
|
||||
-2
@@ -11,7 +11,6 @@ namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrar
|
||||
[DebuggerDisplay("{Value} ({Format})")]
|
||||
public class IsbnModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the ISBN value.
|
||||
/// </summary>
|
||||
@@ -21,5 +20,4 @@ public class IsbnModel
|
||||
/// Gets or sets the format of the ISBN (e.g., ISBN-10 or ISBN-13).
|
||||
/// </summary>
|
||||
public IsbnFormat? Format { get; set; }
|
||||
#endregion
|
||||
}
|
||||
-2
@@ -12,7 +12,6 @@ namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary;
|
||||
[DebuggerDisplay("{Title}")]
|
||||
public class WrittenContentMetadataModel
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the written content.
|
||||
/// </summary>
|
||||
@@ -62,5 +61,4 @@ public class WrittenContentMetadataModel
|
||||
/// Gets or sets the number of pages in the written content.
|
||||
/// </summary>
|
||||
public int? PageCount { get; set; }
|
||||
#endregion
|
||||
}
|
||||
-2
@@ -13,7 +13,6 @@ namespace Lumina.Presentation.Web.Common.Requests.WrittenContentLibrary.BookLibr
|
||||
/// </summary>
|
||||
public class AddBookRequest
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the written content metadata of the book.
|
||||
/// </summary>
|
||||
@@ -98,5 +97,4 @@ public class AddBookRequest
|
||||
/// Gets or sets the list of ratings for this book.
|
||||
/// </summary>
|
||||
public List<BookRatingModel>? Ratings { get; set; }
|
||||
#endregion
|
||||
}
|
||||
@@ -11,16 +11,12 @@ namespace Lumina.Presentation.Web.Common.Services;
|
||||
/// </summary>
|
||||
public interface INotificationService
|
||||
{
|
||||
#region ================================================================== FIELD MEMBERS ================================================================================
|
||||
event Action<NotificationModel>? OnNotification;
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Shows a notification.
|
||||
/// </summary>
|
||||
/// <param name="message">The message of the notification.</param>
|
||||
/// <param name="type">The type of the notification.</param>
|
||||
void Show(string message, NotificationType type);
|
||||
#endregion
|
||||
}
|
||||
@@ -11,11 +11,8 @@ namespace Lumina.Presentation.Web.Common.Services;
|
||||
/// </summary>
|
||||
public class NotificationService : INotificationService
|
||||
{
|
||||
#region ================================================================== FIELD MEMBERS ================================================================================
|
||||
public event Action<NotificationModel>? OnNotification;
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Shows a notification.
|
||||
/// </summary>
|
||||
@@ -25,5 +22,4 @@ public class NotificationService : INotificationService
|
||||
{
|
||||
OnNotification?.Invoke(new NotificationModel { Message = message, Type = type, Id = Guid.NewGuid() });
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
-2
@@ -12,7 +12,6 @@ namespace Lumina.Presentation.Web.Common.Utilities;
|
||||
/// </summary>
|
||||
public static class OptionsBuilderFluentValidationUtilities
|
||||
{
|
||||
#region ================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Extension method to add fluent validation to the options validation pipeline.
|
||||
/// </summary>
|
||||
@@ -29,5 +28,4 @@ public static class OptionsBuilderFluentValidationUtilities
|
||||
serviceProvider => new FluentValidationOptions<TOptions>(optionsBuilder.Name, serviceProvider.GetRequiredService<IValidator<TOptions>>()));
|
||||
return optionsBuilder;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Text.RegularExpressions;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.Utilities;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for strings.
|
||||
/// </summary>
|
||||
public static class StringUtilities
|
||||
{
|
||||
#region ================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Splits a camel case string into separate words.
|
||||
/// </summary>
|
||||
/// <param name="input">The string to be split.</param>
|
||||
/// <returns>The split string.</returns>
|
||||
public static string SplitCamelCase(this string input)
|
||||
{
|
||||
return Regex.Replace(input, "([A-Z])", " $1", RegexOptions.Compiled).Trim();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -13,18 +13,13 @@ namespace Lumina.Presentation.Web.Common.Validation;
|
||||
/// <typeparam name="TOptions">The type of options being validated.</typeparam>
|
||||
public class FluentValidationOptions<TOptions> : IValidateOptions<TOptions> where TOptions : class
|
||||
{
|
||||
#region ================================================================== FIELD MEMBERS ================================================================================
|
||||
private readonly IValidator<TOptions> _validator;
|
||||
#endregion
|
||||
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the name of the options being validated.
|
||||
/// </summary>
|
||||
public string? Name { get; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FluentValidationOptions{TOptions}"/> class.
|
||||
/// </summary>
|
||||
@@ -35,9 +30,7 @@ public class FluentValidationOptions<TOptions> : IValidateOptions<TOptions> wher
|
||||
Name = name;
|
||||
_validator = validator;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Validates the specified <paramref name="options"/>.
|
||||
/// </summary>
|
||||
@@ -61,10 +54,9 @@ public class FluentValidationOptions<TOptions> : IValidateOptions<TOptions> wher
|
||||
// if the validation fails, collect the error messages
|
||||
// TODO: add translation support for the error messages
|
||||
string[] errors = validationResult.Errors.Select(x => $"Options validation failed for '{x.PropertyName}' with error: '{x.ErrorMessage}'")
|
||||
.ToArray();
|
||||
.ToArray();
|
||||
|
||||
// and return them with a failure result
|
||||
return ValidateOptionsResult.Fail(errors);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ namespace Lumina.Presentation.Web.Common.Validators;
|
||||
/// </summary>
|
||||
public class ServerConfigurationModelValidator : AbstractValidator<ServerConfigurationModel>
|
||||
{
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ServerConfigurationModelValidator"/> class.
|
||||
/// </summary>
|
||||
@@ -20,5 +19,4 @@ public class ServerConfigurationModelValidator : AbstractValidator<ServerConfigu
|
||||
RuleFor(x => x.Port).InclusiveBetween((ushort)0, (ushort)65535).WithMessage("Port number must be between 0 and 65535!");
|
||||
RuleFor(x => x.ApiVersion).InclusiveBetween((char)0, (char)255).WithMessage("API version must be between 0 and 255!");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user