(System.Exception exception, [CallerMemberName] string callerMember = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = 0)
+}
+```
+
+### FileParser<P, T>
+
+```csharp
+///
+/// Provides high-level parsing functionality using a specific file format.
+///
+/// The specific file format implementation.
+/// The result type of the parsing.
+public class FileParser where P : FileFormat
+{
+ ///
+ /// Parses content from a string.
+ ///
+ /// The string content to parse.
+ /// The parsed object.
+ public T ParseFromString(string content)
+
+ ///
+ /// Attempts to parse content from a string.
+ ///
+ /// The string content to parse.
+ /// The parsed object, or default on failure.
+ /// True if parsing was successful; otherwise, false.
+ public bool TryParseFromString(string content, out T parsed)
+
+ ///
+ /// Parses content from a file on disk.
+ ///
+ /// The path to the file.
+ /// The parsed object.
+ public T ParseFromDisk(string filePath)
+
+ ///
+ /// Attempts to parse content from a file on disk.
+ ///
+ /// The path to the file.
+ /// The parsed object, or default on failure.
+ /// True if parsing was successful; otherwise, false.
+ public bool TryParseFromDisk(string filePath, out T parsed)
+
+ ///
+ /// Parses content from a file on disk using a FileInfo object.
+ ///
+ /// The FileInfo object representing the file.
+ /// The parsed object.
+ public T ParseFromDisk(FileInfo fileInfo)
+}
+```
+
+## Extensions
+
+### LyricsExtensions
+
+```csharp
+///
+/// Provides extension methods for converting between different lyric structures and text formats.
+///
+public static class LyricsExtensions
+{
+ ///
+ /// Converts a list of raw lyrics to a plain text string.
+ ///
+ /// The list of raw lyrics.
+ /// A string containing the lyrics.
+ public static string ToPlainText(this AList rawElements)
+
+ ///
+ /// Converts a list of time-stamped lyrics to a plain text string.
+ ///
+ /// The list of time-stamped lyrics.
+ /// A string containing the lyrics.
+ public static string ToPlainText(this AList elements)
+
+ ///
+ /// Converts a list of rich time-stamped lyrics to a plain text string.
+ ///
+ /// The list of rich time-stamped lyrics.
+ /// A string containing the lyrics.
+ public static string ToPlainText(this AList richElements)
+
+ ///
+ /// Converts a list of time-stamped lyrics to raw lyrics (removing timestamps).
+ ///
+ /// The list of time-stamped lyrics.
+ /// A list of raw lyrics.
+ public static AList ToRawLyrics(this AList timeStampedLyrics)
+
+ ///
+ /// Converts a list of rich time-stamped lyrics to raw lyrics (removing timestamps and extra data).
+ ///
+ /// The list of rich time-stamped lyrics.
+ /// A list of raw lyrics.
+ public static AList ToRawLyrics(this AList richTimeStampedLyrics)
+
+ ///
+ /// Converts a list of rich time-stamped lyrics to standard time-stamped lyrics (simplifying the structure).
+ ///
+ /// The list of rich time-stamped lyrics.
+ /// A list of time-stamped lyrics.
+ public static AList ToTimeStampedLyrics(this AList richElements)
+}
+```
+
+## Structure
+
+### RawLyric
+
+```csharp
+///
+/// Represents a basic lyric line without timestamps.
+///
+public class RawLyric
+{
+ ///
+ /// Gets or sets the text of the lyric line.
+ ///
+ public string Text { get; set; }
+}
+```
+
+### RegexHolder
+
+```csharp
+///
+/// Holds compiled Regular Expressions for various lyric formats.
+///
+public class RegexHolder
+{
+ /// Regex pattern for standard LRC format.
+ public const string REGEX_LRC = "((\\[)([0-9]*)([:])([0-9]*)([:]|[.])(\\d+\\.\\d+|\\d+)(\\]))((\\s|.).*$)";
+ /// Regex pattern for garbage/metadata lines.
+ public const string REGEX_GARBAGE = "\\D(\\?{0,2}).([:]).([\\w /]*)";
+ /// Regex pattern for environment variables/metadata.
+ public const string REGEX_ENV = "(\\w*)\\=\"(\\w*)";
+ /// Regex pattern for SRT timestamps.
+ public const string REGEX_SRT_TIMESTAMPS = "([0-9:,]*)(\\W(-->)\\W)([0-9:,]*)";
+ /// Regex pattern for Enhanced LRC (ELRC) format data.
+ public const string REGEX_ELRC_DATA = "(\\[)([0-9]*)([:])([0-9]*)([:])(\\d+\\.\\d+|\\d+)(\\])(\\s-\\s)(\\[)([0-9]*)([:])([0-9]*)([:])(\\d+\\.\\d+|\\d+)(\\])\\s(.*$)";
+ /// Regex pattern for KLyrics word format.
+ public const string REGEX_KLYRICS_WORD = "(\\()([0-9]*)(\\,)([0-9]*)(\\))([^\\(\\)\\[\\]\\n]*)";
+ /// Regex pattern for KLyrics timestamp format.
+ public const string REGEX_KLYRICS_TIMESTAMPS = "(\\[)([0-9]*)(\\,)([0-9]*)(\\])";
+
+ /// Compiled Regex for standard LRC format.
+ public static Regex RegexLrc { get; }
+ /// Compiled Regex for garbage/metadata lines.
+ public static Regex RegexGarbage { get; }
+ /// Compiled Regex for environment variables/metadata.
+ public static Regex RegexEnv { get; }
+ /// Compiled Regex for SRT timestamps.
+ public static Regex RegexSrtTimeStamps { get; }
+ /// Compiled Regex for Enhanced LRC (ELRC) format data.
+ public static Regex RegexElrc { get; }
+ /// Compiled Regex for KLyrics word format.
+ public static Regex RegexKlyricsWord { get; }
+ /// Compiled Regex for KLyrics timestamp format.
+ public static Regex RegexKlyricsTimeStamps { get; }
+}
+```
+
+### RichTimeStampedLyric
+
+```csharp
+///
+/// Represents a lyric line with start/end times and individual word timestamps.
+///
+public class RichTimeStampedLyric
+{
+ ///
+ /// Gets or sets the full text of the lyric line.
+ ///
+ public string Text { get; set; }
+
+ ///
+ /// Gets or sets the start time of the lyric line.
+ ///
+ public TimeSpan StartTime { get; set; }
+
+ ///
+ /// Gets or sets the end time of the lyric line.
+ ///
+ public TimeSpan EndTime { get; set; }
+
+ ///
+ /// Gets the start timestamp in total milliseconds.
+ ///
+ public long StartTimestamp { get; }
+
+ ///
+ /// Gets the end timestamp in total milliseconds.
+ ///
+ public long EndTimestamp { get; }
+
+ ///
+ /// Gets or sets the list of words with their own timestamps within this line.
+ ///
+ public AList Words { get; set; }
+}
+```
+
+### RichTimeStampedWord
+
+```csharp
+///
+/// Represents a single word in a lyric with start and end times.
+///
+public class RichTimeStampedWord
+{
+ ///
+ /// Gets or sets the word text.
+ ///
+ public string Word { get; set; }
+
+ ///
+ /// Gets or sets the start time of the word.
+ ///
+ public TimeSpan StartTime { get; set; }
+
+ ///
+ /// Gets or sets the end time of the word.
+ ///
+ public TimeSpan EndTime { get; set; }
+
+ ///
+ /// Gets the start timestamp in total milliseconds.
+ ///
+ public long StartTimestamp { get; }
+
+ ///
+ /// Gets the end timestamp in total milliseconds.
+ ///
+ public long EndTimestamp { get; }
+}
+```
+
+### TimeStampedLyric
+
+```csharp
+///
+/// Represents a lyric line with a start time.
+///
+public class TimeStampedLyric
+{
+ ///
+ /// Gets or sets the text of the lyric line.
+ ///
+ public string Text { get; set; }
+
+ ///
+ /// Gets or sets the start time of the lyric line.
+ ///
+ public TimeSpan StartTime { get; set; }
+
+ ///
+ /// Gets the start timestamp in total milliseconds.
+ ///
+ public long StartTimestamp { get; }
+}
+```
+
+## Formats
+
+### Format Parsers Overview
+
+The DevBase.Format project includes various format parsers:
+
+- **LrcParser** - Parses standard LRC format into `AList`
+- **ElrcParser** - Parses enhanced LRC format into `AList`
+- **KLyricsParser** - Parses KLyrics format into `AList`
+- **SrtParser** - Parses SRT subtitle format into `AList`
+- **AppleLrcXmlParser** - Parses Apple's Line-timed TTML XML into `AList`
+- **AppleRichXmlParser** - Parses Apple's Word-timed TTML XML into `AList`
+- **AppleXmlParser** - Parses Apple's non-timed TTML XML into `AList`
+- **MmlParser** - Parses Musixmatch JSON format into `AList`
+- **RmmlParser** - Parses Rich Musixmatch JSON format into `AList`
+- **EnvParser** - Parses KEY=VALUE style content
+- **RlrcParser** - Parses raw lines as lyrics
+
+Each parser extends the `FileFormat` base class and implements the `Parse` and `TryParse` methods for their specific format types.
+
+# DevBase.Logging Project Documentation
+
+This document contains all class, method, and field signatures with their corresponding comments for the DevBase.Logging project.
+
+## Table of Contents
+
+- [Enums](#enums)
+ - [LogType](#logtype)
+- [Logger](#logger)
+ - [Logger<T>](#loggert)
+
+## Enums
+
+### LogType
+
+```csharp
+///
+/// Represents the severity level of a log message.
+///
+public enum LogType
+{
+ ///
+ /// Informational message, typically used for general application flow.
+ ///
+ INFO,
+
+ ///
+ /// Debugging message, used for detailed information during development.
+ ///
+ DEBUG,
+
+ ///
+ /// Error message, indicating a failure in a specific operation.
+ ///
+ ERROR,
+
+ ///
+ /// Fatal error message, indicating a critical failure that may cause the application to crash.
+ ///
+ FATAL
+}
+```
+
+## Logger
+
+### Logger<T>
+
+```csharp
+///
+/// A generic logger class that provides logging functionality scoped to a specific type context.
+///
+/// The type of the context object associated with this logger.
+public class Logger
+{
+ ///
+ /// The context object used to identify the source of the log messages.
+ ///
+ private T _type
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The context object associated with this logger instance.
+ public Logger(T type)
+
+ ///
+ /// Logs an exception with severity.
+ ///
+ /// The exception to log.
+ public void Write(Exception exception)
+
+ ///
+ /// Logs a message with the specified severity level.
+ ///
+ /// The message to log.
+ /// The severity level of the log message.
+ public void Write(string message, LogType debugType)
+
+ ///
+ /// Formats and writes the log message to the debug listeners.
+ ///
+ /// The message to log.
+ /// The severity level of the log message.
+ private void Print(string message, LogType debugType)
+}
+```
+
+# DevBase.Net Project Documentation
+
+This document contains all class, method, and field signatures with their corresponding comments for the DevBase.Net project.
+
+## Table of Contents
+
+- [Abstract](#abstract)
+ - [GenericBuilder<T>](#genericbuildert)
+ - [HttpHeaderBuilder<T>](#httpheaderbuildert)
+ - [HttpBodyBuilder<T>](#httpbodybuildert)
+ - [HttpFieldBuilder<T>](#httpfieldbuildert)
+ - [BogusHttpHeaderBuilder](#bogushttpheaderbuilder)
+ - [HttpKeyValueListBuilder<T, K, V>](#httpkeyvaluelistbuildert-k-v)
+ - [RequestContent](#requestcontent)
+ - [TypographyRequestContent](#typographyrequestcontent)
+- [Batch](#batch)
+ - [BatchRequests](#batchrequests)
+ - [Batch](#batch)
+ - [BatchProgressInfo](#batchprogressinfo)
+ - [BatchStatistics](#batchstatistics)
+ - [RequeueDecision](#requeuedecision)
+ - [ProxiedBatchRequests](#proxiedbatchrequests)
+ - [ProxiedBatch](#proxiedbatch)
+ - [ProxiedBatchStatistics](#proxiedbatchstatistics)
+ - [ProxyFailureContext](#proxyfailurecontext)
+ - [Proxy Rotation Strategies](#proxy-rotation-strategies)
+- [Cache](#cache)
+ - [CachedResponse](#cachedresponse)
+ - [ResponseCache](#responsecache)
+- [Configuration](#configuration)
+ - [Enums](#enums)
+ - [Configuration Classes](#configuration-classes)
+- [Constants](#constants)
+- [Core](#core)
+ - [BaseRequest](#baserequest)
+ - [Request](#request)
+ - [BaseResponse](#baseresponse)
+ - [Response](#response)
+- [Data](#data)
+- [Exceptions](#exceptions)
+- [Interfaces](#interfaces)
+- [Parsing](#parsing)
+- [Proxy](#proxy)
+- [Security](#security)
+- [Utils](#utils)
+- [Validation](#validation)
+
+## Abstract
+
+### GenericBuilder<T>
+
+```csharp
+///
+/// Abstract base class for generic builders.
+///
+/// The specific builder type.
+public abstract class GenericBuilder where T : GenericBuilder
+{
+ private bool AlreadyBuilt { get; set; }
+
+ ///
+ /// Gets a value indicating whether the builder result is usable (already built).
+ ///
+ public bool Usable { get; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ protected GenericBuilder()
+
+ ///
+ /// Gets the action to perform when building.
+ ///
+ protected abstract Action BuildAction { get; }
+
+ ///
+ /// Builds the object.
+ ///
+ /// The builder instance.
+ /// Thrown if the object has already been built.
+ public T Build()
+
+ ///
+ /// Attempts to build the object.
+ ///
+ /// True if the build was successful; otherwise, false (if already built).
+ public bool TryBuild()
+}
+```
+
+### HttpHeaderBuilder<T>
+
+```csharp
+///
+/// Abstract base class for HTTP header builders.
+///
+/// The specific builder type.
+public abstract class HttpHeaderBuilder where T : HttpHeaderBuilder
+{
+ ///
+ /// Gets the StringBuilder used to construct the header.
+ ///
+ protected StringBuilder HeaderStringBuilder { get; private set; }
+
+ private bool AlreadyBuilt { get; set; }
+
+ ///
+ /// Gets a value indicating whether the builder result is usable (built or has content).
+ ///
+ public bool Usable { get; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ protected HttpHeaderBuilder()
+
+ ///
+ /// Gets the action to perform when building the header.
+ ///
+ protected abstract Action BuildAction { get; }
+
+ ///
+ /// Builds the HTTP header.
+ ///
+ /// The builder instance.
+ /// Thrown if the header has already been built.
+ public T Build()
+}
+```
+
+### HttpBodyBuilder<T>
+
+```csharp
+///
+/// Base class for builders that construct HTTP request bodies.
+///
+/// The specific builder type.
+public abstract class HttpBodyBuilder where T : HttpBodyBuilder
+{
+ ///
+ /// Gets the content type of the body.
+ ///
+ public abstract string ContentType { get; }
+
+ ///
+ /// Gets the content length of the body.
+ ///
+ public abstract long ContentLength { get; }
+
+ ///
+ /// Gets whether the body is built.
+ ///
+ public abstract bool IsBuilt { get; }
+
+ ///
+ /// Builds the body content.
+ ///
+ /// The builder instance.
+ public abstract T Build()
+
+ ///
+ /// Writes the body content to a stream.
+ ///
+ /// The stream to write to.
+ /// Cancellation token.
+ public abstract Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default)
+}
+```
+
+### HttpFieldBuilder<T>
+
+```csharp
+///
+/// Base class for builders that construct single HTTP fields.
+///
+/// The specific builder type.
+public abstract class HttpFieldBuilder where T : HttpFieldBuilder, new()
+{
+ ///
+ /// Gets whether the field is built.
+ ///
+ public bool IsBuilt { get; protected set; }
+
+ ///
+ /// Builds the field.
+ ///
+ /// The builder instance.
+ public abstract T Build()
+}
+```
+
+### BogusHttpHeaderBuilder
+
+```csharp
+///
+/// Extended header builder with support for fake data generation.
+///
+public class BogusHttpHeaderBuilder : HttpHeaderBuilder
+{
+ // Implementation for generating bogus HTTP headers
+}
+```
+
+### HttpKeyValueListBuilder<T, K, V>
+
+```csharp
+///
+/// Base for key-value pair based body builders (e.g. form-urlencoded).
+///
+/// The specific builder type.
+/// The key type.
+/// The value type.
+public abstract class HttpKeyValueListBuilder : HttpBodyBuilder
+ where T : HttpKeyValueListBuilder, new()
+{
+ ///
+ /// Adds a key-value pair.
+ ///
+ /// The key.
+ /// The value.
+ /// The builder instance.
+ public abstract T Add(K key, V value)
+}
+```
+
+### RequestContent
+
+```csharp
+///
+/// Abstract base for request content validation.
+///
+public abstract class RequestContent
+{
+ ///
+ /// Validates the request content.
+ ///
+ /// The content to validate.
+ /// True if valid; otherwise, false.
+ public abstract bool Validate(string content)
+}
+```
+
+### TypographyRequestContent
+
+```csharp
+///
+/// Text-based request content validation with encoding.
+///
+public class TypographyRequestContent : RequestContent
+{
+ ///
+ /// Gets or sets the encoding to use.
+ ///
+ public Encoding Encoding { get; set; }
+
+ ///
+ /// Validates the text content.
+ ///
+ /// The content to validate.
+ /// True if valid; otherwise, false.
+ public override bool Validate(string content)
+}
+```
+
+## Batch
+
+### BatchRequests
+
+```csharp
+///
+/// High-performance batch request execution engine.
+///
+public sealed class BatchRequests : IDisposable, IAsyncDisposable
+{
+ ///
+ /// Gets the number of batches.
+ ///
+ public int BatchCount { get; }
+
+ ///
+ /// Gets the total queue count across all batches.
+ ///
+ public int TotalQueueCount { get; }
+
+ ///
+ /// Gets the response queue count.
+ ///
+ public int ResponseQueueCount { get; }
+
+ ///
+ /// Gets the rate limit.
+ ///
+ public int RateLimit { get; }
+
+ ///
+ /// Gets whether cookies are persisted.
+ ///
+ public bool PersistCookies { get; }
+
+ ///
+ /// Gets whether referer is persisted.
+ ///
+ public bool PersistReferer { get; }
+
+ ///
+ /// Gets whether processing is active.
+ ///
+ public bool IsProcessing { get; }
+
+ ///
+ /// Gets the processed count.
+ ///
+ public int ProcessedCount { get; }
+
+ ///
+ /// Gets the error count.
+ ///
+ public int ErrorCount { get; }
+
+ ///
+ /// Gets the batch names.
+ ///
+ public IReadOnlyList BatchNames { get; }
+
+ ///
+ /// Initializes a new instance of the BatchRequests class.
+ ///
+ public BatchRequests()
+
+ ///
+ /// Sets the rate limit.
+ ///
+ /// Requests per window.
+ /// Time window.
+ /// The BatchRequests instance.
+ public BatchRequests WithRateLimit(int requestsPerWindow, TimeSpan? window = null)
+
+ ///
+ /// Enables cookie persistence.
+ ///
+ /// Whether to persist.
+ /// The BatchRequests instance.
+ public BatchRequests WithCookiePersistence(bool persist = true)
+
+ ///
+ /// Enables referer persistence.
+ ///
+ /// Whether to persist.
+ /// The BatchRequests instance.
+ public BatchRequests WithRefererPersistence(bool persist = true)
+
+ ///
+ /// Creates a new batch.
+ ///
+ /// Batch name.
+ /// The created batch.
+ public Batch CreateBatch(string name)
+
+ ///
+ /// Gets or creates a batch.
+ ///
+ /// Batch name.
+ /// The batch.
+ public Batch GetOrCreateBatch(string name)
+
+ ///
+ /// Gets a batch by name.
+ ///
+ /// Batch name.
+ /// The batch, or null if not found.
+ public Batch? GetBatch(string name)
+
+ ///
+ /// Removes a batch.
+ ///
+ /// Batch name.
+ /// True if removed; otherwise, false.
+ public bool RemoveBatch(string name)
+
+ ///
+ /// Clears all batches.
+ ///
+ /// The BatchRequests instance.
+ public BatchRequests ClearAllBatches()
+
+ ///
+ /// Adds a response callback.
+ ///
+ /// The callback function.
+ /// The BatchRequests instance.
+ public BatchRequests OnResponse(Func callback)
+
+ ///
+ /// Adds a response callback.
+ ///
+ /// The callback action.
+ /// The BatchRequests instance.
+ public BatchRequests OnResponse(Action callback)
+
+ ///
+ /// Adds an error callback.
+ ///
+ /// The callback function.
+ /// The BatchRequests instance.
+ public BatchRequests OnError(Func callback)
+
+ ///
+ /// Adds an error callback.
+ ///
+ /// The callback action.
+ /// The BatchRequests instance.
+ public BatchRequests OnError(Action callback)
+
+ ///
+ /// Adds a progress callback.
+ ///
+ /// The callback function.
+ /// The BatchRequests instance.
+ public BatchRequests OnProgress(Func callback)
+
+ ///
+ /// Adds a progress callback.
+ ///
+ /// The callback action.
+ /// The BatchRequests instance.
+ public BatchRequests OnProgress(Action callback)
+
+ ///
+ /// Adds a response requeue callback.
+ ///
+ /// The callback function.
+ /// The BatchRequests instance.
+ public BatchRequests OnResponseRequeue(Func callback)
+
+ ///
+ /// Adds an error requeue callback.
+ ///
+ /// The callback function.
+ /// The BatchRequests instance.
+ public BatchRequests OnErrorRequeue(Func callback)
+
+ ///
+ /// Attempts to dequeue a response.
+ ///
+ /// The dequeued response.
+ /// True if dequeued; otherwise, false.
+ public bool TryDequeueResponse(out Response? response)
+
+ ///
+ /// Dequeues all responses.
+ ///
+ /// List of responses.
+ public List DequeueAllResponses()
+
+ ///
+ /// Starts processing.
+ ///
+ public void StartProcessing()
+
+ ///
+ /// Stops processing.
+ ///
+ public Task StopProcessingAsync()
+
+ ///
+ /// Executes all batches.
+ ///
+ /// Cancellation token.
+ /// List of responses.
+ public async Task> ExecuteAllAsync(CancellationToken cancellationToken = default)
+
+ ///
+ /// Executes a specific batch.
+ ///
+ /// Batch name.
+ /// Cancellation token.
+ /// List of responses.
+ public async Task> ExecuteBatchAsync(string batchName, CancellationToken cancellationToken = default)
+
+ ///
+ /// Executes all batches as async enumerable.
+ ///
+ /// Cancellation token.
+ /// Async enumerable of responses.
+ public async IAsyncEnumerable ExecuteAllAsyncEnumerable(CancellationToken cancellationToken = default)
+
+ ///
+ /// Resets counters.
+ ///
+ public void ResetCounters()
+
+ ///
+ /// Gets statistics.
+ ///
+ /// Batch statistics.
+ public BatchStatistics GetStatistics()
+
+ ///
+ /// Disposes resources.
+ ///
+ public void Dispose()
+
+ ///
+ /// Disposes resources asynchronously.
+ ///
+ public async ValueTask DisposeAsync()
+}
+```
+
+### Batch
+
+```csharp
+///
+/// Represents a named batch of requests within a BatchRequests engine.
+///
+public sealed class Batch
+{
+ ///
+ /// Gets the name of the batch.
+ ///
+ public string Name { get; }
+
+ ///
+ /// Gets the number of items in the queue.
+ ///
+ public int QueueCount { get; }
+
+ ///
+ /// Adds a request to the batch.
+ ///
+ /// The request to add.
+ /// The current batch instance.
+ public Batch Add(Request request)
+
+ ///
+ /// Adds a collection of requests.
+ ///
+ /// The requests to add.
+ /// The current batch instance.
+ public Batch Add(IEnumerable requests)
+
+ ///
+ /// Adds a request by URL.
+ ///
+ /// The URL to request.
+ /// The current batch instance.
+ public Batch Add(string url)
+
+ ///
+ /// Adds a collection of URLs.
+ ///
+ /// The URLs to add.
+ /// The current batch instance.
+ public Batch Add(IEnumerable urls)
+
+ ///
+ /// Enqueues a request (alias for Add).
+ ///
+ public Batch Enqueue(Request request)
+
+ ///
+ /// Enqueues a request by URL (alias for Add).
+ ///
+ public Batch Enqueue(string url)
+
+ ///
+ /// Enqueues a collection of requests (alias for Add).
+ ///
+ public Batch Enqueue(IEnumerable requests)
+
+ ///
+ /// Enqueues a collection of URLs (alias for Add).
+ ///
+ public Batch Enqueue(IEnumerable urls)
+
+ ///
+ /// Enqueues a request with configuration.
+ ///
+ /// The URL.
+ /// Action to configure the request.
+ /// The current batch instance.
+ public Batch Enqueue(string url, Action configure)
+
+ ///
+ /// Enqueues a request from a factory.
+ ///
+ /// The factory function.
+ /// The current batch instance.
+ public Batch Enqueue(Func requestFactory)
+
+ ///
+ /// Attempts to dequeue a request.
+ ///
+ /// The dequeued request.
+ /// True if dequeued; otherwise, false.
+ public bool TryDequeue(out Request? request)
+
+ ///
+ /// Clears all requests.
+ ///
+ public void Clear()
+
+ ///
+ /// Returns to the parent BatchRequests.
+ ///
+ /// The parent engine.
+ public BatchRequests EndBatch()
+}
+```
+
+### BatchProgressInfo
+
+```csharp
+///
+/// Information about batch processing progress.
+///
+public class BatchProgressInfo
+{
+ ///
+ /// Gets the batch name.
+ ///
+ public string BatchName { get; }
+
+ ///
+ /// Gets the completed count.
+ ///
+ public int Completed { get; }
+
+ ///
+ /// Gets the total count.
+ ///
+ public int Total { get; }
+
+ ///
+ /// Gets the error count.
+ ///
+ public int Errors { get; }
+
+ ///
+ /// Gets the progress percentage.
+ ///
+ public double ProgressPercentage { get; }
+
+ ///
+ /// Initializes a new instance.
+ ///
+ /// Batch name.
+ /// Completed count.
+ /// Total count.
+ /// Error count.
+ public BatchProgressInfo(string batchName, int completed, int total, int errors)
+}
+```
+
+### BatchStatistics
+
+```csharp
+///
+/// Statistics for batch processing.
+///
+public class BatchStatistics
+{
+ ///
+ /// Gets the batch count.
+ ///
+ public int BatchCount { get; }
+
+ ///
+ /// Gets the total queue count.
+ ///
+ public int TotalQueueCount { get; }
+
+ ///
+ /// Gets the processed count.
+ ///
+ public int ProcessedCount { get; }
+
+ ///
+ /// Gets the error count.
+ ///
+ public int ErrorCount { get; }
+
+ ///
+ /// Gets the batch queue counts.
+ ///
+ public IReadOnlyDictionary BatchQueueCounts { get; }
+
+ ///
+ /// Initializes a new instance.
+ ///
+ /// Batch count.
+ /// Total queue count.
+ /// Processed count.
+ /// Error count.
+ /// Batch queue counts.
+ public BatchStatistics(int batchCount, int totalQueueCount, int processedCount, int errorCount, IReadOnlyDictionary batchQueueCounts)
+}
+```
+
+### RequeueDecision
+
+```csharp
+///
+/// Decision for requeuing a request.
+///
+public class RequeueDecision
+{
+ ///
+ /// Gets whether to requeue.
+ ///
+ public bool ShouldRequeue { get; }
+
+ ///
+ /// Gets the modified request (if any).
+ ///
+ public Request? ModifiedRequest { get; }
+
+ ///
+ /// Gets a decision to not requeue.
+ ///
+ public static RequeueDecision NoRequeue { get; }
+
+ ///
+ /// Gets a decision to requeue.
+ ///
+ /// Optional modified request.
+ /// The requeue decision.
+ public static RequeueDecision Requeue(Request? modifiedRequest = null)
+}
+```
+
+### ProxiedBatchRequests
+
+```csharp
+///
+/// Extension of BatchRequests with built-in proxy support.
+///
+public sealed class ProxiedBatchRequests : BatchRequests
+{
+ ///
+ /// Gets the proxy rotation strategy.
+ ///
+ public IProxyRotationStrategy ProxyRotationStrategy { get; }
+
+ ///
+ /// Gets the proxy pool.
+ ///
+ public IReadOnlyList ProxyPool { get; }
+
+ ///
+ /// Configures the proxy pool.
+ ///
+ /// List of proxies.
+ /// The ProxiedBatchRequests instance.
+ public ProxiedBatchRequests WithProxies(IList proxies)
+
+ ///
+ /// Sets the proxy rotation strategy.
+ ///
+ /// The strategy.
+ /// The ProxiedBatchRequests instance.
+ public ProxiedBatchRequests WithProxyRotationStrategy(IProxyRotationStrategy strategy)
+
+ ///
+ /// Gets proxy statistics.
+ ///
+ /// Proxy statistics.
+ public ProxiedBatchStatistics GetProxyStatistics()
+}
+```
+
+### ProxiedBatch
+
+```csharp
+///
+/// A batch with proxy support.
+///
+public sealed class ProxiedBatch : Batch
+{
+ ///
+ /// Gets the assigned proxy.
+ ///
+ public TrackedProxyInfo? AssignedProxy { get; }
+
+ ///
+ /// Gets the proxy failure count.
+ ///
+ public int ProxyFailureCount { get; }
+
+ ///
+ /// Marks proxy as failed.
+ ///
+ public void MarkProxyAsFailed()
+
+ ///
+ /// Resets proxy failure count.
+ ///
+ public void ResetProxyFailureCount()
+}
+```
+
+### ProxiedBatchStatistics
+
+```csharp
+///
+/// Statistics for proxied batch processing.
+///
+public class ProxiedBatchStatistics : BatchStatistics
+{
+ ///
+ /// Gets the total proxy count.
+ ///
+ public int TotalProxyCount { get; }
+
+ ///
+ /// Gets the active proxy count.
+ ///
+ public int ActiveProxyCount { get; }
+
+ ///
+ /// Gets the failed proxy count.
+ ///
+ public int FailedProxyCount { get; }
+
+ ///
+ /// Gets proxy failure details.
+ ///
+ public IReadOnlyDictionary ProxyFailureCounts { get; }
+
+ ///
+ /// Initializes a new instance.
+ ///
+ /// Base statistics.
+ /// Total proxy count.
+ /// Active proxy count.
+ /// Failed proxy count.
+ /// Proxy failure counts.
+ public ProxiedBatchStatistics(BatchStatistics baseStats, int totalProxyCount, int activeProxyCount, int failedProxyCount, IReadOnlyDictionary proxyFailureCounts)
+}
+```
+
+### ProxyFailureContext
+
+```csharp
+///
+/// Context for proxy failure.
+///
+public class ProxyFailureContext
+{
+ ///
+ /// Gets the failed proxy.
+ ///
+ public TrackedProxyInfo Proxy { get; }
+
+ ///
+ /// Gets the exception.
+ ///
+ public System.Exception Exception { get; }
+
+ ///
+ /// Gets the failure count.
+ ///
+ public int FailureCount { get; }
+
+ ///
+ /// Gets the timestamp of failure.
+ ///
+ public DateTime FailureTimestamp { get; }
+
+ ///
+ /// Initializes a new instance.
+ ///
+ /// The proxy.
+ /// The exception.
+ /// Failure count.
+ public ProxyFailureContext(TrackedProxyInfo proxy, System.Exception exception, int failureCount)
+}
+```
+
+### Proxy Rotation Strategies
+
+```csharp
+///
+/// Interface for proxy rotation strategies.
+///
+public interface IProxyRotationStrategy
+{
+ ///
+ /// Selects the next proxy.
+ ///
+ /// Available proxies.
+ /// Failure contexts.
+ /// The selected proxy, or null if none available.
+ TrackedProxyInfo? SelectNextProxy(IReadOnlyList availableProxies, IReadOnlyDictionary failureContexts)
+}
+
+///
+/// Round-robin proxy rotation strategy.
+///
+public class RoundRobinStrategy : IProxyRotationStrategy
+{
+ ///
+ /// Selects the next proxy in round-robin order.
+ ///
+ public TrackedProxyInfo? SelectNextProxy(IReadOnlyList availableProxies, IReadOnlyDictionary failureContexts)
+}
+
+///
+/// Random proxy rotation strategy.
+///
+public class RandomStrategy : IProxyRotationStrategy
+{
+ ///
+ /// Selects a random proxy.
+ ///
+ public TrackedProxyInfo? SelectNextProxy(IReadOnlyList availableProxies, IReadOnlyDictionary failureContexts)
+}
+
+///
+/// Least failures proxy rotation strategy.
+///
+public class LeastFailuresStrategy : IProxyRotationStrategy
+{
+ ///
+ /// Selects the proxy with the least failures.
+ ///
+ public TrackedProxyInfo? SelectNextProxy(IReadOnlyList availableProxies, IReadOnlyDictionary failureContexts)
+}
+
+///
+/// Sticky proxy rotation strategy (keeps using the same proxy until it fails).
+///
+public class StickyStrategy : IProxyRotationStrategy
+{
+ ///
+ /// Gets or sets the current sticky proxy.
+ ///
+ public TrackedProxyInfo? CurrentProxy { get; set; }
+
+ ///
+ /// Selects the current proxy if available, otherwise selects a new one.
+ ///
+ public TrackedProxyInfo? SelectNextProxy(IReadOnlyList availableProxies, IReadOnlyDictionary failureContexts)
+}
+```
+
+## Cache
+
+### CachedResponse
+
+```csharp
+///
+/// Represents a cached HTTP response.
+///
+public class CachedResponse
+{
+ ///
+ /// Gets the cached response data.
+ ///
+ public Response Response { get; }
+
+ ///
+ /// Gets the cache timestamp.
+ ///
+ public DateTime CachedAt { get; }
+
+ ///
+ /// Gets the expiration time.
+ ///
+ public DateTime? ExpiresAt { get; }
+
+ ///
+ /// Gets whether the response is expired.
+ ///
+ public bool IsExpired => ExpiresAt.HasValue && DateTime.UtcNow > ExpiresAt.Value;
+
+ ///
+ /// Initializes a new instance.
+ ///
+ /// The response.
+ /// Expiration time.
+ public CachedResponse(Response response, DateTime? expiresAt = null)
+}
+```
+
+### ResponseCache
+
+```csharp
+///
+/// Integrated caching system using FusionCache.
+///
+public class ResponseCache : IDisposable
+{
+ private readonly FusionCache _cache;
+
+ ///
+ /// Initializes a new instance.
+ ///
+ /// Cache options.
+ public ResponseCache(FusionCacheOptions? options = null)
+
+ ///
+ /// Gets a cached response.
+ ///
+ /// The request.
+ /// Cancellation token.
+ /// The cached response, or null if not found.
+ public async Task GetAsync(Request request, CancellationToken cancellationToken = default)
+
+ ///
+ /// Sets a response in cache.
+ ///
+ /// The request.
+ /// The response.
+ /// Expiration time.
+ /// Cancellation token.
+ public async Task SetAsync(Request request, Response response, TimeSpan? expiration = null, CancellationToken cancellationToken = default)
+
+ ///
+ /// Removes a cached response.
+ ///
+ /// The request.
+ /// Cancellation token.
+ public async Task RemoveAsync(Request request, CancellationToken cancellationToken = default)
+
+ ///
+ /// Clears the cache.
+ ///
+ public void Clear()
+
+ ///
+ /// Disposes resources.
+ ///
+ public void Dispose()
+}
+```
+
+## Configuration
+
+### Enums
+
+#### EnumBackoffStrategy
+
+```csharp
+///
+/// Strategy for retry backoff.
+///
+public enum EnumBackoffStrategy
+{
+ /// Fixed delay between retries.
+ Fixed,
+ /// Linear increase in delay.
+ Linear,
+ /// Exponential increase in delay.
+ Exponential
+}
+```
+
+#### EnumBrowserProfile
+
+```csharp
+///
+/// Browser profile for emulating specific browsers.
+///
+public enum EnumBrowserProfile
+{
+ /// No specific profile.
+ None,
+ /// Chrome browser.
+ Chrome,
+ /// Firefox browser.
+ Firefox,
+ /// Edge browser.
+ Edge,
+ /// Safari browser.
+ Safari
+}
+```
+
+#### EnumHostCheckMethod
+
+```csharp
+///
+/// Method for checking host availability.
+///
+public enum EnumHostCheckMethod
+{
+ /// Use ICMP ping.
+ Ping,
+ /// Use TCP connection.
+ TcpConnect
+}
+```
+
+#### EnumRefererStrategy
+
+```csharp
+///
+/// Strategy for handling referer headers.
+///
+public enum EnumRefererStrategy
+{
+ /// No referer.
+ None,
+ /// Use previous URL as referer.
+ PreviousUrl,
+ /// Use domain root as referer.
+ DomainRoot,
+ /// Use custom referer.
+ Custom
+}
+```
+
+#### EnumRequestLogLevel
+
+```csharp
+///
+/// Log level for request/response logging.
+///
+public enum EnumRequestLogLevel
+{
+ /// No logging.
+ None,
+ /// Log only basic info.
+ Basic,
+ /// Log headers.
+ Headers,
+ /// Log full content.
+ Full
+}
+```
+
+### Configuration Classes
+
+#### RetryPolicy
+
+```csharp
+///
+/// Configuration for request retry policies.
+///
+public sealed class RetryPolicy
+{
+ ///
+ /// Gets the maximum number of retries. Defaults to 3.
+ ///
+ public int MaxRetries { get; init; } = 3;
+
+ ///
+ /// Gets the backoff strategy. Defaults to Exponential.
+ ///
+ public EnumBackoffStrategy BackoffStrategy { get; init; } = EnumBackoffStrategy.Exponential;
+
+ ///
+ /// Gets the initial delay. Defaults to 500ms.
+ ///
+ public TimeSpan InitialDelay { get; init; } = TimeSpan.FromMilliseconds(500);
+
+ ///
+ /// Gets the maximum delay. Defaults to 30 seconds.
+ ///
+ public TimeSpan MaxDelay { get; init; } = TimeSpan.FromSeconds(30);
+
+ ///
+ /// Gets the backoff multiplier. Defaults to 2.0.
+ ///
+ public double BackoffMultiplier { get; init; } = 2.0;
+
+ ///
+ /// Calculates delay for a specific attempt.
+ ///
+ /// Attempt number (1-based).
+ /// Time to wait.
+ public TimeSpan GetDelay(int attemptNumber)
+
+ ///
+ /// Gets the default retry policy.
+ ///
+ public static RetryPolicy Default { get; }
+
+ ///
+ /// Gets a policy with no retries.
+ ///
+ public static RetryPolicy None { get; }
+
+ ///
+ /// Gets an aggressive retry policy.
+ ///
+ public static RetryPolicy Aggressive { get; }
+}
+```
+
+#### HostCheckConfig
+
+```csharp
+///
+/// Configuration for host availability checks.
+///
+public class HostCheckConfig
+{
+ ///
+ /// Gets or sets the check method.
+ ///
+ public EnumHostCheckMethod Method { get; set; } = EnumHostCheckMethod.Ping;
+
+ ///
+ /// Gets or sets the timeout for checks.
+ ///
+ public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(5);
+
+ ///
+ /// Gets or sets the port for TCP checks.
+ ///
+ public int Port { get; set; } = 80;
+
+ ///
+ /// Gets or sets whether to enable checks.
+ ///
+ public bool Enabled { get; set; } = false;
+}
+```
+
+#### JsonPathConfig
+
+```csharp
+///
+/// Configuration for JSON path extraction.
+///
+public class JsonPathConfig
+{
+ ///
+ /// Gets or sets whether to use fast streaming parser.
+ ///
+ public bool UseStreamingParser { get; set; } = true;
+
+ ///
+ /// Gets or sets the buffer size for streaming.
+ ///
+ public int BufferSize { get; set; } = 8192;
+
+ ///
+ /// Gets or sets whether to cache compiled paths.
+ ///
+ public bool CacheCompiledPaths { get; set; } = true;
+}
+```
+
+#### LoggingConfig
+
+```csharp
+///
+/// Configuration for request/response logging.
+///
+public class LoggingConfig
+{
+ ///
+ /// Gets or sets the log level.
+ ///
+ public EnumRequestLogLevel LogLevel { get; set; } = EnumRequestLogLevel.Basic;
+
+ ///
+ /// Gets or sets whether to log request body.
+ ///
+ public bool LogRequestBody { get; set; } = false;
+
+ ///
+ /// Gets or sets whether to log response body.
+ ///
+ public bool LogResponseBody { get; set; } = false;
+
+ ///
+ /// Gets or sets the maximum body size to log.
+ ///
+ public int MaxBodySizeToLog { get; set; } = 1024 * 1024; // 1MB
+
+ ///
+ /// Gets or sets whether to sanitize headers.
+ ///
+ public bool SanitizeHeaders { get; set; } = true;
+}
+```
+
+#### MultiSelectorConfig
+
+```csharp
+///
+/// Configuration for selecting multiple JSON paths.
+///
+public class MultiSelectorConfig
+{
+ ///
+ /// Gets the selectors.
+ ///
+ public IReadOnlyList<(string name, string path)> Selectors { get; }
+
+ ///
+ /// Gets whether to use optimized parsing.
+ ///
+ public bool UseOptimizedParsing { get; }
+
+ ///
+ /// Initializes a new instance.
+ ///
+ /// The selectors.
+ /// Whether to use optimized parsing.
+ public MultiSelectorConfig(IReadOnlyList<(string name, string path)> selectors, bool useOptimizedParsing = true)
+}
+```
+
+#### ScrapingBypassConfig
+
+```csharp
+///
+/// Configuration for anti-scraping bypass.
+///
+public class ScrapingBypassConfig
+{
+ ///
+ /// Gets or sets the referer strategy.
+ ///
+ public EnumRefererStrategy RefererStrategy { get; set; } = EnumRefererStrategy.None;
+
+ ///
+ /// Gets or sets the custom referer.
+ ///
+ public string? CustomReferer { get; set; }
+
+ ///
+ /// Gets or sets the browser profile.
+ ///
+ public EnumBrowserProfile BrowserProfile { get; set; } = EnumBrowserProfile.None;
+
+ ///
+ /// Gets or sets whether to randomize user agent.
+ ///
+ public bool RandomizeUserAgent { get; set; } = false;
+
+ ///
+ /// Gets or sets additional headers to add.
+ ///
+ public Dictionary AdditionalHeaders { get; set; } = new();
+}
+```
+
+## Constants
+
+### AuthConstants
+
+```csharp
+///
+/// Constants for authentication.
+///
+public static class AuthConstants
+{
+ /// Bearer authentication scheme.
+ public const string Bearer = "Bearer";
+ /// Basic authentication scheme.
+ public const string Basic = "Basic";
+ /// Digest authentication scheme.
+ public const string Digest = "Digest";
+}
+```
+
+### EncodingConstants
+
+```csharp
+///
+/// Constants for encoding.
+///
+public static class EncodingConstants
+{
+ /// UTF-8 encoding name.
+ public const string Utf8 = "UTF-8";
+ /// ASCII encoding name.
+ public const string Ascii = "ASCII";
+ /// ISO-8859-1 encoding name.
+ public const string Iso88591 = "ISO-8859-1";
+}
+```
+
+### HeaderConstants
+
+```csharp
+///
+/// Constants for HTTP headers.
+///
+public static class HeaderConstants
+{
+ /// Content-Type header.
+ public const string ContentType = "Content-Type";
+ /// Content-Length header.
+ public const string ContentLength = "Content-Length";
+ /// User-Agent header.
+ public const string UserAgent = "User-Agent";
+ /// Authorization header.
+ public const string Authorization = "Authorization";
+ /// Accept header.
+ public const string Accept = "Accept";
+ /// Cookie header.
+ public const string Cookie = "Cookie";
+ /// Set-Cookie header.
+ public const string SetCookie = "Set-Cookie";
+ /// Referer header.
+ public const string Referer = "Referer";
+}
+```
+
+### HttpConstants
+
+```csharp
+///
+/// Constants for HTTP.
+///
+public static class HttpConstants
+{
+ /// HTTP/1.1 version.
+ public const string Http11 = "HTTP/1.1";
+ /// HTTP/2 version.
+ public const string Http2 = "HTTP/2";
+ /// HTTP/3 version.
+ public const string Http3 = "HTTP/3";
+}
+```
+
+### MimeConstants
+
+```csharp
+///
+/// Constants for MIME types.
+///
+public static class MimeConstants
+{
+ /// JSON MIME type.
+ public const string ApplicationJson = "application/json";
+ /// XML MIME type.
+ public const string ApplicationXml = "application/xml";
+ /// Form URL-encoded MIME type.
+ public const string ApplicationFormUrlEncoded = "application/x-www-form-urlencoded";
+ /// Multipart form-data MIME type.
+ public const string MultipartFormData = "multipart/form-data";
+ /// Text HTML MIME type.
+ public const string TextHtml = "text/html";
+ /// Text plain MIME type.
+ public const string TextPlain = "text/plain";
+}
+```
+
+### PlatformConstants
+
+```csharp
+///
+/// Constants for platforms.
+///
+public static class PlatformConstants
+{
+ /// Windows platform.
+ public const string Windows = "Windows";
+ /// Linux platform.
+ public const string Linux = "Linux";
+ /// macOS platform.
+ public const string MacOS = "macOS";
+}
+```
+
+### ProtocolConstants
+
+```csharp
+///
+/// Constants for protocols.
+///
+public static class ProtocolConstants
+{
+ /// HTTP protocol.
+ public const string Http = "http";
+ /// HTTPS protocol.
+ public const string Https = "https";
+ /// WebSocket protocol.
+ public const string Ws = "ws";
+ /// WebSocket Secure protocol.
+ public const string Wss = "wss";
+}
+```
+
+### UserAgentConstants
+
+```csharp
+///
+/// Constants for user agents.
+///
+public static class UserAgentConstants
+{
+ /// Chrome user agent.
+ public const string Chrome = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36";
+ /// Firefox user agent.
+ public const string Firefox = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0";
+ /// Edge user agent.
+ public const string Edge = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.59";
+}
+```
+
+## Core
+
+### BaseRequest
+
+```csharp
+///
+/// Abstract base class for HTTP requests providing core properties and lifecycle management.
+///
+public abstract class BaseRequest : IDisposable, IAsyncDisposable
+{
+ ///
+ /// Gets the HTTP method.
+ ///
+ public HttpMethod Method { get; }
+
+ ///
+ /// Gets the timeout duration.
+ ///
+ public TimeSpan Timeout { get; }
+
+ ///
+ /// Gets the cancellation token.
+ ///
+ public CancellationToken CancellationToken { get; }
+
+ ///
+ /// Gets the proxy configuration.
+ ///
+ public TrackedProxyInfo? Proxy { get; }
+
+ ///
+ /// Gets the retry policy.
+ ///
+ public RetryPolicy RetryPolicy { get; }
+
+ ///
+ /// Gets whether certificate validation is enabled.
+ ///
+ public bool ValidateCertificates { get; }
+
+ ///
+ /// Gets whether redirects are followed.
+ ///
+ public bool FollowRedirects { get; }
+
+ ///
+ /// Gets the maximum redirects.
+ ///
+ public int MaxRedirects { get; }
+
+ ///
+ /// Gets whether the request is built.
+ ///
+ public bool IsBuilt { get; }
+
+ ///
+ /// Gets the request interceptors.
+ ///
+ public IReadOnlyList RequestInterceptors { get; }
+
+ ///
+ /// Gets the response interceptors.
+ ///
+ public IReadOnlyList ResponseInterceptors { get; }
+
+ ///
+ /// Gets the request URI.
+ ///
+ public abstract ReadOnlySpan Uri { get; }
+
+ ///
+ /// Gets the request body.
+ ///
+ public abstract ReadOnlySpan Body { get; }
+
+ ///
+ /// Builds the request.
+ ///
+ /// The built request.
+ public abstract BaseRequest Build()
+
+ ///
+ /// Sends the request asynchronously.
+ ///
+ /// Cancellation token.
+ /// The response.
+ public abstract Task SendAsync(CancellationToken cancellationToken = default)
+
+ ///
+ /// Disposes resources.
+ ///
+ public virtual void Dispose()
+
+ ///
+ /// Disposes resources asynchronously.
+ ///
+ public virtual ValueTask DisposeAsync()
+}
+```
+
+### Request
+
+```csharp
+///
+/// HTTP request class with full request building and execution capabilities.
+/// Split across partial classes: Request.cs (core), RequestConfiguration.cs (fluent API),
+/// RequestHttp.cs (HTTP execution), RequestContent.cs (content handling), RequestBuilder.cs (file uploads).
+///
+public partial class Request : BaseRequest
+{
+ ///
+ /// Gets the request URI.
+ ///
+ public override ReadOnlySpan Uri { get; }
+
+ ///
+ /// Gets the request body.
+ ///
+ public override ReadOnlySpan Body { get; }
+
+ ///
+ /// Gets the request URI as Uri object.
+ ///
+ public Uri? GetUri()
+
+ ///
+ /// Gets the scraping bypass configuration.
+ ///
+ public ScrapingBypassConfig? ScrapingBypass { get; }
+
+ ///
+ /// Gets the JSON path configuration.
+ ///
+ public JsonPathConfig? JsonPathConfig { get; }
+
+ ///
+ /// Gets the host check configuration.
+ ///
+ public HostCheckConfig? HostCheckConfig { get; }
+
+ ///
+ /// Gets the logging configuration.
+ ///
+ public LoggingConfig? LoggingConfig { get; }
+
+ ///
+ /// Gets whether header validation is enabled.
+ ///
+ public bool HeaderValidationEnabled { get; }
+
+ ///
+ /// Gets the header builder.
+ ///
+ public RequestHeaderBuilder? HeaderBuilder { get; }
+
+ ///
+ /// Gets the request interceptors.
+ ///
+ public new IReadOnlyList RequestInterceptors { get; }
+
+ ///
+ /// Gets the response interceptors.
+ ///
+ public new IReadOnlyList ResponseInterceptors { get; }
+
+ ///
+ /// Initializes a new instance.
+ ///
+ public Request()
+
+ ///
+ /// Initializes with URL.
+ ///
+ /// The URL.
+ public Request(ReadOnlyMemory url)
+
+ ///
+ /// Initializes with URL.
+ ///
+ /// The URL.
+ public Request(string url)
+
+ ///
+ /// Initializes with URI.
+ ///
+ /// The URI.
+ public Request(Uri uri)
+
+ ///
+ /// Initializes with URL and method.
+ ///
+ /// The URL.
+ /// The HTTP method.
+ public Request(string url, HttpMethod method)
+
+ ///
+ /// Initializes with URI and method.
+ ///
+ /// The URI.
+ /// The HTTP method.
+ public Request(Uri uri, HttpMethod method)
+
+ ///
+ /// Builds the request.
+ ///
+ /// The built request.
+ public override BaseRequest Build()
+
+ ///
+ /// Sends the request asynchronously.
+ ///
+ /// Cancellation token.
+ /// The response.
+ public override async Task SendAsync(CancellationToken cancellationToken = default)
+
+ ///
+ /// Disposes resources.
+ ///
+ public override void Dispose()
+
+ ///
+ /// Disposes resources asynchronously.
+ ///
+ public override ValueTask DisposeAsync()
+}
+```
+
+### BaseResponse
+
+```csharp
+///
+/// Abstract base class for HTTP responses providing core properties and content access.
+///
+public abstract class BaseResponse : IDisposable, IAsyncDisposable
+{
+ ///
+ /// Gets the HTTP status code.
+ ///
+ public HttpStatusCode StatusCode { get; }
+
+ ///
+ /// Gets whether the response indicates success.
+ ///
+ public bool IsSuccessStatusCode { get; }
+
+ ///
+ /// Gets the response headers.
+ ///
+ public HttpResponseHeaders Headers { get; }
+
+ ///
+ /// Gets the content headers.
+ ///
+ public HttpContentHeaders? ContentHeaders { get; }
+
+ ///
+ /// Gets the content type.
+ ///
+ public string? ContentType { get; }
+
+ ///
+ /// Gets the content length.
+ ///
+ public long? ContentLength { get; }
+
+ ///
+ /// Gets the HTTP version.
+ ///
+ public Version HttpVersion { get; }
+
+ ///
+ /// Gets the reason phrase.
+ ///
+ public string? ReasonPhrase { get; }
+
+ ///
+ /// Gets whether this is a redirect response.
+ ///
+ public bool IsRedirect { get; }
+
+ ///
+ /// Gets whether this is a client error (4xx).
+ ///
+ public bool IsClientError { get; }
+
+ ///
+ /// Gets whether this is a server error (5xx).
+ ///
+ public bool IsServerError { get; }
+
+ ///
+ /// Gets whether this response indicates rate limiting.
+ ///
+ public bool IsRateLimited { get; }
+
+ ///
+ /// Gets the response content as bytes.
+ ///
+ /// Cancellation token.
+ /// The content bytes.
+ public virtual async Task GetBytesAsync(CancellationToken cancellationToken = default)
+
+ ///
+ /// Gets the response content as string.
+ ///
+ /// The encoding to use.
+ /// Cancellation token.
+ /// The content string.
+ public virtual async Task GetStringAsync(Encoding? encoding = null, CancellationToken cancellationToken = default)
+
+ ///
+ /// Gets the response content stream.
+ ///
+ /// The content stream.
+ public virtual Stream GetStream()
+
+ ///
+ /// Gets cookies from the response.
+ ///
+ /// The cookie collection.
+ public virtual CookieCollection GetCookies()
+
+ ///
+ /// Gets a header value by name.
+ ///
+ /// The header name.
+ /// The header value.
+ public virtual string? GetHeader(string name)
+
+ ///
+ /// Throws if the response does not indicate success.
+ ///
+ public virtual void EnsureSuccessStatusCode()
+
+ ///
+ /// Disposes resources.
+ ///
+ public virtual void Dispose()
+
+ ///
+ /// Disposes resources asynchronously.
+ ///
+ public virtual async ValueTask DisposeAsync()
+}
+```
+
+### Response
+
+```csharp
+///
+/// HTTP response class with parsing and streaming capabilities.
+///
+public sealed class Response : BaseResponse
+{
+ ///
+ /// Gets the request metrics.
+ ///
+ public RequestMetrics Metrics { get; }
+
+ ///
+ /// Gets whether this response was served from cache.
+ ///
+ public bool FromCache { get; }
+
+ ///
+ /// Gets the original request URI.
+ ///
+ public Uri? RequestUri { get; }
+
+ ///
+ /// Gets the response as specified type.
+ ///
+ /// The target type.
+ /// Cancellation token.
+ /// The parsed response.
+ public async Task GetAsync(CancellationToken cancellationToken = default)
+
+ ///
+ /// Parses JSON response.
+ ///
+ /// The target type.
+ /// Whether to use System.Text.Json.
+ /// Cancellation token.
+ /// The parsed object.
+ public async Task ParseJsonAsync(bool useSystemTextJson = true, CancellationToken cancellationToken = default)
+
+ ///
+ /// Parses JSON document.
+ ///
+ /// Cancellation token.
+ /// The JsonDocument.
+ public async Task ParseJsonDocumentAsync(CancellationToken cancellationToken = default)
+
+ ///
+ /// Parses XML response.
+ ///
+ /// Cancellation token.
+ /// The XDocument.
+ public async Task ParseXmlAsync(CancellationToken cancellationToken = default)
+
+ ///
+ /// Parses HTML response.
+ ///
+ /// Cancellation token.
+ /// The IDocument.
+ public async Task ParseHtmlAsync(CancellationToken cancellationToken = default)
+
+ ///
+ /// Parses JSON path.
+ ///
+ /// The target type.
+ /// The JSON path.
+ /// Cancellation token.
+ /// The parsed value.
+ public async Task ParseJsonPathAsync(string path, CancellationToken cancellationToken = default)
+
+ ///
+ /// Parses JSON path list.
+ ///
+ /// The target type.
+ /// The JSON path.
+ /// Cancellation token.
+ /// The parsed list.
+ public async Task> ParseJsonPathListAsync(string path, CancellationToken cancellationToken = default)
+
+ ///
+ /// Parses multiple JSON paths.
+ ///
+ /// The configuration.
+ /// Cancellation token.
+ /// The multi-selector result.
+ public async Task ParseMultipleJsonPathsAsync(MultiSelectorConfig config, CancellationToken cancellationToken = default)
+
+ ///
+ /// Parses multiple JSON paths.
+ ///
+ /// Cancellation token.
+ /// The selectors.
+ /// The multi-selector result.
+ public async Task ParseMultipleJsonPathsAsync(CancellationToken cancellationToken = default, params (string name, string path)[] selectors)
+
+ ///
+ /// Parses multiple JSON paths optimized.
+ ///
+ /// Cancellation token.
+ /// The selectors.
+ /// The multi-selector result.
+ public async Task ParseMultipleJsonPathsOptimizedAsync(CancellationToken cancellationToken = default, params (string name, string path)[] selectors)
+
+ ///
+ /// Streams response lines.
+ ///
+ /// Cancellation token.
+ /// Async enumerable of lines.
+ public async IAsyncEnumerable StreamLinesAsync([EnumeratorCancellation] CancellationToken cancellationToken = default)
+
+ ///
+ /// Streams response chunks.
+ ///
+ /// Chunk size.
+ /// Cancellation token.
+ /// Async enumerable of chunks.
+ public async IAsyncEnumerable StreamChunksAsync(int chunkSize = 4096, [EnumeratorCancellation] CancellationToken cancellationToken = default)
+
+ ///
+ /// Gets header values.
+ ///
+ /// Header name.
+ /// The header values.
+ public IEnumerable GetHeaderValues(string name)
+
+ ///
+ /// Parses bearer token.
+ ///
+ /// The authentication token.
+ public AuthenticationToken? ParseBearerToken()
+
+ ///
+ /// Parses and verifies bearer token.
+ ///
+ /// The secret.
+ /// The authentication token.
+ public AuthenticationToken? ParseAndVerifyBearerToken(string secret)
+
+ ///
+ /// Validates content length.
+ ///
+ /// The validation result.
+ public ValidationResult ValidateContentLength()
+}
+```
+
+## Data
+
+The Data namespace contains various data structures for HTTP requests and responses:
+
+- **Body**: Classes for different body types (JsonBody, FormBody, MultipartBody, etc.)
+- **Header**: Classes for HTTP headers (RequestHeaderBuilder, ResponseHeaders, etc.)
+- **Query**: Classes for query string handling
+- **Cookie**: Classes for cookie handling
+- **Mime**: Classes for MIME type handling
+
+## Exceptions
+
+The Exceptions namespace contains custom exceptions:
+
+- **HttpHeaderException**: Thrown for HTTP header errors
+- **RequestException**: Base class for request errors
+- **ResponseException**: Base class for response errors
+- **ProxyException**: Thrown for proxy-related errors
+- **ValidationException**: Thrown for validation errors
+
+## Interfaces
+
+The Interfaces namespace defines contracts for:
+
+- **IRequestInterceptor**: Interface for request interceptors
+- **IResponseInterceptor**: Interface for response interceptors
+- **IHttpClient**: Interface for HTTP clients
+- **IProxyProvider**: Interface for proxy providers
+
+## Parsing
+
+The Parsing namespace provides parsers for:
+
+- **JsonPathParser**: JSON path extraction
+- **StreamingJsonPathParser**: Fast streaming JSON path parser
+- **MultiSelectorParser**: Multiple JSON path selector
+- **HtmlParser**: HTML parsing utilities
+- **XmlParser**: XML parsing utilities
+
+## Proxy
+
+The Proxy namespace contains:
+
+- **TrackedProxyInfo**: Information about a proxy with tracking
+- **ProxyValidator**: Proxy validation utilities
+- **ProxyPool**: Pool of proxies
+- **ProxyRotator**: Proxy rotation logic
+
+## Security
+
+The Security namespace provides:
+
+- **Token**: JWT token handling
+- **AuthenticationToken**: Authentication token structure
+- **JwtValidator**: JWT validation utilities
+- **CertificateValidator**: Certificate validation
+
+## Utils
+
+The Utils namespace contains utility classes:
+
+- **BogusUtils**: Fake data generation
+- **JsonUtils**: JSON manipulation helpers
+- **ContentDispositionUtils**: Content-Disposition parsing
+- **UriUtils**: URI manipulation utilities
+- **StringBuilderPool**: Pool for StringBuilder instances
+
+## Validation
+
+The Validation namespace provides:
+
+- **HeaderValidator**: HTTP header validation
+- **RequestValidator**: Request validation
+- **ResponseValidator**: Response validation
+- **ValidationResult**: Result of validation
diff --git a/DevBase.Api/Apis/ApiClient.cs b/DevBase.Api/Apis/ApiClient.cs
index e56ff61..97c3938 100644
--- a/DevBase.Api/Apis/ApiClient.cs
+++ b/DevBase.Api/Apis/ApiClient.cs
@@ -2,10 +2,25 @@
namespace DevBase.Api.Apis;
+///
+/// Base class for API clients, providing common error handling and type conversion utilities.
+///
public class ApiClient
{
+ ///
+ /// Gets or sets a value indicating whether to throw exceptions on errors or return default values.
+ ///
public bool StrictErrorHandling { get; set; }
+ ///
+ /// Throws an exception if strict error handling is enabled, otherwise returns a default value for type T.
+ ///
+ /// The return type.
+ /// The exception to throw.
+ /// The calling member name.
+ /// The calling file path.
+ /// The calling line number.
+ /// The default value of T if exception is not thrown.
protected dynamic Throw(
System.Exception exception,
[CallerMemberName] string callerMember = "",
@@ -18,6 +33,14 @@ protected dynamic Throw(
return ToType();
}
+ ///
+ /// Throws an exception if strict error handling is enabled, otherwise returns a default tuple (empty string, false).
+ ///
+ /// The exception to throw.
+ /// The calling member name.
+ /// The calling file path.
+ /// The calling line number.
+ /// A tuple (string.Empty, false) if exception is not thrown.
protected (string, bool) ThrowTuple(
System.Exception exception,
[CallerMemberName] string callerMember = "",
diff --git a/DevBase.Api/Exceptions/AppleMusicException.cs b/DevBase.Api/Exceptions/AppleMusicException.cs
index faa4216..5869c39 100644
--- a/DevBase.Api/Exceptions/AppleMusicException.cs
+++ b/DevBase.Api/Exceptions/AppleMusicException.cs
@@ -3,8 +3,15 @@
namespace DevBase.Api.Exceptions;
+///
+/// Exception thrown for Apple Music API related errors.
+///
public class AppleMusicException : System.Exception
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The type of error.
public AppleMusicException(EnumAppleMusicExceptionType type) : base(GetMessage(type)) { }
private static string GetMessage(EnumAppleMusicExceptionType type)
diff --git a/DevBase.Api/Exceptions/BeautifulLyricsException.cs b/DevBase.Api/Exceptions/BeautifulLyricsException.cs
index f9b57d0..8a31090 100644
--- a/DevBase.Api/Exceptions/BeautifulLyricsException.cs
+++ b/DevBase.Api/Exceptions/BeautifulLyricsException.cs
@@ -3,8 +3,15 @@
namespace DevBase.Api.Exceptions;
+///
+/// Exception thrown for Beautiful Lyrics API related errors.
+///
public class BeautifulLyricsException : System.Exception
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The type of error.
public BeautifulLyricsException(EnumBeautifulLyricsExceptionType type) : base(GetMessage(type)) { }
private static string GetMessage(EnumBeautifulLyricsExceptionType type)
diff --git a/DevBase.Api/Exceptions/DeezerException.cs b/DevBase.Api/Exceptions/DeezerException.cs
index d51c180..e4cb653 100644
--- a/DevBase.Api/Exceptions/DeezerException.cs
+++ b/DevBase.Api/Exceptions/DeezerException.cs
@@ -3,8 +3,15 @@
namespace DevBase.Api.Exceptions;
+///
+/// Exception thrown for Deezer API related errors.
+///
public class DeezerException : System.Exception
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The type of error.
public DeezerException(EnumDeezerExceptionType type) : base(GetMessage(type)) { }
private static string GetMessage(EnumDeezerExceptionType type)
diff --git a/DevBase.Api/Exceptions/NetEaseException.cs b/DevBase.Api/Exceptions/NetEaseException.cs
index eb0abaa..b702071 100644
--- a/DevBase.Api/Exceptions/NetEaseException.cs
+++ b/DevBase.Api/Exceptions/NetEaseException.cs
@@ -3,8 +3,15 @@
namespace DevBase.Api.Exceptions;
+///
+/// Exception thrown for NetEase API related errors.
+///
public class NetEaseException : System.Exception
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The type of error.
public NetEaseException(EnumNetEaseExceptionType type) : base(GetMessage(type)) { }
private static string GetMessage(EnumNetEaseExceptionType type)
diff --git a/DevBase.Api/Exceptions/OpenLyricsClientException.cs b/DevBase.Api/Exceptions/OpenLyricsClientException.cs
index 90aef72..66379c0 100644
--- a/DevBase.Api/Exceptions/OpenLyricsClientException.cs
+++ b/DevBase.Api/Exceptions/OpenLyricsClientException.cs
@@ -3,8 +3,15 @@
namespace DevBase.Api.Exceptions;
+///
+/// Exception thrown for OpenLyricsClient API related errors.
+///
public class OpenLyricsClientException : System.Exception
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The type of error.
public OpenLyricsClientException(EnumOpenLyricsClientExceptionType type) : base(GetMessage(type)) { }
private static string GetMessage(EnumOpenLyricsClientExceptionType type)
diff --git a/DevBase.Api/Exceptions/ReplicateException.cs b/DevBase.Api/Exceptions/ReplicateException.cs
index 902be53..bf0a2c2 100644
--- a/DevBase.Api/Exceptions/ReplicateException.cs
+++ b/DevBase.Api/Exceptions/ReplicateException.cs
@@ -3,8 +3,15 @@
namespace DevBase.Api.Exceptions;
+///
+/// Exception thrown for Replicate API related errors.
+///
public class ReplicateException : System.Exception
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The type of error.
public ReplicateException(EnumReplicateExceptionType type) : base(GetMessage(type)) { }
private static string GetMessage(EnumReplicateExceptionType type)
diff --git a/DevBase.Api/Exceptions/TidalException.cs b/DevBase.Api/Exceptions/TidalException.cs
index bf2987a..59b5021 100644
--- a/DevBase.Api/Exceptions/TidalException.cs
+++ b/DevBase.Api/Exceptions/TidalException.cs
@@ -3,8 +3,15 @@
namespace DevBase.Api.Exceptions;
+///
+/// Exception thrown for Tidal API related errors.
+///
public class TidalException : System.Exception
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The type of error.
public TidalException(EnumTidalExceptionType type) : base(GetMessage(type)) { }
private static string GetMessage(EnumTidalExceptionType type)
diff --git a/DevBase.Api/Serializer/JsonDeserializer.cs b/DevBase.Api/Serializer/JsonDeserializer.cs
index 0be0508..7b8ca19 100644
--- a/DevBase.Api/Serializer/JsonDeserializer.cs
+++ b/DevBase.Api/Serializer/JsonDeserializer.cs
@@ -3,11 +3,18 @@
namespace DevBase.Api.Serializer;
+///
+/// A generic JSON deserializer helper that captures serialization errors.
+///
+/// The type to deserialize into.
public class JsonDeserializer
{
private JsonSerializerSettings _serializerSettings;
private AList _errorList;
+ ///
+ /// Initializes a new instance of the class.
+ ///
public JsonDeserializer()
{
this._errorList = new AList();
@@ -23,16 +30,29 @@ public JsonDeserializer()
};
}
+ ///
+ /// Deserializes the JSON string into an object of type T.
+ ///
+ /// The JSON string.
+ /// The deserialized object.
public T Deserialize(string input)
{
return JsonConvert.DeserializeObject(input, this._serializerSettings);
}
+ ///
+ /// Deserializes the JSON string into an object of type T asynchronously.
+ ///
+ /// The JSON string.
+ /// A task that represents the asynchronous operation. The task result contains the deserialized object.
public Task DeserializeAsync(string input)
{
return Task.FromResult(JsonConvert.DeserializeObject(input, this._serializerSettings));
}
+ ///
+ /// Gets or sets the list of errors encountered during deserialization.
+ ///
public AList ErrorList
{
get => _errorList;
diff --git a/DevBase.Avalonia.Extension/Color/Image/ClusterColorCalculator.cs b/DevBase.Avalonia.Extension/Color/Image/ClusterColorCalculator.cs
index fa046e7..4fdc087 100644
--- a/DevBase.Avalonia.Extension/Color/Image/ClusterColorCalculator.cs
+++ b/DevBase.Avalonia.Extension/Color/Image/ClusterColorCalculator.cs
@@ -9,23 +9,72 @@ namespace DevBase.Avalonia.Extension.Color.Image;
using Color = global::Avalonia.Media.Color;
+///
+/// Calculates dominant colors from an image using KMeans clustering on RGB values.
+///
[Obsolete("Use LabClusterColorCalculator instead")]
public class ClusterColorCalculator
{
+ ///
+ /// Gets or sets the minimum saturation threshold for filtering colors.
+ ///
public double MinSaturation { get; set; } = 50d;
+
+ ///
+ /// Gets or sets the minimum brightness threshold for filtering colors.
+ ///
public double MinBrightness { get; set; } = 70d;
+
+ ///
+ /// Gets or sets the small shift value.
+ ///
public double SmallShift { get; set; } = 1.0d;
+
+ ///
+ /// Gets or sets the big shift value.
+ ///
public double BigShift { get; set; } = 1.0d;
+
+ ///
+ /// Gets or sets the tolerance for KMeans clustering.
+ ///
public double Tolerance { get; set; } = 0.5d;
+
+ ///
+ /// Gets or sets the number of clusters to find.
+ ///
public int Clusters { get; set; } = 20;
+
+ ///
+ /// Gets or sets the maximum range of clusters to consider for the result.
+ ///
public int MaxRange { get; set; } = 5;
+ ///
+ /// Gets or sets a value indicating whether to use a predefined dataset.
+ ///
public bool PredefinedDataset { get; set; } = true;
+
+ ///
+ /// Gets or sets a value indicating whether to filter by saturation.
+ ///
public bool FilterSaturation { get; set; } = true;
+
+ ///
+ /// Gets or sets a value indicating whether to filter by brightness.
+ ///
public bool FilterBrightness { get; set; } = true;
+ ///
+ /// Gets or sets additional colors to include in the clustering dataset.
+ ///
public AList AdditionalColorDataset { get; set; } = new AList();
+ ///
+ /// Calculates the dominant color from the provided bitmap.
+ ///
+ /// The source bitmap.
+ /// The calculated dominant color.
public Color GetColorFromBitmap(Bitmap bitmap)
{
AList pixels = ColorUtils.GetPixels(bitmap);
diff --git a/DevBase.Avalonia.Extension/Color/Image/LabClusterColorCalculator.cs b/DevBase.Avalonia.Extension/Color/Image/LabClusterColorCalculator.cs
index 01a7463..b13d4c7 100644
--- a/DevBase.Avalonia.Extension/Color/Image/LabClusterColorCalculator.cs
+++ b/DevBase.Avalonia.Extension/Color/Image/LabClusterColorCalculator.cs
@@ -15,22 +15,50 @@ namespace DevBase.Avalonia.Extension.Color.Image;
using Color = global::Avalonia.Media.Color;
+///
+/// Calculates dominant colors from an image using KMeans clustering on Lab values.
+/// This is the preferred calculator for better color accuracy closer to human perception.
+///
public class LabClusterColorCalculator
{
+ ///
+ /// Gets or sets the small shift value for post-processing.
+ ///
public double SmallShift { get; set; } = 1.0d;
+ ///
+ /// Gets or sets the big shift value for post-processing.
+ ///
public double BigShift { get; set; } = 1.0d;
+ ///
+ /// Gets or sets the tolerance for KMeans clustering.
+ ///
public double Tolerance { get; set; } = 1E-05d;
+ ///
+ /// Gets or sets the number of clusters to find.
+ ///
public int Clusters { get; set; } = 10;
+ ///
+ /// Gets or sets the maximum range of clusters to consider for the result.
+ ///
public int MaxRange { get; set; } = 5;
+ ///
+ /// Gets or sets a value indicating whether to use a predefined dataset of colors.
+ ///
public bool UsePredefinedSet { get; set; } = true;
+ ///
+ /// Gets or sets a value indicating whether to return a fallback result if filtering removes all colors.
+ ///
public bool AllowEdgeCase { get; set; } = false;
+ ///
+ /// Gets or sets the pre-processing configuration (e.g. blur).
+ ///
public PreProcessingConfiguration PreProcessing { get; set; } =
new PreProcessingConfiguration()
{
@@ -39,6 +67,9 @@ public class LabClusterColorCalculator
BlurPreProcessing = false
};
+ ///
+ /// Gets or sets the filtering configuration (chroma, brightness).
+ ///
public FilterConfiguration Filter { get; set; } =
new FilterConfiguration()
{
@@ -56,6 +87,9 @@ public class LabClusterColorCalculator
}
};
+ ///
+ /// Gets or sets the post-processing configuration (pastel, shifting).
+ ///
public PostProcessingConfiguration PostProcessing { get; set; } =
new PostProcessingConfiguration()
{
@@ -72,19 +106,35 @@ public class LabClusterColorCalculator
private RGBToLabConverter _converter;
+ ///
+ /// Gets or sets additional Lab colors to include in the clustering dataset.
+ ///
public AList AdditionalColorDataset { get; set; } = new AList();
+ ///
+ /// Initializes a new instance of the class.
+ ///
public LabClusterColorCalculator()
{
this._converter = new RGBToLabConverter();
}
+ ///
+ /// Calculates the dominant color from the provided bitmap.
+ ///
+ /// The source bitmap.
+ /// The calculated dominant color.
public Color GetColorFromBitmap(Bitmap bitmap)
{
(KMeansClusterCollection, IOrderedEnumerable>) clusters = ClusterCalculation(bitmap);
return GetRangeAndCalcAverage(clusters.Item1, clusters.Item2, this.MaxRange);
}
+ ///
+ /// Calculates a list of dominant colors from the provided bitmap.
+ ///
+ /// The source bitmap.
+ /// A list of calculated colors.
public AList GetColorListFromBitmap(Bitmap bitmap)
{
(KMeansClusterCollection, IOrderedEnumerable>) clusters = ClusterCalculation(bitmap);
diff --git a/DevBase.Avalonia.Extension/Configuration/BrightnessConfiguration.cs b/DevBase.Avalonia.Extension/Configuration/BrightnessConfiguration.cs
index 10c0bde..7bc9f41 100644
--- a/DevBase.Avalonia.Extension/Configuration/BrightnessConfiguration.cs
+++ b/DevBase.Avalonia.Extension/Configuration/BrightnessConfiguration.cs
@@ -1,8 +1,22 @@
namespace DevBase.Avalonia.Extension.Configuration;
+///
+/// Configuration for brightness filtering.
+///
public class BrightnessConfiguration
{
+ ///
+ /// Gets or sets a value indicating whether brightness filtering is enabled.
+ ///
public bool FilterBrightness { get; set; }
+
+ ///
+ /// Gets or sets the minimum brightness threshold (0-100).
+ ///
public double MinBrightness { get; set; }
+
+ ///
+ /// Gets or sets the maximum brightness threshold (0-100).
+ ///
public double MaxBrightness { get; set; }
}
\ No newline at end of file
diff --git a/DevBase.Avalonia.Extension/Configuration/ChromaConfiguration.cs b/DevBase.Avalonia.Extension/Configuration/ChromaConfiguration.cs
index be239e6..d2ddc4e 100644
--- a/DevBase.Avalonia.Extension/Configuration/ChromaConfiguration.cs
+++ b/DevBase.Avalonia.Extension/Configuration/ChromaConfiguration.cs
@@ -1,8 +1,22 @@
namespace DevBase.Avalonia.Extension.Configuration;
+///
+/// Configuration for chroma (color intensity) filtering.
+///
public class ChromaConfiguration
{
+ ///
+ /// Gets or sets a value indicating whether chroma filtering is enabled.
+ ///
public bool FilterChroma { get; set; }
+
+ ///
+ /// Gets or sets the minimum chroma threshold.
+ ///
public double MinChroma { get; set; }
+
+ ///
+ /// Gets or sets the maximum chroma threshold.
+ ///
public double MaxChroma { get; set; }
}
\ No newline at end of file
diff --git a/DevBase.Avalonia.Extension/Configuration/FilterConfiguration.cs b/DevBase.Avalonia.Extension/Configuration/FilterConfiguration.cs
index c136333..770181b 100644
--- a/DevBase.Avalonia.Extension/Configuration/FilterConfiguration.cs
+++ b/DevBase.Avalonia.Extension/Configuration/FilterConfiguration.cs
@@ -1,8 +1,18 @@
namespace DevBase.Avalonia.Extension.Configuration;
+///
+/// Configuration for color filtering settings.
+///
public class FilterConfiguration
{
+ ///
+ /// Gets or sets the chroma configuration.
+ ///
public ChromaConfiguration ChromaConfiguration { get; set; }
+
+ ///
+ /// Gets or sets the brightness configuration.
+ ///
public BrightnessConfiguration BrightnessConfiguration { get; set; }
}
\ No newline at end of file
diff --git a/DevBase.Avalonia.Extension/Configuration/PostProcessingConfiguration.cs b/DevBase.Avalonia.Extension/Configuration/PostProcessingConfiguration.cs
index d384452..206bfc9 100644
--- a/DevBase.Avalonia.Extension/Configuration/PostProcessingConfiguration.cs
+++ b/DevBase.Avalonia.Extension/Configuration/PostProcessingConfiguration.cs
@@ -1,14 +1,47 @@
namespace DevBase.Avalonia.Extension.Configuration;
+///
+/// Configuration for post-processing of calculated colors.
+///
public class PostProcessingConfiguration
{
+ ///
+ /// Gets or sets the small shift value for color shifting.
+ ///
public double SmallShift { get; set; }
+
+ ///
+ /// Gets or sets the big shift value for color shifting.
+ ///
public double BigShift { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether color shifting post-processing is enabled.
+ ///
public bool ColorShiftingPostProcessing { get; set; }
+
+ ///
+ /// Gets or sets the target lightness for pastel processing.
+ ///
public double PastelLightness { get; set; }
+
+ ///
+ /// Gets or sets the lightness subtractor value for pastel processing when lightness is above guidance.
+ ///
public double PastelLightnessSubtractor { get; set; }
+
+ ///
+ /// Gets or sets the saturation multiplier for pastel processing.
+ ///
public double PastelSaturation { get; set; }
+
+ ///
+ /// Gets or sets the lightness threshold to decide how to adjust pastel lightness.
+ ///
public double PastelGuidance { get; set; }
+ ///
+ /// Gets or sets a value indicating whether pastel post-processing is enabled.
+ ///
public bool PastelPostProcessing { get; set; }
}
\ No newline at end of file
diff --git a/DevBase.Avalonia.Extension/Configuration/PreProcessingConfiguration.cs b/DevBase.Avalonia.Extension/Configuration/PreProcessingConfiguration.cs
index 8ea7eec..821a3c1 100644
--- a/DevBase.Avalonia.Extension/Configuration/PreProcessingConfiguration.cs
+++ b/DevBase.Avalonia.Extension/Configuration/PreProcessingConfiguration.cs
@@ -1,9 +1,22 @@
namespace DevBase.Avalonia.Extension.Configuration;
+///
+/// Configuration for image pre-processing.
+///
public class PreProcessingConfiguration
{
+ ///
+ /// Gets or sets the sigma value for blur.
+ ///
public float BlurSigma { get; set; }
+
+ ///
+ /// Gets or sets the number of blur rounds.
+ ///
public int BlurRounds { get; set; }
+ ///
+ /// Gets or sets a value indicating whether blur pre-processing is enabled.
+ ///
public bool BlurPreProcessing { get; set; }
}
\ No newline at end of file
diff --git a/DevBase.Avalonia.Extension/Converter/RGBToLabConverter.cs b/DevBase.Avalonia.Extension/Converter/RGBToLabConverter.cs
index 9d7bf34..e67ca79 100644
--- a/DevBase.Avalonia.Extension/Converter/RGBToLabConverter.cs
+++ b/DevBase.Avalonia.Extension/Converter/RGBToLabConverter.cs
@@ -2,12 +2,19 @@
namespace DevBase.Avalonia.Extension.Converter;
+///
+/// Converter for transforming between RGB and LAB color spaces.
+///
public class RGBToLabConverter
{
private IColorConverter _converter;
private IColorConverter _unconverter;
+ ///
+ /// Initializes a new instance of the class.
+ /// Configures converters using sRGB working space and D65 illuminant.
+ ///
public RGBToLabConverter()
{
this._converter = new ConverterBuilder()
@@ -21,11 +28,21 @@ public RGBToLabConverter()
.Build();
}
+ ///
+ /// Converts an RGB color to Lab color.
+ ///
+ /// The RGB color.
+ /// The Lab color.
public LabColor ToLabColor(RGBColor color)
{
return this._converter.Convert(color);
}
+ ///
+ /// Converts a Lab color to RGB color.
+ ///
+ /// The Lab color.
+ /// The RGB color.
public RGBColor ToRgbColor(LabColor color)
{
return this._unconverter.Convert(color);
diff --git a/DevBase.Avalonia.Extension/Extension/BitmapExtension.cs b/DevBase.Avalonia.Extension/Extension/BitmapExtension.cs
index c5ab283..3ef434c 100644
--- a/DevBase.Avalonia.Extension/Extension/BitmapExtension.cs
+++ b/DevBase.Avalonia.Extension/Extension/BitmapExtension.cs
@@ -4,8 +4,16 @@
namespace DevBase.Avalonia.Extension.Extension;
+///
+/// Provides extension methods for converting between different Bitmap types.
+///
public static class BitmapExtension
{
+ ///
+ /// Converts an Avalonia Bitmap to a System.Drawing.Bitmap.
+ ///
+ /// The Avalonia bitmap.
+ /// The System.Drawing.Bitmap.
public static Bitmap ToBitmap(this global::Avalonia.Media.Imaging.Bitmap bitmap)
{
using MemoryStream stream = new MemoryStream();
@@ -14,6 +22,11 @@ public static Bitmap ToBitmap(this global::Avalonia.Media.Imaging.Bitmap bitmap)
return new Bitmap(stream);
}
+ ///
+ /// Converts a System.Drawing.Bitmap to an Avalonia Bitmap.
+ ///
+ /// The System.Drawing.Bitmap.
+ /// The Avalonia Bitmap.
public static global::Avalonia.Media.Imaging.Bitmap ToBitmap(this Bitmap bitmap)
{
using MemoryStream memoryStream = new MemoryStream();
@@ -22,6 +35,11 @@ public static Bitmap ToBitmap(this global::Avalonia.Media.Imaging.Bitmap bitmap)
return new global::Avalonia.Media.Imaging.Bitmap(memoryStream);
}
+ ///
+ /// Converts a SixLabors ImageSharp Image to an Avalonia Bitmap.
+ ///
+ /// The ImageSharp Image.
+ /// The Avalonia Bitmap.
public static global::Avalonia.Media.Imaging.Bitmap ToBitmap(this SixLabors.ImageSharp.Image image)
{
using MemoryStream memoryStream = new MemoryStream();
@@ -30,6 +48,11 @@ public static Bitmap ToBitmap(this global::Avalonia.Media.Imaging.Bitmap bitmap)
return new global::Avalonia.Media.Imaging.Bitmap(memoryStream);
}
+ ///
+ /// Converts an Avalonia Bitmap to a SixLabors ImageSharp Image.
+ ///
+ /// The Avalonia Bitmap.
+ /// The ImageSharp Image.
public static SixLabors.ImageSharp.Image ToImage(this global::Avalonia.Media.Imaging.Bitmap bitmap)
{
using MemoryStream memoryStream = new MemoryStream();
diff --git a/DevBase.Avalonia.Extension/Extension/ColorNormalizerExtension.cs b/DevBase.Avalonia.Extension/Extension/ColorNormalizerExtension.cs
index e28b957..3e27d34 100644
--- a/DevBase.Avalonia.Extension/Extension/ColorNormalizerExtension.cs
+++ b/DevBase.Avalonia.Extension/Extension/ColorNormalizerExtension.cs
@@ -2,8 +2,16 @@
namespace DevBase.Avalonia.Extension.Extension;
+///
+/// Provides extension methods for color normalization.
+///
public static class ColorNormalizerExtension
{
+ ///
+ /// Denormalizes an RGBColor (0-1 range) to an Avalonia Color (0-255 range).
+ ///
+ /// The normalized RGBColor.
+ /// The denormalized Avalonia Color.
public static global::Avalonia.Media.Color DeNormalize(this RGBColor normalized)
{
double r = Math.Clamp(normalized.R * 255.0, 0.0, 255.0);
diff --git a/DevBase.Avalonia.Extension/Extension/LabColorExtension.cs b/DevBase.Avalonia.Extension/Extension/LabColorExtension.cs
index 89aea92..a1f146e 100644
--- a/DevBase.Avalonia.Extension/Extension/LabColorExtension.cs
+++ b/DevBase.Avalonia.Extension/Extension/LabColorExtension.cs
@@ -6,10 +6,20 @@
namespace DevBase.Avalonia.Extension.Extension;
+///
+/// Provides extension methods for LabColor operations.
+///
public static class LabColorExtension
{
#region Brightness
+ ///
+ /// Filters a list of LabColors based on lightness (L) values.
+ ///
+ /// The list of LabColors.
+ /// Minimum lightness.
+ /// Maximum lightness.
+ /// A filtered list of LabColors.
public static AList FilterBrightness(this AList colors, double min, double max)
{
AList c = new AList();
@@ -44,6 +54,11 @@ public static AList FilterBrightness(this AList colors, doub
#region Chroma
+ ///
+ /// Calculates the chroma of a LabColor.
+ ///
+ /// The LabColor.
+ /// The chroma value.
public static double Chroma(this LabColor color)
{
double a = color.a;
@@ -51,11 +66,23 @@ public static double Chroma(this LabColor color)
return Math.Sqrt(a * a + b * b);
}
+ ///
+ /// Calculates the chroma percentage relative to a max chroma of 128.
+ ///
+ /// The LabColor.
+ /// The chroma percentage.
public static double ChromaPercentage(this LabColor color)
{
return (color.Chroma() / 128) * 100;
}
+ ///
+ /// Filters a list of LabColors based on chroma percentage.
+ ///
+ /// The list of LabColors.
+ /// Minimum chroma percentage.
+ /// Maximum chroma percentage.
+ /// A filtered list of LabColors.
public static AList FilterChroma(this AList colors, double min, double max)
{
AList c = new AList();
@@ -90,14 +117,31 @@ public static AList FilterChroma(this AList