Implements directory browser dialog, part 1: file system treeview

This commit is contained in:
BinaryAlley committed 2024-09-15 13:07:53 +03:00
1 parent 4a53348013
commit 4e4ecbbfca
318 files changed
+6012 -1184

No files matched your search

@@ -2,12 +2,19 @@
using Lumina.Presentation.Web.Common.Exceptions;
using Lumina.Presentation.Web.Common.Models.Common;
using Lumina.Presentation.Web.Common.Models.Configuration;
using Lumina.Presentation.Web.Common.Models.FileSystem;
using Lumina.Presentation.Web.Common.Models.FileManagement;
using Microsoft.AspNetCore.Components.WebAssembly.Http;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Web.Common.Api;
@@ -33,12 +40,13 @@ public class ApiHttpClient : IApiHttpClient
_httpClient = httpClient;
// read the API server configuration values from the configuration, and assign them to the injected client
var serverConfigurationModel = serverConfigurationOptions.Value;
httpClient.BaseAddress = new Uri(serverConfigurationModel.BaseAddress + ":" + serverConfigurationModel.Port + "/api/v1/");
httpClient.BaseAddress = new Uri($"{serverConfigurationModel.BaseAddress}:{serverConfigurationModel.Port}/api/v{serverConfigurationModel.ApiVersion}/");
_jsonOptions = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
Converters = { new JsonStringEnumConverter() }
};
}
#endregion
@@ -57,7 +65,39 @@ public class ApiHttpClient : IApiHttpClient
using var request = new HttpRequestMessage(HttpMethod.Get, endpoint);
if (!string.IsNullOrEmpty(token))
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
return await SendRequestAsync<TResponse>(request, cancellationToken);
return await SendRequestAsync<TResponse>(request, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Sends a GET request to the specified <paramref name="endpoint"/> as an asynchronous operation and returns the result as a streamable response.
/// </summary>
/// <typeparam name="TResponse">The expected type of the response content.</typeparam>
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
/// <param name="token">The token used for authentication with the API.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="IAsyncEnumerable{T}"/> object, which allows for asynchronous iteration over the deserialized items.</returns>
public async IAsyncEnumerable<TResponse?> GetAsyncEnumerable<TResponse>(string endpoint, string? token = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
using var request = new HttpRequestMessage(HttpMethod.Get, endpoint);
// HttpClient is implemented differently in Blazor WASM, because there are no sockets in the browser, so its BrowserHttpHandler is implemented on top of Fetch API,
// which can provide response content in one of two forms: BrowserHttpContent, which is based on arrayBuffer method (this means that it will always read the response stream to its completion,
// before making the content available), and StreamContent that is wrapping WasmHttpReadStream, which is based on readable streams (this one allows for reading response as it comes).
// WasmHttpReadStream can only work when WebAssemblyEnableStreamingResponse is enabled on request, and only on browsers that support it
request.SetBrowserResponseStreamingEnabled(true);
if (!string.IsNullOrEmpty(token))
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
// send the request and expect only headers initially - this prevents the client from buffering the entire response
using var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
response.EnsureSuccessStatusCode();
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
// Deserialize the JSON content asynchronously as an enumerable of TResponse items
await foreach (var item in JsonSerializer.DeserializeAsyncEnumerable<TResponse>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false))
{
if (cancellationToken.IsCancellationRequested)
yield break;
yield return item;
}
}
/// <summary>
@@ -72,11 +112,11 @@ public class ApiHttpClient : IApiHttpClient
using var request = new HttpRequestMessage(HttpMethod.Get, endpoint);
if (!string.IsNullOrEmpty(token))
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
using var response = await _httpClient.SendAsync(request, cancellationToken);
using var response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
if (!response.IsSuccessStatusCode)
{
// read the content as a string, for error messages
var content = await response.Content.ReadAsStringAsync(cancellationToken);
var content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
ProblemDetailsModel? problemDetails = null;
try
{
@@ -86,7 +126,7 @@ public class ApiHttpClient : IApiHttpClient
throw new ApiException(problemDetails, response.StatusCode);
}
// if the response is successful, read it as a byte array
byte[] responseContent = await response.Content.ReadAsByteArrayAsync(cancellationToken);
byte[] responseContent = await response.Content.ReadAsByteArrayAsync(cancellationToken).ConfigureAwait(false);
string contentType = response.Content.Headers.ContentType?.ToString() ?? "application/octet-stream";
return new BlobDataModel { Data = responseContent, ContentType = contentType };
}
@@ -104,7 +144,7 @@ public class ApiHttpClient : IApiHttpClient
using var request = new HttpRequestMessage(HttpMethod.Delete, endpoint);
if (!string.IsNullOrEmpty(token))
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
return await SendRequestAsync<TResponse>(request, cancellationToken);
return await SendRequestAsync<TResponse>(request, cancellationToken).ConfigureAwait(false);
}
/// <summary>
@@ -123,7 +163,7 @@ public class ApiHttpClient : IApiHttpClient
if (!string.IsNullOrEmpty(token))
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
request.Content = new StringContent(JsonSerializer.Serialize(data, _jsonOptions), Encoding.UTF8, "application/json");
return await SendRequestAsync<TResponse>(request, cancellationToken);
return await SendRequestAsync<TResponse>(request, cancellationToken).ConfigureAwait(false);
}
/// <summary>
@@ -142,23 +182,23 @@ public class ApiHttpClient : IApiHttpClient
if (!string.IsNullOrEmpty(token))
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
request.Content = new StringContent(JsonSerializer.Serialize(data, _jsonOptions), Encoding.UTF8, "application/json");
return await SendRequestAsync<TResponse>(request, cancellationToken);
return await SendRequestAsync<TResponse>(request, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Sends an HTTP request and deserializes the response into the specified type if the request is successful.
/// If the request fails, it attempts to deserialize the response content into a <see cref="ProblemDetailsModel"/> and throws an <see cref="ApiException"/>.
/// </summary>
/// <typeparam name="TResponse">The expected type of the response content.</typeparam>
/// <param name="request">The <see cref="HttpRequestMessage"/> to be sent.</param>
/// <param name="cancellationToken">A token to cancel the operation.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>The deserialized response content as an object of type <typeparamref name="TResponse"/>.</returns>
/// <exception cref="ApiException">Thrown if the response is not successful, with the <see cref="ProblemDetailsModel"/> if available.</exception>
private async Task<TResponse> SendRequestAsync<TResponse>(HttpRequestMessage request, CancellationToken cancellationToken)
{
// send the HTTP request and read the response
var response = await _httpClient.SendAsync(request, cancellationToken);
var content = await response.Content.ReadAsStringAsync(cancellationToken);
var response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
var content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
// if the response is successful, deserialize the content to TResponse and return it
if (response.IsSuccessStatusCode)
return JsonSerializer.Deserialize<TResponse>(content, _jsonOptions)!;
@@ -1,5 +1,8 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Models.FileSystem;
using Lumina.Presentation.Web.Common.Models.FileManagement;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Web.Common.Api;
@@ -20,6 +23,16 @@ public interface IApiHttpClient
/// <returns>The deserialized response containing the result of the GET request.</returns>
Task<TResponse> GetAsync<TResponse>(string endpoint, string? token = null, CancellationToken cancellationToken = default);
/// <summary>
/// Sends a GET request to the specified <paramref name="endpoint"/> as an asynchronous operation and returns the result as a streamable response.
/// </summary>
/// <typeparam name="TResponse">The expected type of the response content.</typeparam>
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
/// <param name="token">The token used for authentication with the API.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="IAsyncEnumerable{T}"/> object, which allows for asynchronous iteration over the deserialized items.</returns>
IAsyncEnumerable<TResponse?> GetAsyncEnumerable<TResponse>(string endpoint, string? token = null, CancellationToken cancellationToken = default);
/// <summary>
/// Sends a GET request to the specified <paramref name="endpoint"/> as an asynchronous operation and returns the result.
/// </summary>
@@ -1,33 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Models.Books;
using Lumina.Presentation.Web.Common.Models.Contributors;
using Lumina.Presentation.Web.Common.Enums;
#endregion
namespace Lumina.Presentation.Web.Common.Contracts.Books;
/// <summary>
/// Represents a request to add a book.
/// </summary>
public class AddBookRequest
{
#region ==================================================================== PROPERTIES =================================================================================
public WrittenContentMetadataDto? Metadata { get; set; }
public BookFormat? Format { get; set; }
public string? Edition { get; set; }
public int? VolumeNumber { get; set; }
public BookSeriesDto? Series { get; set; }
public string? ASIN { get; set; }
public string? GoodreadsId { get; set; }
public string? LCCN { get; set; }
public string? OCLCNumber { get; set; }
public string? OpenLibraryId { get; set; }
public string? LibraryThingId { get; set; }
public string? GoogleBooksId { get; set; }
public string? BarnesAndNobleId { get; set; }
public string? AppleBooksId { get; set; }
public List<IsbnDto>? ISBNs { get; set; }
public List<MediaContributorDto>? Contributors { get; set; }
public List<BookRatingDto>? Ratings { get; set; }
#endregion
}
@@ -1,7 +1,8 @@
using Lumina.Presentation.Web.Common.Models.Configuration;
using Lumina.Presentation.Web.Common.Utilities;
using Lumina.Presentation.Web.Common.Validators;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace Lumina.Presentation.Web.Common.DependencyInjection;
@@ -1,9 +1,12 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Core.Services.UI;
using Lumina.Presentation.Web.Common.Api;
using Polly;
using System.Net;
using FluentValidation;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Core.Services.UI;
using Microsoft.Extensions.DependencyInjection;
using Polly;
using System;
using System.Net;
using System.Net.Http;
#endregion
namespace Lumina.Presentation.Web.Common.DependencyInjection;
@@ -0,0 +1,57 @@
namespace Lumina.Presentation.Web.Common.Enums.AudioLibrary;
/// <summary>
/// Enumeration for the types of audio content libraries.
/// </summary>
public enum AudioContentType
{
/// <summary>
/// A musical composition typically consisting of vocals and/or instruments.
/// </summary>
Music,
/// <summary>
/// A recording of a book or other written work being read aloud.
/// </summary>
AudioBook,
/// <summary>
/// An audio recording of a live musical or spoken word performance.
/// </summary>
LivePerformance,
/// <summary>
/// A recorded conversation where one person asks questions and another provides answers.
/// </summary>
Interview,
/// <summary>
/// A new performance or recording of a previously released song.
/// </summary>
Cover,
/// <summary>
/// An alternative version of a recorded song, typically with altered instrumentation or structure.
/// </summary>
Remix,
/// <summary>
/// An audio recording used to create a specific acoustic environment or impression.
/// </summary>
Soundeffect,
/// <summary>
/// A digital audio file made available on the internet for downloading to a computer or mobile device.
/// </summary>
Podcast,
/// <summary>
/// A regularly scheduled broadcast program consisting of music, talk, or other audio content.
/// </summary>
RadioShow,
/// <summary>
/// A collection of music used as background sound for a movie, TV show, video game, or other media.
/// </summary>
Soundtrack,
}
@@ -1,4 +1,4 @@
namespace Lumina.Presentation.Web.Common.Enums;
namespace Lumina.Presentation.Web.Common.Enums.AudioLibrary;
/// <summary>
/// Enumeration for the various sources of audio ratings.
@@ -1,4 +1,4 @@
namespace Lumina.Presentation.Web.Common.Enums;
namespace Lumina.Presentation.Web.Common.Enums.BookLibrary;
/// <summary>
/// Enumeration for various book formats.
@@ -1,4 +1,4 @@
namespace Lumina.Presentation.Web.Common.Enums;
namespace Lumina.Presentation.Web.Common.Enums.BookLibrary;
/// <summary>
/// Enumeration for the various sources of book ratings.
@@ -1,4 +1,4 @@
namespace Lumina.Presentation.Web.Common.Enums;
namespace Lumina.Presentation.Web.Common.Enums.BookLibrary;
/// <summary>
/// Enumeration for the different ISBN (International Standard Book Number) formats.
@@ -0,0 +1,62 @@
namespace Lumina.Presentation.Web.Common.Enums.BookLibrary;
/// <summary>
/// Enumeration for the types of written content libraries.
/// </summary>
public enum WrittenContentType
{
/// <summary>
/// A printed or written literary work.
/// </summary>
Book,
/// <summary>
/// An electronic version of a printed book.
/// </summary>
EBook,
/// <summary>
/// A set of related books published in succession.
/// </summary>
BookSeries,
/// <summary>
/// A magazine or book containing sequential art in the form of a narrative.
/// </summary>
ComicBook,
/// <summary>
/// A set of related comic books published in succession.
/// </summary>
ComicSeries,
/// <summary>
/// A periodical publication containing articles, stories, and other content.
/// </summary>
Magazine,
/// <summary>
/// A style of Japanese comic books and graphic novels.
/// </summary>
Manga,
/// <summary>
/// A novel in comic-strip format, typically with sophisticated artwork and complex storylines.
/// </summary>
GraphicNovel,
/// <summary>
/// A scholarly article presenting original research or analysis.
/// </summary>
AcademicPaper,
/// <summary>
/// A handwritten or printed form of musical notation.
/// </summary>
SheetMusic,
/// <summary>
/// A script for a film, television program, or other visual media.
/// </summary>
Screenplay,
}
@@ -0,0 +1,22 @@
namespace Lumina.Presentation.Web.Common.Enums.FileSystem;
/// <summary>
/// Enumeration for the types of file system elements.
/// </summary>
public enum FileSystemItemType
{
/// <summary>
/// Represents a file system root, which can be a drive on Windows, and a path separator on Unix.
/// </summary>
Root,
/// <summary>
/// Represents a directory, which is a directory that can contain other directories or files.
/// </summary>
Directory,
/// <summary>
/// Represents a file, which is a document, executable, or other data stored on the file system.
/// </summary>
File
}
@@ -0,0 +1,17 @@
namespace Lumina.Presentation.Web.Common.Enums.FileSystem;
/// <summary>
/// Enumeration for platform types.
/// </summary>
public enum PlatformType
{
/// <summary>
/// Represents Unix-based operating systems, including Linux and macOS.
/// </summary>
Unix,
/// <summary>
/// Represents Microsoft Windows operating systems.
/// </summary>
Windows,
}
@@ -0,0 +1,32 @@
namespace Lumina.Presentation.Web.Common.Enums.Library;
/// <summary>
/// Enumeration for the types of libraries.
/// </summary>
public enum LibraryType
{
/// <summary>
/// Content that is written, such as books, articles, or other written works.
/// </summary>
WrittenContent,
/// <summary>
/// Content that is video, such as movies, TV shows, or other video works.
/// </summary>
VideoContent,
/// <summary>
/// Content that is audio, such as podcasts, radio shows, or other audio works.
/// </summary>
AudioContent,
/// <summary>
/// Content that is visual, such as images, paintings, or other visual works.
/// </summary>
VisualContent,
/// <summary>
/// Content that is miscellaneous, such as lyrics, movie posters, or other miscellaneous works.
/// </summary>
MiscellaneousContent,
}
@@ -0,0 +1,12 @@
namespace Lumina.Presentation.Web.Common.Enums.Library;
/// <summary>
/// Enumeration for the types of miscellaneous content libraries.
/// </summary>
public enum MiscellaneousContentType
{
/// <summary>
/// A collection of media that does not fit into any other category.
/// </summary>
Other,
}
@@ -0,0 +1,12 @@
namespace Lumina.Presentation.Web.Common.Enums.PhotoLibrary;
/// <summary>
/// Enumeration for the types of visual content libraries.
/// </summary>
public enum VisualContentType
{
/// <summary>
/// A collection of photographs organized together.
/// </summary>
PhotoAlbum,
}
@@ -0,0 +1,62 @@
namespace Lumina.Presentation.Web.Common.Enums.VideoLibrary;
/// <summary>
/// Enumeration for the types of video content libraries.
/// </summary>
public enum VideoContentType
{
/// <summary>
/// A series of related episodes broadcast on television or streaming platforms.
/// </summary>
TvShow,
/// <summary>
/// A feature-length film produced for cinema or home viewing.
/// </summary>
Movie,
/// <summary>
/// A collection of related films released in succession.
/// </summary>
FilmSeries,
/// <summary>
/// A collection of related films, TV shows, and other media sharing a fictional universe.
/// </summary>
FilmFranchise,
/// <summary>
/// A live musical performance recorded on video.
/// </summary>
Concert,
/// <summary>
/// A non-fictional film or TV program presenting facts and information about a specific subject.
/// </summary>
Documentary,
/// <summary>
/// An instructional video designed to teach a skill or provide information on a specific topic.
/// </summary>
Tutorial,
/// <summary>
/// Privately recorded videos, often for personal use or sharing with friends and family.
/// </summary>
Personal,
/// <summary>
/// Japanese animated productions, typically characterized by colorful graphics and vibrant characters.
/// </summary>
Anime,
/// <summary>
/// Videos hosted on or originating from the YouTube platform.
/// </summary>
Youtube,
/// <summary>
/// A short video, typically set to music, such as a music video or promotional clip.
/// </summary>
Videoclip,
}
@@ -1,4 +1,4 @@
namespace Lumina.Presentation.Web.Common.Enums;
namespace Lumina.Presentation.Web.Common.Enums.VideoLibrary;
/// <summary>
/// Enumeration for the various sources of video ratings.
@@ -1,5 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Models.Common;
using System;
using System.Net;
#endregion
@@ -1,63 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Models.Common;
#endregion
namespace Lumina.Presentation.Web.Common.Models.Books;
/// <summary>
/// Represents written content metadata.
/// </summary>
public class WrittenContentMetadataDto
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets the title of the media item.
/// </summary>
public string? Title { get; set; }
/// <summary>
/// Gets the original title of the media item.
/// </summary>
public string? OriginalTitle { get; set; }
/// <summary>
/// Gets the optional description of the media item.
/// </summary>
public string? Description { get; set; }
/// <summary>
/// Gets the release information of the media item.
/// </summary>
public ReleaseInfoDto? ReleaseInfo { get; set; }
/// <summary>
/// Gets the list of genres associated with the media item.
/// </summary>
public List<GenreDto>? Genres { get; set; }
/// <summary>
/// Gets the list of tags associated with the media item.
/// </summary>
public List<TagDto>? Tags { get; set; }
/// <summary>
/// Gets the optional language of the media item.
/// </summary>
public LanguageInfoDto? Language { get; set; }
/// <summary>
/// Gets the optional original language of the media item.
/// </summary>
public LanguageInfoDto? OriginalLanguage { get; set; }
/// <summary>
/// Gets the publisher of the written content.
/// </summary>
public string? Publisher { get; set; }
/// <summary>
/// Gets the number of pages in the written content.
/// </summary>
public int? PageCount { get; set; }
#endregion
}
@@ -1,9 +1,14 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.Common;
/// <summary>
/// Represents a request to get genre information.
/// </summary>
public class GenreDto
[DebuggerDisplay("{Name}")]
public class GenreModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
@@ -1,9 +1,14 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.Common;
/// <summary>
/// Represents a request to get language information.
/// </summary>
public class LanguageInfoDto
[DebuggerDisplay("{LanguageName}")]
public class LanguageInfoModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Serialization;
#endregion
namespace Lumina.Presentation.Web.Common.Models.Common;
/// <summary>
/// Model that follows the RFC 7807 standard for problem details in HTTP APIs.
/// </summary>
[DebuggerDisplay("{Title} ({Status})")]
public class ProblemDetailsModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets or sets the URI reference that identifies the problem type.
/// </summary>
[JsonPropertyName("type")]
public string? Type { get; set; }
/// <summary>
/// Gets or sets a short, human-readable summary of the problem type.
/// </summary>
[JsonPropertyName("title")]
public string? Title { get; set; }
/// <summary>
/// Gets or sets the HTTP status code generated by the server for this occurrence of the problem.
/// </summary>
[JsonPropertyName("status")]
public int? Status { get; set; }
/// <summary>
/// Gets or sets a detailed explanation specific to this occurrence of the problem.
/// </summary>
[JsonPropertyName("detail")]
public string? Detail { get; set; }
/// <summary>
/// Gets or sets a URI reference that identifies the specific occurrence of the problem.
/// </summary>
[JsonPropertyName("instance")]
public string? Instance { get; set; }
/// <summary>
/// Gets or sets additional extension data that may be included with the problem details.
/// This allows for including extra, non-standard fields in the problem details.
/// </summary>
[JsonExtensionData]
public IDictionary<string, JsonElement>? Extensions { get; set; }
#endregion
}
@@ -1,9 +1,14 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.Common;
/// <summary>
/// Represents a rating.
/// </summary>
public abstract class RatingDto
[DebuggerDisplay("{Value}/{MaxValue}")]
public abstract class RatingModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
@@ -1,9 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.Common;
/// <summary>
/// Represents a request to get release information.
/// </summary>
public class ReleaseInfoDto
[DebuggerDisplay("{OriginalReleaseDate}")]
public class ReleaseInfoModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
@@ -1,9 +1,14 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.Common;
/// <summary>
/// Represents a request to get tag information.
/// </summary>
public class TagDto
[DebuggerDisplay("{Name}")]
public class TagModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
@@ -1,8 +1,13 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.Configuration;
/// <summary>
/// Model for deserializing server configuration settings.
/// </summary>
[DebuggerDisplay("{SectionName}")]
public class ServerConfigurationModel
{
#region ================================================================== FIELD MEMBERS ================================================================================
@@ -10,6 +15,11 @@ public class ServerConfigurationModel
#endregion
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets or sets the remote API server path.
/// </summary>
public required char ApiVersion { get; init; }
/// <summary>
/// Gets or sets the remote API server path.
/// </summary>
@@ -1,19 +0,0 @@
namespace Lumina.Presentation.Web.Common.Models.Contributors;
/// <summary>
/// Represents a media contributor.
/// </summary>
public class MediaContributorDto
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets the name of the contributor.
/// </summary>
public MediaContributorNameDto? Name { get; set; }
/// <summary>
/// Gets the role of the contributor.
/// </summary>
public MediaContributorRoleDto? Role { get; set; }
#endregion
}
@@ -0,0 +1,24 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.FileManagement;
/// <summary>
/// Represents a model for storing binary data (blob).
/// </summary>
[DebuggerDisplay("{ContentType} (Data.Length)")]
public class BlobDataModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets or sets the binary data as a byte array.
/// </summary>
public byte[] Data { get; set; } = null!;
/// <summary>
/// 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
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.FileSystem;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.FileManagement;
/// <summary>
/// Model for files and directories displayed in custom directory/file browser dialogs.
/// </summary>
[DebuggerDisplay("{Path}")]
public class FileSystemItemModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets or sets the full path to the file system item.
/// </summary>
public string? Path { get; set; }
/// <summary>
/// Gets the type of the file system element.
/// </summary>
public FileSystemItemType ItemType { get; set; }
/// <summary>
/// Gets or sets the file extension of the item, if applicable (e.g., ".txt", ".jpg").
/// </summary>
public string? Extension { get; set; }
/// <summary>
/// Gets or sets the source path or identifier for the icon representing the file system item.
/// </summary>
public string? IconSource { get; set; }
/// <summary>
/// Gets or sets a friendly name for the file system item, which may be a user-friendly display name.
/// </summary>
public string? FriendlyName { get; set; }
#endregion
}
@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.FileSystem;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.FileManagement;
/// <summary>
/// Generic file system node.
/// </summary>
[DebuggerDisplay("{Path}")]
public class FileSystemTreeNodeModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets or sets the full path of the file or directory.
/// </summary>
public string Path { get; set; } = null!;
/// <summary>
/// Gets or sets the name of the file or directory.
/// </summary>
public string Name { get; set; } = null!;
/// <summary>
/// Gets or sets the type of the item, indicating whether it is a file, directory, or drive.
/// </summary>
public FileSystemItemType ItemType { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the node is expanded.
/// </summary>
public bool IsExpanded { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the child nodes have been loaded.
/// </summary>
public bool ChildrenLoaded { get; set; }
/// <summary>
/// Gets or sets the list of child nodes.
/// </summary>
public List<FileSystemTreeNodeModel> Children { get; set; } = [];
#endregion
}
@@ -0,0 +1,20 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.FileSystem;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.FileManagement;
/// <summary>
/// Model containing the file system platform type.
/// </summary>
[DebuggerDisplay("{PlatformType}")]
public class FileSystemTypeModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets or sets the file system platform type.
/// </summary>
public PlatformType PlatformType { get; set; }
#endregion
}
@@ -1,14 +1,14 @@
namespace Lumina.Presentation.Web.Common.Models.Books;
namespace Lumina.Presentation.Web.Common.Models.FileManagement;
/// <summary>
/// Represents a request to get book series information.
/// Represents a response containing a file system path.
/// </summary>
public class BookSeriesDto
public class PathSegmentModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets the title of the book series.
/// Gets or sets the returned path.
/// </summary>
public string? Title { get; set; }
public string Path { get; set; } = null!;
#endregion
}
@@ -0,0 +1,14 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.FileManagement;
/// <summary>
/// A model representing a file system path separator.
/// </summary>
/// <param name="Separator">The system's path separator.</param>
[DebuggerDisplay("{Separator}")]
public record PathSeparatorModel(
string Separator
);
@@ -0,0 +1,37 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Library;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.Libraries;
/// <summary>
/// Represents a library element.
/// </summary>
[DebuggerDisplay("{Title}")]
public class LibraryModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets or sets the unique identifier of the library.
/// </summary>
public Guid? Id { get; set; }
/// <summary>
/// Gets or sets the title of the library.
/// </summary>
public string? Title { get; set; }
/// <summary>
/// Gets or sets the type of the library.
/// </summary>
public LibraryType? LibraryType { get; set; }
/// <summary>
/// Gets or sets the collection of directories that contain the library files.
/// </summary>
public List<string> Paths { get; set; } = [];
#endregion
}
@@ -0,0 +1,25 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.MediaContributors;
/// <summary>
/// Represents a media contributor.
/// </summary>
[DebuggerDisplay("{Name}")]
public class MediaContributorModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets the name of the contributor.
/// </summary>
public MediaContributorNameModel? Name { get; set; }
/// <summary>
/// Gets the role of the contributor.
/// </summary>
public MediaContributorRoleModel? Role { get; set; }
#endregion
}
@@ -1,9 +1,14 @@
namespace Lumina.Presentation.Web.Common.Models.Contributors;
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.MediaContributors;
/// <summary>
/// Represents a media contributor name.
/// </summary>
public class MediaContributorNameDto
[DebuggerDisplay("{DisplayName}")]
public class MediaContributorNameModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
@@ -1,9 +1,14 @@
namespace Lumina.Presentation.Web.Common.Models.Contributors;
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.MediaContributors;
/// <summary>
/// Represents a media contributor role.
/// </summary>
public class MediaContributorRoleDto
[DebuggerDisplay("{Name}")]
public class MediaContributorRoleModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
@@ -1,9 +1,14 @@
namespace Lumina.Presentation.Web.Common.Models.UI;
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.UI;
/// <summary>
/// Represents an item in a combobox.
/// </summary>
/// <typeparam name="TValue">The type used for the <see cref="Value"/> property of the item.</typeparam>
[DebuggerDisplay("{Text}")]
public class ComboboxItem<TValue>
{
#region ==================================================================== PROPERTIES =================================================================================
@@ -16,5 +21,10 @@ public class ComboboxItem<TValue>
/// Gets or sets the value of the item, that is used by the application.
/// </summary>
public TValue? Value { get; set; }
/// <summary>
/// Gets or sets the property indicating whether this element can be selected or not.
/// </summary>
public bool IsEnabled { get; set; } = true;
#endregion
}
@@ -0,0 +1,208 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Models.Common;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Represents a book.
/// </summary>
[DebuggerDisplay("{Title}")]
public class BookModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets the Id of the media item.
/// </summary>
public Guid Id { get; init; }
/// <summary>
/// Gets the title of the media item.
/// </summary>
public string Title { get; init; } = null!;
/// <summary>
/// Gets the original title of the media item.
/// </summary>
public string? OriginalTitle { get; init; }
/// <summary>
/// Gets the optional description of the media item.
/// </summary>
public string? Description { get; init; }
/// <summary>
/// Gets the optional original release date of the media item.
/// </summary>
public DateOnly? OriginalReleaseDate { get; init; }
/// <summary>
/// Gets the optional original release year of the media item.
/// This is useful when only the year of original release is known.
/// </summary>
public int? OriginalReleaseYear { get; init; }
/// <summary>
/// Gets the optional re-release or reissue date of the media item.
/// </summary>
public DateOnly? ReReleaseDate { get; init; }
/// <summary>
/// Gets the optional re-release or reissue year of the media item.
/// </summary>
public int? ReReleaseYear { get; init; }
/// <summary>
/// Gets the optional country or region of release.
/// </summary>
public string? ReleaseCountry { get; init; }
/// <summary>
/// Gets the optional release version or edition. (e.g. "Original", "Director's Cut", "2.0")
/// </summary>
public string? ReleaseVersion { get; init; }
/// <summary>
/// Gets the ISO 639-1 two-letter language code.
/// </summary>
public string? LanguageCode { get; init; }
/// <summary>
/// Gets the full name of the language in English.
/// </summary>
public string? LanguageName { get; init; }
/// <summary>
/// Gets an optional native name of the language.
/// </summary>
public string? LanguageNativeName { get; init; }
/// <summary>
/// Gets the optional ISO 639-1 two-letter original language code.
/// </summary>
public string? OriginalLanguageCode { get; init; }
/// <summary>
/// Gets the optional full name of the original language in English.
/// </summary>
public string? OriginalLanguageName { get; init; }
/// <summary>
/// Gets an optional native name of the original language.
/// </summary>
public string? OriginalLanguageNativeName { get; init; }
/// <summary>
/// Gets the list of tags associated with the media item.
/// </summary>
public HashSet<TagModel> Tags { get; set; } = [];
/// <summary>
/// Gets the list of genres associated with the media item.
/// </summary>
public HashSet<GenreModel> Genres { get; set; } = [];
/// <summary>
/// Gets the publisher of the written content.
/// </summary>
public string? Publisher { get; init; }
/// <summary>
/// Gets the number of pages in the written content.
/// </summary>
public int? PageCount { get; init; }
/// <summary>
/// Gets the format of the book (e.g., Hardcover, Paperback), if applicable.
/// </summary>
public string Format { get; init; } = null!;
/// <summary>
/// Gets the edition of the book, if applicable.
/// </summary>
public string? Edition { get; init; }
/// <summary>
/// Gets the volume or book number in the series, if applicable.
/// </summary>
public int? VolumeNumber { get; init; }
/// <summary>
/// Gets the series id, if the book is part of a series.
/// </summary>
//public Guid? BookSeriesId { get; init; } = null;
/// <summary>
/// Gets the ASIN (Amazon Standard Identification Number) of the book.
/// </summary>
public string? ASIN { get; init; } = null!;
/// <summary>
/// Gets the Goodreads ID of the book.
/// </summary>
public string? GoodreadsId { get; init; } = null!;
/// <summary>
/// Gets the Library of Congress Control Number (LCCN) of the book.
/// </summary>
public string? LCCN { get; init; } = null!;
/// <summary>
/// Gets the OCLC Number (WorldCat identifier) of the book.
/// </summary>
public string? OCLCNumber { get; init; } = null!;
/// <summary>
/// Gets the Open Library ID of the book.
/// </summary>
public string? OpenLibraryId { get; init; } = null!;
/// <summary>
/// Gets the LibraryThing ID of the book.
/// </summary>
public string? LibraryThingId { get; init; } = null!;
/// <summary>
/// Gets the Google Books ID of the book.
/// </summary>
public string? GoogleBooksId { get; init; } = null!;
/// <summary>
/// Gets the Barnes & Noble ID of the book.
/// </summary>
public string? BarnesAndNobleId { get; init; } = null!;
/// <summary>
/// Gets the Apple Books ID of the book.
/// </summary>
public string? AppleBooksId { get; init; } = null!;
/// <summary>
/// Gets the list of ISBN (International Standard Book Number) of the book.
/// </summary>
public List<IsbnModel> ISBNs { get; set; } = [];
/// <summary>
/// Gets the list of media contributors (actors, directors, etc) starring in this book.
/// </summary>
//public List<ContributorIdModel> ContributorIds { get; init; } = [];
/// <summary>
/// Gets the list of ratings for this book.
/// </summary>
public List<BookRatingModel> Ratings { get; init; } = [];
/// <summary>
/// Gets the time and date when the entity was added.
/// </summary>
public DateTime Created { get; set; }
/// <summary>
/// Gets the optional time and date when the entity was updated.
/// </summary>
public DateTime? Updated { get; set; }
#endregion
}
@@ -1,18 +1,20 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.BookLibrary;
using Lumina.Presentation.Web.Common.Models.Common;
using Lumina.Presentation.Web.Common.Enums;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.Books;
namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Represents a book rating.
/// </summary>
public class BookRatingDto : RatingDto
[DebuggerDisplay("{Value}/{MaxValue}")]
public class BookRatingModel : RatingModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets the optional source of the rating (e.g., "Goodreads", "Amazon").
/// Gets or sets the source of the book rating (e.g., a specific website or platform).
/// </summary>
public BookRatingSource? Source { get; set; }
#endregion
@@ -0,0 +1,19 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Represents a request to get book series information.
/// </summary>
[DebuggerDisplay("{Title}")]
public class BookSeriesModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets or sets the title of the book series.
/// </summary>
public string? Title { get; set; }
#endregion
}
@@ -1,22 +1,24 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums;
using Lumina.Presentation.Web.Common.Enums.BookLibrary;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.Books;
namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Represents a request to get ISBN information.
/// </summary>
public class IsbnDto
[DebuggerDisplay("{Value} ({Format})")]
public class IsbnModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets the value of the ISBN.
/// Gets or sets the ISBN value.
/// </summary>
public string? Value { get; set; }
/// <summary>
/// Gets the format of the ISBN.
/// Gets or sets the format of the ISBN (e.g., ISBN-10 or ISBN-13).
/// </summary>
public IsbnFormat? Format { get; set; }
#endregion
@@ -0,0 +1,66 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Models.Common;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary;
/// <summary>
/// Represents written content metadata.
/// </summary>
[DebuggerDisplay("{Title}")]
public class WrittenContentMetadataModel
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets or sets the title of the written content.
/// </summary>
public string? Title { get; set; }
/// <summary>
/// Gets or sets the original title of the written content, if different from the current title.
/// </summary>
public string? OriginalTitle { get; set; }
/// <summary>
/// Gets or sets a brief description or summary of the written content.
/// </summary>
public string? Description { get; set; }
/// <summary>
/// Gets or sets the release information, including release date and other relevant details.
/// </summary>
public ReleaseInfoModel? ReleaseInfo { get; set; }
/// <summary>
/// Gets or sets the list of genres associated with the written content.
/// </summary>
public List<GenreModel>? Genres { get; set; }
/// <summary>
/// Gets or sets the list of tags that further describe or categorize the written content.
/// </summary>
public List<TagModel>? Tags { get; set; }
/// <summary>
/// Gets or sets the language in which the written content is written.
/// </summary>
public LanguageInfoModel? Language { get; set; }
/// <summary>
/// Gets or sets the original language of the written content, if it has been translated.
/// </summary>
public LanguageInfoModel? OriginalLanguage { get; set; }
/// <summary>
/// Gets or sets the name of the publisher of the written content.
/// </summary>
public string? Publisher { get; set; }
/// <summary>
/// Gets or sets the number of pages in the written content.
/// </summary>
public int? PageCount { get; set; }
#endregion
}
@@ -0,0 +1,102 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.BookLibrary;
using Lumina.Presentation.Web.Common.Models.MediaContributors;
using Lumina.Presentation.Web.Common.Models.WrittenContentLibrary;
using Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrary;
using System.Collections.Generic;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Represents a request to add a book.
/// </summary>
public class AddBookRequest
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets or sets the written content metadata of the book.
/// </summary>
public WrittenContentMetadataModel? Metadata { get; set; }
/// <summary>
/// Gets or sets the format of the book (e.g., Hardcover, Paperback), if applicable.
/// </summary>
public BookFormat? Format { get; set; }
/// <summary>
/// Gets or sets the edition of the book, if applicable.
/// </summary>
public string? Edition { get; set; }
/// <summary>
/// Gets or sets the volume or book number in the series, if applicable.
/// </summary>
public int? VolumeNumber { get; set; }
/// <summary>
/// Gets or sets the series name, if the book is part of a series.
/// </summary>
public BookSeriesModel? Series { get; set; }
/// <summary>
/// Gets or sets the ASIN (Amazon Standard Identification Number) of the book, if applicable.
/// </summary>
public string? ASIN { get; set; }
/// <summary>
/// Gets or sets the Goodreads ID of the book, if applicable.
/// </summary>
public string? GoodreadsId { get; set; }
/// <summary>
/// Gets or sets the Library of Congress Control Number (LCCN) of the book, if applicable.
/// </summary>
public string? LCCN { get; set; }
/// <summary>
/// Gets or sets the OCLC Number (WorldCat identifier) of the book, if applicable.
/// </summary>
public string? OCLCNumber { get; set; }
/// <summary>
/// Gets or sets the Open Library ID of the book, if applicable.
/// </summary>
public string? OpenLibraryId { get; set; }
/// <summary>
/// Gets or sets the LibraryThing ID of the book, if applicable.
/// </summary>
public string? LibraryThingId { get; set; }
/// <summary>
/// Gets or sets the Google Books ID of the book, if applicable.
/// </summary>
public string? GoogleBooksId { get; set; }
/// <summary>
/// Gets or sets the Barnes & Noble ID of the book, if applicable.
/// </summary>
public string? BarnesAndNobleId { get; set; }
/// <summary>
/// Gets or sets the Apple Books ID of the book, if applicable.
/// </summary>
public string? AppleBooksId { get; set; }
/// <summary>
/// Gets or sets the list of ISBN (International Standard Book Number) of the book.
/// </summary>
public List<IsbnModel>? ISBNs { get; set; }
/// <summary>
/// Gets or sets the list of media contributors (actors, directors, etc) starring in this book.
/// </summary>
public List<MediaContributorModel>? Contributors { get; set; }
/// <summary>
/// Gets or sets the list of ratings for this book.
/// </summary>
public List<BookRatingModel>? Ratings { get; set; }
#endregion
}
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
using Lumina.Presentation.Web.Common.Validation;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
#endregion
@@ -0,0 +1,23 @@
#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
}
@@ -1,6 +1,8 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
using Microsoft.Extensions.Options;
using System;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Common.Validation;
@@ -8,7 +10,7 @@ namespace Lumina.Presentation.Web.Common.Validation;
/// <summary>
/// Provides options for fluent validation of a specific options type.
/// </summary>
/// <typeparam name="TOptions">The type of options being validated</typeparam>
/// <typeparam name="TOptions">The type of options being validated.</typeparam>
public class FluentValidationOptions<TOptions> : IValidateOptions<TOptions> where TOptions : class
{
#region ================================================================== FIELD MEMBERS ================================================================================
@@ -18,6 +18,7 @@ public class ServerConfigurationModelValidator : AbstractValidator<ServerConfigu
{
RuleFor(x => x.BaseAddress).NotEmpty().WithMessage("Base address cannot be empty!");
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
}