CLASS ValidateLinksCommand
- Namespace: SuCoS.Commands
- Source File: ValidateLinksCommand.cs
Validates internal and external links in generated HTML content.
Fields
PagesWithFailedLinks (ConcurrentDictionary<IPage, List<(string Link, LinkStatus Status)>>) = []: Dictionary to store pages with their failed links
Properties
DefaultRetryCount
(int) = 3: Number of times to retry failed external link validations
DefaultRetryInterval
(int) = 1000: Interval in milliseconds between retry attempts
DefaultTimeout
(int) = 10000: Timeout in milliseconds for external link validation requests
Public Methods
Parse
public async Task<ValidateLinksCommand> Parse()
Parses content and validates all links
Returns: Task<ValidateLinksCommand>
- The current command instance
GenerateReport
public Task<int> GenerateReport()
Generates validation report and returns exit code
Returns: Task<int>
- Exit code indicating success (0) or failure (1)
ValidateInternalLink
public static Task<LinkStatus> ValidateInternalLink(Uri linkStripped, Uri link, IDictionary<Uri, IOutput> outputReferences)
Validates if an internal link exists in output references
Parameters:
linkStripped(Uri): Link to validatelink(Uri)outputReferences(IDictionary<Uri, IOutput>): Dictionary of output references
Returns: Task<LinkStatus>
- True if link is valid, false otherwise
ValidateExternalLink
public async Task<LinkStatus> ValidateExternalLink(Uri link, Uri sourceFile, IHttpClientWrapper httpClient)
Validates if an external link is accessible
Parameters:
link(Uri): Link to validatesourceFile(Uri): Source file containing the linkhttpClient(IHttpClientWrapper): HTTP client for making requests
Returns: Task<LinkStatus>
- True if link is valid, false otherwise