diff --git a/.docfx/.dockerignore b/.docfx/.dockerignore index c063843c1..2d737874b 100644 --- a/.docfx/.dockerignore +++ b/.docfx/.dockerignore @@ -3,3 +3,4 @@ wwwroot/ obj/ bin/ *.ps1 +!run-actions/**/*.ps1 diff --git a/.docfx/BuildDocfxImage.ps1 b/.docfx/BuildDocfxImage.ps1 index 3d88c39da..62b5bf228 100644 --- a/.docfx/BuildDocfxImage.ps1 +++ b/.docfx/BuildDocfxImage.ps1 @@ -1,3 +1,10 @@ +#requires -Version 7.0 +<# +.SYNOPSIS +Generates run-action scripts and DocFX metadata, validates generated assets, +builds the multi-platform DocFX container image, and verifies the published site +inside the built image. +#> [CmdletBinding()] param( # Regenerate metadata even when the inputs and generated files are unchanged. @@ -52,8 +59,11 @@ function Get-MetadataFiles { $totalTimer = [Diagnostics.Stopwatch]::StartNew() Push-Location $PSScriptRoot try { + & (Join-Path $PSScriptRoot 'BuildRunActions.ps1') + & (Join-Path $PSScriptRoot 'TestRunActions.ps1') $docfxRoot = $PSScriptRoot $repoRoot = Split-Path -Parent $docfxRoot + $skipSignAssembly = !(Test-Path -LiteralPath (Join-Path $repoRoot 'cuemon.snk') -PathType Leaf) $sourceRoot = Join-Path $repoRoot 'src' $docfxConfig = Get-Content -LiteralPath (Join-Path $docfxRoot 'docfx.json') -Raw | ConvertFrom-Json $version = minver -i -t v -v w @@ -103,7 +113,7 @@ try { } ) $inputValues = @( - $version; $docfxVersion; $sdkVersion; $revision; $branch + $version; $docfxVersion; $sdkVersion; $revision; $branch; "SkipSignAssembly=$skipSignAssembly" $docfxConfig.metadata | ConvertTo-Json -Depth 100 -Compress foreach ($name in @('CI', 'EMAIL', 'Configuration', 'MSBuildSDKsPath', 'DOTNET_ROOT', 'NUGET_PACKAGES', 'GITHUB_RUN_NUMBER')) { "$name=$([Environment]::GetEnvironmentVariable($name))" @@ -130,12 +140,18 @@ try { $metadataTimer = [Diagnostics.Stopwatch]::StartNew() # One restore graph replaces DocFX's separate restore for each project. $restoreSolution = Join-Path ([IO.Path]::GetTempPath()) ("cuemon-docfx-{0}.slnx" -f [Guid]::NewGuid()) + $restoreProperties = @() + $metadataProperties = @() + if ($skipSignAssembly) { + $restoreProperties = @('-p:SkipSignAssembly=true') + $metadataProperties = @('--property', 'SkipSignAssembly=true') + } try { $projectsXml = foreach ($project in $sourceProjects) { ' ' -f [Security.SecurityElement]::Escape($project) } @('') + $projectsXml + @('') | Set-Content -LiteralPath $restoreSolution -Encoding utf8 - dotnet restore $restoreSolution --verbosity quiet + dotnet restore $restoreSolution --verbosity quiet @restoreProperties Assert-CommandSucceeded 'dotnet restore' } finally { if (Test-Path -LiteralPath $restoreSolution) { Remove-Item -LiteralPath $restoreSolution } @@ -146,7 +162,7 @@ try { foreach ($file in $metadataFiles) { Remove-Item -LiteralPath $file } $generationFingerprint = Get-Fingerprint $inputPaths $inputValues # Keep all groups in one process; DocFX carries resolver state across groups. - docfx metadata docfx.json --noRestore + docfx metadata docfx.json --noRestore @metadataProperties Assert-CommandSucceeded 'docfx metadata' $metadataFiles = @(Get-MetadataFiles) if ($metadataFiles.Count -eq 0) { throw 'DocFX did not generate metadata.' } @@ -165,7 +181,13 @@ try { $imageTimer = [Diagnostics.Stopwatch]::StartNew() docker buildx build -t cuemon-docfx:$version --platform linux/arm64,linux/amd64 --load -f Dockerfile.docfx . Assert-CommandSucceeded 'docker buildx build' + + docker run --rm --entrypoint sh --mount "type=bind,source=$docfxRoot,target=/verify,readonly" cuemon-docfx:$version /verify/verify-docfx-site.sh --site /usr/share/nginx/html --source /verify --manifest /verify/run-actions.manifest.json + Assert-CommandSucceeded 'docker run verify-docfx-site' Write-Host ('Docker image: {0:N2}s; total: {1:N2}s' -f $imageTimer.Elapsed.TotalSeconds, $totalTimer.Elapsed.TotalSeconds) } finally { Pop-Location + if (Test-Path -LiteralPath (Join-Path $PSScriptRoot 'run-actions')) { + Remove-Item -LiteralPath (Join-Path $PSScriptRoot 'run-actions') -Recurse -Force + } } diff --git a/.docfx/BuildRunActions.ps1 b/.docfx/BuildRunActions.ps1 new file mode 100644 index 000000000..096dd499f --- /dev/null +++ b/.docfx/BuildRunActions.ps1 @@ -0,0 +1,563 @@ +#requires -Version 7.0 +[CmdletBinding()] +param( + [string] $ManifestPath = (Join-Path $PSScriptRoot 'run-actions.manifest.json'), + [string] $OutputRoot = (Join-Path $PSScriptRoot 'run-actions') +) +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +Set-StrictMode -Version Latest + +if (-not (Test-Path -LiteralPath $ManifestPath -PathType Leaf)) { + throw "Run-actions manifest not found: $ManifestPath" +} + +$CsrunTestVerificationTemplate = @' +function Assert-CsrunTestOutput([string] $Output) { + $lines = @($Output -split '\r?\n') + $headers = @($lines | Where-Object { $_ -match '^Test run summary: Passed! - .+\)$' }) + if ($headers.Count -ne 1) { throw 'Expected exactly one completed xUnit test summary.' } + $headerIndex = [Array]::IndexOf($lines, $headers[0]) + $summaryLines = @($lines | Select-Object -Skip ($headerIndex + 1) -First 4) + $counts = @{} + foreach ($line in $summaryLines) { + if ($line -match '^\s*(total|failed|succeeded|skipped):\s*(\d+)\s*$') { $counts[$Matches[1]] = [int]$Matches[2] } + } + if ($counts.Count -ne 4) { throw 'The xUnit test summary counts are incomplete or ambiguous.' } + $failed = $counts.failed + $passed = $counts.succeeded + $skipped = $counts.skipped + $total = $counts.total + if ($total -lt 1 -or $passed -lt 1 -or $failed -ne 0 -or $skipped -ne 0 -or $passed -ne $total) { + throw 'Tests must execute at least once, all pass, and none fail or skip.' + } +} +'@ + +function Normalize([string] $Text) { $Text.Replace("`r`n", "`n").TrimEnd("`n", "`r") } +function Quote-Literal([string] $Value) { "'" + $Value.Replace("'", "''") + "'" } +function Test-NetFrameworkTfm([string] $Framework) { return (-not [string]::IsNullOrWhiteSpace($Framework) -and $Framework -match '^net4\d+$') } + +function Sort-ManifestValue($Value) { + if ($Value -is [System.Collections.IDictionary]) { + $ordered = [ordered]@{} + [string[]] $keys = @($Value.Keys) + [Array]::Sort($keys, [StringComparer]::Ordinal) + foreach ($key in $keys) { $ordered[$key] = Sort-ManifestValue $Value[$key] } + return $ordered + } + if ($Value -is [array]) { return ,@($Value | ForEach-Object { Sort-ManifestValue $_ }) } + return $Value +} + +function New-StandalonePair { + param( + [Parameter(Mandatory)][hashtable] $Manifest, + [string] $Image = 'codebeltnet/csrun:10' + ) + if ([string]::IsNullOrWhiteSpace($Image)) { $Image = 'codebeltnet/csrun:10' } + $ordered = Sort-ManifestValue $Manifest + $manifestJson = ConvertTo-Json -InputObject $ordered -Depth 100 + $verifyTests = $ordered.mode -eq 'test' + $prefix = "#requires -Version 7.0`n`$ErrorActionPreference = 'Stop'`n`$PSNativeCommandUseErrorActionPreference = `$false`n`$manifest = @'`n" + $manifestJson + "`n'@`n" + $suffix = @' +if ($process.ExitCode -ne 0) { throw "csrun execution failed with exit code $($process.ExitCode). $diagnostics" } +if ($verifyTests) { Assert-CsrunTestOutput $output } +'@ + $engineSetup = @' +# Downloads and executes the latest stable csrun release with your permissions. +# Source and release history: https://github.com/codebeltnet/csrun +$engineDirectory = Join-Path ([IO.Path]::GetTempPath()) ('csrun-' + [guid]::NewGuid().ToString('N')) +$null = New-Item -ItemType Directory -Path $engineDirectory +$enginePath = Join-Path $engineDirectory 'csrun.ps1' +$process = $null +try { + $release = Invoke-RestMethod 'https://api.github.com/repos/codebeltnet/csrun/releases/latest' + $assets = @($release.assets | Where-Object name -CEQ 'csrun.ps1') + if ($assets.Count -ne 1 -or $assets[0].digest -notmatch '^sha256:[0-9a-f]{64}$') { + throw "csrun release $($release.tag_name) must publish one csrun.ps1 asset with a SHA-256 digest." + } + $asset = $assets[0] + Invoke-WebRequest $asset.browser_download_url -OutFile $enginePath + $actualHash = (Get-FileHash -LiteralPath $enginePath -Algorithm SHA256).Hash + if ("sha256:$actualHash" -ne $asset.digest) { throw "csrun asset checksum mismatch: $actualHash" } +'@ + $nativeInvoke = @' +$startInfo = [Diagnostics.ProcessStartInfo]::new('pwsh') +foreach ($argument in @('-NoProfile','-NonInteractive','-File')) { $startInfo.ArgumentList.Add($argument) } +$startInfo.ArgumentList.Add($enginePath) +$startInfo.ArgumentList.Add('-ManifestJson') +$startInfo.ArgumentList.Add($manifest) +$startInfo.RedirectStandardOutput = $true +$startInfo.RedirectStandardError = $true +$startInfo.UseShellExecute = $false +$process = [Diagnostics.Process]::new() +$process.StartInfo = $startInfo +if (-not $process.Start()) { throw 'Could not start csrun.' } +$stdoutTask = $process.StandardOutput.ReadToEndAsync() +$stderrTask = $process.StandardError.ReadToEndAsync() +$process.WaitForExit() +$output = $stdoutTask.GetAwaiter().GetResult() +$diagnostics = $stderrTask.GetAwaiter().GetResult() +Write-Output $output +if ($diagnostics) { [Console]::Error.Write($diagnostics) } +'@ + $dockerInvoke = (@' +$enginePayload = [Convert]::ToBase64String([IO.File]::ReadAllBytes($enginePath)) +$containerInput = $enginePayload + "`n" + $manifest +$command = ' +$ErrorActionPreference = "Stop" +$enginePath = Join-Path ([IO.Path]::GetTempPath()) ("csrun-release-" + [guid]::NewGuid().ToString("N") + ".ps1") +$engineBytes = [Convert]::FromBase64String([Console]::In.ReadLine()) +[IO.File]::WriteAllBytes($enginePath, $engineBytes) +$manifest = [Console]::In.ReadToEnd() +& $enginePath -ManifestJson $manifest +exit $LASTEXITCODE +' +$output = (@($containerInput | & docker run --rm -i --entrypoint pwsh __IMAGE__ -NoProfile -NonInteractive -Command $command) -join [Environment]::NewLine) +$process = [pscustomobject]@{ ExitCode = $LASTEXITCODE } +$diagnostics = '' +Write-Output $output +'@).Replace('__IMAGE__', (Quote-Literal $Image)) + $engineCleanup = @' +} catch { + [Console]::Error.WriteLine("csrun diagnostics retained in: $engineDirectory") + throw +} finally { + $resolvedTemp = [IO.Path]::TrimEndingDirectorySeparator([IO.Path]::GetFullPath([IO.Path]::GetTempPath())) + $resolvedEngineDirectory = [IO.Path]::GetFullPath($engineDirectory) + if ([IO.Path]::GetDirectoryName($resolvedEngineDirectory) -ne $resolvedTemp -or + [IO.Path]::GetFileName($resolvedEngineDirectory) -cnotmatch '^csrun-[a-f0-9]{32}$') { throw 'Unsafe cleanup path.' } + if ($process -and $process.ExitCode -eq 0) { Remove-Item -LiteralPath $resolvedEngineDirectory -Recurse -Force } +} +'@ + $encoding = '$OutputEncoding = [Text.UTF8Encoding]::new($false)' + "`n" + '[Console]::OutputEncoding = $OutputEncoding' + "`n" + $native = "& {`n" + ($prefix + $encoding + '$verifyTests = $' + $verifyTests.ToString().ToLowerInvariant() + "`n" + $CsrunTestVerificationTemplate + "`n" + $engineSetup + "`n" + $nativeInvoke + "`n" + $engineCleanup + "`n" + $suffix).TrimEnd() + "`n}`n" + $docker = "& {`n" + ($prefix + $encoding + '$verifyTests = $' + $verifyTests.ToString().ToLowerInvariant() + "`n" + $CsrunTestVerificationTemplate + "`n" + $engineSetup + "`n" + $dockerInvoke + "`n" + $engineCleanup + "`n" + $suffix).TrimEnd() + "`n}`n" + return @{ native = $native; docker = $docker } +} + +function New-RepositoryPair { + param( + [Parameter(Mandatory)][string] $Repository, + [Parameter(Mandatory)][string] $Commit, + [Parameter(Mandatory)][string] $Project, + [Parameter(Mandatory)][string] $Test, + [Parameter(Mandatory)][string] $Framework, + [Parameter(Mandatory)][string] $Image + ) + if ($Repository -notmatch '^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$' -or $Commit -notmatch '^[a-fA-F0-9]{40}$' -or + $Project -notmatch '^[A-Za-z0-9_./-]+\.csproj$' -or $Project.Split('/') -contains '..' -or $Project.StartsWith('/') -or + $Test -notmatch '^[A-Za-z0-9_.+]+$' -or $Framework -notmatch '^(?:net\d+\.\d+|net4\d+)$' -or + $Image -notmatch '^mcr\.microsoft\.com/dotnet/sdk:[A-Za-z0-9_.-]+$') { + throw 'Expected a pinned GitHub repository, relative project, exact xUnit method, TFM and official SDK image.' + } + $template = @' +& { +#requires -Version 7.0 + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $false + # Executes trusted repository build tasks and NuGet packages with your permissions. + # Review the pinned source before running; a container is not a security sandbox. + __PREREQUISITE__ + $work = Join-Path ([IO.Path]::GetTempPath()) ('dx-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) + $null = New-Item -ItemType Directory -Path $work + try { + $commit = '__COMMIT__' + Invoke-WebRequest "https://codeload.github.com/__REPOSITORY__/zip/$commit" -OutFile "$work/source.zip" + Expand-Archive -LiteralPath "$work/source.zip" -DestinationPath "$work/extracted" + Move-Item -LiteralPath "$work/extracted/__ARCHIVE__-$commit" -Destination "$work/repo" + $project = '__PROJECT__' + $test = '__TEST__' + __EXECUTE__ + $code = $LASTEXITCODE + if ($code -ne 0) { throw "Repository test failed with exit code $code. See $work/run.log" } + # Require exactly the original test, executed and passing, with no runner errors. + [xml] $report = Get-Content -LiteralPath "$work/results/result.xml" -Raw + $tests = @($report.SelectNodes('/assemblies/assembly/collection/test')) + $assemblies = @($report.SelectNodes('/assemblies/assembly')) + if ($assemblies.Count -ne 1 -or $assemblies[0].total -ne '1' -or $assemblies[0].passed -ne '1' -or + $assemblies[0].errors -ne '0' -or $tests.Count -ne 1 -or $tests[0].name -cne $test -or $tests[0].result -cne 'Pass') { + throw "Expected exactly one passing $test; inspect $work/results/result.xml" + } + Write-Host "Verified: $test (1 executed, 1 passed)." + } + catch { + # Preserve diagnostics outside the repository even though downloaded source is cleaned. + $diagnostics = "$work-diagnostics" + $null = New-Item -ItemType Directory -Path $diagnostics -Force + foreach ($name in @('run.log', 'results')) { + if (Test-Path -LiteralPath "$work/$name") { Copy-Item -LiteralPath "$work/$name" -Destination $diagnostics -Recurse } + } + Write-Warning "Execution not verified. Diagnostics: $diagnostics" + throw + } + finally { + $resolved = [IO.Path]::GetFullPath($work) + $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar + if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe cleanup path.' } + Remove-Item -LiteralPath $resolved -Recurse -Force + } +} +'@ + $native = (@' +Push-Location "$work/repo" + try { + dotnet run --project $project --framework __FRAMEWORK__ -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory "$work/results" 2>&1 | Tee-Object -FilePath "$work/run.log" + } + finally { Pop-Location } +'@).Replace('__FRAMEWORK__', $Framework) + $docker = (@' +$dockerUser = @() + if ($IsLinux) { + # Keep bind-mounted build output removable by the host user. + $hostUid = id -u + if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host UID.' } + $hostGid = id -g + if ($LASTEXITCODE -ne 0) { throw 'Cannot resolve host GID.' } + $dockerUser = @('--user', "${hostUid}:${hostGid}") + } + # Let Docker's init reap orphaned build processes and keep build servers disposable. + docker run --rm --init @dockerUser --env HOME=/tmp --env DOTNET_CLI_HOME=/tmp --env MSBUILDDISABLENODEREUSE=1 --mount "type=bind,source=$work,target=/work" --workdir /work/repo __IMAGE__ dotnet run --disable-build-servers --project $project --framework __FRAMEWORK__ -p:SkipSignAssembly=true -- --filter-method $test --report-xunit-xml --report-xunit-xml-filename result.xml --results-directory /work/results 2>&1 | Tee-Object -FilePath "$work/run.log" +'@).Replace('__FRAMEWORK__', $Framework).Replace('__IMAGE__', $Image) + $template = $template.Replace('__COMMIT__', $Commit).Replace('__REPOSITORY__', $Repository).Replace('__ARCHIVE__', $Repository.Split('/')[1]).Replace('__PROJECT__', $Project).Replace('__TEST__', $Test) + return @{ + native = $template.Replace('__PREREQUISITE__', "`$null = Get-Command dotnet -ErrorAction Stop").Replace('__EXECUTE__', $native) + docker = $template.Replace('__PREREQUISITE__', "`$null = Get-Command docker -ErrorAction Stop`n docker info *> `$null`n if (`$LASTEXITCODE -ne 0) { throw 'Docker daemon unavailable.' }").Replace('__EXECUTE__', $docker) + } +} + +function New-HostPair { + param( + [Parameter(Mandatory)][string] $Source, + [string] $Framework = 'net10.0', + [string] $Sdk = 'Microsoft.NET.Sdk.Web', + [string[]] $DependsOn = @(), + [string] $ProbePath = '/', + [string] $ProbeMethod = 'GET', + [int] $TimeoutSeconds = 15, + [int] $ExpectedStatusCode = 0, + [string] $ExpectedBodyContains = '', + [int] $StartupDelayMs = 1000, + [string] $Image = 'codebeltnet/csrun:10' + ) + if ($Framework -notmatch '^(?:net\d+\.\d+|net4\d+)$') { throw "Invalid host framework: $Framework" } + if ($Sdk -notmatch '^[A-Za-z0-9_.]+$') { throw "Invalid host SDK: $Sdk" } + if ($ProbeMethod -notmatch '^(GET|HEAD|POST|PUT|DELETE|OPTIONS|PATCH)$') { throw "Invalid host probeMethod: $ProbeMethod" } + if ($TimeoutSeconds -lt 3 -or $TimeoutSeconds -gt 300) { throw "Host timeoutSeconds must be between 3 and 300." } + $isNetFramework = Test-NetFrameworkTfm $Framework + $cleanDependsOn = @($DependsOn | Where-Object { -not [string]::IsNullOrWhiteSpace([string]$_) }) + foreach ($pin in $cleanDependsOn) { + if ($pin -notmatch '^[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+$') { throw "Invalid host dependsOn pin: $pin" } + } + $pkgLines = @($cleanDependsOn | ForEach-Object { + $parts = $_ -split '@', 2 + " " + }) + if ($isNetFramework -and -not ($cleanDependsOn | Where-Object { $_ -like 'Microsoft.NETFramework.ReferenceAssemblies@*' })) { + $pkgLines += ' ' + } + $itemGroup = if ($pkgLines.Count) { "`n `n" + ($pkgLines -join "`n") + "`n " } else { '' } + $langVersionLine = if ($isNetFramework) { "`n latest" } else { '' } + $csproj = "`n `n Exe`n $Framework`n enable`n enable$langVersionLine`n $itemGroup`n`n" + $payloadJson = ([ordered]@{ + csproj = $csproj + source = $Source.Replace("`r`n", "`n").TrimEnd("`r", "`n") + "`n" + probePath = $ProbePath + probeMethod = $ProbeMethod + timeoutSeconds = $TimeoutSeconds + expectedStatusCode = $ExpectedStatusCode + expectedBodyContains = $ExpectedBodyContains + startupDelayMs = $StartupDelayMs + } | ConvertTo-Json -Depth 10).Replace("`r`n", "`n") + $payloadB64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($payloadJson)) + $runnerBody = @' +$payload = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($payloadB64)) | ConvertFrom-Json +$work = Join-Path ([IO.Path]::GetTempPath()) ('dx-host-' + [guid]::NewGuid().ToString('N').Substring(0, 8)) +$null = New-Item -ItemType Directory -Path $work +$buildProcess = $null +$hostProcess = $null +$deadline = [DateTimeOffset]::UtcNow.AddSeconds([int]$payload.timeoutSeconds) +try { + $utf8NoBom = [Text.UTF8Encoding]::new($false) + $csprojPath = Join-Path $work 'HostSample.csproj' + [IO.File]::WriteAllText($csprojPath, $payload.csproj, $utf8NoBom) + [IO.File]::WriteAllText((Join-Path $work 'Program.cs'), $payload.source, $utf8NoBom) + $buildStartInfo = [Diagnostics.ProcessStartInfo]::new('dotnet') + foreach ($a in @('build', $csprojPath, '-c', 'Release', '--nologo', '-v', 'quiet')) { $buildStartInfo.ArgumentList.Add($a) } + $buildStartInfo.WorkingDirectory = $work + $buildStartInfo.RedirectStandardOutput = $true + $buildStartInfo.RedirectStandardError = $true + $buildStartInfo.UseShellExecute = $false + $buildProcess = [Diagnostics.Process]::new() + $buildProcess.StartInfo = $buildStartInfo + if (-not $buildProcess.Start()) { throw 'Could not start host sample build.' } + $buildStdoutTask = $buildProcess.StandardOutput.ReadToEndAsync() + $buildStderrTask = $buildProcess.StandardError.ReadToEndAsync() + $buildRemainingMs = [int][Math]::Ceiling(($deadline - [DateTimeOffset]::UtcNow).TotalMilliseconds) + if ($buildRemainingMs -le 0 -or -not $buildProcess.WaitForExit($buildRemainingMs)) { + try { if (-not $buildProcess.HasExited) { $buildProcess.Kill($true) } } catch {} + $null = $buildProcess.WaitForExit(5000) + throw "Host sample build timed out after $($payload.timeoutSeconds)s." + } + $buildOut = $buildStdoutTask.GetAwaiter().GetResult() + $buildErr = $buildStderrTask.GetAwaiter().GetResult() + if ($buildProcess.ExitCode -ne 0) { + $buildText = ($buildOut + "`n" + $buildErr).Trim() + throw "Host sample build failed (exit $($buildProcess.ExitCode)): $buildText" + } + if ([DateTimeOffset]::UtcNow -ge $deadline) { + throw "Host sample timed out after $($payload.timeoutSeconds)s before starting host." + } + $listener = [Net.Sockets.TcpListener]::new([Net.IPAddress]::Loopback, 0) + $listener.Start() + $port = $listener.LocalEndpoint.Port + $listener.Stop() + $baseUrl = "http://127.0.0.1:$port" + $startInfo = [Diagnostics.ProcessStartInfo]::new('dotnet') + foreach ($a in @('run','--no-build','-c','Release','--project',$csprojPath)) { $startInfo.ArgumentList.Add($a) } + $startInfo.Environment['ASPNETCORE_URLS'] = $baseUrl + $startInfo.Environment['DOTNET_ENVIRONMENT'] = 'Development' + $startInfo.RedirectStandardOutput = $true + $startInfo.RedirectStandardError = $true + $startInfo.UseShellExecute = $false + $hostProcess = [Diagnostics.Process]::new() + $hostProcess.StartInfo = $startInfo + if (-not $hostProcess.Start()) { throw 'Could not start host process.' } + $stdoutTask = $hostProcess.StandardOutput.ReadToEndAsync() + $stderrTask = $hostProcess.StandardError.ReadToEndAsync() + if ($payload.probePath) { + $probeUrl = $baseUrl + $payload.probePath + $probed = $false + $lastError = '' + $httpClient = [Net.Http.HttpClient]::new() + $httpClient.Timeout = [TimeSpan]::FromSeconds(3) + try { + while ([DateTimeOffset]::UtcNow -lt $deadline) { + if ($hostProcess.HasExited) { + $stdOut = $stdoutTask.GetAwaiter().GetResult() + $errOut = $stderrTask.GetAwaiter().GetResult() + throw "Host exited before probe succeeded (exit $($hostProcess.ExitCode)). $stdOut $errOut" + } + $probeRemainingMs = [int][Math]::Ceiling(($deadline - [DateTimeOffset]::UtcNow).TotalMilliseconds) + if ($probeRemainingMs -le 0) { break } + $cts = [Threading.CancellationTokenSource]::new([Math]::Min(3000, $probeRemainingMs)) + try { + $req = [Net.Http.HttpRequestMessage]::new([Net.Http.HttpMethod]::new([string]$payload.probeMethod), $probeUrl) + $resp = $httpClient.Send($req, $cts.Token) + $statusCode = [int]$resp.StatusCode + $body = $resp.Content.ReadAsStringAsync($cts.Token).GetAwaiter().GetResult() + if ([int]$payload.expectedStatusCode -gt 0 -and $statusCode -ne [int]$payload.expectedStatusCode) { + throw "Expected HTTP $($payload.expectedStatusCode) from $($payload.probePath), got HTTP $statusCode. Body: $body" + } + if ($payload.expectedBodyContains -and -not $body.Contains([string]$payload.expectedBodyContains, [StringComparison]::Ordinal)) { + throw "Expected response body to contain '$($payload.expectedBodyContains)'. Body: $body" + } + Write-Output "HTTP $statusCode $($payload.probeMethod) $($payload.probePath)" + if ($body) { Write-Output $body } + $probed = $true + break + } catch [Net.Http.HttpRequestException] { + $lastError = $_.Exception.Message + Start-Sleep -Milliseconds 200 + } catch [Threading.Tasks.TaskCanceledException] { + $lastError = $_.Exception.Message + Start-Sleep -Milliseconds 200 + } catch [OperationCanceledException] { + $lastError = $_.Exception.Message + Start-Sleep -Milliseconds 200 + } finally { + $cts.Dispose() + } + } + } finally { + $httpClient.Dispose() + } + if (-not $probed) { throw "Host probe '$($payload.probeMethod) $($payload.probePath)' timed out after $($payload.timeoutSeconds)s. Last error: $lastError" } + } else { + $requiredDelayMs = [Math]::Max([int]$payload.startupDelayMs, 0) + $delayRemainingMs = [int][Math]::Floor(($deadline - [DateTimeOffset]::UtcNow).TotalMilliseconds) + $sleepMs = [Math]::Min($requiredDelayMs, [Math]::Max($delayRemainingMs, 0)) + if ($sleepMs -gt 0) { $null = $hostProcess.WaitForExit($sleepMs) } + if ($hostProcess.HasExited -and $hostProcess.ExitCode -ne 0) { + $stdOut = $stdoutTask.GetAwaiter().GetResult() + $errOut = $stderrTask.GetAwaiter().GetResult() + throw "Host exited with code $($hostProcess.ExitCode). $stdOut $errOut" + } + if ($delayRemainingMs -lt $requiredDelayMs) { + throw "Host startup observation (${requiredDelayMs}ms) timed out after $($payload.timeoutSeconds)s with only $([Math]::Max($delayRemainingMs, 0))ms remaining." + } + Write-Output "Host started cleanly and ran for ${requiredDelayMs}ms." + } +} finally { + if ($buildProcess) { + try { + if (-not $buildProcess.HasExited) { $buildProcess.Kill($true) } + $null = $buildProcess.WaitForExit(5000) + } catch {} + $buildProcess.Dispose() + } + if ($hostProcess) { + try { + if (-not $hostProcess.HasExited) { $hostProcess.Kill($true) } + $null = $hostProcess.WaitForExit(5000) + } catch {} + $hostProcess.Dispose() + } + $resolved = [IO.Path]::GetFullPath($work) + $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('/','\') + [IO.Path]::DirectorySeparatorChar + if ($resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase) -and (Test-Path -LiteralPath $resolved)) { + Remove-Item -LiteralPath $resolved -Recurse -Force -ErrorAction SilentlyContinue + } +} +'@ + $runnerNorm = $runnerBody.Replace("`r`n", "`n").TrimEnd() + $native = "& {`n#requires -Version 7.0`n`$ErrorActionPreference = 'Stop'`n`$PSNativeCommandUseErrorActionPreference = `$false`n`$OutputEncoding = [Text.UTF8Encoding]::new(`$false)`n[Console]::OutputEncoding = `$OutputEncoding`n`$null = Get-Command dotnet -ErrorAction Stop`n`$payloadB64 = '$payloadB64'`n" + $runnerNorm + "`n}`n" + $runnerB64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("`$ErrorActionPreference = 'Stop'`n`$PSNativeCommandUseErrorActionPreference = `$false`n`$payloadB64 = '$payloadB64'`n" + $runnerNorm + "`n")) + $quotedImage = Quote-Literal $Image + $docker = @" +& { +#requires -Version 7.0 + `$ErrorActionPreference = 'Stop' + `$PSNativeCommandUseErrorActionPreference = `$false + `$OutputEncoding = [Text.UTF8Encoding]::new(`$false) + [Console]::OutputEncoding = `$OutputEncoding + `$null = Get-Command docker -ErrorAction Stop + docker info *> `$null + if (`$LASTEXITCODE -ne 0) { throw 'Docker daemon unavailable.' } + `$runnerB64 = '$runnerB64' + `$command = '`$ErrorActionPreference = "Stop"; `$s = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String([Console]::In.ReadToEnd())); `$p = Join-Path ([IO.Path]::GetTempPath()) ("dx-host-runner-" + [guid]::NewGuid().ToString("N") + ".ps1"); [IO.File]::WriteAllText(`$p, `$s); try { & pwsh -NoProfile -NonInteractive -File `$p; exit `$LASTEXITCODE } finally { Remove-Item -LiteralPath `$p -Force -ErrorAction SilentlyContinue }' + `$output = (@(`$runnerB64 | & docker run --rm -i --init --entrypoint pwsh $quotedImage -NoProfile -NonInteractive -Command `$command) -join [Environment]::NewLine) + `$code = `$LASTEXITCODE + Write-Output `$output + if (`$code -ne 0) { throw "Host execution failed in Docker with exit code `$code." } +} +"@ + "`n" + return @{ native = $native; docker = $docker } +} + +$doc = Get-Content -LiteralPath $ManifestPath -Raw | ConvertFrom-Json -AsHashtable +if (-not ($doc -is [System.Collections.IDictionary])) { + throw "Malformed run-actions manifest at ${ManifestPath}: root JSON value must be an object." +} +if (-not $doc.ContainsKey('schemaVersion') -or $doc.schemaVersion -ne 1) { + throw "Unsupported run-actions manifest schemaVersion: $($doc['schemaVersion'])" +} +if (-not $doc.ContainsKey('examples') -or $null -eq $doc['examples'] -or ($doc['examples'] -is [string]) -or ($doc['examples'] -is [System.Collections.IDictionary])) { + throw "Malformed run-actions manifest at ${ManifestPath}: 'examples' must be an array." +} +$examples = @($doc.examples) +if ($examples.Count -eq 0) { + throw "Run-actions manifest at $ManifestPath contains no examples." +} +$utf8NoBom = [Text.UTF8Encoding]::new($false) +$seenIds = [Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal) +$expectedScripts = [Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal) +$written = 0 + +foreach ($example in $examples) { + if (-not ($example -is [System.Collections.IDictionary])) { + throw "Malformed run-actions manifest at ${ManifestPath}: each example entry must be an object." + } + $id = [string] $example['id'] + if ($id -cnotmatch '^[a-f0-9]{24}$') { throw "Invalid run-action id: $id" } + if (-not $seenIds.Add($id)) { throw "Duplicate run-action id in manifest: $id" } + $strategy = [string] $example['strategy'] + $pair = if ($strategy -ceq 'repository') { + New-RepositoryPair -Repository $example.repository -Commit $example.commit -Project $example.project -Test $example.test -Framework $example.framework -Image $example.image + } elseif ($strategy -ceq 'standalone') { + if (-not $example.ContainsKey('manifest') -or -not ($example.manifest -is [System.Collections.IDictionary]) -or + -not $example.manifest.ContainsKey('mode') -or [string]::IsNullOrWhiteSpace([string]$example.manifest.mode) -or + -not $example.manifest.ContainsKey('source') -or [string]::IsNullOrWhiteSpace([string]$example.manifest.source)) { + throw "Malformed standalone manifest entry for $id" + } + New-StandalonePair -Manifest $example.manifest -Image $example.image + } elseif ($strategy -ceq 'host') { + if (-not $example.ContainsKey('source') -or [string]::IsNullOrWhiteSpace([string]$example.source)) { + throw "Malformed host entry for ${id}: missing 'source'." + } + $hh = if ($example.ContainsKey('hostHarness') -and $example.hostHarness) { $example.hostHarness } else { @{} } + $hostParams = @{ + Source = [string]$example.source + Framework = if ($hh.ContainsKey('framework') -and $hh.framework) { [string]$hh.framework } elseif ($example.ContainsKey('framework') -and $example.framework) { [string]$example.framework } else { 'net10.0' } + Sdk = if ($hh.ContainsKey('sdk') -and $hh.sdk) { [string]$hh.sdk } else { 'Microsoft.NET.Sdk.Web' } + DependsOn = if ($hh.ContainsKey('dependsOn') -and $hh.dependsOn) { [string[]]@($hh.dependsOn) } else { @() } + ProbePath = if ($hh.ContainsKey('probePath')) { [string]$hh.probePath } else { '/' } + ProbeMethod = if ($hh.ContainsKey('probeMethod') -and $hh.probeMethod) { [string]$hh.probeMethod } else { 'GET' } + TimeoutSeconds = if ($hh.ContainsKey('timeoutSeconds') -and $hh.timeoutSeconds) { [int]$hh.timeoutSeconds } else { 15 } + ExpectedStatusCode = if ($hh.ContainsKey('expectedStatusCode') -and $hh.expectedStatusCode) { [int]$hh.expectedStatusCode } else { 0 } + ExpectedBodyContains = if ($hh.ContainsKey('expectedBodyContains') -and $hh.expectedBodyContains) { [string]$hh.expectedBodyContains } else { '' } + StartupDelayMs = if ($hh.ContainsKey('startupDelayMs') -and $hh.startupDelayMs) { [int]$hh.startupDelayMs } else { 1000 } + Image = if ($example.ContainsKey('image') -and $example.image) { [string]$example.image } else { 'codebeltnet/csrun:10' } + } + New-HostPair @hostParams + } else { + throw "Unsupported run-action strategy '$strategy' for $id" + } + $effectiveFramework = if ($strategy -ceq 'standalone' -and $example.ContainsKey('manifest') -and $example.manifest -and $example.manifest.ContainsKey('framework') -and $example.manifest.framework) { + [string]$example.manifest.framework + } elseif ($strategy -ceq 'host' -and $example.ContainsKey('hostHarness') -and $example.hostHarness -and $example.hostHarness.ContainsKey('framework') -and $example.hostHarness.framework) { + [string]$example.hostHarness.framework + } elseif ($example.ContainsKey('framework') -and $example.framework) { + [string]$example.framework + } else { '' } + $isNetFrameworkExample = Test-NetFrameworkTfm $effectiveFramework + if (-not $example.ContainsKey('transports') -or $null -eq $example['transports'] -or ($example['transports'] -is [string])) { + throw "Missing or invalid 'transports' list for $id" + } + $transports = @($example.transports) + if ($transports.Count -eq 0) { + throw "Empty 'transports' list for $id" + } + $seenTransports = [Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal) + $dir = Join-Path $OutputRoot $id + $writtenForExample = 0 + foreach ($transportValue in $transports) { + $transport = [string] $transportValue + if ($transport -cnotin @('native', 'docker')) { throw "Unsupported transport '$transport' for $id" } + if (-not $seenTransports.Add($transport)) { throw "Duplicate transport '$transport' for $id" } + if ($isNetFrameworkExample -and $transport -ceq 'docker') { continue } + $scriptText = Normalize $pair[$transport] + $tokens = $null; $errors = $null + $null = [Management.Automation.Language.Parser]::ParseInput($scriptText, [ref]$tokens, [ref]$errors) + if ($errors.Count) { throw "Materialized $transport script for $id has syntax errors: $errors" } + $path = Join-Path $dir "$transport.ps1" + $scriptBytes = $utf8NoBom.GetBytes($scriptText) + $needsWrite = $true + if (Test-Path -LiteralPath $path -PathType Leaf) { + $existingBytes = [IO.File]::ReadAllBytes($path) + if ([System.Linq.Enumerable]::SequenceEqual($existingBytes, $scriptBytes)) { + $needsWrite = $false + } + } + if ($needsWrite) { + $null = [IO.Directory]::CreateDirectory($dir) + [IO.File]::WriteAllBytes($path, $scriptBytes) + } + $null = $expectedScripts.Add("$id/$transport.ps1") + $written++ + $writtenForExample++ + } + if ($writtenForExample -eq 0) { + throw "No runnable transports materialized for $id" + } +} + +if (Test-Path -LiteralPath $OutputRoot -PathType Container) { + foreach ($exampleDir in @(Get-ChildItem -LiteralPath $OutputRoot -Directory)) { + if ($exampleDir.Name -cnotmatch '^[a-f0-9]{24}$' -or + ($exampleDir.Attributes -band [IO.FileAttributes]::ReparsePoint)) { continue } + foreach ($name in @('native.ps1', 'docker.ps1')) { + if ($expectedScripts.Contains("$($exampleDir.Name)/$name")) { continue } + $stalePath = Join-Path $exampleDir.FullName $name + if (Test-Path -LiteralPath $stalePath -PathType Leaf) { + Remove-Item -LiteralPath $stalePath -Force + } + } + if (-not @(Get-ChildItem -LiteralPath $exampleDir.FullName -Force).Count) { + Remove-Item -LiteralPath $exampleDir.FullName + } + } +} + +Write-Host "Materialized $written run-action script(s) for $($examples.Count) example(s) into $OutputRoot." diff --git a/.docfx/Dockerfile.docfx b/.docfx/Dockerfile.docfx index e29eda1f0..0436f17f2 100644 --- a/.docfx/Dockerfile.docfx +++ b/.docfx/Dockerfile.docfx @@ -1,3 +1,12 @@ +# Supported entry points (run from .docfx/ or pass .docfx as build context): +# 1. pwsh .docfx/BuildDocfxImage.ps1 (recommended: generates run-actions, metadata, and Docker image) +# 2. Direct docker build: +# pwsh .docfx/BuildRunActions.ps1 +# pwsh .docfx/TestRunActions.ps1 +# docfx metadata .docfx/docfx.json +# docker build -f .docfx/Dockerfile.docfx .docfx +# Direct builds fail immediately if generated run-actions/ scripts are missing or incomplete. + ARG NGINX_VERSION=1.31-alpine FROM --platform=$BUILDPLATFORM dhi.io/nginx:${NGINX_VERSION} AS base @@ -7,8 +16,11 @@ FROM --platform=$BUILDPLATFORM codebeltnet/docfx:2 AS build ADD [".", "docfx"] -RUN cd docfx; \ - docfx build +RUN set -eu; \ + cd docfx; \ + sh ./verify-docfx-site.sh --context .; \ + docfx build; \ + sh ./verify-docfx-site.sh --site wwwroot --source . --manifest run-actions.manifest.json FROM dhi.io/nginx:${NGINX_VERSION} AS final WORKDIR /usr/share/nginx/html diff --git a/.docfx/TestRunActions.ps1 b/.docfx/TestRunActions.ps1 new file mode 100644 index 000000000..483bae506 --- /dev/null +++ b/.docfx/TestRunActions.ps1 @@ -0,0 +1,703 @@ +#requires -Version 7.0 +<# +.SYNOPSIS +Validates Cuemon DocFX run-action manifest integrity, Markdown references, +generated script completeness, .dockerignore rules, determinism, rendered +DocFX site output, and exported OCI image archives. +#> +[CmdletBinding()] +param( + [string] $DocfxRoot = $PSScriptRoot, + [string] $ManifestPath = (Join-Path $DocfxRoot 'run-actions.manifest.json'), + [string] $ScriptsRoot = (Join-Path $DocfxRoot 'run-actions'), + [string] $SiteRoot = '', + [string] $OciArchivePath = '', + [switch] $CheckDeterminism +) + +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +Set-StrictMode -Version Latest + +function Add-Failure([System.Collections.Generic.List[string]] $Errors, [string] $Message) { + $Errors.Add($Message) +} + +function Test-NetFrameworkTfm([string] $Framework) { + return (-not [string]::IsNullOrWhiteSpace($Framework) -and $Framework -match '^net4\d+$') +} + +function Get-ExpectedRunActionMap([string] $Path, [System.Collections.Generic.List[string]] $Errors) { + if (-not (Test-Path -LiteralPath $Path -PathType Leaf)) { + throw "Run-actions manifest not found: $Path" + } + + $doc = Get-Content -LiteralPath $Path -Raw | ConvertFrom-Json -AsHashtable + if (-not ($doc -is [System.Collections.IDictionary])) { + throw "Malformed run-actions manifest at ${Path}: root JSON value must be an object." + } + if (-not $doc.ContainsKey('schemaVersion') -or $doc['schemaVersion'] -ne 1) { + throw "Unsupported run-actions manifest schemaVersion: $($doc['schemaVersion'])" + } + if (-not $doc.ContainsKey('examples') -or $null -eq $doc['examples'] -or ($doc['examples'] -is [string]) -or ($doc['examples'] -is [System.Collections.IDictionary])) { + throw "Malformed run-actions manifest at ${Path}: 'examples' must be an array." + } + + $examples = @($doc['examples']) + if ($examples.Count -eq 0) { + throw "Run-actions manifest at $Path contains no examples." + } + + $map = @{} + foreach ($example in $examples) { + if (-not ($example -is [System.Collections.IDictionary])) { + Add-Failure $Errors 'Manifest contains a non-object example entry.' + continue + } + $id = [string] $example['id'] + if ($id -cnotmatch '^[a-f0-9]{24}$') { + Add-Failure $Errors "Invalid run-action id in manifest: '$id'" + continue + } + if ($map.ContainsKey($id)) { + Add-Failure $Errors "Duplicate run-action id in manifest: '$id'" + continue + } + + $strategy = [string] $example['strategy'] + if ($strategy -cnotin @('standalone', 'repository', 'host')) { + Add-Failure $Errors "Unsupported strategy '$strategy' for manifest entry '$id'." + continue + } + + if ($strategy -ceq 'standalone') { + if (-not $example.ContainsKey('manifest') -or -not ($example['manifest'] -is [System.Collections.IDictionary]) -or + -not $example['manifest'].ContainsKey('mode') -or [string]::IsNullOrWhiteSpace([string]$example['manifest']['mode']) -or + -not $example['manifest'].ContainsKey('source') -or [string]::IsNullOrWhiteSpace([string]$example['manifest']['source'])) { + Add-Failure $Errors "Malformed standalone manifest payload for '$id'." + continue + } + } elseif ($strategy -ceq 'repository') { + foreach ($field in @('repository', 'commit', 'project', 'test', 'framework', 'image')) { + if (-not $example.ContainsKey($field) -or [string]::IsNullOrWhiteSpace([string]$example[$field])) { + Add-Failure $Errors "Missing '$field' in repository manifest entry '$id'." + } + } + } elseif ($strategy -ceq 'host') { + if (-not $example.ContainsKey('source') -or [string]::IsNullOrWhiteSpace([string]$example['source'])) { + Add-Failure $Errors "Missing 'source' in host manifest entry '$id'." + continue + } + } + + $effectiveFramework = if ($strategy -ceq 'standalone' -and $example.ContainsKey('manifest') -and $example['manifest'] -and $example['manifest'].ContainsKey('framework') -and $example['manifest']['framework']) { + [string] $example['manifest']['framework'] + } elseif ($strategy -ceq 'host' -and $example.ContainsKey('hostHarness') -and $example['hostHarness'] -and $example['hostHarness'].ContainsKey('framework') -and $example['hostHarness']['framework']) { + [string] $example['hostHarness']['framework'] + } elseif ($example.ContainsKey('framework') -and $example['framework']) { + [string] $example['framework'] + } else { + '' + } + $isNetFramework = Test-NetFrameworkTfm $effectiveFramework + + if (-not $example.ContainsKey('transports') -or $null -eq $example['transports'] -or ($example['transports'] -is [string])) { + Add-Failure $Errors "Missing or invalid 'transports' array for '$id'." + continue + } + + $expectedTransports = [System.Collections.Generic.List[string]]::new() + $seenTransports = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::Ordinal) + foreach ($tVal in @($example['transports'])) { + $t = [string] $tVal + if ($t -cnotin @('native', 'docker')) { + Add-Failure $Errors "Unsupported transport '$t' for '$id'." + continue + } + if (-not $seenTransports.Add($t)) { + Add-Failure $Errors "Duplicate transport '$t' for '$id'." + continue + } + if ($isNetFramework -and $t -ceq 'docker') { continue } + $expectedTransports.Add($t) + } + + if ($expectedTransports.Count -eq 0) { + Add-Failure $Errors "No active transports remain for '$id'." + continue + } + + $map[$id] = @($expectedTransports) + } + + return $map +} + +function Get-DirectoryFileHashes([string] $Root) { + $hashes = [ordered]@{} + $fullRoot = [IO.Path]::GetFullPath($Root).TrimEnd([IO.Path]::DirectorySeparatorChar, [IO.Path]::AltDirectorySeparatorChar) + foreach ($file in (Get-ChildItem -LiteralPath $fullRoot -Recurse -File | Sort-Object FullName)) { + $rel = $file.FullName.Substring($fullRoot.Length + 1).Replace('\', '/') + $hashes[$rel] = (Get-FileHash -LiteralPath $file.FullName -Algorithm SHA256).Hash + } + return $hashes +} + +function Resolve-RelativeWebPath([string] $BaseRelDir, [string] $Href) { + $combined = if ($Href.StartsWith('/')) { + $Href.TrimStart('/') + } elseif ([string]::IsNullOrEmpty($BaseRelDir)) { + $Href + } else { + "$BaseRelDir/$Href" + } + + $stack = [System.Collections.Generic.List[string]]::new() + foreach ($segment in $combined.Split('/')) { + if ([string]::IsNullOrEmpty($segment) -or $segment -eq '.') { continue } + if ($segment -eq '..') { + if ($stack.Count -eq 0) { return $null } + $stack.RemoveAt($stack.Count - 1) + } else { + $stack.Add($segment) + } + } + return ($stack -join '/') +} + +function Test-OciArchiveAssets([string] $ArchivePath, [System.Collections.Generic.HashSet[string]] $ExpectedScripts, [System.Collections.Generic.List[string]] $Errors) { + if (-not (Test-Path -LiteralPath $ArchivePath -PathType Leaf)) { + Add-Failure $Errors "OCI archive not found: $ArchivePath" + return + } + + $blobs = @{} + $archiveStream = [IO.File]::OpenRead($ArchivePath) + try { + $tarReader = [System.Formats.Tar.TarReader]::new($archiveStream, $true) + try { + while ($null -ne ($entry = $tarReader.GetNextEntry())) { + if ($entry.EntryType -ne [System.Formats.Tar.TarEntryType]::RegularFile -and + $entry.EntryType -ne [System.Formats.Tar.TarEntryType]::V7RegularFile) { + continue + } + $name = $entry.Name.Replace('\', '/').TrimStart('./') + if ($name -ceq 'index.json' -or $name.StartsWith('blobs/sha256/', [StringComparison]::Ordinal)) { + $ms = [IO.MemoryStream]::new() + if ($null -ne $entry.DataStream) { + $entry.DataStream.CopyTo($ms) + } + $blobs[$name] = $ms.ToArray() + $ms.Dispose() + } + } + } finally { + $tarReader.Dispose() + } + } finally { + $archiveStream.Dispose() + } + + if (-not $blobs.ContainsKey('index.json')) { + Add-Failure $Errors "OCI archive '$ArchivePath' is missing index.json." + return + } + + $indexDoc = [Text.Encoding]::UTF8.GetString($blobs['index.json']) | ConvertFrom-Json -AsHashtable + $manifestRefs = @($indexDoc['manifests']) + if ($manifestRefs.Count -eq 0) { + Add-Failure $Errors "OCI archive '$ArchivePath' index.json contains no manifests." + return + } + + $platformManifestDigests = [System.Collections.Generic.List[string]]::new() + foreach ($mRef in $manifestRefs) { + $digest = [string] $mRef['digest'] + if ($digest -cnotmatch '^sha256:([a-f0-9]{64})$') { continue } + $blobKey = "blobs/sha256/$($Matches[1])" + if (-not $blobs.ContainsKey($blobKey)) { + Add-Failure $Errors "OCI archive '$ArchivePath' is missing manifest blob '$blobKey'." + continue + } + $mObj = [Text.Encoding]::UTF8.GetString($blobs[$blobKey]) | ConvertFrom-Json -AsHashtable + if ($mObj.ContainsKey('manifests')) { + foreach ($nested in @($mObj['manifests'])) { + $p = $nested['platform'] + if ($p -and $p['os'] -ceq 'unknown' -and $p['architecture'] -ceq 'unknown') { continue } + if ([string]$nested['digest'] -cmatch '^sha256:([a-f0-9]{64})$') { + $platformManifestDigests.Add($Matches[1]) + } + } + } elseif ($mObj.ContainsKey('layers')) { + $p = $mRef['platform'] + if ($p -and $p['os'] -ceq 'unknown' -and $p['architecture'] -ceq 'unknown') { continue } + $platformManifestDigests.Add($digest.Substring(7)) + } + } + + if ($platformManifestDigests.Count -eq 0) { + Add-Failure $Errors "OCI archive '$ArchivePath' contains no runnable platform manifests." + return + } + + foreach ($manifestHex in ($platformManifestDigests | Select-Object -Unique)) { + $mBlobKey = "blobs/sha256/$manifestHex" + $manifestDoc = [Text.Encoding]::UTF8.GetString($blobs[$mBlobKey]) | ConvertFrom-Json -AsHashtable + $files = @{} + + foreach ($layer in @($manifestDoc['layers'])) { + $layerDigest = [string] $layer['digest'] + if ($layerDigest -cnotmatch '^sha256:([a-f0-9]{64})$') { continue } + $layerKey = "blobs/sha256/$($Matches[1])" + if (-not $blobs.ContainsKey($layerKey)) { + Add-Failure $Errors "OCI archive '$ArchivePath' is missing layer blob '$layerKey' for manifest '$manifestHex'." + continue + } + + $layerBytes = $blobs[$layerKey] + $mediaType = [string] $layer['mediaType'] + $isGzip = $mediaType -like '*gzip*' -or ($layerBytes.Length -ge 2 -and $layerBytes[0] -eq 0x1F -and $layerBytes[1] -eq 0x8B) + $isZstd = $mediaType -like '*zstd*' -or ($layerBytes.Length -ge 4 -and $layerBytes[0] -eq 0x28 -and $layerBytes[1] -eq 0xB5 -and $layerBytes[2] -eq 0x2F -and $layerBytes[3] -eq 0xFD) + + $layerStream = [IO.MemoryStream]::new($layerBytes, $false) + $decompressedTemp = $null + $tarInput = $null + if ($isGzip) { + $tarInput = [IO.Compression.GzipStream]::new($layerStream, [IO.Compression.CompressionMode]::Decompress) + } elseif ($isZstd) { + $zstdType = 'System.IO.Compression.ZstandardStream' -as [type] + if ($null -ne $zstdType) { + $tarInput = $zstdType::new($layerStream, [IO.Compression.CompressionMode]::Decompress) + } elseif (Get-Command zstd -ErrorAction SilentlyContinue) { + $tmpIn = [IO.Path]::GetTempFileName() + $decompressedTemp = [IO.Path]::GetTempFileName() + try { + [IO.File]::WriteAllBytes($tmpIn, $layerBytes) + & zstd -d -f -q $tmpIn -o $decompressedTemp + if ($LASTEXITCODE -ne 0) { throw "zstd decompression failed for layer '$layerKey'." } + $tarInput = [IO.File]::OpenRead($decompressedTemp) + } finally { + if (Test-Path -LiteralPath $tmpIn) { Remove-Item -LiteralPath $tmpIn -Force } + } + } else { + $tmpTar = [IO.Path]::GetTempFileName() + try { + [IO.File]::WriteAllBytes($tmpTar, $layerBytes) + $tarEntries = @(& tar -tvf $tmpTar 2>&1) + if ($LASTEXITCODE -ne 0) { throw "Failed to inspect zstd layer '$layerKey' with tar: $($tarEntries -join ' ')" } + foreach ($line in $tarEntries) { + if ($line -match '^[^d]\S*\s+\S+\s+(?\d+)\s+.+?\s+(?\S+)$') { + $entryPath = $Matches['path'].Replace('\', '/').TrimStart('./') + $files[$entryPath] = [long]$Matches['size'] + } + } + } finally { + if (Test-Path -LiteralPath $tmpTar) { Remove-Item -LiteralPath $tmpTar -Force } + } + $layerStream.Dispose() + continue + } + } else { + $tarInput = $layerStream + } + try { + $layerReader = [System.Formats.Tar.TarReader]::new($tarInput, $true) + try { + while ($null -ne ($entry = $layerReader.GetNextEntry())) { + $entryPath = $entry.Name.Replace('\', '/').TrimStart('./') + $entryDir = [IO.Path]::GetDirectoryName($entryPath)?.Replace('\', '/') + $entryLeaf = [IO.Path]::GetFileName($entryPath) + if ($entryLeaf -ceq '.wh..wh..opq' -and $entryDir) { + $prefix = "$entryDir/" + foreach ($existing in @($files.Keys | Where-Object { $_.StartsWith($prefix, [StringComparison]::Ordinal) })) { + $files.Remove($existing) + } + continue + } + if ($entryLeaf.StartsWith('.wh.', [StringComparison]::Ordinal)) { + $targetName = $entryLeaf.Substring(4) + $targetPath = if ($entryDir) { "$entryDir/$targetName" } else { $targetName } + $files.Remove($targetPath) + $dirPrefix = "$targetPath/" + foreach ($existing in @($files.Keys | Where-Object { $_.StartsWith($dirPrefix, [StringComparison]::Ordinal) })) { + $files.Remove($existing) + } + continue + } + if ($entry.EntryType -eq [System.Formats.Tar.TarEntryType]::RegularFile -or + $entry.EntryType -eq [System.Formats.Tar.TarEntryType]::V7RegularFile) { + $files[$entryPath] = $entry.Length + } + } + } finally { + $layerReader.Dispose() + } + } finally { + if ($null -ne $tarInput -and $tarInput -ne $layerStream) { $tarInput.Dispose() } + $layerStream.Dispose() + if ($decompressedTemp -and (Test-Path -LiteralPath $decompressedTemp)) { + Remove-Item -LiteralPath $decompressedTemp -Force + } + } + } + + $jsPath = 'usr/share/nginx/html/public/run-actions.js' + if (-not $files.ContainsKey($jsPath) -or $files[$jsPath] -le 0) { + Add-Failure $Errors "OCI manifest '$manifestHex' is missing non-empty '$jsPath'." + } + + $missingInLayer = 0 + foreach ($relScript in $ExpectedScripts) { + $ociPath = "usr/share/nginx/html/run-actions/$relScript" + if (-not $files.ContainsKey($ociPath) -or $files[$ociPath] -le 0) { + $missingInLayer++ + if ($missingInLayer -le 10) { + Add-Failure $Errors "OCI manifest '$manifestHex' is missing '$ociPath'." + } + } + } + if ($missingInLayer -gt 10) { + Add-Failure $Errors "OCI manifest '$manifestHex' is missing $missingInLayer total run-action script(s)." + } + } +} + +$errors = [System.Collections.Generic.List[string]]::new() +$docfxFullRoot = [IO.Path]::GetFullPath($DocfxRoot) +$expectedById = Get-ExpectedRunActionMap -Path $ManifestPath -Errors $errors + +$expectedScripts = [System.Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal) +foreach ($id in $expectedById.Keys) { + foreach ($transport in $expectedById[$id]) { + $null = $expectedScripts.Add("$id/$transport.ps1") + } +} + +# Validate docfx.json and template files. +$docfxConfigPath = Join-Path $docfxFullRoot 'docfx.json' +if (-not (Test-Path -LiteralPath $docfxConfigPath -PathType Leaf)) { + Add-Failure $errors "DocFX configuration not found: $docfxConfigPath" +} else { + $docfxConfig = Get-Content -LiteralPath $docfxConfigPath -Raw | ConvertFrom-Json -AsHashtable + $resourceFiles = @() + if ($docfxConfig.ContainsKey('build') -and $docfxConfig['build'] -and $docfxConfig['build'].ContainsKey('resource')) { + foreach ($res in @($docfxConfig['build']['resource'])) { + $resourceFiles += @($res['files']) + } + } + if ($resourceFiles -notcontains 'run-actions/**') { + Add-Failure $errors "docfx.json build.resource must include 'run-actions/**'." + } +} + +$runActionsJsPath = Join-Path $docfxFullRoot 'templates/cuemon/public/run-actions.js' +if (-not (Test-Path -LiteralPath $runActionsJsPath -PathType Leaf) -or (Get-Item -LiteralPath $runActionsJsPath).Length -eq 0) { + Add-Failure $errors "Missing or empty template asset: $runActionsJsPath" +} +$mainJsPath = Join-Path $docfxFullRoot 'templates/cuemon/public/main.js' +if (-not (Test-Path -LiteralPath $mainJsPath -PathType Leaf) -or + ([IO.File]::ReadAllText($mainJsPath) -notmatch "import\s+'\./run-actions\.js'")) { + Add-Failure $errors "Template entry script templates/cuemon/public/main.js must import './run-actions.js'." +} + +# Validate .dockerignore does not exclude nested run-actions/**/*.ps1 scripts. +$dockerignorePath = Join-Path $docfxFullRoot '.dockerignore' +if (Test-Path -LiteralPath $dockerignorePath -PathType Leaf) { + $ignoreLines = @([IO.File]::ReadAllLines($dockerignorePath) | ForEach-Object { $_.Trim() } | Where-Object { $_ -and -not $_.StartsWith('#') }) + $excludesRunActionsDir = $ignoreLines | Where-Object { $_ -ceq 'run-actions/' -or $_ -ceq 'run-actions/**' -or $_ -ceq 'run-actions' } + if ($excludesRunActionsDir) { + Add-Failure $errors ".dockerignore must not exclude 'run-actions/'." + } + $hasWildcardPs1 = ($ignoreLines -contains '*.ps1') -or ($ignoreLines -contains '**/*.ps1') + $hasNegation = $ignoreLines -contains '!run-actions/**/*.ps1' + if ($hasWildcardPs1 -and -not $hasNegation) { + Add-Failure $errors ".dockerignore ignores .ps1 files without explicitly preserving '!run-actions/**/*.ps1'." + } +} + +# Validate all Markdown run-action references against the manifest. +$excludedSegments = @('obj', 'wwwroot', 'packages', 'run-actions') +$mdFiles = @( + Get-ChildItem -LiteralPath $docfxFullRoot -Recurse -File -Filter '*.md' | + Where-Object { + $rel = $_.FullName.Substring($docfxFullRoot.Length).TrimStart('\', '/').Replace('\', '/') + $firstSegment = ($rel -split '/', 2)[0] + $firstSegment -notin $excludedSegments + } +) + +$divRegex = [regex]'[^>]*)>(?.*?)' +$idAttrRegex = [regex]'data-example-id="(?[^"]*)"' +$linkRegex = [regex]'[^>]*?)>' +$hrefAttrRegex = [regex]'href="(?[^"]*)"' +$transportAttrRegex = [regex]'data-transport="(?[^"]*)"' +$referencedScripts = [System.Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal) + +foreach ($mdFile in $mdFiles) { + $relMd = $mdFile.FullName.Substring($docfxFullRoot.Length).TrimStart('\', '/').Replace('\', '/') + $content = [IO.File]::ReadAllText($mdFile.FullName) + $cleaned = $divRegex.Replace($content, { + param($match) + $attrs = $match.Groups['attrs'].Value + $inner = $match.Groups['inner'].Value + $idMatch = $idAttrRegex.Match($attrs) + if (-not $idMatch.Success) { + Add-Failure $errors "${relMd}: docfx-run-actions block is missing data-example-id." + return '' + } + $id = $idMatch.Groups['id'].Value + if ($id -cnotmatch '^[a-f0-9]{24}$') { + Add-Failure $errors "${relMd}: invalid data-example-id '$id'." + return '' + } + if (-not $expectedById.ContainsKey($id)) { + Add-Failure $errors "${relMd}: referenced run-action id '$id' is missing from $ManifestPath." + return '' + } + + $foundTransports = [System.Collections.Generic.List[string]]::new() + foreach ($linkMatch in $linkRegex.Matches($inner)) { + $linkAttrs = $linkMatch.Groups['attrs'].Value + $hrefMatch = $hrefAttrRegex.Match($linkAttrs) + $trMatch = $transportAttrRegex.Match($linkAttrs) + if (-not $hrefMatch.Success -or -not $trMatch.Success) { + Add-Failure $errors "${relMd} ($id): run-action anchor missing href or data-transport." + continue + } + $href = $hrefMatch.Groups['href'].Value + $tr = $trMatch.Groups['transport'].Value + if ($tr -cnotin @('native', 'docker')) { + Add-Failure $errors "${relMd} ($id): unsupported data-transport '$tr'." + continue + } + $expectedHref = "~/run-actions/$id/$tr.ps1" + if ($href -cne $expectedHref) { + Add-Failure $errors "${relMd} ($id): expected href '$expectedHref' but found '$href'." + } + if ($foundTransports.Contains($tr)) { + Add-Failure $errors "${relMd} ($id): duplicate data-transport '$tr'." + } else { + $foundTransports.Add($tr) + } + $null = $referencedScripts.Add("$id/$tr.ps1") + } + + $expectedList = ($expectedById[$id] | Sort-Object) -join ',' + $foundList = ($foundTransports | Sort-Object) -join ',' + if ($expectedList -cne $foundList) { + Add-Failure $errors "${relMd} ($id): transports [$foundList] do not match manifest [$expectedList]." + } + return '' + }) + + if ($cleaned -replace '', '' -match 'docfx-run-actions|(?:~/|/)?run-actions/') { + Add-Failure $errors "${relMd}: contains malformed docfx-run-actions markup or stray run-actions reference." + } +} + +if ($referencedScripts.Count -eq 0) { + Add-Failure $errors "No run-action references were discovered in Markdown under $docfxFullRoot." +} + +# Validate generated scripts under $ScriptsRoot. +$executionScriptRegex = [regex]'^& \{\r?\n#requires -Version 7\.0\r?\n[\s\S]*\r?\n\}\r?\n?$' +if (-not (Test-Path -LiteralPath $ScriptsRoot -PathType Container)) { + Add-Failure $errors "Generated run-actions directory not found: $ScriptsRoot" +} else { + $allRequired = [System.Collections.Generic.HashSet[string]]::new($expectedScripts, [StringComparer]::Ordinal) + $allRequired.UnionWith($referencedScripts) + + foreach ($relScript in ($allRequired | Sort-Object)) { + $scriptPath = Join-Path $ScriptsRoot $relScript + if (-not (Test-Path -LiteralPath $scriptPath -PathType Leaf)) { + Add-Failure $errors "Missing generated run-action script: $scriptPath" + continue + } + $info = Get-Item -LiteralPath $scriptPath + if ($info.Length -eq 0) { + Add-Failure $errors "Generated run-action script is empty: $scriptPath" + continue + } + $scriptText = [IO.File]::ReadAllText($scriptPath) + if (-not $executionScriptRegex.IsMatch($scriptText)) { + Add-Failure $errors "Generated run-action script does not match run-actions.js contract: $scriptPath" + } + $tokens = $null; $parseErrors = $null + $null = [Management.Automation.Language.Parser]::ParseInput($scriptText, [ref]$tokens, [ref]$parseErrors) + if ($parseErrors.Count -gt 0) { + Add-Failure $errors "Generated run-action script has PowerShell syntax errors: $scriptPath" + } + } + + $scriptsFullRoot = [IO.Path]::GetFullPath($ScriptsRoot).TrimEnd([IO.Path]::DirectorySeparatorChar, [IO.Path]::AltDirectorySeparatorChar) + foreach ($diskScript in (Get-ChildItem -LiteralPath $scriptsFullRoot -Recurse -File -Filter '*.ps1')) { + $relDisk = $diskScript.FullName.Substring($scriptsFullRoot.Length + 1).Replace('\', '/') + if (-not $expectedScripts.Contains($relDisk)) { + Add-Failure $errors "Unexpected or stale generated script in ${ScriptsRoot}: $relDisk" + } + } +} + +# Determinism check: generate twice from scratch into temp directories and compare hashes. +if ($CheckDeterminism) { + $builderScript = Join-Path $docfxFullRoot 'BuildRunActions.ps1' + if (-not (Test-Path -LiteralPath $builderScript -PathType Leaf)) { + Add-Failure $errors "Generator script not found for determinism check: $builderScript" + } else { + $tempBase = Join-Path ([IO.Path]::GetTempPath()) ('dx-ra-det-' + [guid]::NewGuid().ToString('N')) + $run1 = Join-Path $tempBase 'run1' + $run2 = Join-Path $tempBase 'run2' + try { + & $builderScript -ManifestPath $ManifestPath -OutputRoot $run1 | Out-Null + & $builderScript -ManifestPath $ManifestPath -OutputRoot $run2 | Out-Null + + $hashes1 = Get-DirectoryFileHashes $run1 + $hashes2 = Get-DirectoryFileHashes $run2 + + if ($hashes1.Count -ne $expectedScripts.Count) { + Add-Failure $errors "Determinism run1 produced $($hashes1.Count) files, expected $($expectedScripts.Count)." + } + if (($hashes1.Keys -join '|') -cne ($hashes2.Keys -join '|')) { + Add-Failure $errors 'Determinism check failed: repeated runs produced different file sets.' + } else { + foreach ($key in $hashes1.Keys) { + if ($hashes1[$key] -cne $hashes2[$key]) { + Add-Failure $errors "Determinism check failed: non-deterministic content for '$key'." + break + } + } + } + + if (Test-Path -LiteralPath $ScriptsRoot -PathType Container) { + $hashesLive = Get-DirectoryFileHashes $ScriptsRoot + if (($hashes1.Keys -join '|') -cne ($hashesLive.Keys -join '|')) { + Add-Failure $errors "Generated directory '$ScriptsRoot' file set differs from clean generation." + } else { + foreach ($key in $hashes1.Keys) { + if ($hashes1[$key] -cne $hashesLive[$key]) { + Add-Failure $errors "Generated file '$key' in '$ScriptsRoot' differs from clean generation." + break + } + } + } + } + } finally { + if (Test-Path -LiteralPath $tempBase) { + Remove-Item -LiteralPath $tempBase -Recurse -Force + } + } + } +} + +# Validate published DocFX HTML output directory if provided. +if (-not [string]::IsNullOrWhiteSpace($SiteRoot)) { + if (-not (Test-Path -LiteralPath $SiteRoot -PathType Container)) { + Add-Failure $errors "Published site directory not found: $SiteRoot" + } else { + $siteFullRoot = [IO.Path]::GetFullPath($SiteRoot).TrimEnd([IO.Path]::DirectorySeparatorChar, [IO.Path]::AltDirectorySeparatorChar) + $siteJs = Join-Path $siteFullRoot 'public/run-actions.js' + if (-not (Test-Path -LiteralPath $siteJs -PathType Leaf) -or (Get-Item -LiteralPath $siteJs).Length -eq 0) { + Add-Failure $errors "Published site is missing non-empty public/run-actions.js: $siteJs" + } + + $siteScriptsRoot = Join-Path $siteFullRoot 'run-actions' + if (-not (Test-Path -LiteralPath $siteScriptsRoot -PathType Container)) { + Add-Failure $errors "Published site is missing run-actions directory: $siteScriptsRoot" + } else { + foreach ($relScript in ($expectedScripts | Sort-Object)) { + $siteScriptPath = Join-Path $siteScriptsRoot $relScript + if (-not (Test-Path -LiteralPath $siteScriptPath -PathType Leaf) -or (Get-Item -LiteralPath $siteScriptPath).Length -eq 0) { + Add-Failure $errors "Published site is missing generated script: run-actions/$relScript" + } elseif (Test-Path -LiteralPath (Join-Path $ScriptsRoot $relScript) -PathType Leaf) { + $srcBytes = [IO.File]::ReadAllBytes((Join-Path $ScriptsRoot $relScript)) + $siteBytes = [IO.File]::ReadAllBytes($siteScriptPath) + if (-not [System.Linq.Enumerable]::SequenceEqual($srcBytes, $siteBytes)) { + Add-Failure $errors "Published script differs from generated source script: run-actions/$relScript" + } + } + } + } + + $htmlFiles = @(Get-ChildItem -LiteralPath $siteFullRoot -Recurse -File -Filter '*.html') + if ($htmlFiles.Count -eq 0) { + Add-Failure $errors "No HTML files found in published site: $siteFullRoot" + } + + $frameworkManifest = Join-Path $siteFullRoot 'framework-views.json' + $frameworkPrefixes = @() + if (Test-Path -LiteralPath $frameworkManifest -PathType Leaf) { + $framework = Get-Content -LiteralPath $frameworkManifest -Raw | ConvertFrom-Json -AsHashtable + $frameworkPrefixes = @(foreach ($entry in $framework.views.GetEnumerator()) { + if ($entry.Key -cne $framework.defaultView) { "_frameworks/$($entry.Value.directory)" } + }) + } + $htmlLinksChecked = 0 + foreach ($htmlFile in $htmlFiles) { + $relHtml = $htmlFile.FullName.Substring($siteFullRoot.Length + 1).Replace('\', '/') + $publicHtml = $relHtml + foreach ($prefix in $frameworkPrefixes) { + if ($relHtml.StartsWith("$prefix$($framework.apiPath)", [StringComparison]::Ordinal)) { + $publicHtml = $relHtml.Substring($prefix.Length + 1) + break + } + } + $baseRelDir = [IO.Path]::GetDirectoryName($publicHtml)?.Replace('\', '/') + $htmlText = [IO.File]::ReadAllText($htmlFile.FullName) + foreach ($match in $divRegex.Matches($htmlText)) { + $attrs = $match.Groups['attrs'].Value + $inner = $match.Groups['inner'].Value + $idMatch = $idAttrRegex.Match($attrs) + if (-not $idMatch.Success) { + Add-Failure $errors "${relHtml}: docfx-run-actions block missing data-example-id." + continue + } + $id = $idMatch.Groups['id'].Value + if (-not $expectedById.ContainsKey($id)) { + Add-Failure $errors "${relHtml}: referenced id '$id' missing from manifest." + continue + } + foreach ($linkMatch in $linkRegex.Matches($inner)) { + $linkAttrs = $linkMatch.Groups['attrs'].Value + $hrefMatch = $hrefAttrRegex.Match($linkAttrs) + $trMatch = $transportAttrRegex.Match($linkAttrs) + if (-not $hrefMatch.Success -or -not $trMatch.Success) { + Add-Failure $errors "${relHtml} ($id): anchor missing href or data-transport." + continue + } + $href = $hrefMatch.Groups['href'].Value + $tr = $trMatch.Groups['transport'].Value + $resolved = Resolve-RelativeWebPath -BaseRelDir $baseRelDir -Href $href + if ($null -eq $resolved -or $resolved -cne "run-actions/$id/$tr.ps1") { + Add-Failure $errors "${relHtml} ($id): href '$href' resolved to '$resolved' instead of 'run-actions/$id/$tr.ps1'." + continue + } + $targetFile = Join-Path $siteFullRoot $resolved + if (-not (Test-Path -LiteralPath $targetFile -PathType Leaf) -or (Get-Item -LiteralPath $targetFile).Length -eq 0) { + Add-Failure $errors "${relHtml} ($id): published target '$resolved' is missing or empty." + } + $htmlLinksChecked++ + } + } + $cleanedHtml = $divRegex.Replace($htmlText, '') + if ($cleanedHtml -match 'href="[^"]*run-actions/[^"]*"') { + Add-Failure $errors "${relHtml}: contains stray run-actions href outside docfx-run-actions block." + } + } + if ($htmlLinksChecked -eq 0) { + Add-Failure $errors "No docfx-run-actions links were found in HTML under $siteFullRoot." + } + } +} + +if (-not [string]::IsNullOrWhiteSpace($OciArchivePath)) { + Test-OciArchiveAssets -ArchivePath $OciArchivePath -ExpectedScripts $expectedScripts -Errors $errors +} + +if ($errors.Count -gt 0) { + foreach ($err in $errors) { + Write-Error $err -ErrorAction Continue + } + throw "DocFX run-action validation failed with $($errors.Count) error(s)." +} + +Write-Host "Validated $($expectedById.Count) manifest example(s), $($referencedScripts.Count) Markdown reference(s), and $($expectedScripts.Count) generated script(s)." diff --git a/.docfx/api/namespaces/Cuemon.AspNetCore.Authentication.Hmac.md b/.docfx/api/namespaces/Cuemon.AspNetCore.Authentication.Hmac.md index 7152c8d91..075ff9eaa 100644 --- a/.docfx/api/namespaces/Cuemon.AspNetCore.Authentication.Hmac.md +++ b/.docfx/api/namespaces/Cuemon.AspNetCore.Authentication.Hmac.md @@ -4,4 +4,4 @@ summary: *content --- Implement [HMAC-based request signing](https://www.okta.com/identity-101/hmac/) (inspired by [AWS Signature Version 4](https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-auth-using-authorization-header.html) and its [signing process](https://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html)) in your ASP.NET Core application. Use this namespace when you need to authenticate requests using a hash-based message authentication code. Start with `HmacAuthenticationHandler` for validating HMAC-signed requests in your authentication pipeline. -[!INCLUDE [availability-modern](../../includes/availability-modern.md) \ No newline at end of file +[!INCLUDE [availability-modern](../../includes/availability-modern.md)] \ No newline at end of file diff --git a/.docfx/api/types/Cuemon.ActionFactory`1.md b/.docfx/api/types/Cuemon.ActionFactory`1.md index 8f32b6695..3f65c3741 100644 --- a/.docfx/api/types/Cuemon.ActionFactory`1.md +++ b/.docfx/api/types/Cuemon.ActionFactory`1.md @@ -7,39 +7,36 @@ example: The following example demonstrates how to use to wrap and invoke a delegate with n-tuple arguments. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.Examples; +// Create a mutable tuple with string and int arguments +var tuple = new MutableTuple("Hello", 42); -public class ActionFactoryExample +// Define an action that processes the tuple +void Process(MutableTuple t) { - public void Demonstrate() - { - // Create a mutable tuple with string and int arguments - var tuple = new MutableTuple("Hello", 42); - - // Define an action that processes the tuple - void Process(MutableTuple t) - { - Console.WriteLine($"Message: {t.Arg1}, Value: {t.Arg2}"); + Console.WriteLine($"Message: {t.Arg1}, Value: {t.Arg2}"); +} - // Wrap the action and tuple in an ActionFactory - var factory = new ActionFactory>(Process, tuple); +// Wrap the action and tuple in an ActionFactory +var factory = new ActionFactory>(Process, tuple); - // Inspect factory state - Console.WriteLine(factory.HasDelegate); // True - Console.WriteLine(factory.GenericArguments.Arg1); // "Hello" - Console.WriteLine(factory.GenericArguments.Arg2); // 42 +// Inspect factory state +Console.WriteLine(factory.HasDelegate); // True +Console.WriteLine(factory.GenericArguments.Arg1); // "Hello" +Console.WriteLine(factory.GenericArguments.Arg2); // 42 - // Invoke the wrapped delegate - factory.ExecuteMethod(); // Output: "Message: Hello, Value: 42" +// Invoke the wrapped delegate +factory.ExecuteMethod(); // Output: "Message: Hello, Value: 42" - // Create a clone for safe concurrent use - var clone = factory.Clone() as ActionFactory>; - clone?.ExecuteMethod(); - -}} -} +// Create a clone for safe concurrent use +var clone = factory.Clone() as ActionFactory>; +clone?.ExecuteMethod(); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Alphanumeric.md b/.docfx/api/types/Cuemon.Alphanumeric.md index ed48ce78e..0e3b823bf 100644 --- a/.docfx/api/types/Cuemon.Alphanumeric.md +++ b/.docfx/api/types/Cuemon.Alphanumeric.md @@ -7,19 +7,16 @@ example: The following example demonstrates how to use the `Alphanumeric` class to access predefined character sets. It prints the available character ranges for digits, uppercase letters, hexadecimal characters, and punctuation marks. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.CharacterSets; - -public class AlphanumericExample -{ - public void Demonstrate() - { - Console.WriteLine(Alphanumeric.Numbers); // "0123456789" - Console.WriteLine(Alphanumeric.UppercaseLetters); // "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - Console.WriteLine(Alphanumeric.Hexadecimal); // "0123456789ABCDEF" - Console.WriteLine(Alphanumeric.PunctuationMarks); // "!@#$%^&*()_-+=[{]};:<>|.,/?`~\"'" - } -} +Console.WriteLine(Alphanumeric.Numbers); // "0123456789" +Console.WriteLine(Alphanumeric.UppercaseLetters); // "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +Console.WriteLine(Alphanumeric.Hexadecimal); // "0123456789ABCDEF" +Console.WriteLine(Alphanumeric.PunctuationMarks); // "!@#$%^&*()_-+=[{]};:<>|.,/?`~\"'" ``` + + + + diff --git a/.docfx/api/types/Cuemon.ArgumentReservedKeywordException.md b/.docfx/api/types/Cuemon.ArgumentReservedKeywordException.md index e14046b94..aa9a0122a 100644 --- a/.docfx/api/types/Cuemon.ArgumentReservedKeywordException.md +++ b/.docfx/api/types/Cuemon.ArgumentReservedKeywordException.md @@ -7,34 +7,26 @@ example: The following example shows how to throw an `ArgumentReservedKeywordException` when a parameter value matches a reserved SQL keyword. It demonstrates the expected validation failure and how to catch the exception with access to the parameter name. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.Validation +var reservedKeywords = new[] { "select", "insert", "update", "delete", "from", "where" }; +try { - public class ReservedKeywordValidator + var columnName = "select"; + if (Array.Exists(reservedKeywords, keyword => string.Equals(keyword, columnName, StringComparison.OrdinalIgnoreCase))) { - private static readonly string[] SqlReservedKeywords = new[] - { - "select", "insert", "update", "delete", "from", "where" - }; - - public static void ValidateColumnName(string paramName, string value) - { - if (Array.Exists(SqlReservedKeywords, - kw => string.Equals(kw, value, StringComparison.OrdinalIgnoreCase))) - { - throw new ArgumentReservedKeywordException(paramName, value, - "Value must not be a reserved SQL keyword."); - - // Usage: - // try { ValidateColumnName("sortBy", "select"); } - // catch (ArgumentReservedKeywordException ex) when (ex.ParamName == "sortBy") - // { - // Console.WriteLine($"Validation failed: {ex.Message}"); - // } - -}}} + throw new ArgumentReservedKeywordException("sortBy", columnName, "Value must not be a reserved SQL keyword."); + } +} +catch (ArgumentReservedKeywordException ex) +{ + Console.WriteLine(ex.Message); + Console.WriteLine(ex.ParamName); } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.AuthenticationHandlerFeature.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.AuthenticationHandlerFeature.md index 471c3ddf1..4a77ec465 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.AuthenticationHandlerFeature.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.AuthenticationHandlerFeature.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to keep the authenticate result and user principal synchronized on the current HTTP features. ```csharp +// Program.cs using System; using System.Security.Claims; using Cuemon.AspNetCore.Authentication; @@ -14,24 +15,19 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features.Authentication; -namespace MyApp.Examples; +var principal = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "Agent") }, "Basic")); +var result = AuthenticateResult.Success(new AuthenticationTicket(principal, "Basic")); +var context = new DefaultHttpContext(); -public static class AuthenticationHandlerFeatureExample -{ - public static void Demonstrate() - { - var principal = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "Agent") }, "Basic")); - var result = AuthenticateResult.Success(new AuthenticationTicket(principal, "Basic")); - var context = new DefaultHttpContext(); +AuthenticationHandlerFeature.Set(result, context); - AuthenticationHandlerFeature.Set(result, context); - - var authenticateFeature = (AuthenticationHandlerFeature)context.Features.Get()!; - var httpAuthenticationFeature = (AuthenticationHandlerFeature)context.Features.Get()!; - - Console.WriteLine(authenticateFeature.AuthenticateResult == result); - Console.WriteLine(httpAuthenticationFeature.User.Identity?.Name); - } -} +var authenticateFeature = (AuthenticationHandlerFeature)context.Features.Get()!; +var httpAuthenticationFeature = (AuthenticationHandlerFeature)context.Features.Get()!; +Console.WriteLine(authenticateFeature.AuthenticateResult == result); +Console.WriteLine(httpAuthenticationFeature.User.Identity?.Name); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Authenticator.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Authenticator.md index e87b222c7..49f2f3313 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Authenticator.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Authenticator.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to authenticate an HTTP request by parsing the `Authorization` header and resolving a claims principal. ```csharp +// Program.cs using System; using System.Security.Claims; using Cuemon; @@ -14,31 +15,26 @@ using Cuemon.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; using Microsoft.Net.Http.Headers; -namespace MyApp.Examples; - -public static class AuthenticatorExample +var context = new DefaultHttpContext() { - public static void Demonstrate() - { - var context = new DefaultHttpContext() - { - Request = { IsHttps = true } - }; - context.Request.Headers.Append(HeaderNames.Authorization, "Basic YWxpY2U6cGFzc3dvcmQ="); - - var result = Authenticator.Authenticate(context, false, - (HttpContext _, string authorizationHeader) => authorizationHeader, - (HttpContext _, string credentials, out ConditionalValue principal) => - { - principal = new SuccessfulValue( - new ClaimsPrincipal(new ClaimsIdentity( - new[] { new Claim(ClaimTypes.Name, "alice") }, "Basic"))); - return true; - }); + Request = { IsHttps = true } +}; +context.Request.Headers.Append(HeaderNames.Authorization, "Basic YWxpY2U6cGFzc3dvcmQ="); - Console.WriteLine("Succeeded: " + result.Succeeded); - Console.WriteLine("User: " + result.Result?.Identity?.Name); - } -} +var result = Authenticator.Authenticate(context, false, + (HttpContext _, string authorizationHeader) => authorizationHeader, + (HttpContext _, string credentials, out ConditionalValue principal) => + { + principal = new SuccessfulValue( + new ClaimsPrincipal(new ClaimsIdentity( + new[] { new Claim(ClaimTypes.Name, "alice") }, "Basic"))); + return true; + }); +Console.WriteLine("Succeeded: " + result.Succeeded); +Console.WriteLine("User: " + result.Result?.Identity?.Name); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.AuthorizationHeaderOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.AuthorizationHeaderOptions.md index e81ad7bda..9166f1a59 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.AuthorizationHeaderOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.AuthorizationHeaderOptions.md @@ -7,26 +7,22 @@ example: The following example demonstrates how to customize the delimiters used when parsing authorization header credentials. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Authentication; -namespace MyApp.Examples; - -public static class AuthorizationHeaderOptionsExample +var options = new AuthorizationHeaderOptions { - public static void Demonstrate() - { - var options = new AuthorizationHeaderOptions - { - CredentialsDelimiter = ", ", - CredentialsKeyValueDelimiter = "=" - }; - - options.ValidateOptions(); + CredentialsDelimiter = ", ", + CredentialsKeyValueDelimiter = "=" +}; - Console.WriteLine(options.CredentialsDelimiter); - Console.WriteLine(options.CredentialsKeyValueDelimiter); - } -} +options.ValidateOptions(); +Console.WriteLine(options.CredentialsDelimiter); +Console.WriteLine(options.CredentialsKeyValueDelimiter); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationHandler.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationHandler.md index 010339568..59ad6c174 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationHandler.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationHandler.md @@ -7,42 +7,51 @@ example: The following example demonstrates how to register `BasicAuthenticationHandler` with ASP.NET Core authentication services. It sets up a `ServiceCollection`, registers the handler with a custom authenticator callback that validates credentials against hardcoded values, and builds the service provider. The handler is then resolved from DI and its configured realm is written to the console, confirming the authentication pipeline wires up correctly. ```csharp +// Program.cs using System; using System.Security.Claims; using Cuemon.AspNetCore.Authentication.Basic; using Microsoft.AspNetCore.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using MyApp.Examples; -namespace MyApp.Examples; +BasicAuthenticationHandlerExample.Demonstrate(); -public static class BasicAuthenticationHandlerExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class BasicAuthenticationHandlerExample { - var services = new ServiceCollection(); - - services.AddLogging(); - services.AddAuthentication(BasicAuthorizationHeader.Scheme) - .AddScheme(BasicAuthorizationHeader.Scheme, options => - { - options.Realm = "docs-example"; - options.RequireSecureConnection = false; - options.Authenticator = (username, password) => + public static void Demonstrate() + { + var services = new ServiceCollection(); + + services.AddLogging(); + services.AddAuthentication(BasicAuthorizationHeader.Scheme) + .AddScheme(BasicAuthorizationHeader.Scheme, options => { - if (username == "Agent" && password == "Test") + options.Realm = "docs-example"; + options.RequireSecureConnection = false; + options.Authenticator = (username, password) => { - return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, BasicAuthorizationHeader.Scheme)); - } + if (username == "Agent" && password == "Test") + { + return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, BasicAuthorizationHeader.Scheme)); + } - return null; - }; - }); + return null; + }; + }); - using var provider = services.BuildServiceProvider(); - var handler = provider.GetRequiredService(); + using var provider = services.BuildServiceProvider(); + var options = provider.GetRequiredService>().Get(BasicAuthorizationHeader.Scheme); - Console.WriteLine($"Authentication realm: {handler.Options.Realm}"); + Console.WriteLine($"Authentication realm: {options.Realm}"); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationMiddleware.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationMiddleware.md index 8aa46f3d8..6843a6bfa 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationMiddleware.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationMiddleware.md @@ -7,25 +7,21 @@ example: The following example demonstrates how to construct `BasicAuthenticationMiddleware` with inline option setup. ```csharp +// Program.cs using System; using System.Threading.Tasks; using Cuemon.AspNetCore.Authentication.Basic; -namespace MyApp.Examples; - -public static class BasicAuthenticationMiddlewareExample +var middleware = new BasicAuthenticationMiddleware(_ => Task.CompletedTask, options => { - public static void Demonstrate() - { - var middleware = new BasicAuthenticationMiddleware(_ => Task.CompletedTask, options => - { - options.Realm = "docs-example"; - options.RequireSecureConnection = false; - options.Authenticator = (username, password) => null; - }); - - Console.WriteLine(middleware.Options.Realm); - } -} + options.Realm = "docs-example"; + options.RequireSecureConnection = false; + options.Authenticator = (username, password) => null; +}); +Console.WriteLine(middleware.Options.Realm); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationOptions.md index cb584a677..adcf52200 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationOptions.md @@ -7,35 +7,31 @@ example: The following example demonstrates how to configure `BasicAuthenticationOptions` with a realm and authenticator delegate. ```csharp +// Program.cs using System; using System.Security.Claims; using Cuemon.AspNetCore.Authentication.Basic; -namespace MyApp.Examples; - -public static class BasicAuthenticationOptionsExample +var options = new BasicAuthenticationOptions { - public static void Demonstrate() + Realm = "docs-example", + RequireSecureConnection = false, + Authenticator = (username, password) => { - var options = new BasicAuthenticationOptions + if (username == "Agent" && password == "Test") { - Realm = "docs-example", - RequireSecureConnection = false, - Authenticator = (username, password) => - { - if (username == "Agent" && password == "Test") - { - return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, BasicAuthorizationHeader.Scheme)); - } - - return null; - } - }; - - options.ValidateOptions(); + return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, BasicAuthorizationHeader.Scheme)); + } - Console.WriteLine(options.Realm); + return null; } -} +}; +options.ValidateOptions(); + +Console.WriteLine(options.Realm); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticator.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticator.md index 80999bf5b..8f9546c66 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticator.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticator.md @@ -7,26 +7,23 @@ example: The following example demonstrates how to assign and invoke a delegate when validating a basic-auth username and password pair. ```csharp +// Program.cs using System; using System.Security.Claims; using Cuemon.AspNetCore.Authentication.Basic; -namespace MyApp.Examples; - -public static class BasicAuthenticatorExample +BasicAuthenticator authenticator = (username, password) => { - public static void Demonstrate() - { - BasicAuthenticator authenticator = (username, password) => - { - return username == "Agent" && password == "Test" - ? new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, BasicAuthorizationHeader.Scheme)) - : null; - }; + return username == "Agent" && password == "Test" + ? new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, BasicAuthorizationHeader.Scheme)) + : null; +}; - var principal = authenticator("Agent", "Test"); +var principal = authenticator("Agent", "Test"); - Console.WriteLine(principal?.Identity?.Name); - } -} +Console.WriteLine(principal?.Identity?.Name); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeader.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeader.md index 8579b0b94..cd555abf4 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeader.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeader.md @@ -7,21 +7,17 @@ example: The following example demonstrates how to serialize and parse a Basic authorization header. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Authentication.Basic; -namespace MyApp.Examples; - -public static class BasicAuthorizationHeaderExample -{ - public static void Demonstrate() - { - var header = new BasicAuthorizationHeader("Agent", "Test"); - var parsed = BasicAuthorizationHeader.Create(header.ToString()); - - Console.WriteLine(parsed.UserName); - Console.WriteLine(parsed.Password); - } -} +var header = new BasicAuthorizationHeader("Agent", "Test"); +var parsed = BasicAuthorizationHeader.Create(header.ToString()); +Console.WriteLine(parsed.UserName); +Console.WriteLine(parsed.Password); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeaderBuilder.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeaderBuilder.md index 6a3a78d03..1cb961d4e 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeaderBuilder.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeaderBuilder.md @@ -7,20 +7,17 @@ example: The following example demonstrates how to build a Basic Authorization header value using `BasicAuthorizationHeaderBuilder`. ```csharp +// Program.cs +using System; using Cuemon.AspNetCore.Authentication.Basic; -namespace MyApp.Examples; - -public class BasicAuthorizationHeaderBuilderExample -{ - public void Demonstrate() - { - var builder = new BasicAuthorizationHeaderBuilder(); - builder.AddUserName("alice"); - builder.AddPassword("password"); - var headerValue = builder.Build(); // "Basic YWxpY2U6cGFzc3dvcmQ=" - -} -} - +var builder = new BasicAuthorizationHeaderBuilder(); +builder.AddUserName("alice"); +builder.AddPassword("password"); +var headerValue = builder.Build(); // "Basic YWxpY2U6cGFzc3dvcmQ=" +Console.WriteLine(headerValue); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicFields.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicFields.md index 31ea99219..7453a9ff6 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicFields.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Basic.BasicFields.md @@ -7,24 +7,20 @@ example: The following example demonstrates how to use the field constants of `BasicFields` to construct a Basic authorization header. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Authentication.Basic; -namespace MyApp.Examples; - -public static class BasicFieldsExample -{ - public static void Demonstrate() - { - var builder = new BasicAuthorizationHeaderBuilder(); - builder.AddUserName("alice"); - builder.AddPassword("s3cret"); - var header = builder.Build(); - - Console.WriteLine(BasicAuthorizationHeader.Scheme); - Console.WriteLine(BasicFields.Realm); - Console.WriteLine(BasicFields.Credentials); - } -} +var builder = new BasicAuthorizationHeaderBuilder(); +builder.AddUserName("alice"); +builder.AddPassword("s3cret"); +var header = builder.Build(); +Console.WriteLine(BasicAuthorizationHeader.Scheme); +Console.WriteLine(BasicFields.Realm); +Console.WriteLine(BasicFields.Credentials); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationHandler.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationHandler.md index e68621afa..14cf69df9 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationHandler.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationHandler.md @@ -7,42 +7,51 @@ example: The following example demonstrates how to register `DigestAuthenticationHandler` with ASP.NET Core authentication services. It configures DI with `INonceTracker`, registers a digest authentication scheme with a username/password lookup callback, and builds the service provider. The handler is then resolved from DI and its configured realm is written to the console, verifying that digest authentication wiring is operational. ```csharp +// Program.cs using System; using System.Security.Claims; using Cuemon.AspNetCore.Authentication; using Cuemon.AspNetCore.Authentication.Digest; using Microsoft.AspNetCore.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using MyApp.Examples; -namespace MyApp.Examples; +DigestAuthenticationHandlerExample.Demonstrate(); -public static class DigestAuthenticationHandlerExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class DigestAuthenticationHandlerExample { - var services = new ServiceCollection(); - - services.AddLogging(); - services.AddSingleton(); - services.AddAuthentication(DigestAuthorizationHeader.Scheme) - .AddScheme(DigestAuthorizationHeader.Scheme, options => - { - options.Realm = "docs-example"; - options.RequireSecureConnection = false; - options.Authenticator = (string username, out string password) => + public static void Demonstrate() + { + var services = new ServiceCollection(); + + services.AddLogging(); + services.AddSingleton(); + services.AddAuthentication(DigestAuthorizationHeader.Scheme) + .AddScheme(DigestAuthorizationHeader.Scheme, options => { - password = username == "Agent" ? "Test" : null; - return password == null - ? null - : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, DigestAuthorizationHeader.Scheme)); - }; - }); - - using var provider = services.BuildServiceProvider(); - var handler = provider.GetRequiredService(); - - Console.WriteLine($"Authentication realm: {handler.Options.Realm}"); + options.Realm = "docs-example"; + options.RequireSecureConnection = false; + options.Authenticator = (string username, out string password) => + { + password = username == "Agent" ? "Test" : null; + return password == null + ? null + : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, DigestAuthorizationHeader.Scheme)); + }; + }); + + using var provider = services.BuildServiceProvider(); + var options = provider.GetRequiredService>().Get(DigestAuthorizationHeader.Scheme); + + Console.WriteLine($"Authentication realm: {options.Realm}"); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationMiddleware.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationMiddleware.md index afa669c88..1bf9ad040 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationMiddleware.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationMiddleware.md @@ -7,30 +7,38 @@ example: The following example demonstrates how to construct `DigestAuthenticationMiddleware` with inline option setup. ```csharp +// Program.cs using System; using System.Security.Claims; using System.Threading.Tasks; using Cuemon.AspNetCore.Authentication.Digest; +using MyApp.Examples; -namespace MyApp.Examples; +DigestAuthenticationMiddlewareExample.Demonstrate(); -public static class DigestAuthenticationMiddlewareExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class DigestAuthenticationMiddlewareExample { - var middleware = new DigestAuthenticationMiddleware(_ => Task.CompletedTask, options => + public static void Demonstrate() { - options.Realm = "docs-example"; - options.RequireSecureConnection = false; - options.Authenticator = (string username, out string password) => + var middleware = new DigestAuthenticationMiddleware(_ => Task.CompletedTask, options => { - password = username == "Agent" ? "Test" : null; - return password == null ? null : new ClaimsPrincipal(new ClaimsIdentity()); - }; - }); + options.Realm = "docs-example"; + options.RequireSecureConnection = false; + options.Authenticator = (string username, out string password) => + { + password = username == "Agent" ? "Test" : null; + return password == null ? null : new ClaimsPrincipal(new ClaimsIdentity()); + }; + }); - Console.WriteLine(middleware.Options.Realm); + Console.WriteLine(middleware.Options.Realm); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationOptions.md index e81f8956c..b02763c51 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationOptions.md @@ -7,34 +7,30 @@ example: The following example demonstrates how to configure `DigestAuthenticationOptions` with a realm, digest algorithm, and authenticator delegate. ```csharp +// Program.cs using System; using System.Security.Claims; using Cuemon.AspNetCore.Authentication.Digest; -namespace MyApp.Examples; - -public static class DigestAuthenticationOptionsExample +var options = new DigestAuthenticationOptions { - public static void Demonstrate() + DigestAlgorithm = DigestCryptoAlgorithm.Sha256, + Realm = "docs-example", + RequireSecureConnection = false, + Authenticator = (string username, out string password) => { - var options = new DigestAuthenticationOptions - { - DigestAlgorithm = DigestCryptoAlgorithm.Sha256, - Realm = "docs-example", - RequireSecureConnection = false, - Authenticator = (string username, out string password) => - { - password = username == "Agent" ? "Test" : null; - return password == null - ? null - : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, DigestAuthorizationHeader.Scheme)); - } - }; - - options.ValidateOptions(); - - Console.WriteLine(options.DigestAlgorithm); + password = username == "Agent" ? "Test" : null; + return password == null + ? null + : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, DigestAuthorizationHeader.Scheme)); } -} +}; +options.ValidateOptions(); + +Console.WriteLine(options.DigestAlgorithm); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticator.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticator.md index b799cd916..1fca83980 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticator.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticator.md @@ -7,28 +7,25 @@ example: The following example demonstrates how to assign and invoke a delegate when a digest-auth username resolves to a stored password. ```csharp +// Program.cs using System; using System.Security.Claims; using Cuemon.AspNetCore.Authentication.Digest; -namespace MyApp.Examples; - -public static class DigestAuthenticatorExample +DigestAuthenticator authenticator = (string username, out string password) => { - public static void Demonstrate() - { - DigestAuthenticator authenticator = (string username, out string password) => - { - password = username == "Agent" ? "Test" : null; - return password == null - ? null - : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, DigestAuthorizationHeader.Scheme)); - }; + password = username == "Agent" ? "Test" : null; + return password == null + ? null + : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, DigestAuthorizationHeader.Scheme)); +}; - var principal = authenticator("Agent", out var password); +var principal = authenticator("Agent", out var password); - Console.WriteLine(password); - Console.WriteLine(principal?.Identity?.Name); - } -} +Console.WriteLine(password); +Console.WriteLine(principal?.Identity?.Name); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeader.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeader.md index cb9dbd305..b48278135 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeader.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeader.md @@ -7,32 +7,28 @@ example: The following example demonstrates how to serialize and parse a Digest access authentication header. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Authentication.Digest; -namespace MyApp.Examples; +var header = new DigestAuthorizationHeader( + realm: "docs-example", + nonce: "abc123", + opaque: "opaque456", + algorithm: "SHA-256", + userName: "Agent", + uri: "/resource", + nc: "00000001", + cNonce: "client-nonce", + qop: "auth", + response: "deadbeef"); -public static class DigestAuthorizationHeaderExample -{ - public static void Demonstrate() - { - var header = new DigestAuthorizationHeader( - realm: "docs-example", - nonce: "abc123", - opaque: "opaque456", - algorithm: "SHA-256", - userName: "Agent", - uri: "/resource", - nc: "00000001", - cNonce: "client-nonce", - qop: "auth", - response: "deadbeef"); - - var parsed = DigestAuthorizationHeader.Create(header.ToString()); - - Console.WriteLine(parsed.UserName); - Console.WriteLine(parsed.Response); - } -} +var parsed = DigestAuthorizationHeader.Create(header.ToString()); +Console.WriteLine(parsed.UserName); +Console.WriteLine(parsed.Response); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeaderBuilder.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeaderBuilder.md index 01f80d664..2662fb79e 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeaderBuilder.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeaderBuilder.md @@ -7,36 +7,32 @@ example: The following example demonstrates how to build a Digest access authorization header from a challenge header. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Authentication.Digest; using Microsoft.AspNetCore.Http; using Microsoft.Net.Http.Headers; -namespace MyApp.Examples; - -public static class DigestAuthorizationHeaderBuilderExample +var headers = new HeaderDictionary { - public static void Demonstrate() - { - var headers = new HeaderDictionary - { - [HeaderNames.WWWAuthenticate] = "Digest realm=\"docs-example\", qop=\"auth, auth-int\", nonce=\"abc123\", opaque=\"opaque456\", stale=false, algorithm=SHA-256" - }; - - var builder = new DigestAuthorizationHeaderBuilder(DigestCryptoAlgorithm.Sha256) - .AddRealm("docs-example") - .AddUserName("Agent") - .AddUri("/resource") - .AddNc(1) - .AddCnonce("client-nonce") - .AddQopAuthentication() - .AddFromWwwAuthenticateHeader(headers) - .AddResponse("Test", "GET"); - - var header = builder.Build(); - - Console.WriteLine(header.ToString()); - } -} - + [HeaderNames.WWWAuthenticate] = "Digest realm=\"docs-example\", qop=\"auth, auth-int\", nonce=\"abc123\", opaque=\"opaque456\", stale=false, algorithm=SHA-256" +}; + +var builder = new DigestAuthorizationHeaderBuilder(DigestCryptoAlgorithm.Sha256) + .AddRealm("docs-example") + .AddUserName("Agent") + .AddUri("/resource") + .AddNc(1) + .AddCnonce("client-nonce") + .AddQopAuthentication() + .AddFromWwwAuthenticateHeader(headers) + .AddResponse("Test", "GET"); + +var header = builder.Build(); + +Console.WriteLine(header.ToString()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestCryptoAlgorithm.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestCryptoAlgorithm.md index a14d5bc3f..eeae62d70 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestCryptoAlgorithm.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestCryptoAlgorithm.md @@ -7,19 +7,15 @@ example: The following example demonstrates how `DigestCryptoAlgorithm` selects the hash algorithm used by `DigestAuthorizationHeaderBuilder`. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Authentication.Digest; -namespace MyApp.Examples; - -public static class DigestCryptoAlgorithmExample -{ - public static void Demonstrate() - { - var builder = new DigestAuthorizationHeaderBuilder(DigestCryptoAlgorithm.Sha512Slash256); - - Console.WriteLine(builder.DigestAlgorithm); - } -} +var builder = new DigestAuthorizationHeaderBuilder(DigestCryptoAlgorithm.Sha512Slash256); +Console.WriteLine(builder.DigestAlgorithm); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestFields.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestFields.md index 2b200b8b4..d6c7672ce 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestFields.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestFields.md @@ -7,26 +7,22 @@ example: The following example demonstrates how to use the field constants of `DigestFields` when building a Digest access authorization header. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Authentication.Digest; -namespace MyApp.Examples; - -public static class DigestFieldsExample -{ - public static void Demonstrate() - { - var builder = new DigestAuthorizationHeaderBuilder(DigestCryptoAlgorithm.Sha256); - builder.AddRealm("my-realm"); - builder.AddUserName("alice"); - builder.AddUri("/api/resource"); - builder.AddNc(1); - builder.AddCnonce(Guid.NewGuid().ToString("N")); - - Console.WriteLine(DigestFields.Realm); - Console.WriteLine(DigestFields.Nonce); - Console.WriteLine(DigestFields.QualityOfProtection); - } -} +var builder = new DigestAuthorizationHeaderBuilder(DigestCryptoAlgorithm.Sha256); +builder.AddRealm("my-realm"); +builder.AddUserName("alice"); +builder.AddUri("/api/resource"); +builder.AddNc(1); +builder.AddCnonce(Guid.NewGuid().ToString("N")); +Console.WriteLine(DigestFields.Realm); +Console.WriteLine(DigestFields.Nonce); +Console.WriteLine(DigestFields.QualityOfProtection); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestHashFactory.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestHashFactory.md index 23b1bdd15..4cfbf7fa1 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestHashFactory.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Digest.DigestHashFactory.md @@ -7,24 +7,20 @@ example: The following example demonstrates how to create a cryptographic hash instance using `DigestHashFactory` with a specified algorithm. ```csharp +// Program.cs using System; using System.Text; using Cuemon.AspNetCore.Authentication.Digest; using Cuemon.Security; -namespace MyApp.Examples; +Hash hash = DigestHashFactory.CreateCrypto(DigestCryptoAlgorithm.Sha256); -public static class DigestHashFactoryExample -{ - public static void Demonstrate() - { - Hash hash = DigestHashFactory.CreateCrypto(DigestCryptoAlgorithm.Sha256); - - var bytes = Encoding.UTF8.GetBytes("hello-world"); - var result = hash.ComputeHash(bytes); - - Console.WriteLine(result.ToHexadecimalString()); - } -} +var bytes = Encoding.UTF8.GetBytes("hello-world"); +var result = hash.ComputeHash(bytes); +Console.WriteLine(result.ToHexadecimalString()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationHandler.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationHandler.md index 169d0735d..9b0fc30e6 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationHandler.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationHandler.md @@ -7,41 +7,50 @@ example: The following example demonstrates how to register `HmacAuthenticationHandler` with ASP.NET Core authentication services. It creates a `ServiceCollection`, registers the handler under a custom HMAC scheme with a client ID/secret authenticator callback, and builds the service provider. The handler is resolved from DI and its configured scheme is written to the console, confirming that HMAC authentication configuration works end-to-end. ```csharp +// Program.cs using System; using System.Security.Claims; using Cuemon.AspNetCore.Authentication.Hmac; using Microsoft.AspNetCore.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using MyApp.Examples; -namespace MyApp.Examples; +HmacAuthenticationHandlerExample.Demonstrate(); -public static class HmacAuthenticationHandlerExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class HmacAuthenticationHandlerExample { - const string authenticationScheme = "hmac-docs"; - var services = new ServiceCollection(); - - services.AddLogging(); - services.AddAuthentication(authenticationScheme) - .AddScheme(authenticationScheme, options => - { - options.AuthenticationScheme = authenticationScheme; - options.RequireSecureConnection = false; - options.Authenticator = (string clientId, out string clientSecret) => + public static void Demonstrate() + { + const string authenticationScheme = "hmac-docs"; + var services = new ServiceCollection(); + + services.AddLogging(); + services.AddAuthentication(authenticationScheme) + .AddScheme(authenticationScheme, options => { - clientSecret = clientId == "Agent-Api" ? "Test" : null; - return clientSecret == null - ? null - : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, clientId) }, authenticationScheme)); - }; - }); - - using var provider = services.BuildServiceProvider(); - var handler = provider.GetRequiredService(); - - Console.WriteLine($"Authentication scheme: {handler.Options.AuthenticationScheme}"); + options.AuthenticationScheme = authenticationScheme; + options.RequireSecureConnection = false; + options.Authenticator = (string clientId, out string clientSecret) => + { + clientSecret = clientId == "Agent-Api" ? "Test" : null; + return clientSecret == null + ? null + : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, clientId) }, authenticationScheme)); + }; + }); + + using var provider = services.BuildServiceProvider(); + var options = provider.GetRequiredService>().Get(authenticationScheme); + + Console.WriteLine($"Authentication scheme: {options.AuthenticationScheme}"); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationMiddleware.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationMiddleware.md index a3954f910..be3eb30bd 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationMiddleware.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationMiddleware.md @@ -7,30 +7,38 @@ example: The following example demonstrates how to construct `HmacAuthenticationMiddleware` with inline option setup. ```csharp +// Program.cs using System; using System.Security.Claims; using System.Threading.Tasks; using Cuemon.AspNetCore.Authentication.Hmac; +using MyApp.Examples; -namespace MyApp.Examples; +HmacAuthenticationMiddlewareExample.Demonstrate(); -public static class HmacAuthenticationMiddlewareExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class HmacAuthenticationMiddlewareExample { - var middleware = new HmacAuthenticationMiddleware(_ => Task.CompletedTask, options => + public static void Demonstrate() { - options.AuthenticationScheme = "hmac-docs"; - options.RequireSecureConnection = false; - options.Authenticator = (string clientId, out string clientSecret) => + var middleware = new HmacAuthenticationMiddleware(_ => Task.CompletedTask, options => { - clientSecret = clientId == "Agent-Api" ? "Test" : null; - return clientSecret == null ? null : new ClaimsPrincipal(new ClaimsIdentity()); - }; - }); + options.AuthenticationScheme = "hmac-docs"; + options.RequireSecureConnection = false; + options.Authenticator = (string clientId, out string clientSecret) => + { + clientSecret = clientId == "Agent-Api" ? "Test" : null; + return clientSecret == null ? null : new ClaimsPrincipal(new ClaimsIdentity()); + }; + }); - Console.WriteLine(middleware.Options.AuthenticationScheme); + Console.WriteLine(middleware.Options.AuthenticationScheme); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationOptions.md index 7922776e2..d5f9f692f 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationOptions.md @@ -7,35 +7,31 @@ example: The following example demonstrates how to configure `HmacAuthenticationOptions` for HMAC request signing. ```csharp +// Program.cs using System; using System.Security.Claims; using Cuemon.AspNetCore.Authentication.Hmac; using Cuemon.Security.Cryptography; -namespace MyApp.Examples; - -public static class HmacAuthenticationOptionsExample +var options = new HmacAuthenticationOptions { - public static void Demonstrate() + AuthenticationScheme = "hmac-docs", + Algorithm = KeyedCryptoAlgorithm.HmacSha256, + RequireSecureConnection = false, + Authenticator = (string clientId, out string clientSecret) => { - var options = new HmacAuthenticationOptions - { - AuthenticationScheme = "hmac-docs", - Algorithm = KeyedCryptoAlgorithm.HmacSha256, - RequireSecureConnection = false, - Authenticator = (string clientId, out string clientSecret) => - { - clientSecret = clientId == "Agent-Api" ? "Test" : null; - return clientSecret == null - ? null - : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, clientId) }, "hmac-docs")); - } - }; - - options.ValidateOptions(); - - Console.WriteLine(options.AuthenticationScheme); + clientSecret = clientId == "Agent-Api" ? "Test" : null; + return clientSecret == null + ? null + : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, clientId) }, "hmac-docs")); } -} +}; +options.ValidateOptions(); + +Console.WriteLine(options.AuthenticationScheme); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticator.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticator.md index 24b275a91..b2714e2a3 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticator.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticator.md @@ -7,28 +7,25 @@ example: The following example demonstrates how to assign and invoke a delegate for client-id and shared-secret lookup. ```csharp +// Program.cs using System; using System.Security.Claims; using Cuemon.AspNetCore.Authentication.Hmac; -namespace MyApp.Examples; - -public static class HmacAuthenticatorExample +HmacAuthenticator authenticator = (string clientId, out string clientSecret) => { - public static void Demonstrate() - { - HmacAuthenticator authenticator = (string clientId, out string clientSecret) => - { - clientSecret = clientId == "Agent-Api" ? "Test" : null; - return clientSecret == null - ? null - : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, clientId) }, HmacFields.Scheme)); - }; + clientSecret = clientId == "Agent-Api" ? "Test" : null; + return clientSecret == null + ? null + : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, clientId) }, HmacFields.Scheme)); +}; - var principal = authenticator("Agent-Api", out var secret); +var principal = authenticator("Agent-Api", out var secret); - Console.WriteLine(secret); - Console.WriteLine(principal?.Identity?.Name); - } -} +Console.WriteLine(secret); +Console.WriteLine(principal?.Identity?.Name); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeader.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeader.md index a15f110d1..712874a15 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeader.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeader.md @@ -7,18 +7,17 @@ example: The following example demonstrates how to parse an HMAC Authorization header value. ```csharp +// Program.cs +using System; using Cuemon.AspNetCore.Authentication.Hmac; -namespace MyApp.Examples; - -public class HmacAuthorizationHeaderExample -{ - public void Demonstrate() - { - var header = HmacAuthorizationHeader.Create( - HmacFields.Scheme, - "HMAC Credential=alice/some-scope, SignedHeaders=date;host, Signature=abc123"); - var clientId = header.ClientId; // "alice" - } -} +var header = HmacAuthorizationHeader.Create( + HmacFields.Scheme, + "HMAC Credential=alice/some-scope, SignedHeaders=date;host, Signature=abc123"); +var clientId = header.ClientId; // "alice" +Console.WriteLine(clientId); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeaderBuilder.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeaderBuilder.md index dee289fac..272b5adcb 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeaderBuilder.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeaderBuilder.md @@ -7,31 +7,27 @@ example: The following example demonstrates how to build an HMAC authorization header for an outgoing HTTP request. ```csharp +// Program.cs using System; using System.Globalization; using System.Net.Http; using Cuemon.AspNetCore.Authentication.Hmac; -namespace MyApp.Examples; +using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cuemon.net/resource?name=Agent"); +request.Headers.Date = DateTimeOffset.Parse("2022-07-10T12:50:42Z", CultureInfo.InvariantCulture); +request.Headers.Host = "api.cuemon.net"; -public static class HmacAuthorizationHeaderBuilderExample -{ - public static void Demonstrate() - { - using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.cuemon.net/resource?name=Agent"); - request.Headers.Date = DateTimeOffset.Parse("2022-07-10T12:50:42Z", CultureInfo.InvariantCulture); - request.Headers.Host = "api.cuemon.net"; +var builder = new HmacAuthorizationHeaderBuilder() + .AddFromRequest(request) + .AddClientId("Agent-Api") + .AddClientSecret("Test") + .AddCredentialScope("20220710/us-east-1/docs/request"); - var builder = new HmacAuthorizationHeaderBuilder() - .AddFromRequest(request) - .AddClientId("Agent-Api") - .AddClientSecret("Test") - .AddCredentialScope("20220710/us-east-1/docs/request"); - - var header = builder.Build(); - - Console.WriteLine(header.ToString()); - } -} +var header = builder.Build(); +Console.WriteLine(header.ToString()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacFields.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacFields.md index a88ff94b2..7485cba3c 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacFields.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.Hmac.HmacFields.md @@ -7,32 +7,28 @@ example: The following example demonstrates how to reference the field constants of `HmacFields` when building an HMAC authorization header. ```csharp +// Program.cs using System; using System.Net.Http; using Cuemon.AspNetCore.Authentication.Hmac; -namespace MyApp.Examples; +using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.example.com/resource"); +request.Headers.Date = DateTimeOffset.UtcNow; +request.Headers.Host = "api.example.com"; -public static class HmacFieldsExample -{ - public static void Demonstrate() - { - using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.example.com/resource"); - request.Headers.Date = DateTimeOffset.UtcNow; - request.Headers.Host = "api.example.com"; +var builder = new HmacAuthorizationHeaderBuilder() + .AddFromRequest(request) + .AddClientId("my-client") + .AddClientSecret("my-secret") + .AddCredentialScope("20250101/us-east-1/service/aws4_request"); - var builder = new HmacAuthorizationHeaderBuilder() - .AddFromRequest(request) - .AddClientId("my-client") - .AddClientSecret("my-secret") - .AddCredentialScope("20250101/us-east-1/service/aws4_request"); - - var header = builder.Build(); - - Console.WriteLine(HmacFields.Scheme); - Console.WriteLine(HmacFields.SignedHeaders); - Console.WriteLine(HmacFields.CanonicalRequest); - } -} +var header = builder.Build(); +Console.WriteLine(HmacFields.Scheme); +Console.WriteLine(HmacFields.SignedHeaders); +Console.WriteLine(HmacFields.CanonicalRequest); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.MemoryNonceTracker.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.MemoryNonceTracker.md index 3983b3f77..7caf68143 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.MemoryNonceTracker.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.MemoryNonceTracker.md @@ -7,26 +7,22 @@ example: The following example demonstrates how to add, inspect, and remove nonce entries from the in-memory tracker. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Authentication; -namespace MyApp.Examples; +using var tracker = new MemoryNonceTracker(); -public static class MemoryNonceTrackerExample -{ - public static void Demonstrate() - { - using var tracker = new MemoryNonceTracker(); - - tracker.TryAddEntry("nonce-1", 7); - - if (tracker.TryGetEntry("nonce-1", out var entry)) - { - Console.WriteLine(entry.Count); - } +tracker.TryAddEntry("nonce-1", 7); - Console.WriteLine(tracker.TryRemoveEntry("nonce-1")); - } +if (tracker.TryGetEntry("nonce-1", out var entry)) +{ + Console.WriteLine(entry.Count); } +Console.WriteLine(tracker.TryRemoveEntry("nonce-1")); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Authentication.NonceTrackerEntry.md b/.docfx/api/types/Cuemon.AspNetCore.Authentication.NonceTrackerEntry.md index 7668f8906..3e21bd99d 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Authentication.NonceTrackerEntry.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Authentication.NonceTrackerEntry.md @@ -7,18 +7,14 @@ example: The following example demonstrates a nonce tracker entry that holds nonce data for authentication. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Authentication; -namespace MyApp.Examples; - -public class NonceTrackerEntryExample -{ - public void Demonstrate() - { - var entry = new NonceTrackerEntry(1, DateTime.UtcNow); - Console.WriteLine($"Count: {entry.Count}, Created: {entry.Created}"); - } -} - +var entry = new NonceTrackerEntry(1, DateTime.UtcNow); +Console.WriteLine($"Count: {entry.Count}, Created: {entry.Created}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Builder.MiddlewareBuilderFactory.md b/.docfx/api/types/Cuemon.AspNetCore.Builder.MiddlewareBuilderFactory.md index aee815b35..27ba66729 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Builder.MiddlewareBuilderFactory.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Builder.MiddlewareBuilderFactory.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to register a custom middleware in the application pipeline using `MiddlewareBuilderFactory`. ```csharp +// Program.cs using System; using System.Diagnostics; using System.Threading.Tasks; @@ -14,30 +15,37 @@ using Cuemon.AspNetCore.Builder; using Cuemon.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; +using MyApp.Examples; -namespace MyApp.Examples; +MiddlewareBuilderFactoryExample.Demonstrate(); -public class TimingMiddleware : Middleware +namespace MyApp.Examples { - public TimingMiddleware(RequestDelegate next) : base(next) { } - - public override async Task InvokeAsync(HttpContext context) + public class TimingMiddleware : Middleware { - var sw = Stopwatch.StartNew(); - await Next(context); - sw.Stop(); - Console.WriteLine($"{context.Request.Path} took {sw.ElapsedMilliseconds} ms"); + public TimingMiddleware(RequestDelegate next) : base(next) { } + + public override async Task InvokeAsync(HttpContext context) + { + var sw = Stopwatch.StartNew(); + await Next(context); + sw.Stop(); + Console.WriteLine($"{context.Request.Path} took {sw.ElapsedMilliseconds} ms"); + } } -} - -public static class MiddlewareBuilderFactoryExample -{ - public static void Demonstrate() + public static class MiddlewareBuilderFactoryExample { - var builder = WebApplication.CreateBuilder().Build(); + public static void Demonstrate() + { + var builder = WebApplication.CreateBuilder().Build(); - MiddlewareBuilderFactory.UseMiddleware(builder); + MiddlewareBuilderFactory.UseMiddleware(builder); + Console.WriteLine("TimingMiddleware registered."); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Configuration.CacheBustingOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Configuration.CacheBustingOptions.md index c3a31f76c..4d8fe836d 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Configuration.CacheBustingOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Configuration.CacheBustingOptions.md @@ -7,21 +7,20 @@ example: The following example demonstrates how to configure cache-busting options for static resources. ```csharp +// Program.cs using System; +using Cuemon; using Cuemon.Configuration; +using Cuemon.AspNetCore.Configuration; - namespace Cuemon.AspNetCore.Configuration; + var options = new CacheBustingOptions +{ + PreferredCasing = CasingMethod.UpperCase +}; - public static class CacheBustingOptionsExample - { - public static void Demonstrate() - { - var options = new CacheBustingOptions - { - PreferredCasing = CasingMethod.UpperCase - }; - - Console.WriteLine(options.PreferredCasing); - } - } +Console.WriteLine(options.PreferredCasing); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Configuration.DynamicCacheBusting.md b/.docfx/api/types/Cuemon.AspNetCore.Configuration.DynamicCacheBusting.md index 4d1676bf8..0d62b76ec 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Configuration.DynamicCacheBusting.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Configuration.DynamicCacheBusting.md @@ -7,30 +7,26 @@ example: The following example demonstrates how to use `DynamicCacheBusting` to resolve versioned static resource URLs at runtime. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.AspNetCore.Configuration; using Microsoft.Extensions.Options; -namespace MyApp.Examples; - -public class DynamicCacheBustingExample +var options = Options.Create(new DynamicCacheBustingOptions { - public void Demonstrate() - { - var options = Options.Create(new DynamicCacheBustingOptions - { - PreferredLength = 8, - PreferredCharacters = Alphanumeric.LettersAndNumbers, - TimeToLive = TimeSpan.FromHours(12) - }); - - var cacheBusting = new DynamicCacheBusting(options); + PreferredLength = 8, + PreferredCharacters = Alphanumeric.LettersAndNumbers, + TimeToLive = TimeSpan.FromHours(12) +}); - // Version is regenerated when the configured TimeToLive has elapsed. - string version = cacheBusting.Version; - Console.WriteLine(version); - } -} +var cacheBusting = new DynamicCacheBusting(options); +// Version is regenerated when the configured TimeToLive has elapsed. +string version = cacheBusting.Version; +Console.WriteLine(version); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Configuration.DynamicCacheBustingOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Configuration.DynamicCacheBustingOptions.md index 797d1ba25..5d4cdf601 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Configuration.DynamicCacheBustingOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Configuration.DynamicCacheBustingOptions.md @@ -7,25 +7,24 @@ example: The following example demonstrates configuration options for dynamic cache busting. ```csharp +// Program.cs using System; +using Cuemon; using Cuemon.Configuration; using Microsoft.Extensions.Options; +using Cuemon.AspNetCore.Configuration; - namespace Cuemon.AspNetCore.Configuration; + var options = new DynamicCacheBustingOptions +{ + PreferredCasing = CasingMethod.UpperCase, + PreferredLength = 6, + TimeToLive = TimeSpan.FromMinutes(5) +}; - public static class DynamicCacheBustingOptionsExample - { - public static void Demonstrate() - { - var options = new DynamicCacheBustingOptions - { - PreferredCasing = CasingMethod.UpperCase, - PreferredLength = 6, - TimeToLive = TimeSpan.FromMinutes(5) - }; - - var cacheBusting = new DynamicCacheBusting(Options.Create(options)); - Console.WriteLine(cacheBusting.Version); - } - } +var cacheBusting = new DynamicCacheBusting(Options.Create(options)); +Console.WriteLine(cacheBusting.Version); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptions.md index 8171e897c..0ede93ca2 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptions.md @@ -7,22 +7,20 @@ example: The following example demonstrates how to configure fault descriptor options for structured error responses. ```csharp +// Program.cs +using System; using Cuemon.AspNetCore.Diagnostics; using Cuemon.Diagnostics; -namespace MyApp.Examples; - -public class FaultDescriptorOptionsExample +var options = new FaultDescriptorOptions { - public void Demonstrate() - { - var options = new FaultDescriptorOptions - { - SensitivityDetails = FaultSensitivityDetails.FailureWithStackTrace, - RootHelpLink = new System.Uri("https://example.com/errors") - }; - -} -} + SensitivityDetails = FaultSensitivityDetails.FailureWithStackTrace, + RootHelpLink = new Uri("https://example.com/errors") +}; +Console.WriteLine(options.SensitivityDetails); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptionsDecoratorExtensions.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptionsDecoratorExtensions.md index 207d7705c..9922d0148 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptionsDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptionsDecoratorExtensions.md @@ -7,26 +7,26 @@ example: `FaultDescriptorOptionsDecoratorExtensions` provides extension methods on `Decorator.Enclose` for resolving HTTP exception descriptors from failure objects using `FaultDescriptorOptions`. This example creates a `FaultDescriptorOptions` instance and a `BadRequestException` as the failure input, then wraps the options with `Decorator.Enclose` and calls `TryResolveHttpExceptionDescriptor` with the failure and an `HttpContext`. The resolved descriptor's `StatusCode` is output as `400`, confirming the failure was correctly mapped to a `Bad Request` HTTP response. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.AspNetCore.Diagnostics; using Cuemon.AspNetCore.Http; using Microsoft.AspNetCore.Http; -namespace MyApp.Examples; +var options = new FaultDescriptorOptions(); +var failure = new BadRequestException("Bad request"); +var context = new DefaultHttpContext(); -public class FaultDescriptorOptionsDecoratorExtensionsExample -{ - public void Demonstrate(HttpContext context) - { - var options = new FaultDescriptorOptions(); - var failure = new BadRequestException("Bad request"); - Decorator.Enclose(options).TryResolveHttpExceptionDescriptor( - failure, - context, - descriptor => Console.WriteLine("Resolved descriptor"), - out var descriptor); - Console.WriteLine(descriptor.StatusCode); // 400 - } -} +Decorator.Enclose(options).TryResolveHttpExceptionDescriptor( + failure, + context, + descriptor => Console.WriteLine("Resolved descriptor"), + out var descriptor); + +Console.WriteLine(descriptor.StatusCode); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptor.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptor.md index 247876f3f..d008ed25d 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptor.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptor.md @@ -7,23 +7,21 @@ example: The following example demonstrates creating an HTTP exception descriptor with diagnostic evidence. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Http; +using Cuemon.AspNetCore.Diagnostics; - namespace Cuemon.AspNetCore.Diagnostics; + var descriptor = new HttpExceptionDescriptor(new BadRequestException()) +{ + Instance = new Uri("urn:request:42"), + RequestId = "req-42", + CorrelationId = "corr-42" +}; - public static class HttpExceptionDescriptorExample - { - public static void Demonstrate() - { - var descriptor = new HttpExceptionDescriptor(new BadRequestException()) - { - Instance = new Uri("urn:request:42"), - RequestId = "req-42", - CorrelationId = "corr-42" - }; - - Console.WriteLine($"{descriptor.StatusCode} {descriptor.Message}"); - } - } +Console.WriteLine($"{descriptor.StatusCode} {descriptor.Message}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorDecoratorExtensions.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorDecoratorExtensions.md index 76ed36d0e..5aac28423 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorDecoratorExtensions.md @@ -7,27 +7,25 @@ example: `HttpExceptionDescriptorDecoratorExtensions` provides extension methods on `Decorator.Enclose` for converting `HttpExceptionDescriptor` instances into ASP.NET Core `ProblemDetails` objects for structured API error responses. This example creates an `HttpExceptionDescriptor` from a `BadRequestException` with `CorrelationId`, `RequestId`, and `TraceId` set as context, then wraps it with `Decorator.Enclose` and calls `ToProblemDetails` with `FaultSensitivityDetails.None`. The resulting `ProblemDetails.Title` is printed to the console, showing the error output ready for serialization into an HTTP API response body. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.AspNetCore.Http; using Cuemon.Diagnostics; using Microsoft.AspNetCore.Mvc; +using Cuemon.AspNetCore.Diagnostics; -namespace Cuemon.AspNetCore.Diagnostics; - -public static class HttpExceptionDescriptorDecoratorExtensionsExample +var descriptor = new HttpExceptionDescriptor(new BadRequestException()) { - public static void Demonstrate() - { - var descriptor = new HttpExceptionDescriptor(new BadRequestException()) - { - CorrelationId = "corr-42", - RequestId = "req-42", - TraceId = "trace-42" - }; + CorrelationId = "corr-42", + RequestId = "req-42", + TraceId = "trace-42" +}; - ProblemDetails problem = Decorator.Enclose(descriptor).ToProblemDetails(FaultSensitivityDetails.None); - Console.WriteLine(problem.Title); - } -} +ProblemDetails problem = Decorator.Enclose(descriptor).ToProblemDetails(FaultSensitivityDetails.None); +Console.WriteLine(problem.Title); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseFormatter`1.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseFormatter`1.md index 21940db21..7f89d46cf 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseFormatter`1.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseFormatter`1.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to use to support content negotiation for exceptions. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; @@ -14,32 +15,40 @@ using System.Net.Http; using System.Net.Http.Headers; using Cuemon.Configuration; using Cuemon.Net.Http; +using Cuemon.AspNetCore.Diagnostics; -namespace Cuemon.AspNetCore.Diagnostics; +HttpExceptionDescriptorResponseFormatterExample.Demonstrate(); -public static class HttpExceptionDescriptorResponseFormatterExample +namespace Cuemon.AspNetCore.Diagnostics { - public static void Demonstrate() + public static class HttpExceptionDescriptorResponseFormatterExample { - var formatter = new HttpExceptionDescriptorResponseFormatter(_ => { }); - - formatter.Populate((exceptionDescriptor, mediaType) => - new StringContent($"{exceptionDescriptor.StatusCode}:{mediaType.MediaType}")); - - var exceptionDescriptor = new HttpExceptionDescriptor( - new InvalidOperationException("boom"), - 418, - "Teapot", - "Short and stout"); - - using var response = formatter.ExceptionDescriptorHandlers.First().ToHttpResponseMessage(exceptionDescriptor); - Console.WriteLine(response.Content.ReadAsStringAsync().GetAwaiter().GetResult()); - } - - private sealed class SampleFormatterOptions : IContentNegotiation, IParameterObject - { - public IReadOnlyCollection SupportedMediaTypes { get; } = - new[] { new MediaTypeHeaderValue("text/plain") }; + public static void Demonstrate() + { + var formatter = new HttpExceptionDescriptorResponseFormatter(_ => { }); + + formatter.Populate((exceptionDescriptor, mediaType) => + new StringContent($"{exceptionDescriptor.StatusCode}:{mediaType.MediaType}")); + + var exceptionDescriptor = new HttpExceptionDescriptor( + new InvalidOperationException("boom"), + 418, + "Teapot", + "Short and stout"); + + using var response = formatter.ExceptionDescriptorHandlers.First().ToHttpResponseMessage(exceptionDescriptor); + Console.WriteLine(response.Content.ReadAsStringAsync().GetAwaiter().GetResult()); + } + + private sealed class SampleFormatterOptions : IContentNegotiation, IParameterObject + { + public IReadOnlyCollection SupportedMediaTypes { get; } = + new[] { new MediaTypeHeaderValue("text/plain") }; + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandler.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandler.md index 7541540ea..1adb99e19 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandler.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandler.md @@ -7,21 +7,19 @@ example: The following example demonstrates how to use `HttpExceptionDescriptorResponseHandler` to write structured error responses. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Http; using Cuemon.Diagnostics; +using Cuemon.AspNetCore.Diagnostics; - namespace Cuemon.AspNetCore.Diagnostics; + var handler = HttpExceptionDescriptorResponseHandler.CreateDefaultFallbackHandler(FaultSensitivityDetails.None); +var exceptionDescriptor = new HttpExceptionDescriptor(new BadRequestException()); - public static class HttpExceptionDescriptorResponseHandlerExample - { - public static void Demonstrate() - { - var handler = HttpExceptionDescriptorResponseHandler.CreateDefaultFallbackHandler(FaultSensitivityDetails.None); - var exceptionDescriptor = new HttpExceptionDescriptor(new BadRequestException()); - - using var response = handler.ToHttpResponseMessage(exceptionDescriptor); - Console.WriteLine($"{(int)response.StatusCode} {handler.ContentType.MediaType}"); - } - } +using var response = handler.ToHttpResponseMessage(exceptionDescriptor); +Console.WriteLine($"{(int)response.StatusCode} {handler.ContentType.MediaType}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerDecoratorExtensions.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerDecoratorExtensions.md index 0b2700b4b..fec2ab2e7 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerDecoratorExtensions.md @@ -7,6 +7,8 @@ example: `HttpExceptionDescriptorResponseHandlerDecoratorExtensions` provides extension methods on `Decorator.Enclose` for registering additional response handlers that control how HTTP exception descriptors are serialized and returned. This example creates an initial `HttpExceptionDescriptorResponseHandler` for `application/json` with a `500 Internal Server Error` status, wraps a `List` containing it, and calls `AddResponseHandler` with an options delegate specifying a custom content type, `ContentFactory`, and `StatusCodeFactory`. After execution, the list contains both handlers configured for different response scenarios in the error pipeline. ```csharp +// Program.cs +using System; using System.Collections.Generic; using System.Net; using System.Net.Http; @@ -14,27 +16,24 @@ using System.Net.Http.Headers; using Cuemon; using Cuemon.AspNetCore.Diagnostics; -namespace MyApp.Examples; - -public class HttpExceptionDescriptorResponseHandlerDecoratorExtensionsExample -{ - public void Demonstrate() +var handler = new HttpExceptionDescriptorResponseHandler( + new MediaTypeHeaderValue("application/json"), + ed => new HttpResponseMessage(HttpStatusCode.InternalServerError) { - var handler = new HttpExceptionDescriptorResponseHandler( - new MediaTypeHeaderValue("application/json"), - ed => new HttpResponseMessage(HttpStatusCode.InternalServerError) - { - Content = new StringContent(ed.Message) - }); - var list = new List { handler }; + Content = new StringContent(ed.Message) + }); +var list = new List { handler }; - Decorator.Enclose(list).AddResponseHandler(o => - { - o.ContentType = new MediaTypeHeaderValue("application/json"); - o.ContentFactory = ed => new StringContent(ed.Message); - o.StatusCodeFactory = ed => HttpStatusCode.InternalServerError; - }); - } -} +Decorator.Enclose(list).AddResponseHandler(o => +{ + o.ContentType = new MediaTypeHeaderValue("application/json"); + o.ContentFactory = ed => new StringContent(ed.Message); + o.StatusCodeFactory = ed => HttpStatusCode.InternalServerError; +}); +Console.WriteLine($"Response handlers: {list.Count}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerOptions.md index d0f3e24b6..b4525023f 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerOptions.md @@ -7,24 +7,25 @@ example: The following example demonstrates response handler options for HTTP exception descriptors. ```csharp +// Program.cs +using System; using System.Net; using System.Net.Http; using System.Net.Http.Headers; +using Cuemon.AspNetCore.Diagnostics; - namespace Cuemon.AspNetCore.Diagnostics; + var options = new HttpExceptionDescriptorResponseHandlerOptions +{ + ContentType = new MediaTypeHeaderValue("text/plain"), + ContentFactory = exceptionDescriptor => new StringContent(exceptionDescriptor.Message), + StatusCodeFactory = exceptionDescriptor => (HttpStatusCode)exceptionDescriptor.StatusCode +}; - public static class HttpExceptionDescriptorResponseHandlerOptionsExample - { - public static void Demonstrate() - { - var options = new HttpExceptionDescriptorResponseHandlerOptions - { - ContentType = new MediaTypeHeaderValue("text/plain"), - ContentFactory = exceptionDescriptor => new StringContent(exceptionDescriptor.Message), - StatusCodeFactory = exceptionDescriptor => (HttpStatusCode)exceptionDescriptor.StatusCode - }; +options.ValidateOptions(); - options.ValidateOptions(); - } - } +Console.WriteLine(options.ContentType); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpFaultResolver.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpFaultResolver.md index 84c549ce6..a9c31e647 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpFaultResolver.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpFaultResolver.md @@ -7,27 +7,24 @@ example: The following example demonstrates how to create an HTTP fault resolver that maps exceptions to HTTP error responses. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Diagnostics; using Cuemon.Diagnostics; -namespace MyApp.Examples; +var resolver = new HttpFaultResolver( + exception => exception is ArgumentNullException, + exception => new HttpExceptionDescriptor(exception, 400, null, "Argument was null.")); -public class HttpFaultResolverExample +if (resolver.TryResolveFault(new ArgumentNullException("value"), out var descriptor)) { - public void Demonstrate() - { - var resolver = new HttpFaultResolver( - exception => exception is ArgumentNullException, - exception => new HttpExceptionDescriptor(exception, 400, null, "Argument was null.")); - - if (resolver.TryResolveFault(new ArgumentNullException("value"), out var descriptor)) - { - Console.WriteLine(descriptor.StatusCode); // 400 - } - - var resolved = resolver.TryResolveFault(new InvalidOperationException(), out _); - Console.WriteLine(resolved); // False - } + Console.WriteLine(descriptor.StatusCode); // 400 } + +var resolved = resolver.TryResolveFault(new InvalidOperationException(), out _); +Console.WriteLine(resolved); // False ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpFaultResolverDecoratorExtensions.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpFaultResolverDecoratorExtensions.md index 3c115fac6..5828fda9d 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpFaultResolverDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpFaultResolverDecoratorExtensions.md @@ -7,34 +7,42 @@ example: The following example demonstrates how to register fault resolvers using the decorator pattern over a list of `HttpFaultResolver`. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon.AspNetCore.Diagnostics; using Cuemon.AspNetCore.Http; - using Cuemon; -namespace Examples; +using Examples; + +Console.WriteLine(new FaultResolverRegistrationExample().RegisterResolvers()); -public class FaultResolverRegistrationExample +namespace Examples { - public IList RegisterResolvers() + public class FaultResolverRegistrationExample { - var resolvers = new List(); + public IList RegisterResolvers() + { + var resolvers = new List(); - // Add a resolver for NotFoundException (404) - Decorator.Enclose(resolvers).AddHttpFaultResolver( - message: "The requested resource was not found.", - helpLink: new Uri("https://example.com/errors/404")); + // Add a resolver for NotFoundException (404) + Decorator.Enclose(resolvers).AddHttpFaultResolver( + message: "The requested resource was not found.", + helpLink: new Uri("https://example.com/errors/404")); - // Add a resolver for UnauthorizedException (401) with a custom code - Decorator.Enclose(resolvers).AddHttpFaultResolver( - statusCode: 401, - code: "UNAUTHORIZED", - message: "Authentication is required."); + // Add a resolver for UnauthorizedException (401) with a custom code + Decorator.Enclose(resolvers).AddHttpFaultResolver( + statusCode: 401, + code: "UNAUTHORIZED", + message: "Authentication is required."); - return resolvers; + return resolvers; + } + } } -} - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpRequestEvidence.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpRequestEvidence.md index 420367ba1..ce13788fd 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpRequestEvidence.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.HttpRequestEvidence.md @@ -7,6 +7,7 @@ example: `HttpRequestEvidence` captures HTTP request diagnostic data including headers, query parameters, form data, and the request body for logging and debugging scenarios. This example sets up a `DefaultHttpContext` with a POST request to `https://api.example.com/orders`, including an `Authorization` header, `X-Trace-Id`, a `status=pending` query string, form data with `customerId=42`, and a captured request body. Key steps include constructing an `HttpRequestEvidence` from the request and supplying a custom body converter delegate that redacts sensitive values by replacing `"42"` with `"***"`. Console output displays each evidence property (location, method, headers, query, form, body, and redacted body). ```csharp +// Program.cs using System; using System.Collections.Generic; using System.IO; @@ -15,47 +16,36 @@ using Cuemon.AspNetCore.Diagnostics; using Microsoft.Extensions.Primitives; using Microsoft.AspNetCore.Http; -namespace MyApp.Diagnostics -{ - public class HttpRequestEvidenceExample +var context = new DefaultHttpContext(); +context.Request.Scheme = "https"; +context.Request.Host = new HostString("api.example.com"); +context.Request.Path = "/orders"; +context.Request.QueryString = new QueryString("?status=pending"); +context.Request.Method = HttpMethods.Post; +context.Request.ContentType = "application/x-www-form-urlencoded"; +context.Request.Headers["Authorization"] = "Bearer eyJhbGci..."; +context.Request.Headers["X-Trace-Id"] = "abc-123"; +context.Request.Form = new FormCollection( + new Dictionary { - public void Demonstrate() - { - var context = new DefaultHttpContext(); - context.Request.Scheme = "https"; - context.Request.Host = new HostString("api.example.com"); - context.Request.Path = "/orders"; - context.Request.QueryString = new QueryString("?status=pending"); - context.Request.Method = HttpMethods.Post; - context.Request.ContentType = "application/x-www-form-urlencoded"; - context.Request.Headers["Authorization"] = "Bearer eyJhbGci..."; - context.Request.Headers["X-Trace-Id"] = "abc-123"; - context.Request.Form = new FormCollection( - new Dictionary - { - { "customerId", "42" } - }); - - // Capture the request body so HttpRequestEvidence can retrieve it - var bodyBytes = Encoding.UTF8.GetBytes("customerId=42"); - context.Items[HttpRequestEvidence.HttpContextItemsKeyForCapturedRequestBody] = - new MemoryStream(bodyBytes); - - var evidence = new HttpRequestEvidence(context.Request); - - Console.WriteLine($"Location: {evidence.Location}"); - Console.WriteLine($"Method: {evidence.Method}"); - Console.WriteLine($"Auth Header: {evidence.Headers["Authorization"]}"); - Console.WriteLine($"Query: status={evidence.Query["status"]}"); - Console.WriteLine($"Form: customerId={evidence.Form["customerId"]}"); - Console.WriteLine($"Body: {evidence.Body}"); - - // Provide a custom body converter to redact sensitive data - var redacted = new HttpRequestEvidence(context.Request, - stream => new StreamReader(stream).ReadToEnd().Replace("42", "***")); - Console.WriteLine($"Redacted Body: {redacted.Body}"); - -}} -} - + { "customerId", "42" } + }); + +// Capture the request body so HttpRequestEvidence can retrieve it +var bodyBytes = Encoding.UTF8.GetBytes("customerId=42"); +context.Items[HttpRequestEvidence.HttpContextItemsKeyForCapturedRequestBody] = + new MemoryStream(bodyBytes); + +var evidence = new HttpRequestEvidence(context.Request); + +Console.WriteLine($"Location: {evidence.Location}"); +Console.WriteLine($"Method: {evidence.Method}"); +Console.WriteLine($"Auth Header: {evidence.Headers["Authorization"]}"); +Console.WriteLine($"Query: status={evidence.Query["status"]}"); +Console.WriteLine($"Form: customerId={evidence.Form["customerId"]}"); +Console.WriteLine($"Body: {evidence.Body}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.PreferredFaultDescriptor.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.PreferredFaultDescriptor.md index ad1bb1482..bff344d21 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.PreferredFaultDescriptor.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.PreferredFaultDescriptor.md @@ -7,16 +7,14 @@ example: The following example demonstrates how to use the enum to configure the error response format for the `FaultDescriptorFilter`. ```csharp +// Program.cs using System; +using Cuemon.AspNetCore.Diagnostics; -namespace Cuemon.AspNetCore.Diagnostics; - -public static class PreferredFaultDescriptorExample -{ - public static void Demonstrate() - { var preferredFormat = PreferredFaultDescriptor.ProblemDetails; Console.WriteLine(preferredFormat); - } -} ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTiming.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTiming.md index 3d0dc54d0..91aa00618 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTiming.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTiming.md @@ -7,20 +7,18 @@ example: The following example demonstrates how to use `ServerTiming` to communicate performance metrics via the Server-Timing header. ```csharp +// Program.cs using System; using System.Linq; +using Cuemon.AspNetCore.Diagnostics; - namespace Cuemon.AspNetCore.Diagnostics; + var timing = new ServerTiming(); +timing.AddServerTiming("db", TimeSpan.FromMilliseconds(12), "SQL query"); - public static class ServerTimingExample - { - public static void Demonstrate() - { - var timing = new ServerTiming(); - timing.AddServerTiming("db", TimeSpan.FromMilliseconds(12), "SQL query"); - - var metric = timing.Metrics.First(); - Console.WriteLine($"{metric.Name}:{metric.Duration}"); - } - } +var metric = timing.Metrics.First(); +Console.WriteLine($"{metric.Name}:{metric.Duration}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTimingMetric.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTimingMetric.md index e99fa942a..225f00ab2 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTimingMetric.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTimingMetric.md @@ -7,15 +7,10 @@ example: `ServerTimingMetric` records performance data points for the HTTP `Server-Timing` header, supporting metrics with or without duration and description. This example constructs three metrics — `"db-query"` with 135.2ms duration and a description, `"cache-hit"` as a marker-only metric, and `"redis-get"` with a 3.7ms duration — then integrates them with `IServerTiming` via `AddServerTiming` to build a complete server-timing collection. Key steps include creating metrics with various constructor overloads and iterating the final list. Console output shows header-value strings such as `db-query;dur=135.2;desc="Customer order lookup"` and `cache-hit`. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Diagnostics; -namespace MyApp.Diagnostics -{ - public class ServerTimingMetricExample - { - public void Demonstrate() - { // Record a metric for a database query var dbMetric = new ServerTimingMetric("db-query", TimeSpan.FromMilliseconds(135.2), @@ -48,7 +43,9 @@ namespace MyApp.Diagnostics { Console.WriteLine(metric); -}}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTimingMiddleware.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTimingMiddleware.md index 871895950..6af41d85a 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTimingMiddleware.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTimingMiddleware.md @@ -7,42 +7,53 @@ example: The following example demonstrates how to register and use `ServerTimingMiddleware` to emit `Server-Timing` performance metrics in the response header. ```csharp +// Program.cs using System; using System.Threading.Tasks; +using Cuemon.AspNetCore.Diagnostics; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; - namespace Cuemon.AspNetCore.Diagnostics; +await ServerTimingMiddlewareExample.DemonstrateAsync(); - public static class ServerTimingMiddlewareExample - { - public static async Task DemonstrateAsync() - { - var context = new DefaultHttpContext(); - var middleware = new ServerTimingMiddleware(httpContext => httpContext.Response.WriteAsync("Hello")); - - using var loggerFactory = LoggerFactory.Create(builder => { }); - var serverTiming = new ServerTiming(); - serverTiming.AddServerTiming("db", TimeSpan.FromMilliseconds(12), "SQL query"); - - await middleware.InvokeAsync( - context, - loggerFactory.CreateLogger(), - new SampleHostEnvironment(), - serverTiming, - Options.Create(new ServerTimingOptions { SuppressHeaderPredicate = _ => false })); - - Console.WriteLine(context.Response.Headers[ServerTiming.HeaderName].ToString()); - } - private sealed class SampleHostEnvironment : IHostEnvironment +namespace Cuemon.AspNetCore.Diagnostics +{ + public static class ServerTimingMiddlewareExample { - public string ApplicationName { get; set; } = "Docs"; - public IFileProvider ContentRootFileProvider { get; set; } = new NullFileProvider(); - public string ContentRootPath { get; set; } = "."; - public string EnvironmentName { get; set; } = Environments.Development; - } + public static async Task DemonstrateAsync() + { + var context = new DefaultHttpContext(); + var middleware = new ServerTimingMiddleware(httpContext => httpContext.Response.WriteAsync("Hello")); + + using var loggerFactory = LoggerFactory.Create(builder => { }); + var serverTiming = new ServerTiming(); + serverTiming.AddServerTiming("db", TimeSpan.FromMilliseconds(12), "SQL query"); + + await middleware.InvokeAsync( + context, + loggerFactory.CreateLogger(), + new SampleHostEnvironment(), + serverTiming, + Options.Create(new ServerTimingOptions { SuppressHeaderPredicate = _ => false })); + + // The middleware writes this header when the response starts. + Console.WriteLine($"{ServerTiming.HeaderName}: {string.Join(", ", serverTiming.Metrics)}"); } + + private sealed class SampleHostEnvironment : IHostEnvironment + { + public string ApplicationName { get; set; } = "Docs"; + public IFileProvider ContentRootFileProvider { get; set; } = new NullFileProvider(); + public string ContentRootPath { get; set; } = "."; + public string EnvironmentName { get; set; } = Environments.Development; + } + } +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTimingOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTimingOptions.md index 31ab5d8cd..09aff8012 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTimingOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Diagnostics.ServerTimingOptions.md @@ -7,21 +7,18 @@ example: The following example demonstrates how to configure `ServerTimingOptions`. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Diagnostics; -namespace MyApp.Examples; - -public class ServerTimingOptionsExample +var options = new ServerTimingOptions { - public void Demonstrate() - { - var options = new ServerTimingOptions - { - TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(10) - }; - -} -} + TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(10) +}; +Console.WriteLine($"Threshold: {options.TimeMeasureCompletedThreshold}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Hosting.HostingEnvironmentMiddleware.md b/.docfx/api/types/Cuemon.AspNetCore.Hosting.HostingEnvironmentMiddleware.md index 25b1d129e..a38f86f37 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Hosting.HostingEnvironmentMiddleware.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Hosting.HostingEnvironmentMiddleware.md @@ -7,37 +7,52 @@ example: The following example demonstrates how to register and use `HostingEnvironmentMiddleware` in the ASP.NET Core pipeline. ```csharp +// Program.cs using System; using System.Threading.Tasks; +using Cuemon.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; - namespace Cuemon.AspNetCore.Hosting; +await HostingEnvironmentMiddlewareExample.DemonstrateAsync(); - public static class HostingEnvironmentMiddlewareExample +namespace Cuemon.AspNetCore.Hosting +{ + public static class HostingEnvironmentMiddlewareExample + { + public static async Task DemonstrateAsync() { - public static async Task DemonstrateAsync() - { - var context = new DefaultHttpContext(); - var middleware = new HostingEnvironmentMiddleware( - httpContext => httpContext.Response.WriteAsync("Hello"), - Options.Create(new HostingEnvironmentOptions + var context = new DefaultHttpContext(); + var environment = new SampleHostEnvironment(); + var options = Options.Create(new HostingEnvironmentOptions { HeaderName = "X-Environment", SuppressHeaderPredicate = _ => false - })); + }); - await middleware.InvokeAsync(context, new SampleHostEnvironment()); - Console.WriteLine(context.Response.Headers["X-Environment"].ToString()); - } - private sealed class SampleHostEnvironment : IHostEnvironment - { - public string ApplicationName { get; set; } = "Docs"; - public IFileProvider ContentRootFileProvider { get; set; } = new NullFileProvider(); - public string ContentRootPath { get; set; } = "."; - public string EnvironmentName { get; set; } = Environments.Staging; - } + var middleware = new HostingEnvironmentMiddleware( + httpContext => httpContext.Response.WriteAsync("Hello"), + options); + + await middleware.InvokeAsync(context, environment); + + // The middleware writes this header when the response starts. + Console.WriteLine($"{options.Value.HeaderName}: {environment.EnvironmentName}"); } + + private sealed class SampleHostEnvironment : IHostEnvironment + { + public string ApplicationName { get; set; } = "Docs"; + public IFileProvider ContentRootFileProvider { get; set; } = new NullFileProvider(); + public string ContentRootPath { get; set; } = "."; + public string EnvironmentName { get; set; } = Environments.Staging; + } + } +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Hosting.HostingEnvironmentOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Hosting.HostingEnvironmentOptions.md index ab4a919ad..e1a0d0ad1 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Hosting.HostingEnvironmentOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Hosting.HostingEnvironmentOptions.md @@ -7,23 +7,21 @@ example: The following example demonstrates how to configure hosting environment options. ```csharp +// Program.cs using System; using Microsoft.Extensions.Hosting; +using Cuemon.AspNetCore.Hosting; - namespace Cuemon.AspNetCore.Hosting; + var options = new HostingEnvironmentOptions +{ + HeaderName = "X-Environment", + SuppressHeaderPredicate = environment => environment.IsProduction() +}; - public static class HostingEnvironmentOptionsExample - { - public static void Demonstrate() - { - var options = new HostingEnvironmentOptions - { - HeaderName = "X-Environment", - SuppressHeaderPredicate = environment => environment.IsProduction() - }; - - options.ValidateOptions(); - Console.WriteLine(options.HeaderName); - } - } +options.ValidateOptions(); +Console.WriteLine(options.HeaderName); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.BadRequestException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.BadRequestException.md index e2919d998..5109e8de6 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.BadRequestException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.BadRequestException.md @@ -7,22 +7,20 @@ example: The following example demonstrates how to use `BadRequestException` for model validation errors in an API controller. ```csharp +// Program.cs using System; +using Cuemon.AspNetCore.Http; -namespace Cuemon.AspNetCore.Http; +var missingFields = new[] { "email", "displayName" }; +var exception = new BadRequestException( + $"The JSON payload is missing required fields: {string.Join(", ", missingFields)}.", + new FormatException("Unexpected end of JSON input.")); -public static class BadRequestExceptionExample -{ - public static void Demonstrate() - { - var missingFields = new[] { "email", "displayName" }; - var exception = new BadRequestException( - $"The JSON payload is missing required fields: {string.Join(", ", missingFields)}.", - new FormatException("Unexpected end of JSON input.")); - - Console.WriteLine(exception.StatusCode); - Console.WriteLine(exception.Message); - Console.WriteLine(exception.InnerException?.Message); - } -} +Console.WriteLine(exception.StatusCode); +Console.WriteLine(exception.Message); +Console.WriteLine(exception.InnerException?.Message); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.ConflictException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.ConflictException.md index c4f6f2a59..c5f7876a8 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.ConflictException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.ConflictException.md @@ -7,48 +7,44 @@ example: The following example demonstrates how to use to signal HTTP 409 Conflict responses. It compares the default, custom-message, inner-exception, and status-code parsing paths before applying a timestamp check that represents optimistic concurrency in an application service. The console output exposes the status code, reason phrase, and caller-facing message that an API exception handler can return to a client. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Http; -namespace MyApp.Examples; +// Create a ConflictException with default message +var ex = new ConflictException(); +Console.WriteLine(ex.StatusCode); // 409 +Console.WriteLine(ex.ReasonPhrase); // Conflict +Console.WriteLine(ex.Message); // The request could not be completed due to a conflict... -public class ConflictExceptionExample +// Create with a custom message +var custom = new ConflictException("A record with the same email address already exists."); +Console.WriteLine(custom.Message); + +// Create with inner exception +var inner = new InvalidOperationException("Duplicate key violation."); +var withInner = new ConflictException("Resource update conflict.", inner); +Console.WriteLine(withInner.InnerException?.Message); // Duplicate key violation. + +// Use TryParse from the base class to resolve by status code +if (HttpStatusCodeException.TryParse(409, out var parsed)) { - public void Demonstrate() - { - // Create a ConflictException with default message - var ex = new ConflictException(); - Console.WriteLine(ex.StatusCode); // 409 - Console.WriteLine(ex.ReasonPhrase); // Conflict - Console.WriteLine(ex.Message); // The request could not be completed due to a conflict... - - // Create with a custom message - var custom = new ConflictException("A record with the same email address already exists."); - Console.WriteLine(custom.Message); - - // Create with inner exception - var inner = new InvalidOperationException("Duplicate key violation."); - var withInner = new ConflictException("Resource update conflict.", inner); - Console.WriteLine(withInner.InnerException?.Message); // Duplicate key violation. - - // Use TryParse from the base class to resolve by status code - if (HttpStatusCodeException.TryParse(409, out var parsed)) - { - Console.WriteLine(parsed.Message); // The request could not be completed due to a conflict. - Console.WriteLine(parsed.StatusCode); // 409 - } - - // Simulate a conflict check without throwing - var dbTimestamp = DateTime.UtcNow; - var clientTimestamp = dbTimestamp.AddHours(-1); - if (clientTimestamp < dbTimestamp) - { - var conflict = new ConflictException( - "The resource was modified by another user. Please refresh and retry."); - Console.WriteLine(conflict.Message); // The resource was modified by another user... - - } - } + Console.WriteLine(parsed.Message); // The request could not be completed due to a conflict. + Console.WriteLine(parsed.StatusCode); // 409 } +// Simulate a conflict check without throwing +var dbTimestamp = DateTime.UtcNow; +var clientTimestamp = dbTimestamp.AddHours(-1); +if (clientTimestamp < dbTimestamp) +{ + var conflict = new ConflictException( + "The resource was modified by another user. Please refresh and retry."); + Console.WriteLine(conflict.Message); // The resource was modified by another user... + +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.ForbiddenException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.ForbiddenException.md index 4166670b2..ca42b73b1 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.ForbiddenException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.ForbiddenException.md @@ -7,28 +7,25 @@ example: The following example demonstrates how to use `ForbiddenException` to reject unauthorized access in an authorization filter. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Http; -namespace MyApp.Examples; - -public class ForbiddenExceptionExample +try { - public void Demonstrate() + var userRole = "guest"; + if (userRole != "admin") { - try - { - var userRole = "guest"; - if (userRole != "admin") - { - throw new ForbiddenException("Only administrators can perform this action."); - } - } - catch (ForbiddenException ex) - { - Console.WriteLine(ex.StatusCode); // 403 - Console.WriteLine(ex.Message); // Only administrators can perform this action. - } + throw new ForbiddenException("Only administrators can perform this action."); } } +catch (ForbiddenException ex) +{ + Console.WriteLine(ex.StatusCode); // 403 + Console.WriteLine(ex.Message); // Only administrators can perform this action. +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.GoneException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.GoneException.md index cb59d3bec..a6a420c89 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.GoneException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.GoneException.md @@ -7,23 +7,32 @@ example: The following example demonstrates how to return a `GoneException` from a deprecated API endpoint that has been removed. ```csharp +// Program.cs using System; +using Cuemon.AspNetCore.Http; -namespace Cuemon.AspNetCore.Http; +GoneExceptionExample.Demonstrate(); -public static class GoneExceptionExample +namespace Cuemon.AspNetCore.Http { - public static void Demonstrate() + public static class GoneExceptionExample { - var exception = CreateArchivedEndpointException("/v1/orders"); + public static void Demonstrate() + { + var exception = CreateArchivedEndpointException("/v1/orders"); - Console.WriteLine(exception.Message); - Console.WriteLine(exception.StatusCode); - } + Console.WriteLine(exception.Message); + Console.WriteLine(exception.StatusCode); + } - private static GoneException CreateArchivedEndpointException(string route) - { - return new GoneException($"The resource at '{route}' has been retired."); + private static GoneException CreateArchivedEndpointException(string route) + { + return new GoneException($"The resource at '{route}' has been retired."); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.HeaderDictionaryDecoratorExtensions.md b/.docfx/api/types/Cuemon.AspNetCore.Http.HeaderDictionaryDecoratorExtensions.md index e8588b7a5..c40ba7201 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.HeaderDictionaryDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.HeaderDictionaryDecoratorExtensions.md @@ -7,6 +7,7 @@ example: `HeaderDictionaryDecoratorExtensions` provides extension methods on `Decorator.Enclose` for merging, sanitizing, and updating `IHeaderDictionary` instances. This example creates a target `HeaderDictionary` with `"X-Existing"` and a source with both `"X-Existing"` and `"X-New"`, then calls `AddRange` to selectively add only non-existing headers. It also demonstrates `AddOrUpdateHeader` with control-character sanitization (removing `\r\n` from a value) and `AddOrUpdateHeaders` to copy `HttpResponseMessage` response headers into the target. Console output confirms `"X-Existing"` retains its original value, `"X-New"` is added, sanitized headers are cleaned to `"helloworld"`, and response headers are merged as `"alpha,beta"`. ```csharp +// Program.cs using System; using System.Net.Http; using Cuemon; @@ -14,45 +15,39 @@ using Cuemon.AspNetCore.Http; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; -namespace MyApp.AspNetCore.Http +// Add non-existing headers from one dictionary into another +var target = new HeaderDictionary { - public class HeaderDictionaryDecoratorExtensionsExample - { - public void Demonstrate() - { - // Add non-existing headers from one dictionary into another - var target = new HeaderDictionary - { - { "X-Existing", "value1" } - }; + { "X-Existing", "value1" } +}; - var source = new HeaderDictionary - { - { "X-Existing", "value1" }, - { "X-New", "value2" } - }; - - // Only adds headers that do not already exist in target - Decorator.Enclose(target).AddRange(source); - - Console.WriteLine(target["X-Existing"]); // "value1" - Console.WriteLine(target["X-New"]); // "value2" +var source = new HeaderDictionary +{ + { "X-Existing", "value1" }, + { "X-New", "value2" } +}; - // Add or update a single header with control-character sanitization - Decorator.Enclose(target).AddOrUpdateHeader( - "X-Sanitized", new StringValues("hello\r\nworld"), useAsciiEncodingConversion: false); +// Only adds headers that do not already exist in target +Decorator.Enclose(target).AddRange(source); - Console.WriteLine(target["X-Sanitized"]); // "helloworld" +Console.WriteLine(target["X-Existing"]); // "value1" +Console.WriteLine(target["X-New"]); // "value2" - // Copy response headers into an IHeaderDictionary - using var response = new HttpResponseMessage(); - response.Headers.Add("X-Custom", new[] { "alpha", "beta" }); +// Add or update a single header with control-character sanitization +Decorator.Enclose(target).AddOrUpdateHeader( + "X-Sanitized", new StringValues("hello\r\nworld"), useAsciiEncodingConversion: false); - Decorator.Enclose(target).AddOrUpdateHeaders(response.Headers); +Console.WriteLine(target["X-Sanitized"]); // "helloworld" - Console.WriteLine(target["X-Custom"]); // "alpha,beta" +// Copy response headers into an IHeaderDictionary +using var response = new HttpResponseMessage(); +response.Headers.Add("X-Custom", new[] { "alpha", "beta" }); -}} -} +Decorator.Enclose(target).AddOrUpdateHeaders(response.Headers); +Console.WriteLine(target["X-Custom"]); // "alpha,beta" ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ApiKeyException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ApiKeyException.md index b587f6202..3907b7ce8 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ApiKeyException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ApiKeyException.md @@ -7,17 +7,15 @@ example: The following example demonstrates how a is used to signal that a request's API key header validation failed. ```csharp +// Program.cs using System; using Microsoft.AspNetCore.Http; +using Cuemon.AspNetCore.Http.Headers; - namespace Cuemon.AspNetCore.Http.Headers; - - public static class ApiKeyExceptionExample - { - public static void Demonstrate() - { - var exception = new ApiKeyException(StatusCodes.Status403Forbidden, "The API key was rejected."); - Console.WriteLine($"{exception.StatusCode} {exception.ReasonPhrase}"); - } - } + var exception = new ApiKeyException(StatusCodes.Status403Forbidden, "The API key was rejected."); +Console.WriteLine($"{exception.StatusCode} {exception.ReasonPhrase}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ApiKeySentinelMiddleware.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ApiKeySentinelMiddleware.md index 6f504c81b..98b28285d 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ApiKeySentinelMiddleware.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ApiKeySentinelMiddleware.md @@ -7,36 +7,45 @@ example: The following example demonstrates how to register and use `ApiKeySentinelMiddleware` in the ASP.NET Core pipeline. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; +using Cuemon.AspNetCore.Http.Headers; - namespace Cuemon.AspNetCore.Http.Headers; +await ApiKeySentinelMiddlewareExample.DemonstrateAsync(); - public static class ApiKeySentinelMiddlewareExample - { - public static async Task DemonstrateAsync() +namespace Cuemon.AspNetCore.Http.Headers +{ + public static class ApiKeySentinelMiddlewareExample { - var context = new DefaultHttpContext(); - var options = Options.Create(new ApiKeySentinelOptions - { - AllowedKeys = new List { "secret-key" } - }); + public static async Task DemonstrateAsync() + { + var context = new DefaultHttpContext(); + var options = Options.Create(new ApiKeySentinelOptions + { + AllowedKeys = new List { "secret-key" } + }); - context.Request.Headers[options.Value.HeaderName] = "secret-key"; + context.Request.Headers[options.Value.HeaderName] = "secret-key"; - var middleware = new ApiKeySentinelMiddleware( - httpContext => - { - httpContext.Response.StatusCode = StatusCodes.Status200OK; - return Task.CompletedTask; - }, - options); + var middleware = new ApiKeySentinelMiddleware( + httpContext => + { + httpContext.Response.StatusCode = StatusCodes.Status200OK; + return Task.CompletedTask; + }, + options); - await middleware.InvokeAsync(context); - Console.WriteLine(context.Response.StatusCode); + await middleware.InvokeAsync(context); + Console.WriteLine(context.Response.StatusCode); + } } - } +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ApiKeySentinelOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ApiKeySentinelOptions.md index 0717cf7bd..860f53245 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ApiKeySentinelOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ApiKeySentinelOptions.md @@ -7,24 +7,22 @@ example: The following example demonstrates configuring API key sentinel options. ```csharp +// Program.cs using System; using System.Collections.Generic; +using Cuemon.AspNetCore.Http.Headers; - namespace Cuemon.AspNetCore.Http.Headers; + var options = new ApiKeySentinelOptions +{ + AllowedKeys = new List { "secret-key" } +}; - public static class ApiKeySentinelOptionsExample - { - public static void Demonstrate() - { - var options = new ApiKeySentinelOptions - { - AllowedKeys = new List { "secret-key" } - }; - - options.ValidateOptions(); - using var response = options.ResponseHandler("wrong-key"); - var message = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); - Console.WriteLine(message); - } - } +options.ValidateOptions(); +using var response = options.ResponseHandler("wrong-key"); +var message = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); +Console.WriteLine(message); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CacheableMiddleware.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CacheableMiddleware.md index fa25bfeb4..b38f062d7 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CacheableMiddleware.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CacheableMiddleware.md @@ -7,37 +7,39 @@ example: The following example demonstrates how to register and use `CacheableMiddleware` in the ASP.NET Core pipeline. ```csharp +// Program.cs using System; +using System.Threading.Tasks; using Cuemon.AspNetCore.Builder; using Cuemon.AspNetCore.Http.Headers; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Microsoft.Net.Http.Headers; -namespace MyApp.Examples; +var services = new ServiceCollection(); +services.AddLogging(); +using var provider = services.BuildServiceProvider(); +var app = new ApplicationBuilder(provider); -public class CacheableMiddlewareExample +MiddlewareBuilderFactory.UseConfigurableMiddleware(app, options => { - public void Configure(IApplicationBuilder app) + options.CacheControl = new CacheControlHeaderValue { - // Standard registration via MiddlewareBuilderFactory (recommended) - MiddlewareBuilderFactory.UseConfigurableMiddleware(app, options => - { - options.CacheControl = new CacheControlHeaderValue - { - Public = true, - MaxAge = TimeSpan.FromDays(1) - }; - options.Expires = new ExpiresHeaderValue(TimeSpan.FromDays(1)); - }); - } + Public = true, + MaxAge = TimeSpan.FromDays(1) + }; + options.Expires = new ExpiresHeaderValue(TimeSpan.FromDays(1)); +}); - public void DirectInstantiation(RequestDelegate next, IOptions options) - { - // Direct usage of the CacheableMiddleware type - var middleware = new CacheableMiddleware(next, options); - Console.WriteLine($"Middleware created (CacheControl: {options.Value.UseCacheControl})"); - } -} +var cacheOptions = Options.Create(new CacheableOptions +{ + CacheControl = new CacheControlHeaderValue { Public = true, MaxAge = TimeSpan.FromDays(1) } +}); +var middleware = new CacheableMiddleware(_ => Task.CompletedTask, cacheOptions); +Console.WriteLine($"CacheControl enabled: {cacheOptions.Value.UseCacheControl}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CacheableOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CacheableOptions.md index 6fd38f1e3..0b292d2df 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CacheableOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CacheableOptions.md @@ -7,27 +7,25 @@ example: The following example shows how to configure `CacheableOptions` with cache-control and expiration headers. After validation, it prints whether each header type is enabled. ```csharp +// Program.cs using System; using Microsoft.Net.Http.Headers; +using Cuemon.AspNetCore.Http.Headers; - namespace Cuemon.AspNetCore.Http.Headers; + var options = new CacheableOptions +{ + CacheControl = new CacheControlHeaderValue + { + Public = true, + MaxAge = TimeSpan.FromHours(12) + }, + Expires = new ExpiresHeaderValue(TimeSpan.FromHours(12)) +}; - public static class CacheableOptionsExample - { - public static void Demonstrate() - { - var options = new CacheableOptions - { - CacheControl = new CacheControlHeaderValue - { - Public = true, - MaxAge = TimeSpan.FromHours(12) - }, - Expires = new ExpiresHeaderValue(TimeSpan.FromHours(12)) - }; - - options.ValidateOptions(); - Console.WriteLine($"{options.UseCacheControl}:{options.UseExpires}"); - } - } +options.ValidateOptions(); +Console.WriteLine($"{options.UseCacheControl}:{options.UseExpires}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ChecksumBuilderDecoratorExtensions.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ChecksumBuilderDecoratorExtensions.md index a7f16fc62..6241b3481 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ChecksumBuilderDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ChecksumBuilderDecoratorExtensions.md @@ -7,21 +7,19 @@ example: The following example demonstrates how to create an `EntityTagHeaderValue` from a `ChecksumBuilder` using the decorator pattern. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Data.Integrity; using Cuemon.Security; +using Cuemon.AspNetCore.Http.Headers; - namespace Cuemon.AspNetCore.Http.Headers; + var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); +var entityTag = Decorator.Enclose(builder).ToEntityTagHeaderValue(isWeak: true); - public static class ChecksumBuilderDecoratorExtensionsExample - { - public static void Demonstrate() - { - var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); - var entityTag = Decorator.Enclose(builder).ToEntityTagHeaderValue(isWeak: true); - - Console.WriteLine(entityTag.ToString()); - } - } +Console.WriteLine(entityTag.ToString()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierMiddleware.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierMiddleware.md index 7335aab50..c1e89af22 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierMiddleware.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierMiddleware.md @@ -7,7 +7,7 @@ example: The following example demonstrates how to register `CorrelationIdentifierMiddleware` in the ASP.NET Core pipeline with a custom header name and correlation token. It then reads the correlation ID from an endpoint to confirm the middleware is working. ```csharp -using System.Threading.Tasks; +// Program.cs using System; using Cuemon.AspNetCore.Http.Headers; using Cuemon.Messaging; @@ -16,37 +16,30 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -namespace MyApp.Http.Headers +var services = new ServiceCollection(); +services.AddLogging(); +services.Configure(options => { - public class CorrelationIdentifierMiddlewareRegistration - { - // Called from Startup.ConfigureServices or Program.cs - public void ConfigureServices(IServiceCollection services) - { - services.Configure(o => - { - // Use a custom header name - o.HeaderName = HttpHeaderNames.XCorrelationId; - // Provide a specific correlation token - o.Token = new CorrelationToken(); - }); - } + options.HeaderName = HttpHeaderNames.XCorrelationId; + options.Token = new CorrelationToken(); +}); - // Called from Startup.Configure or Program.cs - public void Configure(IApplicationBuilder app) - { - // Add the Correlation ID middleware to the pipeline - app.UseMiddleware(); +using var provider = services.BuildServiceProvider(); +var app = new ApplicationBuilder(provider); +app.UseMiddleware(); +app.Run(async context => +{ + var correlationId = context.Items[CorrelationIdentifierMiddleware.HttpContextItemsKey]; + await context.Response.WriteAsync($"Correlation ID: {correlationId}"); +}); - // Example endpoint that reads the correlation ID - app.Run(async context => - { - var correlationId = context.Items[CorrelationIdentifierMiddleware.HttpContextItemsKey]; - await context.Response.WriteAsync( - $"Correlation ID: {correlationId}"); - }); - } - } -} +var pipeline = app.Build(); +var httpContext = new DefaultHttpContext { RequestServices = provider }; +await pipeline(httpContext); +Console.WriteLine(httpContext.Items[CorrelationIdentifierMiddleware.HttpContextItemsKey]); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierOptions.md index d5f4d9c4a..4317a0320 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierOptions.md @@ -7,22 +7,20 @@ example: The following example shows how to configure `CorrelationIdentifierOptions` with a custom correlation token. After validation, it prints the token's correlation ID. ```csharp +// Program.cs using System; using Cuemon.Messaging; +using Cuemon.AspNetCore.Http.Headers; - namespace Cuemon.AspNetCore.Http.Headers; + var options = new CorrelationIdentifierOptions +{ + Token = new CorrelationToken("corr-42") +}; - public static class CorrelationIdentifierOptionsExample - { - public static void Demonstrate() - { - var options = new CorrelationIdentifierOptions - { - Token = new CorrelationToken("corr-42") - }; - - options.ValidateOptions(); - Console.WriteLine(options.Token.CorrelationId); - } - } +options.ValidateOptions(); +Console.WriteLine(options.Token.CorrelationId); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ExpiresHeaderValue.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ExpiresHeaderValue.md index 67b5dc047..778c82519 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ExpiresHeaderValue.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.ExpiresHeaderValue.md @@ -7,25 +7,20 @@ example: The following example demonstrates how to use to specify when a response should be considered stale. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Http.Headers; -namespace MyApp.Examples; +// Create an Expires header value that makes the response stale after 1 hour +var expires = new ExpiresHeaderValue(TimeSpan.FromHours(1)); -public class ExpiresHeaderValueExample -{ - public void Demonstrate() - { - // Create an Expires header value that makes the response stale after 1 hour - var expires = new ExpiresHeaderValue(TimeSpan.FromHours(1)); - - // The ToString() method produces the RFC 1123 format - string headerValue = expires.ToString(); - Console.WriteLine($"Expires: {headerValue}"); - - // Output example: "Expires: Thu, 17 Jun 2026 12:00:00 GMT" - -} -} +// The ToString() method produces the RFC 1123 format +string headerValue = expires.ToString(); +Console.WriteLine($"Expires: {headerValue}"); +// Output example: "Expires: Thu, 17 Jun 2026 12:00:00 GMT" ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.RequestIdentifierMiddleware.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.RequestIdentifierMiddleware.md index 76e039cc0..d96556bb8 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.RequestIdentifierMiddleware.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.RequestIdentifierMiddleware.md @@ -7,30 +7,30 @@ example: The following example demonstrates how to register the in the ASP.NET Core pipeline to add a unique Request-ID header to every response. ```csharp +// Program.cs using System; using System.Threading.Tasks; +using Cuemon.AspNetCore.Http.Headers; using Cuemon.Messaging; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; - namespace Cuemon.AspNetCore.Http.Headers; +var context = new DefaultHttpContext(); +var options = Options.Create(new RequestIdentifierOptions +{ + Token = new RequestToken("req-42") +}); - public static class RequestIdentifierMiddlewareExample - { - public static async Task DemonstrateAsync() - { - var context = new DefaultHttpContext(); - var options = Options.Create(new RequestIdentifierOptions - { - Token = new RequestToken("req-42") - }); +var middleware = new RequestIdentifierMiddleware( + httpContext => httpContext.Response.WriteAsync("Hello"), + options); - var middleware = new RequestIdentifierMiddleware( - httpContext => httpContext.Response.WriteAsync("Hello"), - options); +await middleware.InvokeAsync(context); - await middleware.InvokeAsync(context); - Console.WriteLine(context.Response.Headers[options.Value.HeaderName].ToString()); - } - } +// The middleware writes this header when the response starts. +Console.WriteLine($"{options.Value.HeaderName}: {options.Value.Token.RequestId}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.RequestIdentifierOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.RequestIdentifierOptions.md index d107a326a..a9f80df4a 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.RequestIdentifierOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.RequestIdentifierOptions.md @@ -7,22 +7,20 @@ example: The following example demonstrates how to configure to customize the Request-ID header name and token generator. ```csharp +// Program.cs using System; using Cuemon.Messaging; +using Cuemon.AspNetCore.Http.Headers; - namespace Cuemon.AspNetCore.Http.Headers; + var options = new RequestIdentifierOptions +{ + Token = new RequestToken("req-42") +}; - public static class RequestIdentifierOptionsExample - { - public static void Demonstrate() - { - var options = new RequestIdentifierOptions - { - Token = new RequestToken("req-42") - }; - - options.ValidateOptions(); - Console.WriteLine(options.Token.RequestId); - } - } +options.ValidateOptions(); +Console.WriteLine(options.Token.RequestId); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.RetryConditionScope.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.RetryConditionScope.md index 51c7afd98..092db26ca 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.RetryConditionScope.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.RetryConditionScope.md @@ -7,21 +7,19 @@ example: The following example demonstrates how to use `RetryConditionScope` to choose the format of a Retry-After header. It compares delta-seconds and absolute-date scopes and prints the resulting header value. ```csharp +// Program.cs using System; using System.Net.Http.Headers; +using Cuemon.AspNetCore.Http.Headers; -namespace Cuemon.AspNetCore.Http.Headers; +var scope = RetryConditionScope.DeltaSeconds; +string retryAfter = scope == RetryConditionScope.DeltaSeconds + ? new RetryConditionHeaderValue(TimeSpan.FromSeconds(30)).ToString() + : new RetryConditionHeaderValue(DateTimeOffset.UtcNow.AddMinutes(1)).ToString(); -public static class RetryConditionScopeExample -{ - public static void Demonstrate() - { - var scope = RetryConditionScope.DeltaSeconds; - string retryAfter = scope == RetryConditionScope.DeltaSeconds - ? new RetryConditionHeaderValue(TimeSpan.FromSeconds(30)).ToString() - : new RetryConditionHeaderValue(DateTimeOffset.UtcNow.AddMinutes(1)).ToString(); - - Console.WriteLine(retryAfter); - } -} +Console.WriteLine(retryAfter); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.UserAgentException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.UserAgentException.md index 303dfe829..0809ad10a 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.UserAgentException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.UserAgentException.md @@ -7,17 +7,15 @@ example: The following example demonstrates how a is used to signal that a request's User-Agent header was rejected. ```csharp +// Program.cs using System; using Microsoft.AspNetCore.Http; +using Cuemon.AspNetCore.Http.Headers; - namespace Cuemon.AspNetCore.Http.Headers; - - public static class UserAgentExceptionExample - { - public static void Demonstrate() - { - var exception = new UserAgentException(StatusCodes.Status400BadRequest, "The User-Agent header is required."); - Console.WriteLine($"{exception.StatusCode} {exception.ReasonPhrase}"); - } - } + var exception = new UserAgentException(StatusCodes.Status400BadRequest, "The User-Agent header is required."); +Console.WriteLine($"{exception.StatusCode} {exception.ReasonPhrase}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.UserAgentSentinelMiddleware.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.UserAgentSentinelMiddleware.md index f1badca4e..666cceae3 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.UserAgentSentinelMiddleware.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.UserAgentSentinelMiddleware.md @@ -7,39 +7,48 @@ example: The following example demonstrates how to register the to require a specific User-Agent header on incoming requests. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; using Microsoft.Net.Http.Headers; +using Cuemon.AspNetCore.Http.Headers; - namespace Cuemon.AspNetCore.Http.Headers; +await UserAgentSentinelMiddlewareExample.DemonstrateAsync(); - public static class UserAgentSentinelMiddlewareExample - { - public static async Task DemonstrateAsync() +namespace Cuemon.AspNetCore.Http.Headers +{ + public static class UserAgentSentinelMiddlewareExample { - var context = new DefaultHttpContext(); - var options = Options.Create(new UserAgentSentinelOptions - { - RequireUserAgentHeader = true, - ValidateUserAgentHeader = true, - AllowedUserAgents = new List { "Cuemon-Agent" } - }); - - context.Request.Headers[HeaderNames.UserAgent] = "Cuemon-Agent"; - - var middleware = new UserAgentSentinelMiddleware( - httpContext => + public static async Task DemonstrateAsync() + { + var context = new DefaultHttpContext(); + var options = Options.Create(new UserAgentSentinelOptions { - httpContext.Response.StatusCode = StatusCodes.Status200OK; - return Task.CompletedTask; - }, - options); + RequireUserAgentHeader = true, + ValidateUserAgentHeader = true, + AllowedUserAgents = new List { "Cuemon-Agent" } + }); - await middleware.InvokeAsync(context); - Console.WriteLine(context.Response.StatusCode); + context.Request.Headers[HeaderNames.UserAgent] = "Cuemon-Agent"; + + var middleware = new UserAgentSentinelMiddleware( + httpContext => + { + httpContext.Response.StatusCode = StatusCodes.Status200OK; + return Task.CompletedTask; + }, + options); + + await middleware.InvokeAsync(context); + Console.WriteLine(context.Response.StatusCode); + } } - } +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.UserAgentSentinelOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.UserAgentSentinelOptions.md index 38441c4b1..62cb03466 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.UserAgentSentinelOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.UserAgentSentinelOptions.md @@ -7,26 +7,24 @@ example: The following example demonstrates how to configure to restrict which User-Agent headers are allowed. ```csharp +// Program.cs using System; using System.Collections.Generic; +using Cuemon.AspNetCore.Http.Headers; - namespace Cuemon.AspNetCore.Http.Headers; + var options = new UserAgentSentinelOptions +{ + RequireUserAgentHeader = true, + ValidateUserAgentHeader = true, + AllowedUserAgents = new List { "Cuemon-Agent" } +}; - public static class UserAgentSentinelOptionsExample - { - public static void Demonstrate() - { - var options = new UserAgentSentinelOptions - { - RequireUserAgentHeader = true, - ValidateUserAgentHeader = true, - AllowedUserAgents = new List { "Cuemon-Agent" } - }; - - options.ValidateOptions(); - using var response = options.ResponseHandler("Unknown-Agent"); - var message = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); - Console.WriteLine(message); - } - } +options.ValidateOptions(); +using var response = options.ResponseHandler("Unknown-Agent"); +var message = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); +Console.WriteLine(message); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.VaryAcceptMiddleware.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.VaryAcceptMiddleware.md index 0392a8f99..f0450ac7e 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.VaryAcceptMiddleware.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Headers.VaryAcceptMiddleware.md @@ -7,22 +7,22 @@ example: The following example demonstrates how to register the to append a `Vary: Accept` header to every response. ```csharp +// Program.cs using System; using System.Threading.Tasks; +using Cuemon.AspNetCore.Http.Headers; using Microsoft.AspNetCore.Http; using Microsoft.Net.Http.Headers; - namespace Cuemon.AspNetCore.Http.Headers; +var context = new DefaultHttpContext(); +var middleware = new VaryAcceptMiddleware(httpContext => httpContext.Response.WriteAsync("Hello")); - public static class VaryAcceptMiddlewareExample - { - public static async Task DemonstrateAsync() - { - var context = new DefaultHttpContext(); - var middleware = new VaryAcceptMiddleware(httpContext => httpContext.Response.WriteAsync("Hello")); +await middleware.InvokeAsync(context); - await middleware.InvokeAsync(context); - Console.WriteLine(context.Response.Headers[HeaderNames.Vary].ToString()); - } - } +// The middleware writes this header when the response starts. +Console.WriteLine($"{HeaderNames.Vary}: {HeaderNames.Accept}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.HttpContextDecoratorExtensions.md b/.docfx/api/types/Cuemon.AspNetCore.Http.HttpContextDecoratorExtensions.md index e82a9d95d..a263a3747 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.HttpContextDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.HttpContextDecoratorExtensions.md @@ -7,6 +7,7 @@ example: `HttpContextDecoratorExtensions` provides extension methods on `Decorator.Enclose` for invoking throttling sentinels, API key sentinels, user-agent sentinels, and writing exception descriptor responses on `HttpContext`. This example configures a `DefaultHttpContext` with `"X-Api-Key: secret-key"` and `"User-Agent: Cuemon Docs"` headers, sets up `ThrottlingSentinelOptions` with a quota of 2 requests per minute, `ApiKeySentinelOptions` with allowed keys, and `UserAgentSentinelOptions`. Key steps include calling `InvokeThrottlerSentinelAsync`, `InvokeApiKeySentinelAsync`, and `InvokeUserAgentSentinelAsync`, then writing a `400 Bad Request` exception descriptor response via `WriteExceptionDescriptorResponseAsync`. Console output confirms the final response status code. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Net; @@ -20,46 +21,43 @@ using Cuemon.AspNetCore.Http.Throttling; using Microsoft.AspNetCore.Http; using Microsoft.Net.Http.Headers; using HttpMediaTypeHeaderValue = System.Net.Http.Headers.MediaTypeHeaderValue; +using Cuemon.AspNetCore.Http; -namespace Cuemon.AspNetCore.Http; +var context = new DefaultHttpContext(); +context.Request.Headers["X-Api-Key"] = "secret-key"; +context.Request.Headers[HeaderNames.UserAgent] = "Cuemon Docs"; -public static class HttpContextDecoratorExtensionsExample +var throttlingOptions = new ThrottlingSentinelOptions { - public static async Task DemonstrateAsync() - { - var context = new DefaultHttpContext(); - context.Request.Headers["X-Api-Key"] = "secret-key"; - context.Request.Headers[HeaderNames.UserAgent] = "Cuemon Docs"; - - var throttlingOptions = new ThrottlingSentinelOptions - { - ContextResolver = _ => "client-1", - Quota = new ThrottleQuota(2, TimeSpan.FromMinutes(1)) - }; + ContextResolver = _ => "client-1", + Quota = new ThrottleQuota(2, TimeSpan.FromMinutes(1)) +}; - await Decorator.Enclose(context).InvokeThrottlerSentinelAsync(new MemoryThrottlingCache(), throttlingOptions); +await Decorator.Enclose(context).InvokeThrottlerSentinelAsync(new MemoryThrottlingCache(), throttlingOptions); - var apiKeyOptions = new ApiKeySentinelOptions - { - AllowedKeys = new List { "secret-key" } - }; +var apiKeyOptions = new ApiKeySentinelOptions +{ + AllowedKeys = new List { "secret-key" } +}; - await Decorator.Enclose(context).InvokeApiKeySentinelAsync(apiKeyOptions); +await Decorator.Enclose(context).InvokeApiKeySentinelAsync(apiKeyOptions); - var userAgentOptions = new UserAgentSentinelOptions(); - await Decorator.Enclose(context).InvokeUserAgentSentinelAsync(userAgentOptions); +var userAgentOptions = new UserAgentSentinelOptions(); +await Decorator.Enclose(context).InvokeUserAgentSentinelAsync(userAgentOptions); - var handler = new HttpExceptionDescriptorResponseHandler( - new HttpMediaTypeHeaderValue("text/plain"), - exceptionDescriptor => new HttpResponseMessage((HttpStatusCode)exceptionDescriptor.StatusCode) - { - Content = new StringContent(exceptionDescriptor.Message) - }); +var handler = new HttpExceptionDescriptorResponseHandler( + new HttpMediaTypeHeaderValue("text/plain"), + exceptionDescriptor => new HttpResponseMessage((HttpStatusCode)exceptionDescriptor.StatusCode) + { + Content = new StringContent(exceptionDescriptor.Message) + }); - var descriptor = new HttpExceptionDescriptor(new InvalidOperationException("Bad request"), StatusCodes.Status400BadRequest); - await Decorator.Enclose(context).WriteExceptionDescriptorResponseAsync(handler, descriptor, CancellationToken.None); +var descriptor = new HttpExceptionDescriptor(new InvalidOperationException("Bad request"), StatusCodes.Status400BadRequest); +await Decorator.Enclose(context).WriteExceptionDescriptorResponseAsync(handler, descriptor, CancellationToken.None); - Console.WriteLine(context.Response.StatusCode); - } -} +Console.WriteLine(context.Response.StatusCode); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.HttpRequestDecoratorExtensions.md b/.docfx/api/types/Cuemon.AspNetCore.Http.HttpRequestDecoratorExtensions.md index 101fb7ad9..e2705090a 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.HttpRequestDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.HttpRequestDecoratorExtensions.md @@ -7,30 +7,28 @@ example: The following example demonstrates how to inspect HTTP request state using the class accessed through the class. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Data.Integrity; using Cuemon.Security; using Microsoft.AspNetCore.Http; using Microsoft.Net.Http.Headers; +using Cuemon.AspNetCore.Http; -namespace Cuemon.AspNetCore.Http; +var context = new DefaultHttpContext(); +context.Request.Method = HttpMethods.Get; -public static class HttpRequestDecoratorExtensionsExample -{ - public static void Demonstrate() - { - var context = new DefaultHttpContext(); - context.Request.Method = HttpMethods.Get; +var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); +context.Request.Headers[HeaderNames.IfNoneMatch] = + string.Concat("\"", builder.Checksum.ToHexadecimalString(), "\""); - var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); - context.Request.Headers[HeaderNames.IfNoneMatch] = - string.Concat("\"", builder.Checksum.ToHexadecimalString(), "\""); +var request = Decorator.Enclose(context.Request); +var canServeFromCache = request.IsGetOrHeadMethod() && request.IsClientSideResourceCached(builder); - var request = Decorator.Enclose(context.Request); - var canServeFromCache = request.IsGetOrHeadMethod() && request.IsClientSideResourceCached(builder); - - Console.WriteLine(canServeFromCache); - } -} +Console.WriteLine(canServeFromCache); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.HttpResponseDecoratorExtensions.md b/.docfx/api/types/Cuemon.AspNetCore.Http.HttpResponseDecoratorExtensions.md index 2c6ac9521..83aca1d13 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.HttpResponseDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.HttpResponseDecoratorExtensions.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to add ETag and Last-Modified HTTP response headers using the class accessed through the class. ```csharp +// Program.cs using System; using System.Text; using Cuemon; @@ -15,22 +16,18 @@ using Cuemon.Data.Integrity; using Cuemon.Security; using Microsoft.AspNetCore.Http; -namespace MyApp.Examples; +var context = new DefaultHttpContext(); +var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); +builder.CombineWith(Encoding.UTF8.GetBytes("content-data")); -public class HttpResponseDecoratorExtensionsExample -{ - public void AddCachingHeaders(HttpResponse response, HttpRequest request) - { - // Add an ETag header based on content integrity - var builder = new ChecksumBuilder(() => new FowlerNollVo64()); - builder.CombineWith(Encoding.UTF8.GetBytes("content-data")); - Decorator.Enclose(response).AddOrUpdateEntityTagHeader(request, builder); - - // Add a Last-Modified header - var lastModified = new DateTime(2025, 6, 1, 12, 0, 0, DateTimeKind.Utc); - Decorator.Enclose(response).AddOrUpdateLastModifiedHeader(request, lastModified); - -} -} +Decorator.Enclose(context.Response).AddOrUpdateEntityTagHeader(context.Request, builder); +var lastModified = new DateTime(2025, 6, 1, 12, 0, 0, DateTimeKind.Utc); +Decorator.Enclose(context.Response).AddOrUpdateLastModifiedHeader(context.Request, lastModified); +Console.WriteLine(context.Response.Headers.ETag.ToString()); +Console.WriteLine(context.Response.Headers.LastModified.ToString()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.HttpStatusCodeExceptionDecoratorExtensions.md b/.docfx/api/types/Cuemon.AspNetCore.Http.HttpStatusCodeExceptionDecoratorExtensions.md index 2a3c22aca..a3d05c163 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.HttpStatusCodeExceptionDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.HttpStatusCodeExceptionDecoratorExtensions.md @@ -7,34 +7,34 @@ example: The following example demonstrates how to add response headers to an `HttpStatusCodeException` using the decorator pattern. ```csharp +// Program.cs +using System; using System.Net.Http; using System.Net.Http.Headers; using Cuemon.AspNetCore.Http; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; - +using System.Linq; using Cuemon; -namespace Examples; -public class HttpStatusCodeExceptionHeadersExample +var exception = new NotFoundException("Resource not found."); +var headers = new HeaderDictionary { - public void AddHeadersToException() - { - var exception = new NotFoundException("Resource not found."); - var headers = new HeaderDictionary - { - { "X-Correlation-Id", new StringValues("abc-123") }, - { "X-Request-Id", new StringValues("req-456") } - }; - - Decorator.Enclose(exception).AddResponseHeaders(headers); + { "X-Correlation-Id", new StringValues("abc-123") }, + { "X-Request-Id", new StringValues("req-456") } +}; - using var message = new HttpResponseMessage(); - message.Headers.Add("X-Server-Id", "server-01"); +Decorator.Enclose(exception).AddResponseHeaders(headers); - Decorator.Enclose(exception).AddResponseHeaders(message.Headers); +using var message = new HttpResponseMessage(); +message.Headers.Add("X-Server-Id", "server-01"); -} -} +Decorator.Enclose(exception).AddResponseHeaders(message.Headers); +Console.WriteLine($"Correlation header: {headers["X-Correlation-Id"]}"); +Console.WriteLine($"Server header: {message.Headers.GetValues("X-Server-Id").First()}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Int32DecoratorExtensions.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Int32DecoratorExtensions.md index bc9885f13..1141f598a 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Int32DecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Int32DecoratorExtensions.md @@ -7,44 +7,38 @@ example: The following example demonstrates how to use the extension methods to classify HTTP status codes through the pattern. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.AspNetCore.Http; -namespace MyApp.Examples; - -public class Example -{ - public void Run() - { - - int statusCode = 500; - - // Wrap the int in a Decorator and use the extension methods - var decorator = Decorator.Enclose(statusCode); - - bool isInfo = decorator.IsInformationStatusCode(); - bool isSuccess = decorator.IsSuccessStatusCode(); - bool isRedirect = decorator.IsRedirectionStatusCode(); - bool isClientError = decorator.IsClientErrorStatusCode(); - bool isServerError = decorator.IsServerErrorStatusCode(); - bool isNotModified = decorator.IsNotModifiedStatusCode(); - - Console.WriteLine($"HTTP {statusCode}:"); - Console.WriteLine($" Informational (100-199): {isInfo}"); - Console.WriteLine($" Successful (200-299): {isSuccess}"); - Console.WriteLine($" Redirection (300-399): {isRedirect}"); - Console.WriteLine($" Client Error (400-499): {isClientError}"); - Console.WriteLine($" Server Error (500-599): {isServerError}"); - Console.WriteLine($" Not Modified (304): {isNotModified}"); - - // Use with a success status code - int ok = 200; - var okDecorator = Decorator.Enclose(ok); - Console.WriteLine($"\n{ok} is success: {okDecorator.IsSuccessStatusCode()}"); // True - Console.WriteLine($"404 is client error: {Decorator.Enclose(404).IsClientErrorStatusCode()}"); // True - -} -} - +int statusCode = 500; + +// Wrap the int in a Decorator and use the extension methods +var decorator = Decorator.Enclose(statusCode); + +bool isInfo = decorator.IsInformationStatusCode(); +bool isSuccess = decorator.IsSuccessStatusCode(); +bool isRedirect = decorator.IsRedirectionStatusCode(); +bool isClientError = decorator.IsClientErrorStatusCode(); +bool isServerError = decorator.IsServerErrorStatusCode(); +bool isNotModified = decorator.IsNotModifiedStatusCode(); + +Console.WriteLine($"HTTP {statusCode}:"); +Console.WriteLine($" Informational (100-199): {isInfo}"); +Console.WriteLine($" Successful (200-299): {isSuccess}"); +Console.WriteLine($" Redirection (300-399): {isRedirect}"); +Console.WriteLine($" Client Error (400-499): {isClientError}"); +Console.WriteLine($" Server Error (500-599): {isServerError}"); +Console.WriteLine($" Not Modified (304): {isNotModified}"); + +// Use with a success status code +int ok = 200; +var okDecorator = Decorator.Enclose(ok); +Console.WriteLine($"\n{ok} is success: {okDecorator.IsSuccessStatusCode()}"); // True +Console.WriteLine($"404 is client error: {Decorator.Enclose(404).IsClientErrorStatusCode()}"); // True ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.InternalServerErrorException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.InternalServerErrorException.md index 8dab158c1..34a3bada6 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.InternalServerErrorException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.InternalServerErrorException.md @@ -7,19 +7,17 @@ example: The following example demonstrates how to use `InternalServerErrorException` to represent an unexpected server-side failure in an exception handling middleware. ```csharp +// Program.cs using System; +using Cuemon.AspNetCore.Http; -namespace Cuemon.AspNetCore.Http; +var failure = new InvalidOperationException("The invoice pipeline failed to commit the transaction."); +var exception = new InternalServerErrorException(failure); -public static class InternalServerErrorExceptionExample -{ - public static void Demonstrate() - { - var failure = new InvalidOperationException("The invoice pipeline failed to commit the transaction."); - var exception = new InternalServerErrorException(failure); - - Console.WriteLine(exception.StatusCode); - Console.WriteLine(exception.InnerException?.Message); - } -} +Console.WriteLine(exception.StatusCode); +Console.WriteLine(exception.InnerException?.Message); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.MethodNotAllowedException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.MethodNotAllowedException.md index 408d64ce3..88e8ff4c5 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.MethodNotAllowedException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.MethodNotAllowedException.md @@ -7,19 +7,17 @@ example: The following example demonstrates how to use `MethodNotAllowedException` when a POST-only endpoint receives a GET request. ```csharp +// Program.cs using System; +using Cuemon.AspNetCore.Http; -namespace Cuemon.AspNetCore.Http; +var allowedMethods = string.Join(", ", new[] { "POST", "PUT" }); +var exception = new MethodNotAllowedException($"Only {allowedMethods} are supported for /orders."); -public static class MethodNotAllowedExceptionExample -{ - public static void Demonstrate() - { - var allowedMethods = string.Join(", ", new[] { "POST", "PUT" }); - var exception = new MethodNotAllowedException($"Only {allowedMethods} are supported for /orders."); - - Console.WriteLine(exception.Message); - Console.WriteLine(exception.StatusCode); - } -} +Console.WriteLine(exception.Message); +Console.WriteLine(exception.StatusCode); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.NotAcceptableException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.NotAcceptableException.md index 41f59ebd2..70c16c5b8 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.NotAcceptableException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.NotAcceptableException.md @@ -7,19 +7,17 @@ example: The following example demonstrates how to configure an ASP.NET Core MVC filter that returns a `NotAcceptableException`. ```csharp +// Program.cs using System; +using Cuemon.AspNetCore.Http; -namespace Cuemon.AspNetCore.Http; +var acceptHeader = "application/xml"; +var exception = new NotAcceptableException($"The endpoint cannot produce '{acceptHeader}'."); -public static class NotAcceptableExceptionExample -{ - public static void Demonstrate() - { - var acceptHeader = "application/xml"; - var exception = new NotAcceptableException($"The endpoint cannot produce '{acceptHeader}'."); - - Console.WriteLine(exception.Message); - Console.WriteLine(exception.StatusCode); - } -} +Console.WriteLine(exception.Message); +Console.WriteLine(exception.StatusCode); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.NotFoundException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.NotFoundException.md index db3d85e88..530b77c80 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.NotFoundException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.NotFoundException.md @@ -7,31 +7,40 @@ example: The following example demonstrates how to use `NotFoundException` when a requested resource does not exist. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Http; +using MyApp.Examples; -namespace MyApp.Examples; +new NotFoundExceptionExample().Demonstrate(); -public class NotFoundExceptionExample +namespace MyApp.Examples { - public void Demonstrate() + public class NotFoundExceptionExample { - try + public void Demonstrate() { - var userId = 999; - var user = FindUser(userId); - if (user == null) + try { - throw new NotFoundException($"User with ID {userId} was not found."); + var userId = 999; + var user = FindUser(userId); + if (user == null) + { + throw new NotFoundException($"User with ID {userId} was not found."); + } + } + catch (NotFoundException ex) + { + Console.WriteLine(ex.StatusCode); // 404 + Console.WriteLine(ex.Message); // User with ID 999 was not found. } } - catch (NotFoundException ex) - { - Console.WriteLine(ex.StatusCode); // 404 - Console.WriteLine(ex.Message); // User with ID 999 was not found. - } - } - private object FindUser(int id) => null; + private object FindUser(int id) => null; + } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.PayloadTooLargeException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.PayloadTooLargeException.md index 6391ec3d4..08134d3eb 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.PayloadTooLargeException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.PayloadTooLargeException.md @@ -7,48 +7,44 @@ example: The following example demonstrates how to use to signal HTTP 413 Payload Too Large responses. It constructs the exception with default and custom messages, wraps an inner exception, and uses `TryParse` to resolve by status code. A payload-size guard check then creates the exception conditionally. Each variant writes status code, reason phrase, and message to the console, showing how to communicate request-entity-size violations. ```csharp +// Program.cs using System.IO; using System; using Cuemon.AspNetCore.Http; -namespace MyApp.Examples; +// Create a PayloadTooLargeException with default message +var ex = new PayloadTooLargeException(); +Console.WriteLine(ex.StatusCode); // 413 +Console.WriteLine(ex.ReasonPhrase); // Payload Too Large -public class PayloadTooLargeExceptionExample +// Create with a custom message +var custom = new PayloadTooLargeException("Upload size exceeds the maximum of 10 MB."); +Console.WriteLine(custom.Message); + +// Create with inner exception +var inner = new InvalidOperationException("Stream exceeded configured limit."); +var withInner = new PayloadTooLargeException("Request entity too large.", inner); +Console.WriteLine(withInner.InnerException?.Message); // Stream exceeded configured limit. + +// Use TryParse from the base class to resolve by status code +if (HttpStatusCodeException.TryParse(413, "File exceeds 10 MB limit.", out var parsed)) { - public void Demonstrate() - { - // Create a PayloadTooLargeException with default message - var ex = new PayloadTooLargeException(); - Console.WriteLine(ex.StatusCode); // 413 - Console.WriteLine(ex.ReasonPhrase); // Payload Too Large - - // Create with a custom message - var custom = new PayloadTooLargeException("Upload size exceeds the maximum of 10 MB."); - Console.WriteLine(custom.Message); - - // Create with inner exception - var inner = new InvalidOperationException("Stream exceeded configured limit."); - var withInner = new PayloadTooLargeException("Request entity too large.", inner); - Console.WriteLine(withInner.InnerException?.Message); // Stream exceeded configured limit. - - // Use TryParse from the base class to resolve by status code - if (HttpStatusCodeException.TryParse(413, "File exceeds 10 MB limit.", out var parsed)) - { - Console.WriteLine(parsed.Message); // File exceeds 10 MB limit. - Console.WriteLine(parsed.StatusCode); // 413 - } - - // Simulate a payload size check - long uploadSize = 15 * 1024 * 1024; // 15 MB - long maxSize = 10 * 1024 * 1024; // 10 MB - if (uploadSize > maxSize) - { - var rejected = new PayloadTooLargeException( - $"Upload of {uploadSize / 1024 / 1024} MB exceeds the {maxSize / 1024 / 1024} MB limit."); - Console.WriteLine(rejected.Message); - - } - } + Console.WriteLine(parsed.Message); // File exceeds 10 MB limit. + Console.WriteLine(parsed.StatusCode); // 413 } +// Simulate a payload size check +long uploadSize = 15 * 1024 * 1024; // 15 MB +long maxSize = 10 * 1024 * 1024; // 10 MB +if (uploadSize > maxSize) +{ + var rejected = new PayloadTooLargeException( + $"Upload of {uploadSize / 1024 / 1024} MB exceeds the {maxSize / 1024 / 1024} MB limit."); + Console.WriteLine(rejected.Message); + +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.PreconditionFailedException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.PreconditionFailedException.md index b0298d9d9..670214efb 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.PreconditionFailedException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.PreconditionFailedException.md @@ -7,26 +7,24 @@ example: The following example demonstrates how to use `PreconditionFailedException` when a conditional request header check fails. ```csharp +// Program.cs using System; +using Cuemon.AspNetCore.Http; -namespace Cuemon.AspNetCore.Http; - -public static class PreconditionFailedExceptionExample +const string currentEtag = "\"v2\""; +const string suppliedEtag = "\"v1\""; +if (!string.Equals(suppliedEtag, currentEtag, StringComparison.Ordinal)) { - public static void Demonstrate() - { - const string currentEtag = "\"v2\""; - const string suppliedEtag = "\"v1\""; - if (!string.Equals(suppliedEtag, currentEtag, StringComparison.Ordinal)) - { - var exception = new PreconditionFailedException( - $"The supplied If-Match value {suppliedEtag} does not match the current ETag {currentEtag}.", - new InvalidOperationException("The resource changed after the client read it.")); + var exception = new PreconditionFailedException( + $"The supplied If-Match value {suppliedEtag} does not match the current ETag {currentEtag}.", + new InvalidOperationException("The resource changed after the client read it.")); - Console.WriteLine(exception.StatusCode); - Console.WriteLine(exception.Message); - Console.WriteLine(exception.InnerException?.Message); - } - } + Console.WriteLine(exception.StatusCode); + Console.WriteLine(exception.Message); + Console.WriteLine(exception.InnerException?.Message); } ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.PreconditionRequiredException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.PreconditionRequiredException.md index 4872b6453..1a365a609 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.PreconditionRequiredException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.PreconditionRequiredException.md @@ -7,21 +7,19 @@ example: The following example demonstrates how to use `PreconditionRequiredException` when a request requires conditional headers. ```csharp +// Program.cs using System; +using Cuemon.AspNetCore.Http; -namespace Cuemon.AspNetCore.Http; +var hasConditionHeader = false; +var exception = hasConditionHeader + ? new PreconditionRequiredException() + : new PreconditionRequiredException("Supply an If-Match header before retrying the update."); -public static class PreconditionRequiredExceptionExample -{ - public static void Demonstrate() - { - var hasConditionHeader = false; - var exception = hasConditionHeader - ? new PreconditionRequiredException() - : new PreconditionRequiredException("Supply an If-Match header before retrying the update."); - - Console.WriteLine(exception.Message); - Console.WriteLine(exception.StatusCode); - } -} +Console.WriteLine(exception.Message); +Console.WriteLine(exception.StatusCode); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.MemoryThrottlingCache.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.MemoryThrottlingCache.md index 0e6003764..e29358dcb 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.MemoryThrottlingCache.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.MemoryThrottlingCache.md @@ -7,19 +7,17 @@ example: The following example shows how to create a `MemoryThrottlingCache`, add a throttle request for a client, and retrieve the request count from the cache. ```csharp +// Program.cs using System; +using Cuemon.AspNetCore.Http.Throttling; -namespace Cuemon.AspNetCore.Http.Throttling; - -public static class MemoryThrottlingCacheExample -{ - public static void Demonstrate() - { var cache = new MemoryThrottlingCache(); var request = new ThrottleRequest(new ThrottleQuota(10, TimeSpan.FromMinutes(1))); cache.TryAdd("client-1", request); Console.WriteLine(cache["client-1"].Total); - } -} ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottleQuota.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottleQuota.md index 478163c21..5d171eb1c 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottleQuota.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottleQuota.md @@ -7,42 +7,37 @@ example: The following example demonstrates how to create `ThrottleQuota` instances using different time units and a `TimeSpan` directly. It then tracks request usage with `ThrottleRequest`, including incrementing and refreshing the window. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.AspNetCore.Http.Throttling; -namespace MyApp.Http.Throttling -{ - public class ThrottleQuotaExample - { - public void Demonstrate() - { - // Allow 100 requests per 1 minute window - var quotaPerMinute = new ThrottleQuota(100, 1, TimeUnit.Minutes); - Console.WriteLine($"Rate limit: {quotaPerMinute.RateLimit}"); - Console.WriteLine($"Window: {quotaPerMinute.Window.TotalMinutes} min"); +// Allow 100 requests per 1 minute window +var quotaPerMinute = new ThrottleQuota(100, 1, TimeUnit.Minutes); +Console.WriteLine($"Rate limit: {quotaPerMinute.RateLimit}"); +Console.WriteLine($"Window: {quotaPerMinute.Window.TotalMinutes} min"); - // Allow 1000 requests per 1 hour window (using TimeSpan directly) - var quotaPerHour = new ThrottleQuota(1000, TimeSpan.FromHours(1)); - Console.WriteLine($"Rate limit: {quotaPerHour.RateLimit}"); - Console.WriteLine($"Window: {quotaPerHour.Window.TotalHours} h"); +// Allow 1000 requests per 1 hour window (using TimeSpan directly) +var quotaPerHour = new ThrottleQuota(1000, TimeSpan.FromHours(1)); +Console.WriteLine($"Rate limit: {quotaPerHour.RateLimit}"); +Console.WriteLine($"Window: {quotaPerHour.Window.TotalHours} h"); - // Allow 10 requests per 15 seconds - var quotaPer15Sec = new ThrottleQuota(10, 15, TimeUnit.Seconds); - Console.WriteLine($"Rate limit: {quotaPer15Sec.RateLimit}"); - Console.WriteLine($"Window: {quotaPer15Sec.Window.TotalSeconds} s"); +// Allow 10 requests per 15 seconds +var quotaPer15Sec = new ThrottleQuota(10, 15, TimeUnit.Seconds); +Console.WriteLine($"Rate limit: {quotaPer15Sec.RateLimit}"); +Console.WriteLine($"Window: {quotaPer15Sec.Window.TotalSeconds} s"); - // Use with ThrottleRequest to track usage - var request = new ThrottleRequest(quotaPerMinute); - Console.WriteLine($"Initial total: {request.Total}"); - Console.WriteLine($"Expires at: {request.Expires:R}"); +// Use with ThrottleRequest to track usage +var request = new ThrottleRequest(quotaPerMinute); +Console.WriteLine($"Initial total: {request.Total}"); +Console.WriteLine($"Expires at: {request.Expires:R}"); - request.IncrementTotal(); - Console.WriteLine($"After one request: {request.Total}"); - - request.Refresh(); // resets if window has expired - -}} -} +request.IncrementTotal(); +Console.WriteLine($"After one request: {request.Total}"); +request.Refresh(); // resets if window has expired ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottleRequest.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottleRequest.md index 6ecfddeb8..42469feba 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottleRequest.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottleRequest.md @@ -7,18 +7,16 @@ example: The following example demonstrates how to use to track HTTP request usage and quota in a throttling scenario. ```csharp +// Program.cs using System; +using Cuemon.AspNetCore.Http.Throttling; -namespace Cuemon.AspNetCore.Http.Throttling; - -public static class ThrottleRequestExample -{ - public static void Demonstrate() - { var request = new ThrottleRequest(new ThrottleQuota(10, TimeSpan.FromMinutes(1))); request.IncrementTotal(); Console.WriteLine(request.Total); - } -} ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottlingException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottlingException.md index 5a4a19ca4..131242f78 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottlingException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottlingException.md @@ -7,33 +7,30 @@ example: The following example demonstrates how a is thrown when a request rate limit has been exceeded. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Http.Throttling; -namespace MyApp.Examples; - -public class ThrottlingExceptionExample +try +{ + // Simulate a rate-limit violation + var resetTime = DateTime.UtcNow.AddMinutes(5); + throw new ThrottlingException( + "API rate limit exceeded.", + rateLimit: 100, + delta: TimeSpan.FromMinutes(5), + reset: resetTime); +} +catch (ThrottlingException ex) { - public void Demonstrate() - { - try - { - // Simulate a rate-limit violation - var resetTime = DateTime.UtcNow.AddMinutes(5); - throw new ThrottlingException( - "API rate limit exceeded.", - rateLimit: 100, - delta: TimeSpan.FromMinutes(5), - reset: resetTime); - } - catch (ThrottlingException ex) - { - Console.WriteLine($"Message: {ex.Message}"); // API rate limit exceeded. - Console.WriteLine($"RateLimit: {ex.RateLimit}"); // 100 - Console.WriteLine($"Delta: {ex.Delta.TotalMinutes} minutes"); // 5 - Console.WriteLine($"Reset: {ex.Reset}"); // UTC reset time - Console.WriteLine($"StatusCode: {ex.StatusCode}"); // 429 - } - } + Console.WriteLine($"Message: {ex.Message}"); // API rate limit exceeded. + Console.WriteLine($"RateLimit: {ex.RateLimit}"); // 100 + Console.WriteLine($"Delta: {ex.Delta.TotalMinutes} minutes"); // 5 + Console.WriteLine($"Reset: {ex.Reset}"); // UTC reset time + Console.WriteLine($"StatusCode: {ex.StatusCode}"); // 429 } ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelMiddleware.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelMiddleware.md index a67a00215..f435f4053 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelMiddleware.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelMiddleware.md @@ -7,34 +7,43 @@ example: The following example demonstrates how to register the to enforce rate limiting in the ASP.NET Core pipeline. ```csharp +// Program.cs using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; +using Cuemon.AspNetCore.Http.Throttling; - namespace Cuemon.AspNetCore.Http.Throttling; +await ThrottlingSentinelMiddlewareExample.DemonstrateAsync(); - public static class ThrottlingSentinelMiddlewareExample - { - public static async Task DemonstrateAsync() +namespace Cuemon.AspNetCore.Http.Throttling +{ + public static class ThrottlingSentinelMiddlewareExample { - var context = new DefaultHttpContext(); - var options = Options.Create(new ThrottlingSentinelOptions - { - ContextResolver = _ => "client-1", - Quota = new ThrottleQuota(10, TimeSpan.FromMinutes(1)) - }); - - var middleware = new ThrottlingSentinelMiddleware( - httpContext => + public static async Task DemonstrateAsync() + { + var context = new DefaultHttpContext(); + var options = Options.Create(new ThrottlingSentinelOptions { - httpContext.Response.StatusCode = StatusCodes.Status200OK; - return Task.CompletedTask; - }, - options); + ContextResolver = _ => "client-1", + Quota = new ThrottleQuota(10, TimeSpan.FromMinutes(1)) + }); + + var middleware = new ThrottlingSentinelMiddleware( + httpContext => + { + httpContext.Response.StatusCode = StatusCodes.Status200OK; + return Task.CompletedTask; + }, + options); - await middleware.InvokeAsync(context, new MemoryThrottlingCache()); - Console.WriteLine(context.Response.Headers[options.Value.RateLimitHeaderName].ToString()); + await middleware.InvokeAsync(context, new MemoryThrottlingCache()); + Console.WriteLine(context.Response.Headers[options.Value.RateLimitHeaderName].ToString()); + } } - } +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelOptions.md index 82c8a4f64..f1c7c0ec8 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelOptions.md @@ -7,10 +7,14 @@ example: The following example shows how to create default and custom `ThrottlingSentinelOptions` to configure rate-limiting behavior. It demonstrates setting the quota, context resolver, header names, and retry-after scope, then validates the configuration and prints the selected values. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Http.Headers; using Cuemon.AspNetCore.Http.Throttling; using Microsoft.AspNetCore.Http; +using MyApp.Http.Throttling; + +Console.WriteLine(new ThrottlingSentinelOptionsExample().CreateDefault()); namespace MyApp.Http.Throttling { @@ -56,3 +60,7 @@ namespace MyApp.Http.Throttling } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.TooManyRequestsException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.TooManyRequestsException.md index bb038a2ca..c0a0ba5dc 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.TooManyRequestsException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.TooManyRequestsException.md @@ -7,50 +7,46 @@ example: The following example demonstrates how to use to signal HTTP 429 Too Many Requests responses. It creates instances with default and custom messages, wraps an inner exception, and resolves by status code via `TryParse`. A rate-limit simulation checks request count against a threshold, then sets the `Retry-After` header. Each variation outputs status code, message, and header values to the console, illustrating rate-limit enforcement patterns. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Http; -namespace MyApp.Examples; +// Create a TooManyRequestsException with default message +var ex = new TooManyRequestsException(); +Console.WriteLine(ex.StatusCode); // 429 +Console.WriteLine(ex.ReasonPhrase); // Too Many Requests +Console.WriteLine(ex.Message); // The allowed number of requests has been exceeded. -public class TooManyRequestsExceptionExample +// Create with a custom message +var custom = new TooManyRequestsException("Rate limit: maximum 100 requests per minute."); +Console.WriteLine(custom.Message); + +// Create with inner exception +var inner = new InvalidOperationException("Request quota exceeded."); +var withInner = new TooManyRequestsException("API rate limit reached.", inner); +Console.WriteLine(withInner.InnerException?.Message); // Request quota exceeded. + +// Use TryParse from the base class to resolve by status code +if (HttpStatusCodeException.TryParse(429, "Slow down!", out var parsed)) { - public void Demonstrate() - { - // Create a TooManyRequestsException with default message - var ex = new TooManyRequestsException(); - Console.WriteLine(ex.StatusCode); // 429 - Console.WriteLine(ex.ReasonPhrase); // Too Many Requests - Console.WriteLine(ex.Message); // The allowed number of requests has been exceeded. - - // Create with a custom message - var custom = new TooManyRequestsException("Rate limit: maximum 100 requests per minute."); - Console.WriteLine(custom.Message); - - // Create with inner exception - var inner = new InvalidOperationException("Request quota exceeded."); - var withInner = new TooManyRequestsException("API rate limit reached.", inner); - Console.WriteLine(withInner.InnerException?.Message); // Request quota exceeded. - - // Use TryParse from the base class to resolve by status code - if (HttpStatusCodeException.TryParse(429, "Slow down!", out var parsed)) - { - Console.WriteLine(parsed.Message); // Slow down! - Console.WriteLine(parsed.StatusCode); // 429 - } - - // Simulate a rate-limit check using the RetryAfter header - var requestCount = 101; - var maxRequests = 100; - if (requestCount > maxRequests) - { - var rateLimited = new TooManyRequestsException( - $"Request #{requestCount} exceeds the limit of {maxRequests} requests per minute."); - rateLimited.Headers["Retry-After"] = "60"; - Console.WriteLine(rateLimited.Message); // Request #101 exceeds the limit... - Console.WriteLine(rateLimited.Headers["Retry-After"]); // 60 - - } - } + Console.WriteLine(parsed.Message); // Slow down! + Console.WriteLine(parsed.StatusCode); // 429 } +// Simulate a rate-limit check using the RetryAfter header +var requestCount = 101; +var maxRequests = 100; +if (requestCount > maxRequests) +{ + var rateLimited = new TooManyRequestsException( + $"Request #{requestCount} exceeds the limit of {maxRequests} requests per minute."); + rateLimited.Headers["Retry-After"] = "60"; + Console.WriteLine(rateLimited.Message); // Request #101 exceeds the limit... + Console.WriteLine(rateLimited.Headers["Retry-After"]); // 60 + +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.UnauthorizedException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.UnauthorizedException.md index dfe62162e..bf83bedc3 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.UnauthorizedException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.UnauthorizedException.md @@ -7,22 +7,20 @@ example: The following example demonstrates how to use `UnauthorizedException` to indicate missing or invalid authentication. ```csharp +// Program.cs using System; +using Cuemon.AspNetCore.Http; -namespace Cuemon.AspNetCore.Http; +const string authenticationScheme = "Bearer"; +var exception = new UnauthorizedException( + $"The request is missing a valid {authenticationScheme} token.", + new InvalidOperationException("Token validation failed.")); -public static class UnauthorizedExceptionExample -{ - public static void Demonstrate() - { - const string authenticationScheme = "Bearer"; - var exception = new UnauthorizedException( - $"The request is missing a valid {authenticationScheme} token.", - new InvalidOperationException("Token validation failed.")); - - Console.WriteLine(exception.StatusCode); - Console.WriteLine(exception.Message); - Console.WriteLine(exception.InnerException?.Message); - } -} +Console.WriteLine(exception.StatusCode); +Console.WriteLine(exception.Message); +Console.WriteLine(exception.InnerException?.Message); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Http.UnsupportedMediaTypeException.md b/.docfx/api/types/Cuemon.AspNetCore.Http.UnsupportedMediaTypeException.md index 98248a4be..f04c4aebe 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Http.UnsupportedMediaTypeException.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Http.UnsupportedMediaTypeException.md @@ -7,23 +7,20 @@ example: The following example demonstrates how to return an `UnsupportedMediaTypeException` when the API receives an unsupported file upload format. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Http; -namespace MyApp.Examples; - -public class UnsupportedMediaTypeExceptionExample +try +{ + throw new UnsupportedMediaTypeException("text/html"); +} +catch (UnsupportedMediaTypeException ex) { - public void Demonstrate() - { - try - { - throw new UnsupportedMediaTypeException("text/html"); - } - catch (UnsupportedMediaTypeException ex) - { - Console.WriteLine(ex.StatusCode); // 415 - } - } + Console.WriteLine(ex.StatusCode); // 415 } ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Breadcrumb.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Breadcrumb.md index 6360d9765..c7e0882d4 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Breadcrumb.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Breadcrumb.md @@ -7,41 +7,38 @@ example: The following example demonstrates how to use to build navigation breadcrumbs for an MVC application. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon.AspNetCore.Mvc; -namespace MyApp.Examples; - -public class BreadcrumbExample +// Build a breadcrumb trail for a product detail page +var breadcrumbs = new List { - public void Demonstrate() - { - // Build a breadcrumb trail for a product detail page - var breadcrumbs = new List - { - new() { Label = "Home", ControllerName = "Home", ActionName = "Index" }, - new() { Label = "Products", ControllerName = "Product", ActionName = "Index" }, - new() { Label = "Electronics", ControllerName = "Product", ActionName = "Category" }, - new() { Label = "Smartphone X", ControllerName = "Product", ActionName = "Details" } - }; - - // Render breadcrumb items - foreach (var crumb in breadcrumbs) - { - Console.WriteLine($"{crumb.Label}"); - // Output: - // Home - // Products - // Electronics - // Smartphone X - - // The last breadcrumb typically represents the current page (no link) - var current = breadcrumbs[^1]; - Console.WriteLine($"{current.Label}"); - // Output: Smartphone X + new() { Label = "Home", ControllerName = "Home", ActionName = "Index" }, + new() { Label = "Products", ControllerName = "Product", ActionName = "Index" }, + new() { Label = "Electronics", ControllerName = "Product", ActionName = "Category" }, + new() { Label = "Smartphone X", ControllerName = "Product", ActionName = "Details" } +}; + +// Render breadcrumb items +foreach (var crumb in breadcrumbs) +{ + Console.WriteLine($"{crumb.Label}"); +// Output: +// Home +// Products +// Electronics +// Smartphone X + +// The last breadcrumb typically represents the current page (no link) +var current = breadcrumbs[^1]; +Console.WriteLine($"{current.Label}"); +// Output: Smartphone X -}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.CacheableFactory.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.CacheableFactory.md index 89033908f..c2a79947c 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.CacheableFactory.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.CacheableFactory.md @@ -7,43 +7,39 @@ example: The following example demonstrates how to create cacheable response objects using `CacheableFactory`. ```csharp +// Program.cs using System; using System.Security.Cryptography; using System.Text; using Cuemon.AspNetCore.Mvc; -namespace MyApp.Examples; +var content = "hello-world"; -public static class CacheableFactoryExample +var lastModified = CacheableFactory.CreateHttpLastModified(content, o => { - public static void Demonstrate() - { - var content = "hello-world"; - - var lastModified = CacheableFactory.CreateHttpLastModified(content, o => - { - o.TimestampProvider = _ => DateTime.UtcNow; - o.ChangedTimestampProvider = _ => DateTime.UtcNow; - }); - - var entityTag = CacheableFactory.CreateHttpEntityTag(content, o => - { - o.ChecksumProvider = value => SHA256.HashData(Encoding.UTF8.GetBytes(value)); - o.WeakChecksumProvider = _ => false; - }); - - var combined = CacheableFactory.Create(content, o => - { - o.TimestampProvider = _ => DateTime.UtcNow; - o.ChecksumProvider = value => SHA256.HashData(Encoding.UTF8.GetBytes(value)); - o.ChangedTimestampProvider = _ => DateTime.UtcNow; - o.WeakChecksumProvider = _ => false; - }); - - Console.WriteLine(lastModified is ICacheableObjectResult); - Console.WriteLine(entityTag is ICacheableObjectResult); - Console.WriteLine(combined is ICacheableObjectResult); - } -} + o.TimestampProvider = _ => DateTime.UtcNow; + o.ChangedTimestampProvider = _ => DateTime.UtcNow; +}); +var entityTag = CacheableFactory.CreateHttpEntityTag(content, o => +{ + o.ChecksumProvider = value => SHA256.HashData(Encoding.UTF8.GetBytes(value)); + o.WeakChecksumProvider = _ => false; +}); + +var combined = CacheableFactory.Create(content, o => +{ + o.TimestampProvider = _ => DateTime.UtcNow; + o.ChecksumProvider = value => SHA256.HashData(Encoding.UTF8.GetBytes(value)); + o.ChangedTimestampProvider = _ => DateTime.UtcNow; + o.WeakChecksumProvider = _ => false; +}); + +Console.WriteLine(lastModified is ICacheableObjectResult); +Console.WriteLine(entityTag is ICacheableObjectResult); +Console.WriteLine(combined is ICacheableObjectResult); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.CacheableObjectResultOptions`1.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.CacheableObjectResultOptions`1.md index 0bf88935d..12d736311 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.CacheableObjectResultOptions`1.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.CacheableObjectResultOptions`1.md @@ -7,33 +7,28 @@ example: The following example demonstrates how to configure to enable HTTP caching (ETag and Last-Modified) for a response model. ```csharp +// Program.cs using System; using System.Security.Cryptography; using System.Text; using Cuemon.AspNetCore.Mvc; -namespace MyApp.Examples; - -public class CacheableObjectResultOptionsExample +var options = new CacheableObjectResultOptions { - public void Demonstrate() - { - var options = new CacheableObjectResultOptions - { - ChecksumProvider = value => SHA256.HashData(Encoding.UTF8.GetBytes(value)), - WeakChecksumProvider = _ => false, - TimestampProvider = _ => DateTime.UtcNow, - ChangedTimestampProvider = _ => DateTime.UtcNow - }; - - options.ValidateOptions(); - - var data = "hello-world"; - byte[] checksum = options.ChecksumProvider(data); - Console.WriteLine($"Checksum length: {checksum.Length}"); // 32 bytes (SHA256) - Console.WriteLine($"Created: {options.TimestampProvider(data)}"); - -} -} - + ChecksumProvider = value => SHA256.HashData(Encoding.UTF8.GetBytes(value)), + WeakChecksumProvider = _ => false, + TimestampProvider = _ => DateTime.UtcNow, + ChangedTimestampProvider = _ => DateTime.UtcNow +}; + +options.ValidateOptions(); + +var data = "hello-world"; +byte[] checksum = options.ChecksumProvider(data); +Console.WriteLine($"Checksum length: {checksum.Length}"); // 32 bytes (SHA256) +Console.WriteLine($"Created: {options.TimestampProvider(data)}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.ContentBasedObjectResultOptions`1.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.ContentBasedObjectResultOptions`1.md index 530ce411f..6c4d116a0 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.ContentBasedObjectResultOptions`1.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.ContentBasedObjectResultOptions`1.md @@ -7,29 +7,24 @@ example: The following example demonstrates how to configure to provide a checksum provider for generating ETags. ```csharp +// Program.cs using System; using System.Security.Cryptography; using System.Text; using Cuemon.AspNetCore.Mvc; -namespace MyApp.Examples; - -public class ContentBasedObjectResultOptionsExample +var options = new ContentBasedObjectResultOptions { - public void Demonstrate() - { - var options = new ContentBasedObjectResultOptions - { - ChecksumProvider = value => SHA256.HashData(Encoding.UTF8.GetBytes(value)), - WeakChecksumProvider = _ => false // use strong ETag - }; - - // Validate that the required properties are configured - options.ValidateOptions(); + ChecksumProvider = value => SHA256.HashData(Encoding.UTF8.GetBytes(value)), + WeakChecksumProvider = _ => false // use strong ETag +}; - Console.WriteLine("ChecksumProvider is configured."); - -} -} +// Validate that the required properties are configured +options.ValidateOptions(); +Console.WriteLine("ChecksumProvider is configured."); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.ExceptionDescriptorResult.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.ExceptionDescriptorResult.md index 63e26b4da..859e50911 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.ExceptionDescriptorResult.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.ExceptionDescriptorResult.md @@ -7,6 +7,7 @@ example: The following example shows how can return either an or ASP.NET Core . ```csharp +// Program.cs using System; using Cuemon; using Cuemon.AspNetCore.Diagnostics; @@ -14,22 +15,18 @@ using Cuemon.AspNetCore.Http; using Cuemon.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc; -namespace MyApp.Examples; +var descriptorResult = new ExceptionDescriptorResult( + new HttpExceptionDescriptor(new BadRequestException("City name is required."))); -public static class ExceptionDescriptorResultExample -{ - public static void Demonstrate() - { - var descriptorResult = new ExceptionDescriptorResult( - new HttpExceptionDescriptor(new BadRequestException("City name is required."))); +var descriptor = (HttpExceptionDescriptor)descriptorResult.Value; +Console.WriteLine(descriptor.StatusCode); - var descriptor = (HttpExceptionDescriptor)descriptorResult.Value; - Console.WriteLine(descriptor.StatusCode); +var problemResult = new ExceptionDescriptorResult( + new ProblemDetails { Title = "Validation failed." }); - var problemResult = new ExceptionDescriptorResult( - new ProblemDetails { Title = "Validation failed." }); - - Console.WriteLine(problemResult.Value is IDecorator); - } -} +Console.WriteLine(problemResult.Value is IDecorator); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpCacheableFilter.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpCacheableFilter.md index 20807fa94..0bdbacda3 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpCacheableFilter.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpCacheableFilter.md @@ -7,24 +7,21 @@ example: The following example shows how to compose from packet-local options and cache validators. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Mvc.Filters.Cacheable; using Microsoft.Extensions.Options; -namespace MyApp.Examples; +var options = new HttpCacheableOptions(); +options.Filters.Add(new HttpEntityTagHeaderFilter(io => io.UseEntityTagResponseParser = true)); +options.Filters.Add(new HttpLastModifiedHeaderFilter()); -public static class HttpCacheableFilterExample -{ - public static void Demonstrate() - { - var options = new HttpCacheableOptions(); - options.Filters.Add(new HttpEntityTagHeaderFilter(io => io.UseEntityTagResponseParser = true)); - options.Filters.Add(new HttpLastModifiedHeaderFilter()); +var filter = new HttpCacheableFilter(Options.Create(options)); - var filter = new HttpCacheableFilter(Options.Create(options)); - - Console.WriteLine(filter.Options.Filters.Count); - Console.WriteLine(filter.Options.UseCacheControl); - } -} +Console.WriteLine(filter.Options.Filters.Count); +Console.WriteLine(filter.Options.UseCacheControl); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpCacheableOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpCacheableOptions.md index 91353b516..a283d243b 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpCacheableOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpCacheableOptions.md @@ -7,32 +7,29 @@ example: The following example configures with a custom `Cache-Control` header and manually adds both cacheable filters used by . ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Mvc.Filters.Cacheable; using Microsoft.Net.Http.Headers; -namespace MyApp.Examples; - -public static class HttpCacheableOptionsExample +var options = new HttpCacheableOptions { - public static void Demonstrate() + CacheControl = new CacheControlHeaderValue { - var options = new HttpCacheableOptions - { - CacheControl = new CacheControlHeaderValue - { - MaxAge = TimeSpan.FromMinutes(15), - Public = true, - MustRevalidate = false - } - }; + MaxAge = TimeSpan.FromMinutes(15), + Public = true, + MustRevalidate = false + } +}; - options.Filters.Add(new HttpEntityTagHeaderFilter(o => o.UseEntityTagResponseParser = true)); - options.Filters.Add(new HttpLastModifiedHeaderFilter()); +options.Filters.Add(new HttpEntityTagHeaderFilter(o => o.UseEntityTagResponseParser = true)); +options.Filters.Add(new HttpLastModifiedHeaderFilter()); - Console.WriteLine(options.UseCacheControl); - Console.WriteLine(options.Filters.Count); - Console.WriteLine(options.CacheControl.MaxAge); - } -} +Console.WriteLine(options.UseCacheControl); +Console.WriteLine(options.Filters.Count); +Console.WriteLine(options.CacheControl.MaxAge); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpEntityTagHeaderFilter.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpEntityTagHeaderFilter.md index 6b0cc333e..4a4b65696 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpEntityTagHeaderFilter.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpEntityTagHeaderFilter.md @@ -7,20 +7,18 @@ example: The following example shows how is added to a cacheable filter pipeline and configured to fall back to parsing the response body. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Mvc.Filters.Cacheable; -namespace MyApp.Examples; -public static class HttpEntityTagHeaderFilterExample -{ - public static void Demonstrate() - { - var filter = new HttpEntityTagHeaderFilter(o => o.UseEntityTagResponseParser = true); - var options = new HttpCacheableOptions(); - options.Filters.Add(filter); +var filter = new HttpEntityTagHeaderFilter(o => o.UseEntityTagResponseParser = true); +var options = new HttpCacheableOptions(); +options.Filters.Add(filter); - Console.WriteLine(filter.Options.UseEntityTagResponseParser); - Console.WriteLine(options.Filters.Count); - } -} +Console.WriteLine(filter.Options.UseEntityTagResponseParser); +Console.WriteLine(options.Filters.Count); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpEntityTagHeaderOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpEntityTagHeaderOptions.md index a0ab637b5..28ec64915 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpEntityTagHeaderOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpEntityTagHeaderOptions.md @@ -4,9 +4,10 @@ example: - *content --- -The following example uses the same way the unit tests exercise its default delegates: by applying an ETag from entity integrity data and then from a response-body fallback parser. +The following example uses the same way the unit tests exercise its default delegates: by applying an ETag from entity integrity data and then from a response-body fallback parser. The sample applies an integrity-backed ETag first, exercises the response-body parser second, and prints whether each provider is configured and whether the response ETag header was populated. ```csharp +// Program.cs using System; using System.IO; using System.Text; @@ -15,36 +16,44 @@ using Cuemon.Data.Integrity; using Cuemon.Security; using Microsoft.AspNetCore.Http; using Microsoft.Net.Http.Headers; +using MyApp.Examples; -namespace MyApp.Examples; +HttpEntityTagHeaderOptionsExample.Demonstrate(); -public static class HttpEntityTagHeaderOptionsExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class HttpEntityTagHeaderOptionsExample { - var options = new HttpEntityTagHeaderOptions + public static void Demonstrate() { - UseEntityTagResponseParser = true - }; + var options = new HttpEntityTagHeaderOptions + { + UseEntityTagResponseParser = true + }; - var context = new DefaultHttpContext(); - context.Request.Method = HttpMethods.Get; + var context = new DefaultHttpContext(); + context.Request.Method = HttpMethods.Get; - options.EntityTagProvider(new SampleEntityDataIntegrity(), context); + options.EntityTagProvider(new SampleEntityDataIntegrity(), context); - using var body = new MemoryStream(Encoding.UTF8.GetBytes("payload")); - options.EntityTagResponseParser(body, context.Request, context.Response); + using var body = new MemoryStream(Encoding.UTF8.GetBytes("payload")); + options.EntityTagResponseParser(body, context.Request, context.Response); - Console.WriteLine(options.HasEntityTagProvider); - Console.WriteLine(options.HasEntityTagResponseParser); - Console.WriteLine(context.Response.Headers.ContainsKey(HeaderNames.ETag)); - } + Console.WriteLine(options.HasEntityTagProvider); + Console.WriteLine(options.HasEntityTagResponseParser); + Console.WriteLine(context.Response.Headers.ContainsKey(HeaderNames.ETag)); + } - private sealed class SampleEntityDataIntegrity : IEntityDataIntegrity - { - public HashResult Checksum => new HashResult(new byte[] { 1, 2, 3 }); + private sealed class SampleEntityDataIntegrity : IEntityDataIntegrity + { + public HashResult Checksum => new HashResult(new byte[] { 1, 2, 3 }); - public EntityDataIntegrityValidation Validation => EntityDataIntegrityValidation.Strong; + public EntityDataIntegrityValidation Validation => EntityDataIntegrityValidation.Strong; + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpLastModifiedHeaderFilter.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpLastModifiedHeaderFilter.md index ad9ba605e..82f62b9fe 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpLastModifiedHeaderFilter.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpLastModifiedHeaderFilter.md @@ -7,20 +7,18 @@ example: The following example shows how can be added to a cacheable pipeline and inspected directly. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Mvc.Filters.Cacheable; -namespace MyApp.Examples; -public static class HttpLastModifiedHeaderFilterExample -{ - public static void Demonstrate() - { - var filter = new HttpLastModifiedHeaderFilter(); - var options = new HttpCacheableOptions(); - options.Filters.Add(filter); +var filter = new HttpLastModifiedHeaderFilter(); +var options = new HttpCacheableOptions(); +options.Filters.Add(filter); - Console.WriteLine(filter.Options.HasLastModifiedProvider); - Console.WriteLine(options.Filters.Count); - } -} +Console.WriteLine(filter.Options.HasLastModifiedProvider); +Console.WriteLine(options.Filters.Count); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpLastModifiedHeaderOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpLastModifiedHeaderOptions.md index b9f76fbf4..c38a9dfe9 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpLastModifiedHeaderOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpLastModifiedHeaderOptions.md @@ -4,46 +4,55 @@ example: - *content --- -The following example applies the default to a timestamped response model. +The following example applies the default to a timestamped response model. The sample supplies created and modified timestamps, applies the provider to a GET response, and prints the resulting Last-Modified header. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Mvc.Filters.Cacheable; using Cuemon.Data.Integrity; using Microsoft.AspNetCore.Http; using Microsoft.Net.Http.Headers; +using MyApp.Examples; -namespace MyApp.Examples; +HttpLastModifiedHeaderOptionsExample.Demonstrate(); -public static class HttpLastModifiedHeaderOptionsExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class HttpLastModifiedHeaderOptionsExample { - var options = new HttpLastModifiedHeaderOptions(); - var context = new DefaultHttpContext(); - context.Request.Method = HttpMethods.Get; + public static void Demonstrate() + { + var options = new HttpLastModifiedHeaderOptions(); + var context = new DefaultHttpContext(); + context.Request.Method = HttpMethods.Get; - var timestamp = new SampleEntityDataTimestamp( - DateTime.Parse("2024-01-01T00:00:00Z"), - DateTime.Parse("2024-01-02T00:00:00Z")); + var timestamp = new SampleEntityDataTimestamp( + DateTime.Parse("2024-01-01T00:00:00Z"), + DateTime.Parse("2024-01-02T00:00:00Z")); - options.LastModifiedProvider(timestamp, context); + options.LastModifiedProvider(timestamp, context); - Console.WriteLine(options.HasLastModifiedProvider); - Console.WriteLine(context.Response.Headers[HeaderNames.LastModified].ToString()); - } + Console.WriteLine(options.HasLastModifiedProvider); + Console.WriteLine(context.Response.Headers[HeaderNames.LastModified].ToString()); + } - private sealed class SampleEntityDataTimestamp : IEntityDataTimestamp - { - public SampleEntityDataTimestamp(DateTime created, DateTime? modified) + private sealed class SampleEntityDataTimestamp : IEntityDataTimestamp { - Created = created; - Modified = modified; - } + public SampleEntityDataTimestamp(DateTime created, DateTime? modified) + { + Created = created; + Modified = modified; + } - public DateTime Created { get; } + public DateTime Created { get; } - public DateTime? Modified { get; } + public DateTime? Modified { get; } + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.FaultDescriptorFilter.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.FaultDescriptorFilter.md index 2ec5eea5e..6967df805 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.FaultDescriptorFilter.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.FaultDescriptorFilter.md @@ -7,29 +7,26 @@ example: The following example creates directly from configured packet-local options. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Diagnostics; using Cuemon.AspNetCore.Mvc.Filters.Diagnostics; using Cuemon.Diagnostics; using Microsoft.Extensions.Options; -namespace MyApp.Examples; - -public static class FaultDescriptorFilterExample +var options = Options.Create(new MvcFaultDescriptorOptions { - public static void Demonstrate() - { - var options = Options.Create(new MvcFaultDescriptorOptions - { - MarkExceptionHandled = true, - FaultDescriptor = PreferredFaultDescriptor.ProblemDetails, - SensitivityDetails = FaultSensitivityDetails.Failure - }); + MarkExceptionHandled = true, + FaultDescriptor = PreferredFaultDescriptor.ProblemDetails, + SensitivityDetails = FaultSensitivityDetails.Failure +}); - var filter = new FaultDescriptorFilter(options); +var filter = new FaultDescriptorFilter(options); - Console.WriteLine(filter.Options.MarkExceptionHandled); - Console.WriteLine(filter.Options.FaultDescriptor); - } -} +Console.WriteLine(filter.Options.MarkExceptionHandled); +Console.WriteLine(filter.Options.FaultDescriptor); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.MvcFaultDescriptorOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.MvcFaultDescriptorOptions.md index 7a7f308aa..4c0a68522 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.MvcFaultDescriptorOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.MvcFaultDescriptorOptions.md @@ -7,26 +7,24 @@ example: The following example configures for Problem Details responses and marks MVC exceptions as handled after the filter runs. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Diagnostics; using Cuemon.AspNetCore.Mvc.Filters.Diagnostics; using Cuemon.Diagnostics; -namespace MyApp.Examples; -public static class MvcFaultDescriptorOptionsExample +var options = new MvcFaultDescriptorOptions { - public static void Demonstrate() - { - var options = new MvcFaultDescriptorOptions - { - MarkExceptionHandled = true, - FaultDescriptor = PreferredFaultDescriptor.ProblemDetails, - SensitivityDetails = FaultSensitivityDetails.Failure - }; + MarkExceptionHandled = true, + FaultDescriptor = PreferredFaultDescriptor.ProblemDetails, + SensitivityDetails = FaultSensitivityDetails.Failure +}; - Console.WriteLine(options.MarkExceptionHandled); - Console.WriteLine(options.FaultDescriptor); - Console.WriteLine(options.HttpFaultResolvers.Count); - } -} +Console.WriteLine(options.MarkExceptionHandled); +Console.WriteLine(options.FaultDescriptor); +Console.WriteLine(options.HttpFaultResolvers.Count); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingAttribute.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingAttribute.md index bae5015f7..e397a2fd0 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingAttribute.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingAttribute.md @@ -7,6 +7,7 @@ example: The following example applies to a controller action and configures the attribute directly. It instantiates the attribute with a name, description, threshold in milliseconds, and desired log level, then applies it declaratively to a `WeatherController` GET endpoint. The attribute outputs its configuration and confirms it implements `IFilterFactory`, demonstrating how to instrument ASP.NET Core endpoints with server-timing metrics. ```csharp +// Program.cs using System; using System.Threading.Tasks; using Cuemon; @@ -14,44 +15,51 @@ using Cuemon.AspNetCore.Mvc.Filters.Diagnostics; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.Logging; +using MyApp.Examples; -namespace MyApp.Examples; +ServerTimingAttributeExample.Demonstrate(); -public static class ServerTimingAttributeExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class ServerTimingAttributeExample { - var attribute = new ServerTimingAttribute + public static void Demonstrate() { + var attribute = new ServerTimingAttribute + { + Name = "weatherApi", + Description = "Weather API endpoint", + Threshold = 500, + ThresholdTimeUnit = TimeUnit.Milliseconds, + DesiredLogLevel = LogLevel.Warning, + EnvironmentName = string.Empty + }; + + Console.WriteLine(attribute.Name); + Console.WriteLine(attribute is IFilterFactory); + Console.WriteLine(attribute.IsReusable); + } + } + [ApiController] + [Route("weather")] + public sealed class WeatherController : ControllerBase + { + [HttpGet] + [ServerTiming( Name = "weatherApi", Description = "Weather API endpoint", Threshold = 500, ThresholdTimeUnit = TimeUnit.Milliseconds, - DesiredLogLevel = LogLevel.Warning, - EnvironmentName = string.Empty - }; - - Console.WriteLine(attribute.Name); - Console.WriteLine(attribute is IFilterFactory); - Console.WriteLine(attribute.IsReusable); - } -} - -[ApiController] -[Route("weather")] -public sealed class WeatherController : ControllerBase -{ - [HttpGet] - [ServerTiming( - Name = "weatherApi", - Description = "Weather API endpoint", - Threshold = 500, - ThresholdTimeUnit = TimeUnit.Milliseconds, - DesiredLogLevel = LogLevel.Warning)] - public async Task GetWeatherAsync() - { - await Task.Delay(300); - return Ok(new { Temperature = 22, Condition = "Sunny" }); + DesiredLogLevel = LogLevel.Warning)] + public async Task GetWeatherAsync() + { + await Task.Delay(300); + return Ok(new { Temperature = 22, Condition = "Sunny" }); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingFilter.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingFilter.md index 254d5cf8b..d261ce3d9 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingFilter.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingFilter.md @@ -7,6 +7,7 @@ example: The following example shows the constructor dependencies used when creating directly. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Diagnostics; using Cuemon.AspNetCore.Mvc.Filters.Diagnostics; @@ -14,38 +15,46 @@ using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using MyApp.Examples; -namespace MyApp.Examples; +ServerTimingFilterExample.Demonstrate(); -public static class ServerTimingFilterExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class ServerTimingFilterExample { - var options = Options.Create(new ServerTimingOptions + public static void Demonstrate() { - UseTimeMeasureProfiler = true, - SuppressHeaderPredicate = _ => false - }); - - using var loggerFactory = LoggerFactory.Create(_ => { }); - var filter = new ServerTimingFilter( - options, - new SampleHostEnvironment(), - loggerFactory.CreateLogger()); - - Console.WriteLine(filter.Options.UseTimeMeasureProfiler); - Console.WriteLine(filter.Options.SuppressHeaderPredicate is not null); - } - - private sealed class SampleHostEnvironment : IHostEnvironment - { - public string EnvironmentName { get; set; } = Environments.Development; + var options = Options.Create(new ServerTimingOptions + { + UseTimeMeasureProfiler = true, + SuppressHeaderPredicate = _ => false + }); + + using var loggerFactory = LoggerFactory.Create(_ => { }); + var filter = new ServerTimingFilter( + options, + new SampleHostEnvironment(), + loggerFactory.CreateLogger()); + + Console.WriteLine(filter.Options.UseTimeMeasureProfiler); + Console.WriteLine(filter.Options.SuppressHeaderPredicate is not null); + } + + private sealed class SampleHostEnvironment : IHostEnvironment + { + public string EnvironmentName { get; set; } = Environments.Development; - public string ApplicationName { get; set; } = nameof(ServerTimingFilterExample); + public string ApplicationName { get; set; } = nameof(ServerTimingFilterExample); - public string ContentRootPath { get; set; } = AppContext.BaseDirectory; + public string ContentRootPath { get; set; } = AppContext.BaseDirectory; - public IFileProvider ContentRootFileProvider { get; set; } = new NullFileProvider(); + public IFileProvider ContentRootFileProvider { get; set; } = new NullFileProvider(); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Headers.ApiKeySentinelAttribute.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Headers.ApiKeySentinelAttribute.md index 71213b9eb..2864d529f 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Headers.ApiKeySentinelAttribute.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Headers.ApiKeySentinelAttribute.md @@ -7,32 +7,17 @@ example: The following example applies to a controller and inspects the filter service type it resolves. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Mvc.Filters.Headers; using Microsoft.AspNetCore.Mvc; -namespace MyApp.Examples; +var attribute = new ApiKeySentinelAttribute(); -[ApiController] -[Route("api/[controller]")] -[ApiKeySentinel] -public sealed class SecureController : ControllerBase -{ - [HttpGet] - public IActionResult GetSecureData() - { - return Ok(new { Data = "Protected data" }); - } -} - -public static class ApiKeySentinelAttributeExample -{ - public static void Demonstrate() - { - var attribute = new ApiKeySentinelAttribute(); - - Console.WriteLine(attribute.ServiceType == typeof(ApiKeySentinelFilter)); - Console.WriteLine(attribute.IsReusable); - } -} +Console.WriteLine(attribute.ServiceType == typeof(ApiKeySentinelFilter)); +Console.WriteLine(attribute.IsReusable); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Headers.ApiKeySentinelFilter.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Headers.ApiKeySentinelFilter.md index 925949e8e..728fa2948 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Headers.ApiKeySentinelFilter.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Headers.ApiKeySentinelFilter.md @@ -7,30 +7,27 @@ example: The following example creates directly from configured options. ```csharp +// Program.cs using System; using System.Net; using Cuemon.AspNetCore.Http.Headers; using Cuemon.AspNetCore.Mvc.Filters.Headers; using Microsoft.Extensions.Options; -namespace MyApp.Examples; - -public static class ApiKeySentinelFilterExample +var options = Options.Create(new ApiKeySentinelOptions { - public static void Demonstrate() - { - var options = Options.Create(new ApiKeySentinelOptions - { - UseGenericResponse = true, - GenericClientStatusCode = HttpStatusCode.NotFound, - GenericClientMessage = "Resource not found." - }); - options.Value.AllowedKeys.Add("Cuemon-Key"); + UseGenericResponse = true, + GenericClientStatusCode = HttpStatusCode.NotFound, + GenericClientMessage = "Resource not found." +}); +options.Value.AllowedKeys.Add("Cuemon-Key"); - var filter = new ApiKeySentinelFilter(options); +var filter = new ApiKeySentinelFilter(options); - Console.WriteLine(filter.Options.HeaderName); - Console.WriteLine(filter.Options.AllowedKeys.Count); - } -} +Console.WriteLine(filter.Options.HeaderName); +Console.WriteLine(filter.Options.AllowedKeys.Count); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Headers.UserAgentSentinelFilter.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Headers.UserAgentSentinelFilter.md index 45dc2bf3b..59c68512d 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Headers.UserAgentSentinelFilter.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Headers.UserAgentSentinelFilter.md @@ -7,28 +7,25 @@ example: The following example configures to require a known `User-Agent` header and then creates the filter directly from those options. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Http.Headers; using Cuemon.AspNetCore.Mvc.Filters.Headers; using Microsoft.Extensions.Options; -namespace MyApp.Examples; - -public static class UserAgentSentinelFilterExample +var options = Options.Create(new UserAgentSentinelOptions { - public static void Demonstrate() - { - var options = Options.Create(new UserAgentSentinelOptions - { - RequireUserAgentHeader = true, - ValidateUserAgentHeader = true - }); - options.Value.AllowedUserAgents.Add("Cuemon-Agent"); + RequireUserAgentHeader = true, + ValidateUserAgentHeader = true +}); +options.Value.AllowedUserAgents.Add("Cuemon-Agent"); - var filter = new UserAgentSentinelFilter(options); +var filter = new UserAgentSentinelFilter(options); - Console.WriteLine(filter.Options.RequireUserAgentHeader); - Console.WriteLine(filter.Options.AllowedUserAgents.Count); - } -} +Console.WriteLine(filter.Options.RequireUserAgentHeader); +Console.WriteLine(filter.Options.AllowedUserAgents.Count); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.ModelBinding.DisableModelBindingAttribute.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.ModelBinding.DisableModelBindingAttribute.md index d10eb79e9..161ada968 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.ModelBinding.DisableModelBindingAttribute.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.ModelBinding.DisableModelBindingAttribute.md @@ -7,31 +7,17 @@ example: The following example demonstrates how to use the to disable a specific model binding value provider, such as when handling file uploads to prevent form value binding. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Mvc.Filters.ModelBinding; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ModelBinding; -namespace MyApp.Examples; - -[DisableModelBinding(typeof(FormValueProviderFactory))] -public class FileUploadController : Controller -{ - [HttpPost("/upload")] - public IActionResult Upload() - { - return Ok("File upload processed."); - } -} - -public class DisableModelBindingAttributeDirectUsage -{ - public void Demonstrate() - { - // Direct instantiation of DisableModelBindingAttribute - var attribute = new DisableModelBindingAttribute(typeof(FormValueProviderFactory)); - Console.WriteLine($"Disabled type: {attribute.ValueProviderFactoryType.Name}"); - } -} - +// Direct instantiation of DisableModelBindingAttribute +var attribute = new DisableModelBindingAttribute(typeof(FormValueProviderFactory)); +Console.WriteLine($"Disabled type: {attribute.ValueProviderFactoryType.Name}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Throttling.ThrottlingSentinelFilter.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Throttling.ThrottlingSentinelFilter.md index 586916bdf..9de3be7a2 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Throttling.ThrottlingSentinelFilter.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.Filters.Throttling.ThrottlingSentinelFilter.md @@ -7,28 +7,25 @@ example: The following example constructs directly with a packet-local throttling cache and options object. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.AspNetCore.Http.Throttling; using Cuemon.AspNetCore.Mvc.Filters.Throttling; using Microsoft.Extensions.Options; -namespace MyApp.Examples; - -public static class ThrottlingSentinelFilterExample +var options = Options.Create(new ThrottlingSentinelOptions { - public static void Demonstrate() - { - var options = Options.Create(new ThrottlingSentinelOptions - { - ContextResolver = _ => "developer-workstation", - Quota = new ThrottleQuota(10, 5, TimeUnit.Seconds) - }); + ContextResolver = _ => "developer-workstation", + Quota = new ThrottleQuota(10, 5, TimeUnit.Seconds) +}); - var filter = new ThrottlingSentinelFilter(options, new MemoryThrottlingCache()); +var filter = new ThrottlingSentinelFilter(options, new MemoryThrottlingCache()); - Console.WriteLine(filter.Options.Quota.RateLimit); - Console.WriteLine(filter.Options.UseRetryAfterHeader); - } -} +Console.WriteLine(filter.Options.Quota.RateLimit); +Console.WriteLine(filter.Options.UseRetryAfterHeader); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.ForbiddenObjectResult.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.ForbiddenObjectResult.md index ba69ed548..c2ea39200 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.ForbiddenObjectResult.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.ForbiddenObjectResult.md @@ -7,10 +7,14 @@ example: `ForbiddenObjectResult` is an `ObjectResult` subclass that returns a `403 Forbidden` HTTP response with an optional diagnostic payload. This example creates a first result with an anonymous object containing `error` and `requiredRole` fields, then inspects its `StatusCode` (403) and `Value`. A second result demonstrates overriding the status code to `404 Not Found` to obscure resource existence when security through obscurity is preferred. Console output confirms the status code values and the diagnostic payload content. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Mvc; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using MyApp.Mvc; + +Console.WriteLine(new ForbiddenObjectResultExample().Demonstrate()); namespace MyApp.Mvc { @@ -42,3 +46,7 @@ namespace MyApp.Mvc } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.ForbiddenResult.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.ForbiddenResult.md index f67869c18..511af1708 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.ForbiddenResult.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.ForbiddenResult.md @@ -7,21 +7,18 @@ example: The following example shows how can return the default 403 status code or a different client-error code when you want to hide the existence of a protected resource. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Mvc; using Microsoft.AspNetCore.Http; -namespace MyApp.Examples; +var forbidden = new ForbiddenResult(); +var disguised = new ForbiddenResult(StatusCodes.Status404NotFound); -public static class ForbiddenResultExample -{ - public static void Demonstrate() - { - var forbidden = new ForbiddenResult(); - var disguised = new ForbiddenResult(StatusCodes.Status404NotFound); - - Console.WriteLine(forbidden.StatusCode); - Console.WriteLine(disguised.StatusCode); - } -} +Console.WriteLine(forbidden.StatusCode); +Console.WriteLine(disguised.StatusCode); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.GoneResult.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.GoneResult.md index 570b3b82d..8b99a46ef 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.GoneResult.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.GoneResult.md @@ -7,18 +7,15 @@ example: The following example shows how can signal that a resource has been permanently removed. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Mvc; -namespace MyApp.Examples; +var result = new GoneResult(); -public static class GoneResultExample -{ - public static void Demonstrate() - { - var result = new GoneResult(); - - Console.WriteLine(result.StatusCode); - } -} +Console.WriteLine(result.StatusCode); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.SeeOtherResult.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.SeeOtherResult.md index 862a2e3ba..653ad77f1 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.SeeOtherResult.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.SeeOtherResult.md @@ -7,19 +7,16 @@ example: The following example shows how supports a 303 POST-redirect-GET response. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Mvc; -namespace MyApp.Examples; +var result = new SeeOtherResult(new Uri("https://example.com/orders/42")); -public static class SeeOtherResultExample -{ - public static void Demonstrate() - { - var result = new SeeOtherResult(new Uri("https://example.com/orders/42")); - - Console.WriteLine(result.StatusCode); - Console.WriteLine(result.Location); - } -} +Console.WriteLine(result.StatusCode); +Console.WriteLine(result.Location); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.TimeBasedObjectResultOptions`1.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.TimeBasedObjectResultOptions`1.md index 911274fd9..ce63fc5d8 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.TimeBasedObjectResultOptions`1.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.TimeBasedObjectResultOptions`1.md @@ -7,29 +7,24 @@ example: The following example demonstrates how to configure to provide timestamp providers for generating Last-Modified headers. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Mvc; -namespace MyApp.Examples; - -public class TimeBasedObjectResultOptionsExample +var options = new TimeBasedObjectResultOptions { - public void Demonstrate() - { - var options = new TimeBasedObjectResultOptions - { - TimestampProvider = value => value, - ChangedTimestampProvider = value => value.AddHours(1) - }; - - // Validate that the required properties are configured - options.ValidateOptions(); + TimestampProvider = value => value, + ChangedTimestampProvider = value => value.AddHours(1) +}; - var created = new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc); - Console.WriteLine($"Created: {options.TimestampProvider(created)}"); - Console.WriteLine($"Modified: {options.ChangedTimestampProvider(created)}"); - -} -} +// Validate that the required properties are configured +options.ValidateOptions(); +var created = new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc); +Console.WriteLine($"Created: {options.TimestampProvider(created)}"); +Console.WriteLine($"Modified: {options.ChangedTimestampProvider(created)}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.TooManyRequestsObjectResult.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.TooManyRequestsObjectResult.md index 1d666d2f4..c4aeb188f 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.TooManyRequestsObjectResult.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.TooManyRequestsObjectResult.md @@ -7,23 +7,32 @@ example: The following example demonstrates how to return a with a descriptive error object to produce a 429 HTTP response. ```csharp +// Program.cs using Cuemon.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc; +using System; +using MyApp.Examples; -namespace MyApp.Examples; +Console.WriteLine(new RateLimitController().GetData()); -public class RateLimitController : Controller +namespace MyApp.Examples { - [HttpGet("/api/rate-limited")] - public IActionResult GetData() + public class RateLimitController : Controller { - return new TooManyRequestsObjectResult(new + [HttpGet("/api/rate-limited")] + public IActionResult GetData() { - error = "API rate limit exceeded. Please try again later.", - retryAfter = 60 - }); + return new TooManyRequestsObjectResult(new + { + error = "API rate limit exceeded. Please try again later.", + retryAfter = 60 + }); + } + } } -} - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Mvc.TooManyRequestsResult.md b/.docfx/api/types/Cuemon.AspNetCore.Mvc.TooManyRequestsResult.md index 9a20f5ae0..3b42dc9a9 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Mvc.TooManyRequestsResult.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Mvc.TooManyRequestsResult.md @@ -7,22 +7,30 @@ example: The following example demonstrates how to return a from a controller action to produce a 429 HTTP response. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc; +using MyApp.Examples; -namespace MyApp.Examples; +Console.WriteLine(new RateLimitController().GetData()); -public class RateLimitController : Controller +namespace MyApp.Examples { - [HttpGet("/api/rate-limited")] - public IActionResult GetData() + public class RateLimitController : Controller { - var result = new TooManyRequestsResult(); - Console.WriteLine(result.StatusCode); // 429 - return result; + [HttpGet("/api/rate-limited")] + public IActionResult GetData() + { + var result = new TooManyRequestsResult(); + Console.WriteLine(result.StatusCode); // 429 + return result; + } + } } -} - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppImageTagHelper.md b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppImageTagHelper.md index aaae07fe8..7a00c5f1c 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppImageTagHelper.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppImageTagHelper.md @@ -7,36 +7,45 @@ example: The following example demonstrates how to create `AppImageTagHelper` with application-scoped options. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Razor.TagHelpers; using Microsoft.Extensions.Options; +using MyApp.Examples; -namespace MyApp.Examples; +AppImageTagHelperExample.Demonstrate(); -public static class AppImageTagHelperExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class AppImageTagHelperExample { - var options = Options.Create(CreateOptions()); - - var tagHelper = new AppImageTagHelper(options) + public static void Demonstrate() { - Src = "images/logo.svg", - Alt = "Codebelt logo" - }; + var options = Options.Create(CreateOptions()); - Console.WriteLine(FormatAssetUrl(tagHelper.Options, tagHelper.Src)); - } + var tagHelper = new AppImageTagHelper(options) + { + Src = "images/logo.svg", + Alt = "Codebelt logo" + }; - private static AppTagHelperOptions CreateOptions() => new() - { - Scheme = ProtocolUriScheme.Relative, - BaseUrl = "static.cuemon.net" - }; + Console.WriteLine(FormatAssetUrl(tagHelper.Options, tagHelper.Src)); + } - private static string FormatAssetUrl(AppTagHelperOptions options, string asset) - { - return options.GetFormattedBaseUrl() + asset; + private static AppTagHelperOptions CreateOptions() => new() + { + Scheme = ProtocolUriScheme.Relative, + BaseUrl = "static.cuemon.net" + }; + + private static string FormatAssetUrl(AppTagHelperOptions options, string asset) + { + return options.GetFormattedBaseUrl() + asset; + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppLinkTagHelper.md b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppLinkTagHelper.md index e3b25d2c1..c17a53a33 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppLinkTagHelper.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppLinkTagHelper.md @@ -7,37 +7,45 @@ example: The following example demonstrates how to create with application-scoped options. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Configuration; using Cuemon.AspNetCore.Razor.TagHelpers; using Microsoft.Extensions.Options; +using MyApp.Examples; -namespace MyApp.Examples; +AppLinkTagHelperExample.Demonstrate(); -public static class AppLinkTagHelperExample +namespace MyApp.Examples { - private sealed class StylesheetVersion : ICacheBusting + public static class AppLinkTagHelperExample { - public string Version => "1.0.0"; - } - - public static void Demonstrate() - { - var options = new AppTagHelperOptions + private sealed class StylesheetVersion : ICacheBusting { - Scheme = ProtocolUriScheme.Relative, - BaseUrl = "static.cuemon.net" - }; + public string Version => "1.0.0"; + } - var version = new StylesheetVersion(); - var tagHelper = new AppLinkTagHelper(Options.Create(options), version) + public static void Demonstrate() { - Href = "css/site.css" - }; - var stylesheetHref = $"{tagHelper.Options.GetFormattedBaseUrl()}{tagHelper.Href}?v={version.Version}"; - - Console.WriteLine(stylesheetHref); + var options = new AppTagHelperOptions + { + Scheme = ProtocolUriScheme.Relative, + BaseUrl = "static.cuemon.net" + }; + + var version = new StylesheetVersion(); + var tagHelper = new AppLinkTagHelper(Options.Create(options), version) + { + Href = "css/site.css" + }; + var stylesheetHref = $"{tagHelper.Options.GetFormattedBaseUrl()}{tagHelper.Href}?v={version.Version}"; + + Console.WriteLine(stylesheetHref); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppScriptTagHelper.md b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppScriptTagHelper.md index e528c1f3c..3f4f49f71 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppScriptTagHelper.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppScriptTagHelper.md @@ -7,30 +7,26 @@ example: The following example demonstrates how to create with application-scoped options. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Razor.TagHelpers; using Microsoft.Extensions.Options; -namespace MyApp.Examples; - -public static class AppScriptTagHelperExample +var options = Options.Create(new AppTagHelperOptions { - public static void Demonstrate() - { - var options = Options.Create(new AppTagHelperOptions - { - Scheme = ProtocolUriScheme.Relative, - BaseUrl = "static.cuemon.net" - }); - - var tagHelper = new AppScriptTagHelper(options) - { - Src = "js/app.js", - Defer = true - }; + Scheme = ProtocolUriScheme.Relative, + BaseUrl = "static.cuemon.net" +}); - Console.WriteLine(string.Concat(tagHelper.Options.GetFormattedBaseUrl(), tagHelper.Src)); - } -} +var tagHelper = new AppScriptTagHelper(options) +{ + Src = "js/app.js", + Defer = true +}; +Console.WriteLine(string.Concat(tagHelper.Options.GetFormattedBaseUrl(), tagHelper.Src)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppTagHelperOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppTagHelperOptions.md index bf233275d..3239561ed 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppTagHelperOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.AppTagHelperOptions.md @@ -32,3 +32,7 @@ public class AppTagHelperOptionsExample } ``` + + +
View Native Script · View Docker Script

Starts the host with a timeout, performs the demonstrated action, and shuts down cleanly.

+ diff --git a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnImageTagHelper.md b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnImageTagHelper.md index 5d06ffe76..e1b0e8f0a 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnImageTagHelper.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnImageTagHelper.md @@ -7,38 +7,46 @@ example: The following example demonstrates how to create `CdnImageTagHelper` with CDN-specific options. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Configuration; using Cuemon.AspNetCore.Razor.TagHelpers; using Microsoft.Extensions.Options; +using MyApp.Examples; -namespace MyApp.Examples; +CdnImageTagHelperExample.Demonstrate(); -public static class CdnImageTagHelperExample +namespace MyApp.Examples { - private sealed class AssetVersion : ICacheBusting + public static class CdnImageTagHelperExample { - public string Version => "2.1.0"; - } - - public static void Demonstrate() - { - var settings = new CdnTagHelperOptions + private sealed class AssetVersion : ICacheBusting { - Scheme = ProtocolUriScheme.Https, - BaseUrl = "nblcdn.net" - }; + public string Version => "2.1.0"; + } - var version = new AssetVersion(); - var tagHelper = new CdnImageTagHelper(Options.Create(settings), version) + public static void Demonstrate() { - Src = "images/logo.svg", - Alt = "Codebelt logo" - }; - var imageUrl = tagHelper.Options.GetFormattedBaseUrl() + tagHelper.Src + "?v=" + version.Version; - - Console.WriteLine(imageUrl); + var settings = new CdnTagHelperOptions + { + Scheme = ProtocolUriScheme.Https, + BaseUrl = "nblcdn.net" + }; + + var version = new AssetVersion(); + var tagHelper = new CdnImageTagHelper(Options.Create(settings), version) + { + Src = "images/logo.svg", + Alt = "Codebelt logo" + }; + var imageUrl = tagHelper.Options.GetFormattedBaseUrl() + tagHelper.Src + "?v=" + version.Version; + + Console.WriteLine(imageUrl); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnLinkTagHelper.md b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnLinkTagHelper.md index a035c553e..3d859d7ea 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnLinkTagHelper.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnLinkTagHelper.md @@ -7,35 +7,43 @@ example: The following example demonstrates how to create `CdnLinkTagHelper` with CDN-specific options. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Razor.TagHelpers; using Microsoft.Extensions.Options; +using MyApp.Examples; -namespace MyApp.Examples; +CdnLinkTagHelperExample.Demonstrate(); -public static class CdnLinkTagHelperExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class CdnLinkTagHelperExample { - var options = Options.Create(CreateStylesheetOptions("nblcdn.net")); - - var tagHelper = new CdnLinkTagHelper(options) + public static void Demonstrate() { - Href = "packages/fontawesome/5.15.3/css/all.css" - }; - var stylesheetHref = tagHelper.Options.GetFormattedBaseUrl() + tagHelper.Href; + var options = Options.Create(CreateStylesheetOptions("nblcdn.net")); - Console.WriteLine(stylesheetHref); - } + var tagHelper = new CdnLinkTagHelper(options) + { + Href = "packages/fontawesome/5.15.3/css/all.css" + }; + var stylesheetHref = tagHelper.Options.GetFormattedBaseUrl() + tagHelper.Href; - private static CdnTagHelperOptions CreateStylesheetOptions(string baseUrl) - { - return new CdnTagHelperOptions + Console.WriteLine(stylesheetHref); + } + + private static CdnTagHelperOptions CreateStylesheetOptions(string baseUrl) { - Scheme = ProtocolUriScheme.Https, - BaseUrl = baseUrl - }; + return new CdnTagHelperOptions + { + Scheme = ProtocolUriScheme.Https, + BaseUrl = baseUrl + }; + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnScriptTagHelper.md b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnScriptTagHelper.md index a0fdc6ce6..66c40e859 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnScriptTagHelper.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnScriptTagHelper.md @@ -7,38 +7,46 @@ example: The following example demonstrates how to create `CdnScriptTagHelper` with CDN-specific options. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Configuration; using Cuemon.AspNetCore.Razor.TagHelpers; using Microsoft.Extensions.Options; +using MyApp.Examples; -namespace MyApp.Examples; +CdnScriptTagHelperExample.Demonstrate(); -public static class CdnScriptTagHelperExample +namespace MyApp.Examples { - private sealed class ScriptVersion : ICacheBusting + public static class CdnScriptTagHelperExample { - public string Version => "1.0.0"; - } - - public static void Demonstrate() - { - var options = Options.Create(new CdnTagHelperOptions + private sealed class ScriptVersion : ICacheBusting { - Scheme = ProtocolUriScheme.Https, - BaseUrl = "nblcdn.net" - }); + public string Version => "1.0.0"; + } - var cacheBusting = new ScriptVersion(); - var tagHelper = new CdnScriptTagHelper(options, cacheBusting) + public static void Demonstrate() { - Src = "packages/fontawesome/5.15.3/js/all.js", - Defer = true - }; - var scriptPath = string.Concat(tagHelper.Options.GetFormattedBaseUrl(), tagHelper.Src, "?v=", cacheBusting.Version); - - Console.WriteLine(scriptPath); + var options = Options.Create(new CdnTagHelperOptions + { + Scheme = ProtocolUriScheme.Https, + BaseUrl = "nblcdn.net" + }); + + var cacheBusting = new ScriptVersion(); + var tagHelper = new CdnScriptTagHelper(options, cacheBusting) + { + Src = "packages/fontawesome/5.15.3/js/all.js", + Defer = true + }; + var scriptPath = string.Concat(tagHelper.Options.GetFormattedBaseUrl(), tagHelper.Src, "?v=", cacheBusting.Version); + + Console.WriteLine(scriptPath); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnTagHelperOptions.md b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnTagHelperOptions.md index 2588fb747..da12e8cca 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnTagHelperOptions.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.CdnTagHelperOptions.md @@ -7,23 +7,19 @@ example: The following example demonstrates how to configure for CDN-scoped tag helpers. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Razor.TagHelpers; -namespace MyApp.Examples; - -public static class CdnTagHelperOptionsExample +var options = new CdnTagHelperOptions { - public static void Demonstrate() - { - var options = new CdnTagHelperOptions - { - Scheme = ProtocolUriScheme.Https, - BaseUrl = "nblcdn.net" - }; - - Console.WriteLine(options.GetFormattedBaseUrl()); - } -} + Scheme = ProtocolUriScheme.Https, + BaseUrl = "nblcdn.net" +}; +Console.WriteLine(options.GetFormattedBaseUrl()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.ProtocolUriScheme.md b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.ProtocolUriScheme.md index 16dc2e201..5c1d396c5 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.ProtocolUriScheme.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.ProtocolUriScheme.md @@ -7,25 +7,20 @@ example: The following example demonstrates how to use the enum when configuring tag helper options. ```csharp +// Program.cs using Cuemon.AspNetCore.Razor.TagHelpers; using System; -namespace DocfxExamples; - -public class ProtocolUriSchemeExample +var options = new CdnTagHelperOptions { - public void Demonstrate() - { - var options = new CdnTagHelperOptions - { - Scheme = ProtocolUriScheme.Https, - BaseUrl = "cdn.example.com" - }; - - var formatted = options.GetFormattedBaseUrl(); - Console.WriteLine(formatted); // Output: https://cdn.example.com/ - -} -} + Scheme = ProtocolUriScheme.Https, + BaseUrl = "cdn.example.com" +}; +var formatted = options.GetFormattedBaseUrl(); +Console.WriteLine(formatted); // Output: https://cdn.example.com/ ``` + + + + diff --git a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.TagHelperBaseUrlMode.md b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.TagHelperBaseUrlMode.md index 856affa91..e39135aea 100644 --- a/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.TagHelperBaseUrlMode.md +++ b/.docfx/api/types/Cuemon.AspNetCore.Razor.TagHelpers.TagHelperBaseUrlMode.md @@ -7,35 +7,31 @@ example: The `TagHelperBaseUrlMode` enumeration controls how the base URL of a static resource is resolved by the app- and CDN-scoped tag helpers. `Configured` (the default) resolves the base URL exclusively from the configured `BaseUrl` and `Scheme`, whereas `Automatic` uses the configured `BaseUrl` when present and otherwise derives the base URL from the current HTTP request — useful when the same deployment is served from multiple origins. The following example demonstrates both modes through `CdnTagHelperOptions` and `GetFormattedBaseUrl`. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Razor.TagHelpers; using Microsoft.AspNetCore.Http; -namespace DocfxExamples; - -public class TagHelperBaseUrlModeExample +var configured = new CdnTagHelperOptions { - public void Demonstrate() - { - var configured = new CdnTagHelperOptions - { - BaseUrlMode = TagHelperBaseUrlMode.Configured, - Scheme = ProtocolUriScheme.Https, - BaseUrl = "static.example.com" - }; - Console.WriteLine(configured.GetFormattedBaseUrl()); // Output: https://static.example.com/ - - var automatic = new CdnTagHelperOptions - { - BaseUrlMode = TagHelperBaseUrlMode.Automatic, - BaseUrl = null // No fixed origin, so fall back to the current HTTP request. - }; - var request = new DefaultHttpContext().Request; - request.Scheme = "https"; - request.Host = new HostString("app.example.com"); - request.PathBase = "/myapp"; - Console.WriteLine(automatic.GetFormattedBaseUrl(request)); // Output: https://app.example.com/myapp/ - } -} + BaseUrlMode = TagHelperBaseUrlMode.Configured, + Scheme = ProtocolUriScheme.Https, + BaseUrl = "static.example.com" +}; +Console.WriteLine(configured.GetFormattedBaseUrl()); // Output: https://static.example.com/ +var automatic = new CdnTagHelperOptions +{ + BaseUrlMode = TagHelperBaseUrlMode.Automatic, + BaseUrl = null // No fixed origin, so fall back to the current HTTP request. +}; +var request = new DefaultHttpContext().Request; +request.Scheme = "https"; +request.Host = new HostString("app.example.com"); +request.PathBase = "/myapp"; +Console.WriteLine(automatic.GetFormattedBaseUrl(request)); // Output: https://app.example.com/myapp/ ``` + + + + diff --git a/.docfx/api/types/Cuemon.AssignmentOperator.md b/.docfx/api/types/Cuemon.AssignmentOperator.md index e03007c07..bd09709f6 100644 --- a/.docfx/api/types/Cuemon.AssignmentOperator.md +++ b/.docfx/api/types/Cuemon.AssignmentOperator.md @@ -7,20 +7,17 @@ example: The following example demonstrates how to use the enum to specify arithmetic or bitwise compound assignment operations. ```csharp +// Program.cs using System; using Cuemon; -namespace Contoso.Billing; +int total = Calculator.Calculate(5, AssignmentOperator.Addition, 3); +int shifted = Calculator.Calculate(5, AssignmentOperator.LeftShift, 2); -public sealed class AssignmentOperatorExample -{ - public static void Run() - { - int total = Calculator.Calculate(5, AssignmentOperator.Addition, 3); - int shifted = Calculator.Calculate(5, AssignmentOperator.LeftShift, 2); - - Console.WriteLine($"Total: {total}"); - Console.WriteLine($"Shifted: {shifted}"); - } -} +Console.WriteLine($"Total: {total}"); +Console.WriteLine($"Shifted: {shifted}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.ByteArrayDecoratorExtensions.md b/.docfx/api/types/Cuemon.ByteArrayDecoratorExtensions.md index 730ebed32..62fa92a00 100644 --- a/.docfx/api/types/Cuemon.ByteArrayDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.ByteArrayDecoratorExtensions.md @@ -7,44 +7,39 @@ example: `ByteArrayDecoratorExtensions` provides extension methods on `Decorator.Enclose` for converting byte arrays into strings, streams, and encoded text with configurable encoding. This example wraps a UTF-8 byte array and the ISO-8859-1-encoded `"Café"` bytes, then calls `ToEncodedString`, `ToStream`, and reads the stream via `StreamReader`. Key steps include setting encoding via the options delegate and verifying the stream is seekable and the correct length. Console output confirms the decoded strings match the original text, and the stream reports `Length = 13` with `CanSeek = True`. ```csharp +// Program.cs using System; using System.IO; using System.Text; using Cuemon; using Cuemon.Text; -namespace MyApp -{ - public class ByteArrayDecoratorExtensionsExample - { - public void Demonstrate() - { - // Create a byte array from a string - byte[] data = Encoding.UTF8.GetBytes("Hello, World!"); - - // Convert bytes to a string with default UTF-8 encoding - string text = Decorator.Enclose(data).ToEncodedString(); - Console.WriteLine(text); // "Hello, World!" - - // Convert bytes to a string with specific encoding - byte[] isoData = Encoding.GetEncoding("iso-8859-1").GetBytes("Café"); - string isoText = Decorator.Enclose(isoData).ToEncodedString(o => - { - o.Encoding = Encoding.GetEncoding("iso-8859-1"); - }); - Console.WriteLine(isoText); // "Café" - - // Convert bytes to a seekable Stream - using Stream stream = Decorator.Enclose(data).ToStream(); - Console.WriteLine(stream.Length); // 13 - Console.WriteLine(stream.CanSeek); // True - - // Read the stream back - using var reader = new StreamReader(stream); - string fromStream = reader.ReadToEnd(); - Console.WriteLine(fromStream); // "Hello, World!" - -}} -} +// Create a byte array from a string +byte[] data = Encoding.UTF8.GetBytes("Hello, World!"); + +// Convert bytes to a string with default UTF-8 encoding +string text = Decorator.Enclose(data).ToEncodedString(); +Console.WriteLine(text); // "Hello, World!" +// Convert bytes to a string with specific encoding +byte[] isoData = Encoding.GetEncoding("iso-8859-1").GetBytes("Café"); +string isoText = Decorator.Enclose(isoData).ToEncodedString(o => +{ + o.Encoding = Encoding.GetEncoding("iso-8859-1"); +}); +Console.WriteLine(isoText); // "Café" + +// Convert bytes to a seekable Stream +using Stream stream = Decorator.Enclose(data).ToStream(); +Console.WriteLine(stream.Length); // 13 +Console.WriteLine(stream.CanSeek); // True + +// Read the stream back +using var reader = new StreamReader(stream); +string fromStream = reader.ReadToEnd(); +Console.WriteLine(fromStream); // "Hello, World!" ``` + + + + diff --git a/.docfx/api/types/Cuemon.Calculator.md b/.docfx/api/types/Cuemon.Calculator.md index 33d479f3b..d2c3f1d8c 100644 --- a/.docfx/api/types/Cuemon.Calculator.md +++ b/.docfx/api/types/Cuemon.Calculator.md @@ -7,32 +7,29 @@ example: The following example demonstrates how to use the `Calculator` class to perform basic arithmetic and bitwise operations. Each method call prints the computed result to the console. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.Arithmetic; +int sum = Calculator.Add(10, 20); +Console.WriteLine(sum); // 30 -public class CalculatorExample -{ - public void Demonstrate() - { - int sum = Calculator.Add(10, 20); - Console.WriteLine(sum); // 30 +int difference = Calculator.Subtract(20, 5); +Console.WriteLine(difference); // 15 - int difference = Calculator.Subtract(20, 5); - Console.WriteLine(difference); // 15 +int product = Calculator.Multiply(4, 5); +Console.WriteLine(product); // 20 - int product = Calculator.Multiply(4, 5); - Console.WriteLine(product); // 20 +int quotient = Calculator.Divide(20, 4); +Console.WriteLine(quotient); // 5 - int quotient = Calculator.Divide(20, 4); - Console.WriteLine(quotient); // 5 +int remainder = Calculator.Remainder(10, 3); +Console.WriteLine(remainder); // 1 - int remainder = Calculator.Remainder(10, 3); - Console.WriteLine(remainder); // 1 - - int bitwiseAnd = Calculator.And(0b1100, 0b1010); - Console.WriteLine(bitwiseAnd); // 8 (0b1000) - } -} +int bitwiseAnd = Calculator.And(0b1100, 0b1010); +Console.WriteLine(bitwiseAnd); // 8 (0b1000) ``` + + + + diff --git a/.docfx/api/types/Cuemon.CasingMethod.md b/.docfx/api/types/Cuemon.CasingMethod.md index 20beb6bad..2e4295ff2 100644 --- a/.docfx/api/types/Cuemon.CasingMethod.md +++ b/.docfx/api/types/Cuemon.CasingMethod.md @@ -7,24 +7,19 @@ example: The following example demonstrates how to use `CasingMethod` to control string casing transformations. ```csharp +// Program.cs using Cuemon; using System; -namespace MyApp.Examples; - -public class CasingMethodExample -{ - public void Demonstrate() - { - var lower = CasingMethod.LowerCase; - var upper = CasingMethod.UpperCase; - var title = CasingMethod.TitleCase; - - Console.WriteLine(lower); // outputs: LowerCase - Console.WriteLine(upper); // outputs: UpperCase - Console.WriteLine(title); // outputs: TitleCase - -} -} +var lower = CasingMethod.LowerCase; +var upper = CasingMethod.UpperCase; +var title = CasingMethod.TitleCase; +Console.WriteLine(lower); // outputs: LowerCase +Console.WriteLine(upper); // outputs: UpperCase +Console.WriteLine(title); // outputs: TitleCase ``` + + + + diff --git a/.docfx/api/types/Cuemon.CharDecoratorExtensions.md b/.docfx/api/types/Cuemon.CharDecoratorExtensions.md index 066b57f13..f089107ea 100644 --- a/.docfx/api/types/Cuemon.CharDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.CharDecoratorExtensions.md @@ -7,33 +7,28 @@ example: `CharDecoratorExtensions` provides extension methods on `Decorator.Enclose` for converting between `IEnumerable` sequences and string collections. This example wraps the characters of `"Hello"` and calls `ToEnumerable` to split them into single-character strings, then `ToStringEquivalent` to rejoin them back into the original string. It also demonstrates the same round-trip with a `char[]` array of `'A'`, `'B'`, `'C'`. Console output confirms the split produces `"H, e, l, l, o"` and the rejoined result matches `"Hello"` and `"ABC"`. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; using Cuemon; -namespace MyApp -{ - public class CharDecoratorExtensionsExample - { - public void Demonstrate() - { - // Convert a sequence of characters to a sequence of single-character strings - IEnumerable characters = "Hello".AsEnumerable(); +// Convert a sequence of characters to a sequence of single-character strings +IEnumerable characters = "Hello".AsEnumerable(); - IEnumerable strings = Decorator.Enclose(characters).ToEnumerable(); - Console.WriteLine(string.Join(", ", strings)); // "H, e, l, l, o" +IEnumerable strings = Decorator.Enclose(characters).ToEnumerable(); +Console.WriteLine(string.Join(", ", strings)); // "H, e, l, l, o" - // Convert a sequence of characters back to a single string - string result = Decorator.Enclose(characters).ToStringEquivalent(); - Console.WriteLine(result); // "Hello" - - // Works with any IEnumerable including char arrays - char[] charArray = { 'A', 'B', 'C' }; - string joined = Decorator.Enclose(charArray.AsEnumerable()).ToStringEquivalent(); - Console.WriteLine(joined); // "ABC" - -}} -} +// Convert a sequence of characters back to a single string +string result = Decorator.Enclose(characters).ToStringEquivalent(); +Console.WriteLine(result); // "Hello" +// Works with any IEnumerable including char arrays +char[] charArray = { 'A', 'B', 'C' }; +string joined = Decorator.Enclose(charArray.AsEnumerable()).ToStringEquivalent(); +Console.WriteLine(joined); // "ABC" ``` + + + + diff --git a/.docfx/api/types/Cuemon.Collections.Generic.Arguments.md b/.docfx/api/types/Cuemon.Collections.Generic.Arguments.md index d934e2f2b..25f51db96 100644 --- a/.docfx/api/types/Cuemon.Collections.Generic.Arguments.md +++ b/.docfx/api/types/Cuemon.Collections.Generic.Arguments.md @@ -7,35 +7,32 @@ example: The following example demonstrates how to use the `Arguments` class to create arrays and enumerables from argument lists. It shows array concatenation, single-element yielding, and object-based overloads. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; using Cuemon.Collections.Generic; -namespace MyApp.Examples; +int[] first = Arguments.ToArrayOf(1, 2, 3); +int[] second = Arguments.ToArrayOf(4, 5, 6); -public static class ArgumentsExample -{ - public static void Demonstrate() - { - int[] first = Arguments.ToArrayOf(1, 2, 3); - int[] second = Arguments.ToArrayOf(4, 5, 6); +// Concat two arrays +int[] combined = Arguments.Concat(first, second); +Console.WriteLine(string.Join(", ", combined)); - // Concat two arrays - int[] combined = Arguments.Concat(first, second); - Console.WriteLine(string.Join(", ", combined)); +// Yield a single element +IEnumerable yielded = Arguments.Yield(42); +Console.WriteLine(yielded.First()); - // Yield a single element - IEnumerable yielded = Arguments.Yield(42); - Console.WriteLine(yielded.First()); +// Convert to IEnumerable +IEnumerable enumerable = Arguments.ToEnumerableOf("a", "b", "c"); +Console.WriteLine(string.Concat(enumerable)); - // Convert to IEnumerable - IEnumerable enumerable = Arguments.ToEnumerableOf("a", "b", "c"); - Console.WriteLine(string.Concat(enumerable)); - - // Object overloads - object[] objs = Arguments.ToArray(1, "two", 3.0); - IEnumerable objEnumerable = Arguments.ToEnumerable(true, false); - } -} +// Object overloads +object[] objs = Arguments.ToArray(1, "two", 3.0); +IEnumerable objEnumerable = Arguments.ToEnumerable(true, false); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Collections.Generic.CollectionDecoratorExtensions.md b/.docfx/api/types/Cuemon.Collections.Generic.CollectionDecoratorExtensions.md index bdd4b281d..a6b3dadde 100644 --- a/.docfx/api/types/Cuemon.Collections.Generic.CollectionDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Collections.Generic.CollectionDecoratorExtensions.md @@ -7,26 +7,21 @@ example: `CollectionDecoratorExtensions` provides extension methods on `Decorator.Enclose` for bulk-adding elements to `ICollection` instances using `AddRange`. This example wraps a `List` with `"apple", "banana"` and calls `AddRange` with individual `"cherry", "date", "elderberry"` arguments and an array `["fig", "grape"]` to insert them in a single operation. Key setup includes calling `Decorator.Enclose(list).AddRange(...)` to access the non-common extension methods. Console output lists all entries after both bulk insertions, confirming that `AddRange` accepts both parameterized and array overloads. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon; using Cuemon.Collections.Generic; -namespace MyApp.Examples -{ - public class CollectionDecoratorExtensionsExample - { - public static void Demonstrate() - { - var list = new List { "apple", "banana" }; +var list = new List { "apple", "banana" }; - // Use Decorator to access non-common extension methods - Decorator.Enclose(list).AddRange("cherry", "date", "elderberry"); - Decorator.Enclose(list).AddRange(new[] { "fig", "grape" }); - - Console.WriteLine(string.Join(", ", list)); - -}} -} +// Use Decorator to access non-common extension methods +Decorator.Enclose(list).AddRange("cherry", "date", "elderberry"); +Decorator.Enclose(list).AddRange(new[] { "fig", "grape" }); +Console.WriteLine(string.Join(", ", list)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Collections.Generic.DictionaryDecoratorExtensions.md b/.docfx/api/types/Cuemon.Collections.Generic.DictionaryDecoratorExtensions.md index 019b27d35..19b84928a 100644 --- a/.docfx/api/types/Cuemon.Collections.Generic.DictionaryDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Collections.Generic.DictionaryDecoratorExtensions.md @@ -7,42 +7,39 @@ example: The following example demonstrates dictionary extension methods available through the `Decorator` wrapper. It shows get-or-fallback, try-add, add-or-update, copying, and depth-indexing operations, printing each result to the console. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; using Cuemon; using Cuemon.Collections.Generic; -namespace Contoso.Inventory; - -public sealed class DictionaryDecoratorExtensionsExample +IDictionary catalog = new Dictionary { - public static void Run() - { - IDictionary catalog = new Dictionary - { - [1] = "apples", - [2] = "bananas" - }; - - var decorated = Decorator.Enclose(catalog); - string fallback = decorated.GetValueOrDefault(3, () => "not found"); - bool found = decorated.TryGetValueOrFallback(42, keys => 2, out var alias); - bool added = decorated.TryAdd(3, "cherries"); - decorated.AddOrUpdate(2, "blueberries"); - KeyValuePair[] entries = decorated.ToEnumerable().ToArray(); - - IDictionary copy = decorated.CopyTo(new Dictionary()); - - IDictionary> depthIndexes = new Dictionary>(); - int depthIndex = Decorator.Enclose(depthIndexes).GetDepthIndex(readerDepth: 0, index: 1, nesting: 0); - - Console.WriteLine($"Fallback: {fallback}"); - Console.WriteLine($"Found fallback key: {found} -> {alias}"); - Console.WriteLine($"Added key 3: {added}"); - Console.WriteLine($"Enumerated entries: {entries.Length}"); - Console.WriteLine($"Copied entries: {copy.Count}"); - Console.WriteLine($"Depth index: {depthIndex}"); - } -} + [1] = "apples", + [2] = "bananas" +}; + +var decorated = Decorator.Enclose(catalog); +string fallback = decorated.GetValueOrDefault(3, () => "not found"); +bool found = decorated.TryGetValueOrFallback(42, keys => 2, out var alias); +bool added = decorated.TryAdd(3, "cherries"); +decorated.AddOrUpdate(2, "blueberries"); +KeyValuePair[] entries = decorated.ToEnumerable().ToArray(); + +IDictionary copy = decorated.CopyTo(new Dictionary()); + +IDictionary> depthIndexes = new Dictionary>(); +int depthIndex = Decorator.Enclose(depthIndexes).GetDepthIndex(readerDepth: 0, index: 1, nesting: 0); + +Console.WriteLine($"Fallback: {fallback}"); +Console.WriteLine($"Found fallback key: {found} -> {alias}"); +Console.WriteLine($"Added key 3: {added}"); +Console.WriteLine($"Enumerated entries: {entries.Length}"); +Console.WriteLine($"Copied entries: {copy.Count}"); +Console.WriteLine($"Depth index: {depthIndex}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Collections.Generic.DynamicComparer.md b/.docfx/api/types/Cuemon.Collections.Generic.DynamicComparer.md index 9f87e6002..140870080 100644 --- a/.docfx/api/types/Cuemon.Collections.Generic.DynamicComparer.md +++ b/.docfx/api/types/Cuemon.Collections.Generic.DynamicComparer.md @@ -7,32 +7,29 @@ example: The following example shows how to create custom `IComparer` instances using `DynamicComparer` with lambda expressions. It demonstrates sorting by string length and in descending order, printing each sorted array. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; using Cuemon.Collections.Generic; -namespace MyApp.Examples; +string[] fruits = ["apple", "pear", "banana", "kiwi"]; -public static class DynamicComparerExample -{ - public static void Demonstrate() - { - string[] fruits = ["apple", "pear", "banana", "kiwi"]; +// Create a dynamic comparer that sorts by string length +IComparer lengthComparer = DynamicComparer.Create((x, y) => + x.Length.CompareTo(y.Length)); - // Create a dynamic comparer that sorts by string length - IComparer lengthComparer = DynamicComparer.Create((x, y) => - x.Length.CompareTo(y.Length)); +Array.Sort(fruits, lengthComparer); +Console.WriteLine(string.Join(", ", fruits)); - Array.Sort(fruits, lengthComparer); - Console.WriteLine(string.Join(", ", fruits)); +// Create a comparer that sorts descending +IComparer descendingComparer = DynamicComparer.Create((x, y) => + string.Compare(y, x, StringComparison.Ordinal)); - // Create a comparer that sorts descending - IComparer descendingComparer = DynamicComparer.Create((x, y) => - string.Compare(y, x, StringComparison.Ordinal)); - - Array.Sort(fruits, descendingComparer); - Console.WriteLine(string.Join(", ", fruits)); - } -} +Array.Sort(fruits, descendingComparer); +Console.WriteLine(string.Join(", ", fruits)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Collections.Generic.DynamicEqualityComparer.md b/.docfx/api/types/Cuemon.Collections.Generic.DynamicEqualityComparer.md index 878c9b810..f298570b2 100644 --- a/.docfx/api/types/Cuemon.Collections.Generic.DynamicEqualityComparer.md +++ b/.docfx/api/types/Cuemon.Collections.Generic.DynamicEqualityComparer.md @@ -7,26 +7,23 @@ example: The following example shows how to create a case-insensitive `IEqualityComparer` using `DynamicEqualityComparer` with lambda expressions. It filters distinct values from a mixed-case word list and prints the result. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; using Cuemon.Collections.Generic; -namespace MyApp.Examples; +string[] words = ["Hello", "world", "hello", "World", "HELLO"]; -public static class DynamicEqualityComparerExample -{ - public static void Demonstrate() - { - string[] words = ["Hello", "world", "hello", "World", "HELLO"]; +// Create a case-insensitive equality comparer for strings +IEqualityComparer caseInsensitive = DynamicEqualityComparer.Create( + hashCalculator: s => StringComparer.OrdinalIgnoreCase.GetHashCode(s), + equalityComparer: (x, y) => string.Equals(x, y, StringComparison.OrdinalIgnoreCase)); - // Create a case-insensitive equality comparer for strings - IEqualityComparer caseInsensitive = DynamicEqualityComparer.Create( - hashCalculator: s => StringComparer.OrdinalIgnoreCase.GetHashCode(s), - equalityComparer: (x, y) => string.Equals(x, y, StringComparison.OrdinalIgnoreCase)); - - string[] distinct = words.Distinct(caseInsensitive).ToArray(); - Console.WriteLine(string.Join(", ", distinct)); - } -} +string[] distinct = words.Distinct(caseInsensitive).ToArray(); +Console.WriteLine(string.Join(", ", distinct)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Collections.Generic.EnumReadOnlyDictionary`1.md b/.docfx/api/types/Cuemon.Collections.Generic.EnumReadOnlyDictionary`1.md index 43336bd6d..5306724d3 100644 --- a/.docfx/api/types/Cuemon.Collections.Generic.EnumReadOnlyDictionary`1.md +++ b/.docfx/api/types/Cuemon.Collections.Generic.EnumReadOnlyDictionary`1.md @@ -7,46 +7,43 @@ example: The following example demonstrates how to use to create a read-only dictionary that maps each enum value (as its underlying integral type wrapped in ) to its string name. ```csharp +// Program.cs using System.Collections.Generic; using System; using System.Linq; using Cuemon.Collections.Generic; -namespace MyApp.Examples; +// Create a dictionary that maps DayOfWeek values to their string names +var days = new EnumReadOnlyDictionary(); -public class EnumReadOnlyDictionaryExample +Console.WriteLine(days.Count); // 7 + +// Iterate through all entries (keys are the underlying integral values) +foreach (var kvp in days.OrderBy(kvp => kvp.Key.ToInt32(null))) +{ + Console.WriteLine($"{kvp.Key.ToInt32(null)} -> {kvp.Value}"); +// Output: +// 0 -> Sunday +// 1 -> Monday +// 2 -> Tuesday +// 3 -> Wednesday +// 4 -> Thursday +// 5 -> Friday +// 6 -> Saturday + +// Access the values collection directly +foreach (var name in days.Values) { - public void Demonstrate() - { - // Create a dictionary that maps DayOfWeek values to their string names - var days = new EnumReadOnlyDictionary(); - - Console.WriteLine(days.Count); // 7 - - // Iterate through all entries (keys are the underlying integral values) - foreach (var kvp in days.OrderBy(kvp => kvp.Key.ToInt32(null))) - { - Console.WriteLine($"{kvp.Key.ToInt32(null)} -> {kvp.Value}"); - // Output: - // 0 -> Sunday - // 1 -> Monday - // 2 -> Tuesday - // 3 -> Wednesday - // 4 -> Thursday - // 5 -> Friday - // 6 -> Saturday - - // Access the values collection directly - foreach (var name in days.Values) - { - Console.WriteLine(name); // Sunday, Monday, ..., Saturday - - // Access the keys collection - foreach (var key in days.Keys) - { - Console.WriteLine(key.ToInt32(null)); // 0, 1, 2, ..., 6 - -}}}} -} + Console.WriteLine(name); // Sunday, Monday, ..., Saturday +// Access the keys collection +foreach (var key in days.Keys) +{ + Console.WriteLine(key.ToInt32(null)); // 0, 1, 2, ..., 6 + +}}} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Collections.Generic.EnumerableSizeComparer-1.md b/.docfx/api/types/Cuemon.Collections.Generic.EnumerableSizeComparer-1.md index a39d69008..f133eee27 100644 --- a/.docfx/api/types/Cuemon.Collections.Generic.EnumerableSizeComparer-1.md +++ b/.docfx/api/types/Cuemon.Collections.Generic.EnumerableSizeComparer-1.md @@ -7,36 +7,31 @@ example: The following example demonstrates how to compare the sizes of enumerable collections using `EnumerableSizeComparer`. It shows comparisons between collections of different and equal sizes, including null-value handling. ```csharp +// Program.cs using System; using System.Collections; using System.Collections.Generic; using Cuemon.Collections.Generic; -namespace MyApp.Examples -{ - public class EnumerableSizeComparerExample - { - public static void Demonstrate() - { - var shortList = new[] { 10, 20, 30 }; - var longList = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; - var equalList = new[] { "x", "y", "z" }; +var shortList = new[] { 10, 20, 30 }; +var longList = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; +var equalList = new[] { "x", "y", "z" }; - var comparer = EnumerableSizeComparer.Default; +var comparer = EnumerableSizeComparer.Default; - int result1 = comparer.Compare(shortList, longList); // -1 (shortList has fewer elements) - int result2 = comparer.Compare(longList, shortList); // 1 (longList has more elements) - int result3 = comparer.Compare(shortList, equalList); // 0 (both have 3 elements) - int result4 = comparer.Compare(null, longList); // -1 (null is less than any non-null) - int result5 = comparer.Compare(shortList, null); // 1 (non-null is greater than null) - - Console.WriteLine($"shortList vs longList : {result1}"); - Console.WriteLine($"longList vs shortList : {result2}"); - Console.WriteLine($"shortList vs equalList: {result3}"); - Console.WriteLine($"null vs longList : {result4}"); - Console.WriteLine($"shortList vs null : {result5}"); - -}} -} +int result1 = comparer.Compare(shortList, longList); // -1 (shortList has fewer elements) +int result2 = comparer.Compare(longList, shortList); // 1 (longList has more elements) +int result3 = comparer.Compare(shortList, equalList); // 0 (both have 3 elements) +int result4 = comparer.Compare(null, longList); // -1 (null is less than any non-null) +int result5 = comparer.Compare(shortList, null); // 1 (non-null is greater than null) +Console.WriteLine($"shortList vs longList : {result1}"); +Console.WriteLine($"longList vs shortList : {result2}"); +Console.WriteLine($"shortList vs equalList: {result3}"); +Console.WriteLine($"null vs longList : {result4}"); +Console.WriteLine($"shortList vs null : {result5}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Collections.Generic.PaginationEnumerable-1.md b/.docfx/api/types/Cuemon.Collections.Generic.PaginationEnumerable-1.md index 52b0d8c33..de7b92fba 100644 --- a/.docfx/api/types/Cuemon.Collections.Generic.PaginationEnumerable-1.md +++ b/.docfx/api/types/Cuemon.Collections.Generic.PaginationEnumerable-1.md @@ -7,17 +7,12 @@ example: The following example demonstrates lazy pagination of a string array using `PaginationEnumerable`. It shows how to access page 2 with 3 items per page and prints page metadata such as page count and navigation flags. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; using Cuemon.Collections.Generic; -namespace MyApp.Examples -{ - public class PaginationEnumerableExample - { - public static void Demonstrate() - { var fruits = new[] { "Apple", "Banana", "Cherry", "Date", "Elderberry", "Fig", "Grape", "Honeydew" }; // Show page 2 with 3 items per page @@ -35,7 +30,9 @@ namespace MyApp.Examples { Console.WriteLine($" {item}"); -}}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Collections.Generic.PaginationList-1.md b/.docfx/api/types/Cuemon.Collections.Generic.PaginationList-1.md index 60ea3d6a3..18cacec99 100644 --- a/.docfx/api/types/Cuemon.Collections.Generic.PaginationList-1.md +++ b/.docfx/api/types/Cuemon.Collections.Generic.PaginationList-1.md @@ -7,16 +7,11 @@ example: The following example demonstrates eager pagination of a customer list using `PaginationList`. It shows indexer-based access and page metadata such as total items, page count, and first/last page flags. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon.Collections.Generic; -namespace MyApp.Examples -{ - public class PaginationListExample - { - public static void Demonstrate() - { var customers = new List { "Alice", "Bob", "Carol", "Dave", "Eve", @@ -40,7 +35,9 @@ namespace MyApp.Examples Console.WriteLine($"First page: {page.FirstPage}"); Console.WriteLine($"Last page: {page.LastPage}"); -}}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Collections.Generic.PaginationOptions.md b/.docfx/api/types/Cuemon.Collections.Generic.PaginationOptions.md index 7e1a37a6b..facaa9d28 100644 --- a/.docfx/api/types/Cuemon.Collections.Generic.PaginationOptions.md +++ b/.docfx/api/types/Cuemon.Collections.Generic.PaginationOptions.md @@ -7,60 +7,55 @@ example: The following example demonstrates how to configure pagination options with a custom page size and number. It shows both lazy (`PaginationEnumerable`) and eager (`PaginationList`) pagination, printing page metadata and specific items. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; using Cuemon.Collections.Generic; -namespace MyApp.Collections; +// Create a source sequence with 100 items +var allItems = Enumerable.Range(1, 100).ToList(); -public class PaginationOptionsExample -{ - public void Demonstrate() - { - // Create a source sequence with 100 items - var allItems = Enumerable.Range(1, 100).ToList(); - - // Configure pagination options directly - var options = new PaginationOptions { PageSize = 10, PageNumber = 3 }; - Console.WriteLine($"Page size: {options.PageSize}, Page number: {options.PageNumber}"); - - // Paginate with 10 items per page, starting at page 3 - var page = new PaginationEnumerable(allItems, - () => allItems.Count, - setup => - { - setup.PageSize = 10; // show 10 items per page - setup.PageNumber = 3; // go to page 3 - }); - - Console.WriteLine($"Page 3 items: {string.Join(", ", page)}"); // 21..30 - Console.WriteLine($"Total pages: {page.PageCount}"); // 10 - Console.WriteLine($"Total items: {page.TotalElementCount}"); // 100 - Console.WriteLine($"Has next page: {page.HasNextPage}"); // True - Console.WriteLine($"First page: {page.FirstPage}"); // False - Console.WriteLine($"Last page: {page.LastPage}"); // False - - // Default PaginationOptions: page 1, 25 items per page - var firstPage = new PaginationEnumerable(allItems, - () => allItems.Count); - - Console.WriteLine($"First page items: {string.Join(", ", firstPage)}"); // 1..25 - Console.WriteLine($"Has previous page: {firstPage.HasPreviousPage}"); // False +// Configure pagination options directly +var options = new PaginationOptions { PageSize = 10, PageNumber = 3 }; +Console.WriteLine($"Page size: {options.PageSize}, Page number: {options.PageNumber}"); - // Using PaginationList for eager materialization with indexer access - var thirdPage = new PaginationList(allItems, - () => allItems.Count, - setup => - { - setup.PageSize = 10; - setup.PageNumber = 3; - }); - - Console.WriteLine($"Third item on page 3: {thirdPage[2]}"); // 23 (zero-based index) - Console.WriteLine($"Page 3 count: {thirdPage.Count}"); // 10 - -} -} +// Paginate with 10 items per page, starting at page 3 +var page = new PaginationEnumerable(allItems, + () => allItems.Count, + setup => + { + setup.PageSize = 10; // show 10 items per page + setup.PageNumber = 3; // go to page 3 + }); + +Console.WriteLine($"Page 3 items: {string.Join(", ", page)}"); // 21..30 +Console.WriteLine($"Total pages: {page.PageCount}"); // 10 +Console.WriteLine($"Total items: {page.TotalElementCount}"); // 100 +Console.WriteLine($"Has next page: {page.HasNextPage}"); // True +Console.WriteLine($"First page: {page.FirstPage}"); // False +Console.WriteLine($"Last page: {page.LastPage}"); // False + +// Default PaginationOptions: page 1, 25 items per page +var firstPage = new PaginationEnumerable(allItems, + () => allItems.Count); + +Console.WriteLine($"First page items: {string.Join(", ", firstPage)}"); // 1..25 +Console.WriteLine($"Has previous page: {firstPage.HasPreviousPage}"); // False + +// Using PaginationList for eager materialization with indexer access +var thirdPage = new PaginationList(allItems, + () => allItems.Count, + setup => + { + setup.PageSize = 10; + setup.PageNumber = 3; + }); +Console.WriteLine($"Third item on page 3: {thirdPage[2]}"); // 23 (zero-based index) +Console.WriteLine($"Page 3 count: {thirdPage.Count}"); // 10 ``` + + + + diff --git a/.docfx/api/types/Cuemon.Collections.Generic.PartitionerCollection-1.md b/.docfx/api/types/Cuemon.Collections.Generic.PartitionerCollection-1.md index 910a6622e..6605ddce6 100644 --- a/.docfx/api/types/Cuemon.Collections.Generic.PartitionerCollection-1.md +++ b/.docfx/api/types/Cuemon.Collections.Generic.PartitionerCollection-1.md @@ -7,16 +7,11 @@ example: The following example shows how to partition a list of numbers into fixed-size groups using `PartitionerCollection`. It iterates through each partition and prints partition-level and collection-level metadata. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon.Collections.Generic; -namespace MyApp.Examples -{ - public class PartitionerCollectionExample - { - public static void Demonstrate() - { var numbers = new List(); for (int i = 1; i <= 50; i++) numbers.Add(i); @@ -43,7 +38,9 @@ namespace MyApp.Examples Console.WriteLine($"Iterated count: {partitioner.IteratedCount}"); Console.WriteLine($"Has remaining partitions: {partitioner.HasPartitions}"); -}}}} -} - +}} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Collections.Generic.PartitionerEnumerable`1.md b/.docfx/api/types/Cuemon.Collections.Generic.PartitionerEnumerable`1.md index faba04d0d..2cef6698d 100644 --- a/.docfx/api/types/Cuemon.Collections.Generic.PartitionerEnumerable`1.md +++ b/.docfx/api/types/Cuemon.Collections.Generic.PartitionerEnumerable`1.md @@ -7,60 +7,57 @@ example: The following example demonstrates how to use to iterate over a sequence in fixed-size partitions. It wraps a sequence of 1000 integers with a partition size of 100, then processes partitions sequentially using `ToList` while tracking the remaining partitions via `HasPartitions`. A smaller string partitioner shows the same behavior with an uneven final batch. The example outputs partition counts and content to the console, verifying that batching works correctly. ```csharp +// Program.cs using System; using System.Linq; using Cuemon.Collections.Generic; -namespace MyApp.Examples; +// Create a sequence of 1000 numbers +var numbers = Enumerable.Range(1, 1000); -public class PartitionerEnumerableExample -{ - public void Demonstrate() - { - // Create a sequence of 1000 numbers - var numbers = Enumerable.Range(1, 1000); - - // Wrap in a partitioner with partition size of 100 - var partitioner = new PartitionerEnumerable(numbers, partitionSize: 100); - - Console.WriteLine(partitioner.PartitionSize); // 100 - Console.WriteLine(partitioner.HasPartitions); // True - Console.WriteLine(partitioner.IteratedCount); // 0 - - // Process the first partition (items 1-100) - var firstBatch = partitioner.ToList(); - Console.WriteLine(firstBatch.Count); // 100 - Console.WriteLine(firstBatch[0]); // 1 - Console.WriteLine(firstBatch[99]); // 100 - - Console.WriteLine(partitioner.IteratedCount); // 1 - Console.WriteLine(partitioner.HasPartitions); // True +// Wrap in a partitioner with partition size of 100 +var partitioner = new PartitionerEnumerable(numbers, partitionSize: 100); - // Process the remaining partitions - while (partitioner.HasPartitions) - { - var batch = partitioner.ToList(); - Console.WriteLine($"Batch {partitioner.IteratedCount}: {batch.Count} items"); - // After exhausting the sequence: - Console.WriteLine(partitioner.HasPartitions); // False - Console.WriteLine(partitioner.IteratedCount); // 10 (1000/100) +Console.WriteLine(partitioner.PartitionSize); // 100 +Console.WriteLine(partitioner.HasPartitions); // True +Console.WriteLine(partitioner.IteratedCount); // 0 - // A partitioner can be iterated multiple times (each iteration - // advances through the source sequence) - var words = new PartitionerEnumerable( - new[] { "a", "b", "c", "d", "e", "f", "g", "h" }, - partitionSize: 3); +// Process the first partition (items 1-100) +var firstBatch = partitioner.ToList(); +Console.WriteLine(firstBatch.Count); // 100 +Console.WriteLine(firstBatch[0]); // 1 +Console.WriteLine(firstBatch[99]); // 100 - while (words.HasPartitions) - { - var chunk = words.ToList(); - Console.WriteLine(string.Join(",", chunk)); - // Output: - // a,b,c - // d,e,f - // g,h - -}}} -} +Console.WriteLine(partitioner.IteratedCount); // 1 +Console.WriteLine(partitioner.HasPartitions); // True +// Process the remaining partitions +while (partitioner.HasPartitions) +{ + var batch = partitioner.ToList(); + Console.WriteLine($"Batch {partitioner.IteratedCount}: {batch.Count} items"); +// After exhausting the sequence: +Console.WriteLine(partitioner.HasPartitions); // False +Console.WriteLine(partitioner.IteratedCount); // 10 (1000/100) + +// A partitioner can be iterated multiple times (each iteration +// advances through the source sequence) +var words = new PartitionerEnumerable( + new[] { "a", "b", "c", "d", "e", "f", "g", "h" }, + partitionSize: 3); + +while (words.HasPartitions) +{ + var chunk = words.ToList(); + Console.WriteLine(string.Join(",", chunk)); +// Output: +// a,b,c +// d,e,f +// g,h + +}} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Collections.Generic.ReferenceComparer-1.md b/.docfx/api/types/Cuemon.Collections.Generic.ReferenceComparer-1.md index cc476c782..05d93a162 100644 --- a/.docfx/api/types/Cuemon.Collections.Generic.ReferenceComparer-1.md +++ b/.docfx/api/types/Cuemon.Collections.Generic.ReferenceComparer-1.md @@ -7,48 +7,43 @@ example: The following example demonstrates how to compare objects by their inheritance depth using `ReferenceComparer`. It shows how objects with deeper inheritance chains are considered greater, including null-value comparisons. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon.Collections.Generic; -namespace MyApp.Collections; +// ReferenceComparer compares objects by their inheritance depth. +// Objects with a deeper inheritance chain are considered "greater." -public class ReferenceComparerExample -{ - public void Demonstrate() - { - // ReferenceComparer compares objects by their inheritance depth. - // Objects with a deeper inheritance chain are considered "greater." +// Compare two strings (string derives from object → depth 2) +string hello = "hello"; +string world = "world"; +IComparer comparer = ReferenceComparer.Default; - // Compare two strings (string derives from object → depth 2) - string hello = "hello"; - string world = "world"; - IComparer comparer = ReferenceComparer.Default; +int result1 = comparer.Compare(hello, world); +Console.WriteLine($"string vs string: {result1}"); // 0 (same depth) - int result1 = comparer.Compare(hello, world); - Console.WriteLine($"string vs string: {result1}"); // 0 (same depth) +// Compare a string with an Exception (deeper hierarchy) +var exception = new InvalidOperationException(); +int result2 = comparer.Compare(hello, exception); +Console.WriteLine($"string vs Exception: {result2}"); // -1 (string is shallower) - // Compare a string with an Exception (deeper hierarchy) - var exception = new InvalidOperationException(); - int result2 = comparer.Compare(hello, exception); - Console.WriteLine($"string vs Exception: {result2}"); // -1 (string is shallower) +// Compare an ArgumentNullException (depth 4) with Exception (depth 3) +var argEx = new ArgumentNullException(); +int result3 = comparer.Compare(argEx, exception); +Console.WriteLine($"ArgumentNullException vs Exception: {result3}"); // 1 (deeper) - // Compare an ArgumentNullException (depth 4) with Exception (depth 3) - var argEx = new ArgumentNullException(); - int result3 = comparer.Compare(argEx, exception); - Console.WriteLine($"ArgumentNullException vs Exception: {result3}"); // 1 (deeper) +// Compare with null values +int result4 = comparer.Compare(hello, null); +Console.WriteLine($"string vs null: {result4}"); // 1 (non-null is greater) - // Compare with null values - int result4 = comparer.Compare(hello, null); - Console.WriteLine($"string vs null: {result4}"); // 1 (non-null is greater) - - int result5 = comparer.Compare(null, hello); - Console.WriteLine($"null vs string: {result5}"); // -1 (null is lesser) - - int result6 = comparer.Compare(null, null); - Console.WriteLine($"null vs null: {result6}"); // 0 (both null) - -} -} +int result5 = comparer.Compare(null, hello); +Console.WriteLine($"null vs string: {result5}"); // -1 (null is lesser) +int result6 = comparer.Compare(null, null); +Console.WriteLine($"null vs null: {result6}"); // 0 (both null) ``` + + + + diff --git a/.docfx/api/types/Cuemon.Collections.Generic.StackDecoratorExtensions.md b/.docfx/api/types/Cuemon.Collections.Generic.StackDecoratorExtensions.md index e7b1a8a3f..d1b752741 100644 --- a/.docfx/api/types/Cuemon.Collections.Generic.StackDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Collections.Generic.StackDecoratorExtensions.md @@ -7,38 +7,33 @@ example: The following example demonstrates how to use `StackDecoratorExtensions.TryPop` to safely pop items from a `Stack` without throwing when it is empty. The decorator extension is present in the `netstandard2.0` asset, so the conditional branch calls it for .NET Framework consumers that select that asset; modern Cuemon.Core assets use the equivalent direct stack operation because the conditional extension type is not exposed there. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon; -#if NETFRAMEWORK || NETSTANDARD2_0_OR_GREATER using Cuemon.Collections.Generic; -#endif -namespace MyApp.Examples; - -public class StackDecoratorExtensionsExample -{ - public static void Demonstrate() - { - var stack = new Stack(); - stack.Push("first"); - stack.Push("second"); - stack.Push("third"); +var stack = new Stack(); +stack.Push("first"); +stack.Push("second"); +stack.Push("third"); #if NETFRAMEWORK || NETSTANDARD2_0_OR_GREATER - var decorator = Decorator.Enclose(stack); - while (decorator.TryPop(out string result)) - { - Console.WriteLine("Popped: " + result); - } - Console.WriteLine("Stack is now empty"); +var decorator = Decorator.Enclose(stack); +while (decorator.TryPop(out string result)) +{ + Console.WriteLine("Popped: " + result); +} +Console.WriteLine("Stack is now empty"); #else - while (stack.Count > 0) - { - Console.WriteLine("Popped: " + stack.Pop()); - } - Console.WriteLine("Stack is now empty"); -#endif - } +while (stack.Count > 0) +{ + Console.WriteLine("Popped: " + stack.Pop()); } +Console.WriteLine("Stack is now empty"); +#endif ``` + + + + diff --git a/.docfx/api/types/Cuemon.Collections.Specialized.DictionaryDecoratorExtensions.md b/.docfx/api/types/Cuemon.Collections.Specialized.DictionaryDecoratorExtensions.md index 3dd4a57c6..cca327386 100644 --- a/.docfx/api/types/Cuemon.Collections.Specialized.DictionaryDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Collections.Specialized.DictionaryDecoratorExtensions.md @@ -40,3 +40,7 @@ public class DictionaryDecoratorExtensionsExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Condition.md b/.docfx/api/types/Cuemon.Condition.md index 8662372bf..714ed0ed2 100644 --- a/.docfx/api/types/Cuemon.Condition.md +++ b/.docfx/api/types/Cuemon.Condition.md @@ -7,18 +7,13 @@ example: The following example demonstrates how to use the `Condition` class to perform common validation checks, equality comparisons, conditional branching, and range assertions. It exercises `AreEqual`, `AreNotEqual`, and `AreSame` for equality, `FlipFlop` and `TernaryIf` for conditional execution, and validation helpers such as `IsEmail`, `IsGuid`, `IsNumeric`, `IsPrime`, and `IsWithinRange`. An async flip-flop variant confirms the API works with task-based delegates. Each result is written to the console, illustrating the full validation utility surface. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Globalization; using System.Threading.Tasks; using Cuemon; -namespace MyApp.Validation -{ - public class ConditionExamples - { - public void DemonstrateConditions() - { // AreEqual / AreNotEqual with default and custom comparers if (Condition.AreEqual("hello", "hello")) { @@ -110,7 +105,9 @@ namespace MyApp.Validation task.Wait(); Console.WriteLine(string.Join(", ", asyncLog)); // "async:true" -}}}}} -} - +}}} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Convertible.md b/.docfx/api/types/Cuemon.Convertible.md index 26efd899f..8951a1f64 100644 --- a/.docfx/api/types/Cuemon.Convertible.md +++ b/.docfx/api/types/Cuemon.Convertible.md @@ -7,24 +7,21 @@ example: The following example shows how to convert common .NET types to byte arrays using `Convertible.GetBytes`. It demonstrates converting an integer and a string, then restoring the integer from its byte representation. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.Conversion; +byte[] intBytes = Convertible.GetBytes(12345); +Console.WriteLine(intBytes.Length); // 4 +Console.WriteLine(BitConverter.ToInt32(intBytes)); // 12345 -public class ConvertibleExample -{ - public void Demonstrate() - { - byte[] intBytes = Convertible.GetBytes(12345); - Console.WriteLine(intBytes.Length); // 4 - Console.WriteLine(BitConverter.ToInt32(intBytes)); // 12345 +byte[] stringBytes = Convertible.GetBytes("Hello"); +Console.WriteLine(stringBytes.Length); // 5 - byte[] stringBytes = Convertible.GetBytes("Hello"); - Console.WriteLine(stringBytes.Length); // 5 - - int restored = BitConverter.ToInt32(intBytes); - Console.WriteLine(restored); // 12345 - } -} +int restored = BitConverter.ToInt32(intBytes); +Console.WriteLine(restored); // 12345 ``` + + + + diff --git a/.docfx/api/types/Cuemon.ConvertibleConverterDictionary.md b/.docfx/api/types/Cuemon.ConvertibleConverterDictionary.md index ee5d999b6..54e728154 100644 --- a/.docfx/api/types/Cuemon.ConvertibleConverterDictionary.md +++ b/.docfx/api/types/Cuemon.ConvertibleConverterDictionary.md @@ -7,60 +7,46 @@ example: The following example demonstrates how to use to register and use type-specific converters that transform values into byte arrays. ```csharp +// Program.cs using System; -using System.Linq; using System.Text; using Cuemon; -namespace MyApp.Examples; +var converters = new ConvertibleConverterDictionary() + .Add(value => BitConverter.GetBytes(value)) + .Add(value => BitConverter.GetBytes(value)) + .Add(value => Encoding.UTF8.GetBytes(value)) + .Add(value => BitConverter.GetBytes(value)); -public class ConvertibleConverterDictionaryExample -{ - public void Demonstrate() - { - // Create a dictionary of converters for different IConvertible types - var converters = new ConvertibleConverterDictionary() - .Add(value => BitConverter.GetBytes(value)) - .Add(value => BitConverter.GetBytes(value)) - .Add(value => Encoding.UTF8.GetBytes(value)) - .Add(value => BitConverter.GetBytes(value)); - - Console.WriteLine(converters.Count); // 4 - - // Check if a converter exists for a specific type - Console.WriteLine(converters.ContainsKey(typeof(int))); // True - Console.WriteLine(converters.ContainsKey(typeof(float))); // False +Console.WriteLine(converters.Count); - // Use a registered converter - if (converters.TryGetValue(typeof(string), out var stringConverter)) - { - byte[] bytes = stringConverter("Hello"); - Console.WriteLine(bytes.Length); // 5 - Console.WriteLine(Encoding.UTF8.GetString(bytes)); // Hello +Console.WriteLine(converters.ContainsKey(typeof(int))); +Console.WriteLine(converters.ContainsKey(typeof(float))); - // Use the indexer to get a converter - var intConverter = converters[typeof(int)]; - if (intConverter != null) - { - byte[] intBytes = intConverter(42); - Console.WriteLine(BitConverter.ToInt32(intBytes)); // 42 - - // Iterate all registered converters - foreach (var kvp in converters) - { - Console.WriteLine($"{kvp.Key.Name} -> converter registered"); - // Output: - // Int32 -> converter registered - // Int64 -> converter registered - // String -> converter registered - // Boolean -> converter registered +if (converters.TryGetValue(typeof(string), out var stringConverter)) +{ + byte[] bytes = stringConverter("Hello"); + Console.WriteLine(bytes.Length); + Console.WriteLine(Encoding.UTF8.GetString(bytes)); +} - // Add a converter using the non-generic Add method - converters.Add(typeof(double), value => BitConverter.GetBytes(value.ToDouble(null))); - Console.WriteLine(converters.Count); // 5 - Console.WriteLine(converters.ContainsKey(typeof(double))); // True +var intConverter = converters[typeof(int)]; +if (intConverter != null) +{ + byte[] intBytes = intConverter(42); + Console.WriteLine(BitConverter.ToInt32(intBytes)); +} -}}}} +foreach (var kvp in converters) +{ + Console.WriteLine($"{kvp.Key.Name} -> converter registered"); } +converters.Add(typeof(double), value => BitConverter.GetBytes(value.ToDouble(null))); +Console.WriteLine(converters.Count); +Console.WriteLine(converters.ContainsKey(typeof(double))); ``` + + + + diff --git a/.docfx/api/types/Cuemon.ConvertibleOptions.md b/.docfx/api/types/Cuemon.ConvertibleOptions.md index 049f8c4c2..c45faa143 100644 --- a/.docfx/api/types/Cuemon.ConvertibleOptions.md +++ b/.docfx/api/types/Cuemon.ConvertibleOptions.md @@ -7,68 +7,68 @@ example: The following example demonstrates how to use to configure byte-order (endianness) and custom converters for the class. ```csharp +// Program.cs using System; -using Cuemon; // for ConvertibleOptions, Convertible, ConvertibleConverterDictionary, Endianness +using Cuemon; +using MyApp.Examples; -namespace MyApp.Examples; +new ConvertibleOptionsExample().Demonstrate(); -public class ConvertibleOptionsExample +namespace MyApp.Examples { - public void Demonstrate() + public class ConvertibleOptionsExample { - // Create options with default endianness (system-dependent) - var options = new ConvertibleOptions(); - Console.WriteLine($"Default byte order: {options.ByteOrder}"); - // Output (on x64): LittleEndian + public void Demonstrate() + { + var options = new ConvertibleOptions(); + Console.WriteLine($"Default byte order: {options.ByteOrder}"); - // Configure for big-endian byte order - options.ByteOrder = Endianness.BigEndian; - Console.WriteLine($"Byte order: {options.ByteOrder}"); // BigEndian + options.ByteOrder = Endianness.BigEndian; + Console.WriteLine($"Byte order: {options.ByteOrder}"); - // Register a custom converter for your own IConvertible type - options.Converters.Add(value => - { - // Convert MyValue to bytes according to the configured byte order - byte[] bytes = BitConverter.GetBytes(value.Amount); - if (options.ByteOrder == Endianness.BigEndian && BitConverter.IsLittleEndian) + MyValue myValue = new MyValue { Amount = 12345 }; + byte[] result = Convertible.GetBytes(myValue, o => { - Array.Reverse(bytes); - } - return bytes; - }); + o.ByteOrder = Endianness.BigEndian; + o.Converters.Add(value => + { + byte[] bytes = BitConverter.GetBytes(value.Amount); + if (o.ByteOrder == Endianness.BigEndian && BitConverter.IsLittleEndian) + { + Array.Reverse(bytes); + } + return bytes; + }); + }); - // Use Convertible.GetBytes with the configured options - MyValue myValue = new MyValue { Amount = 12345 }; - byte[] result = Convertible.GetBytes(myValue, o => - { - o.ByteOrder = options.ByteOrder; - }); - - Console.WriteLine($"Converted bytes: {BitConverter.ToString(result)}"); + Console.WriteLine($"Converted bytes: {BitConverter.ToString(result)}"); + } } -} - -public struct MyValue : IConvertible -{ - public int Amount { get; set; } + public struct MyValue : IConvertible + { + public int Amount { get; set; } - // Minimal IConvertible implementation for illustration - public TypeCode GetTypeCode() => TypeCode.Object; - public bool ToBoolean(IFormatProvider provider) => Convert.ToBoolean(Amount); - public byte ToByte(IFormatProvider provider) => Convert.ToByte(Amount); - public char ToChar(IFormatProvider provider) => Convert.ToChar(Amount); - public DateTime ToDateTime(IFormatProvider provider) => Convert.ToDateTime(Amount); - public decimal ToDecimal(IFormatProvider provider) => Amount; - public double ToDouble(IFormatProvider provider) => Amount; - public short ToInt16(IFormatProvider provider) => Convert.ToInt16(Amount); - public int ToInt32(IFormatProvider provider) => Amount; - public long ToInt64(IFormatProvider provider) => Amount; - public sbyte ToSByte(IFormatProvider provider) => Convert.ToSByte(Amount); - public float ToSingle(IFormatProvider provider) => Amount; - public string ToString(IFormatProvider provider) => Amount.ToString(); - public object ToType(Type conversionType, IFormatProvider provider) => Convert.ChangeType(Amount, conversionType); - public ushort ToUInt16(IFormatProvider provider) => Convert.ToUInt16(Amount); - public uint ToUInt32(IFormatProvider provider) => Convert.ToUInt32(Amount); - public ulong ToUInt64(IFormatProvider provider) => Convert.ToUInt64(Amount); + public TypeCode GetTypeCode() => TypeCode.Object; + public bool ToBoolean(IFormatProvider provider) => Convert.ToBoolean(Amount); + public byte ToByte(IFormatProvider provider) => Convert.ToByte(Amount); + public char ToChar(IFormatProvider provider) => Convert.ToChar(Amount); + public DateTime ToDateTime(IFormatProvider provider) => Convert.ToDateTime(Amount); + public decimal ToDecimal(IFormatProvider provider) => Amount; + public double ToDouble(IFormatProvider provider) => Amount; + public short ToInt16(IFormatProvider provider) => Convert.ToInt16(Amount); + public int ToInt32(IFormatProvider provider) => Amount; + public long ToInt64(IFormatProvider provider) => Amount; + public sbyte ToSByte(IFormatProvider provider) => Convert.ToSByte(Amount); + public float ToSingle(IFormatProvider provider) => Amount; + public string ToString(IFormatProvider provider) => Amount.ToString(provider); + public object ToType(Type conversionType, IFormatProvider provider) => Convert.ChangeType(Amount, conversionType, provider); + public ushort ToUInt16(IFormatProvider provider) => Convert.ToUInt16(Amount, provider); + public uint ToUInt32(IFormatProvider provider) => Convert.ToUInt32(Amount, provider); + public ulong ToUInt64(IFormatProvider provider) => Convert.ToUInt64(Amount, provider); + } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.DataManagerOptions.md b/.docfx/api/types/Cuemon.Data.DataManagerOptions.md index 030abd6b1..ccc949e50 100644 --- a/.docfx/api/types/Cuemon.Data.DataManagerOptions.md +++ b/.docfx/api/types/Cuemon.Data.DataManagerOptions.md @@ -7,31 +7,27 @@ example: `DataManagerOptions` configures connection strings, reader behavior, and connection lifecycle settings for use with `DataManager`. This example creates an options instance with `ConnectionString = "Data Source=app.db"`, `PreferredReaderBehavior` set to `SequentialAccess | CloseConnection`, and both `LeaveConnectionOpen` and `LeaveCommandOpen` set to `false`. After configuration, `ValidateOptions()` is called to confirm the settings are valid. Console output prints the connection string, reader behavior flag, and lifecycle settings. ```csharp +// Program.cs using System; using System.Data; using Cuemon.Data; -namespace MyApp.Data +var options = new DataManagerOptions { - public sealed class DataManagerOptionsExample - { - public void Demonstrate() - { - var options = new DataManagerOptions - { - ConnectionString = "Data Source=app.db", - PreferredReaderBehavior = CommandBehavior.SequentialAccess | CommandBehavior.CloseConnection, - LeaveConnectionOpen = false, - LeaveCommandOpen = false - }; + ConnectionString = "Data Source=app.db", + PreferredReaderBehavior = CommandBehavior.SequentialAccess | CommandBehavior.CloseConnection, + LeaveConnectionOpen = false, + LeaveCommandOpen = false +}; - options.ValidateOptions(); +options.ValidateOptions(); - Console.WriteLine($"Connection: {options.ConnectionString}"); - Console.WriteLine($"Reader behavior: {options.PreferredReaderBehavior}"); - Console.WriteLine($"Leave connection open: {options.LeaveConnectionOpen}"); - Console.WriteLine($"Leave command open: {options.LeaveCommandOpen}"); - } - } -} +Console.WriteLine($"Connection: {options.ConnectionString}"); +Console.WriteLine($"Reader behavior: {options.PreferredReaderBehavior}"); +Console.WriteLine($"Leave connection open: {options.LeaveConnectionOpen}"); +Console.WriteLine($"Leave command open: {options.LeaveCommandOpen}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.DataReaderDecoratorExtensions.md b/.docfx/api/types/Cuemon.Data.DataReaderDecoratorExtensions.md index 72f5e3090..23d64e8b3 100644 --- a/.docfx/api/types/Cuemon.Data.DataReaderDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Data.DataReaderDecoratorExtensions.md @@ -4,49 +4,42 @@ example: - *content --- -`DataReaderDecoratorExtensions` provides extension methods on `Decorator.Enclose` for converting `IDataReader` content into encoded strings or streams, both synchronously and asynchronously. This example creates a single-column DSV data source backed by `DsvDataReader` with three rows of data, then wraps it and calls `ToEncodedString`, `ToEncodedStringAsync`, and `ToStream`. Key steps include repositioning the underlying stream between conversions and using `DsvDataReader` as the input source. Console output shows the string representation of the data and the stream length. +`DataReaderDecoratorExtensions` provides extension methods on `Decorator.Enclose` for converting `IDataReader` content into encoded strings or streams, both synchronously and asynchronously. This example creates a single-column `DataTable` with three rows of data, then wraps a fresh `DataTableReader` for each call to `ToEncodedString`, `ToEncodedStringAsync`, and `ToStream`. Console output shows the string representation of the data and the stream length. ```csharp +// Program.cs using System; using System.Data; using System.IO; -using System.Text; using System.Threading.Tasks; using Cuemon; using Cuemon.Data; -namespace MyApp.Examples -{ - public class DataReaderDecoratorExtensionsExample - { - public static async Task DemonstrateAsync() - { - // Create a single-column DSV data source (must have exactly one field) - var csv = "Value\r\n1001\r\n1002\r\n1003\r\n"; - var bytes = Encoding.UTF8.GetBytes(csv); - - using (var stream = new MemoryStream(bytes)) - using (var reader = new DsvDataReader(new StreamReader(stream))) - { - // Convert the single-field IDataReader to an encoded string (sync) - string result = Decorator.Enclose((IDataReader)reader).ToEncodedString(); - Console.WriteLine(result); - - // Convert the single-field IDataReader to an encoded string (async) - stream.Position = 0; - using (var asyncReader = new DsvDataReader(new StreamReader(new MemoryStream(bytes)))) - { - string asyncResult = await Decorator.Enclose((IDataReader)asyncReader).ToEncodedStringAsync(); - Console.WriteLine(asyncResult); +var table = new DataTable(); +table.Columns.Add("Value", typeof(string)); +table.Rows.Add("1001"); +table.Rows.Add("1002"); +table.Rows.Add("1003"); - // Convert the data reader content to a stream - stream.Position = 0; - using (var readerAgain = new DsvDataReader(new StreamReader(new MemoryStream(bytes)))) - { - Stream dataStream = Decorator.Enclose((IDataReader)readerAgain).ToStream(); - Console.WriteLine($"Stream length: {dataStream.Length}"); +using (var reader = table.CreateDataReader()) +{ + string result = Decorator.Enclose((IDataReader)reader).ToEncodedString(); + Console.WriteLine(result); +} -}}}}} +using (var asyncReader = table.CreateDataReader()) +{ + string asyncResult = await Decorator.Enclose((IDataReader)asyncReader).ToEncodedStringAsync(); + Console.WriteLine(asyncResult); } +using (var streamReader = table.CreateDataReader()) +{ + Stream dataStream = Decorator.Enclose((IDataReader)streamReader).ToStream(); + Console.WriteLine($"Stream length: {dataStream.Length}"); +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.DataStatement.md b/.docfx/api/types/Cuemon.Data.DataStatement.md index 190814f8a..27093aa8d 100644 --- a/.docfx/api/types/Cuemon.Data.DataStatement.md +++ b/.docfx/api/types/Cuemon.Data.DataStatement.md @@ -7,10 +7,14 @@ example: `DataStatement` represents a database command with support for text queries, stored procedures, and parameterized commands. This example creates three different statements: a text query via implicit conversion from `"SELECT * FROM Product"`, a stored procedure `"dbo.GetOrdersByDate"` with a 120-second timeout configured through an options delegate, and a parameterized `UPDATE` command with two `IDataParameter` inputs (`@qty` and `@id`). Console output shows each statement's text, `CommandType`, timeout, parameter count, and parameter names. ```csharp +// Program.cs using System; using System.Data; using System.Linq; using Cuemon.Data; +using MyApp.DataAccess; + +new DataStatementExample().Demonstrate(); namespace MyApp.DataAccess { @@ -67,3 +71,7 @@ namespace MyApp.DataAccess } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.DataStatementOptions.md b/.docfx/api/types/Cuemon.Data.DataStatementOptions.md index a821da286..f67cb272a 100644 --- a/.docfx/api/types/Cuemon.Data.DataStatementOptions.md +++ b/.docfx/api/types/Cuemon.Data.DataStatementOptions.md @@ -7,40 +7,35 @@ example: `DataStatementOptions` provides configuration for `DataStatement` instances including command type, timeout, and parameters. This example creates a text command option with a 30-second timeout and prints its `CommandType` and timeout values, then creates a stored procedure option with a 5-minute timeout and an empty `IDataParameter` array. After configuration, `ValidateOptions()` is called to confirm the stored procedure settings are valid. Console output displays the command type, timeout in seconds, and validation status. ```csharp +// Program.cs using System; using System.Data; using Cuemon.Data; -namespace MyApp.Data +// Create options for a text command with default timeout (90 seconds) +var options = new DataStatementOptions { - public class DataStatementOptionsExample - { - public void Demonstrate() - { - // Create options for a text command with default timeout (90 seconds) - var options = new DataStatementOptions - { - Type = CommandType.Text, - Timeout = TimeSpan.FromSeconds(30) - }; + Type = CommandType.Text, + Timeout = TimeSpan.FromSeconds(30) +}; - Console.WriteLine($"Command type: {options.Type}"); - Console.WriteLine($"Timeout: {options.Timeout.TotalSeconds} seconds"); - Console.WriteLine($"Default timeout: {DataStatementOptions.DefaultTimeout.TotalSeconds} seconds"); - - // Configure for a stored procedure - var spOptions = new DataStatementOptions - { - Type = CommandType.StoredProcedure, - Timeout = TimeSpan.FromMinutes(5), - Parameters = Array.Empty() - }; - - // Validate that parameters is not null - spOptions.ValidateOptions(); - Console.WriteLine("Stored procedure options are valid."); - -}} -} +Console.WriteLine($"Command type: {options.Type}"); +Console.WriteLine($"Timeout: {options.Timeout.TotalSeconds} seconds"); +Console.WriteLine($"Default timeout: {DataStatementOptions.DefaultTimeout.TotalSeconds} seconds"); +// Configure for a stored procedure +var spOptions = new DataStatementOptions +{ + Type = CommandType.StoredProcedure, + Timeout = TimeSpan.FromMinutes(5), + Parameters = Array.Empty() +}; + +// Validate that parameters is not null +spOptions.ValidateOptions(); +Console.WriteLine("Stored procedure options are valid."); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.DataTransfer.md b/.docfx/api/types/Cuemon.Data.DataTransfer.md index 0a95931e1..4302dcd26 100644 --- a/.docfx/api/types/Cuemon.Data.DataTransfer.md +++ b/.docfx/api/types/Cuemon.Data.DataTransfer.md @@ -7,43 +7,40 @@ example: The following example demonstrates how to use to convert an into row-based and column-based collections. ```csharp +// Program.cs using System; using System.Data; using Cuemon.Data; -namespace MyApp.Data; +var table = new DataTable("Products"); +table.Columns.Add("Id", typeof(int)); +table.Columns.Add("Name", typeof(string)); +table.Columns.Add("Price", typeof(decimal)); +table.Rows.Add(1, "Widget", 9.99m); +table.Rows.Add(2, "Gadget", 24.95m); -public sealed class DataTransferExample +using IDataReader reader = table.CreateDataReader(); + +// Convert reader rows to a collection +DataTransferRowCollection rows = DataTransfer.GetRows(reader); +Console.WriteLine($"Row count: {rows.Count}"); +Console.WriteLine($"Columns: {string.Join(", ", rows.ColumnNames)}"); + +// Access data by column name +foreach (DataTransferRow row in rows) { - public void Demonstrate() - { - var table = new DataTable("Products"); - table.Columns.Add("Id", typeof(int)); - table.Columns.Add("Name", typeof(string)); - table.Columns.Add("Price", typeof(decimal)); - table.Rows.Add(1, "Widget", 9.99m); - table.Rows.Add(2, "Gadget", 24.95m); - - using IDataReader reader = table.CreateDataReader(); - - // Convert reader rows to a collection - DataTransferRowCollection rows = DataTransfer.GetRows(reader); - Console.WriteLine($"Row count: {rows.Count}"); - Console.WriteLine($"Columns: {string.Join(", ", rows.ColumnNames)}"); - - // Access data by column name - foreach (DataTransferRow row in rows) - { - Console.WriteLine($"{row["Id"]}: {row["Name"]} @ {row["Price"]:C}"); - } - - // Re-read and get columns - reader.Dispose(); - using IDataReader reader2 = table.CreateDataReader(); - reader2.Read(); - DataTransferColumnCollection columns = DataTransfer.GetColumns(reader2); - Console.WriteLine($"Column count: {columns.Count}"); - Console.WriteLine($"First column: {columns[0].Name} ({columns[0].DataType.Name})"); - } + Console.WriteLine($"{row["Id"]}: {row["Name"]} @ {row["Price"]:C}"); } + +// Re-read and get columns +reader.Dispose(); +using IDataReader reader2 = table.CreateDataReader(); +reader2.Read(); +DataTransferColumnCollection columns = DataTransfer.GetColumns(reader2); +Console.WriteLine($"Column count: {columns.Count}"); +Console.WriteLine($"First column: {columns[0].Name} ({columns[0].DataType.Name})"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.DataTransferColumn.md b/.docfx/api/types/Cuemon.Data.DataTransferColumn.md index 2fff1d4f3..897e1b8ac 100644 --- a/.docfx/api/types/Cuemon.Data.DataTransferColumn.md +++ b/.docfx/api/types/Cuemon.Data.DataTransferColumn.md @@ -7,16 +7,11 @@ example: `DataTransferColumn` provides column metadata such as ordinal position, name, and data type for fields retrieved from an `IDataReader`. This example builds a `DataTable` with `EmployeeId`, `FirstName`, `LastName`, and `HireDate` columns containing two sample rows, creates a data reader, and retrieves a `DataTransferColumnCollection` via `DataTransfer.GetColumns`. It iterates each column to display ordinal, name, and `DataType.Name`, accesses the `"FirstName"` column by name to get its ordinal, and calls `ToString()` on a column instance. Console output shows column metadata such as `[0] EmployeeId (Int32)` and confirms the column name string representation. ```csharp +// Program.cs using System; using System.Data; using Cuemon.Data; -namespace MyApp.Data -{ - public class DataTransferColumnExample - { - public void Demonstrate() - { // Create a DataTable as a sample data source var table = new DataTable("Employees"); table.Columns.Add("EmployeeId", typeof(int)); @@ -49,7 +44,9 @@ namespace MyApp.Data // ToString() returns the column name Console.WriteLine($"Column ToString: {firstNameCol}"); // FirstName -}}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.DataTransferColumnCollection.md b/.docfx/api/types/Cuemon.Data.DataTransferColumnCollection.md index cd73a1c19..4730984c2 100644 --- a/.docfx/api/types/Cuemon.Data.DataTransferColumnCollection.md +++ b/.docfx/api/types/Cuemon.Data.DataTransferColumnCollection.md @@ -7,32 +7,28 @@ example: `DataTransferColumnCollection` is a strongly typed collection of `DataTransferColumn` objects that provides access to column metadata by index and by name. This example creates a `DataTable` with `Id`, `Name`, and `Created` columns containing one data row, then retrieves the column collection via `DataTransfer.GetColumns` from the data reader. It accesses the first column by index, looks up the `"Name"` column by name to get its ordinal, and checks whether a missing column name returns `null`. Console output shows the column count, the first column's name and data type, and the missing-column lookup result. ```csharp +// Program.cs using System; using System.Data; using Cuemon.Data; -namespace MyApp.Data -{ - public sealed class DataTransferColumnCollectionExample - { - public void Demonstrate() - { - var table = new DataTable(); - table.Columns.Add("Id", typeof(int)); - table.Columns.Add("Name", typeof(string)); - table.Columns.Add("Created", typeof(DateTime)); - table.Rows.Add(1, "Alice", new DateTime(2024, 1, 2, 3, 4, 5, DateTimeKind.Utc)); +var table = new DataTable(); +table.Columns.Add("Id", typeof(int)); +table.Columns.Add("Name", typeof(string)); +table.Columns.Add("Created", typeof(DateTime)); +table.Rows.Add(1, "Alice", new DateTime(2024, 1, 2, 3, 4, 5, DateTimeKind.Utc)); - using var reader = table.CreateDataReader(); - reader.Read(); +using var reader = table.CreateDataReader(); +reader.Read(); - DataTransferColumnCollection columns = DataTransfer.GetColumns(reader); +DataTransferColumnCollection columns = DataTransfer.GetColumns(reader); - Console.WriteLine($"Column count: {columns.Count}"); - Console.WriteLine($"First column: {columns[0].Name} ({columns[0].DataType.Name})"); - Console.WriteLine($"Name column ordinal: {columns["Name"].Ordinal}"); - Console.WriteLine($"Missing column found: {columns["Missing"] != null}"); - } - } -} +Console.WriteLine($"Column count: {columns.Count}"); +Console.WriteLine($"First column: {columns[0].Name} ({columns[0].DataType.Name})"); +Console.WriteLine($"Name column ordinal: {columns["Name"].Ordinal}"); +Console.WriteLine($"Missing column found: {columns["Missing"] != null}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.DataTransferRow.md b/.docfx/api/types/Cuemon.Data.DataTransferRow.md index 0e4334f0f..de0b67f2b 100644 --- a/.docfx/api/types/Cuemon.Data.DataTransferRow.md +++ b/.docfx/api/types/Cuemon.Data.DataTransferRow.md @@ -7,16 +7,11 @@ example: `DataTransferRow` provides access to data reader field values by index, column name, or `DataTransferColumn` object, including type-safe access via generic methods and automatic `DBNull` to `null` conversion. This example creates a `DataTable` with `Id`, `Name`, `Created`, and `Notes` columns containing two rows (one with a `DBNull` note), then retrieves a `DataTransferRowCollection` via `DataTransfer.GetRows`. It accesses values using all three lookup approaches — `first[0]` by index, `first["Name"]` by column name, and `first[idCol]` by column object — and uses `As("Id")` for type-safe access. Console output confirms each value, shows `null` for the `DBNull` case, and displays the string representation of the row. ```csharp +// Program.cs using System; using System.Data; using Cuemon.Data; -namespace MyApp.Data -{ - public static class DataTransferRowExamples - { - public static void Demonstrate() - { // Build a DataTable to simulate a database result set. var table = new DataTable(); table.Columns.Add("Id", typeof(int)); @@ -62,7 +57,9 @@ namespace MyApp.Data // String representation of the row. Console.WriteLine("Row string: {0}", first); -}}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.DataTransferRowCollection.md b/.docfx/api/types/Cuemon.Data.DataTransferRowCollection.md index e4747ed1f..d39e0c31c 100644 --- a/.docfx/api/types/Cuemon.Data.DataTransferRowCollection.md +++ b/.docfx/api/types/Cuemon.Data.DataTransferRowCollection.md @@ -7,40 +7,36 @@ example: The following example demonstrates how to use to work with rows returned from a database query via an . ```csharp +// Program.cs using System; using System.Data; using Cuemon.Data; -namespace MyApp.Data -{ - public sealed class DataTransferRowCollectionExample - { - public void Demonstrate() - { - var table = new DataTable("Products"); - table.Columns.Add("Id", typeof(int)); - table.Columns.Add("Name", typeof(string)); - table.Columns.Add("Created", typeof(DateTime)); - table.Columns.Add("Notes", typeof(string)); - table.Rows.Add(1, "Apples", new DateTime(2024, 1, 2, 3, 4, 5, DateTimeKind.Utc), "Fresh"); - table.Rows.Add(2, "Bananas", new DateTime(2024, 2, 3, 4, 5, 6, DateTimeKind.Utc), DBNull.Value); - - using var reader = table.CreateDataReader(); - DataTransferRowCollection rows = DataTransfer.GetRows(reader); - - Console.WriteLine("Columns: " + string.Join(", ", rows.ColumnNames)); - Console.WriteLine($"Row count: {rows.Count}"); - - DataTransferRow firstRow = rows[0]; - Console.WriteLine(firstRow.ToString()); - Console.WriteLine($"First row name: {firstRow["Name"]}"); - Console.WriteLine($"Created: {firstRow.As("Created"):O}"); - - DataTransferRow secondRow = rows[1]; - Console.WriteLine($"Second row notes are null: {secondRow["Notes"] == null}"); - Console.WriteLine($"Contains first row: {rows.Contains(firstRow)}"); - Console.WriteLine($"Index of first row: {rows.IndexOf(firstRow)}"); - } - } -} +var table = new DataTable("Products"); +table.Columns.Add("Id", typeof(int)); +table.Columns.Add("Name", typeof(string)); +table.Columns.Add("Created", typeof(DateTime)); +table.Columns.Add("Notes", typeof(string)); +table.Rows.Add(1, "Apples", new DateTime(2024, 1, 2, 3, 4, 5, DateTimeKind.Utc), "Fresh"); +table.Rows.Add(2, "Bananas", new DateTime(2024, 2, 3, 4, 5, 6, DateTimeKind.Utc), DBNull.Value); + +using var reader = table.CreateDataReader(); +DataTransferRowCollection rows = DataTransfer.GetRows(reader); + +Console.WriteLine("Columns: " + string.Join(", ", rows.ColumnNames)); +Console.WriteLine($"Row count: {rows.Count}"); + +DataTransferRow firstRow = rows[0]; +Console.WriteLine(firstRow.ToString()); +Console.WriteLine($"First row name: {firstRow["Name"]}"); +Console.WriteLine($"Created: {firstRow.As("Created"):O}"); + +DataTransferRow secondRow = rows[1]; +Console.WriteLine($"Second row notes are null: {secondRow["Notes"] == null}"); +Console.WriteLine($"Contains first row: {rows.Contains(firstRow)}"); +Console.WriteLine($"Index of first row: {rows.IndexOf(firstRow)}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.DatabaseDependency.md b/.docfx/api/types/Cuemon.Data.DatabaseDependency.md index e1c707140..37b35f039 100644 --- a/.docfx/api/types/Cuemon.Data.DatabaseDependency.md +++ b/.docfx/api/types/Cuemon.Data.DatabaseDependency.md @@ -7,74 +7,84 @@ example: The following example demonstrates how to use to monitor a relational data source for changes and notify dependent objects. It sets up a `Lazy` with a stub connection and a command that executes `SELECT COUNT(*) FROM Products`, then creates a `DatabaseDependency` with a change event handler that writes to the console. The dependency is started asynchronously, showing how to watch a relational data source for data-change notifications. ```csharp +// Program.cs using System; using System.Data; using System.Threading.Tasks; using Cuemon.Data; using Cuemon.Runtime; +using MyApp.Examples; -namespace MyApp.Examples; +await new DatabaseDependencyExample().DemonstrateAsync(); -public class DatabaseDependencyExample +namespace MyApp.Examples { - public async Task DemonstrateAsync() + public class DatabaseDependencyExample { - var lazyWatcher = new Lazy(() => + public async Task DemonstrateAsync() { - var connection = new StubConnection(); - return new DatabaseWatcher( - connection, - conn => - { - var command = conn.CreateCommand(); - command.CommandText = "SELECT COUNT(*) FROM Products"; - return command.ExecuteReader(); - }); - }); + var lazyWatcher = new Lazy(() => + { + var connection = new StubConnection(); + return new DatabaseWatcher( + connection, + conn => + { + var command = conn.CreateCommand(); + command.CommandText = "SELECT COUNT(*) FROM Products"; + return command.ExecuteReader(); + }); + }); - var dependency = new DatabaseDependency(lazyWatcher, breakTieOnChanged: true); + var dependency = new DatabaseDependency(lazyWatcher, breakTieOnChanged: true); - dependency.DependencyChanged += (sender, args) => - { - Console.WriteLine("Database data has changed!"); - }; + dependency.DependencyChanged += (sender, args) => + { + Console.WriteLine("Database data has changed!"); + }; - await dependency.StartAsync(); - } + await dependency.StartAsync(); + Console.WriteLine("Database dependency started."); + } - private sealed class StubConnection : IDbConnection - { - public string ConnectionString { get; set; } - public int ConnectionTimeout => 30; - public string Database => "MyDb"; - public ConnectionState State => ConnectionState.Closed; - public IDbTransaction BeginTransaction() => null; - public IDbTransaction BeginTransaction(IsolationLevel il) => null; - public void ChangeDatabase(string databaseName) { } - public void Close() { } - public IDbCommand CreateCommand() => new StubCommand(); - public void Open() { } - public void Dispose() { } - } + private sealed class StubConnection : IDbConnection + { + public string ConnectionString { get; set; } + public int ConnectionTimeout => 30; + public string Database => "MyDb"; + public ConnectionState State => ConnectionState.Closed; + public IDbTransaction BeginTransaction() => null; + public IDbTransaction BeginTransaction(IsolationLevel il) => null; + public void ChangeDatabase(string databaseName) { } + public void Close() { } + public IDbCommand CreateCommand() => new StubCommand(); + public void Open() { } + public void Dispose() { } + } - private sealed class StubCommand : IDbCommand - { - public string CommandText { get; set; } - public int CommandTimeout { get; set; } - public CommandType CommandType { get; set; } - public IDbConnection Connection { get; set; } - public IDataParameterCollection Parameters => null; - public IDbTransaction Transaction { get; set; } - public UpdateRowSource UpdatedRowSource { get; set; } - public bool DesignTimeVisible { get; set; } - public void Cancel() { } - public IDbDataParameter CreateParameter() => null; - public int ExecuteNonQuery() => 0; - public IDataReader ExecuteReader() => null; - public IDataReader ExecuteReader(CommandBehavior behavior) => null; - public object ExecuteScalar() => 0; - public void Prepare() { } - public void Dispose() { } + private sealed class StubCommand : IDbCommand + { + public string CommandText { get; set; } + public int CommandTimeout { get; set; } + public CommandType CommandType { get; set; } + public IDbConnection Connection { get; set; } + public IDataParameterCollection Parameters => null; + public IDbTransaction Transaction { get; set; } + public UpdateRowSource UpdatedRowSource { get; set; } + public bool DesignTimeVisible { get; set; } + public void Cancel() { } + public IDbDataParameter CreateParameter() => null; + public int ExecuteNonQuery() => 0; + public IDataReader ExecuteReader() => null; + public IDataReader ExecuteReader(CommandBehavior behavior) => null; + public object ExecuteScalar() => 0; + public void Prepare() { } + public void Dispose() { } + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.DatabaseWatcher.md b/.docfx/api/types/Cuemon.Data.DatabaseWatcher.md index 1cc038092..d925a7971 100644 --- a/.docfx/api/types/Cuemon.Data.DatabaseWatcher.md +++ b/.docfx/api/types/Cuemon.Data.DatabaseWatcher.md @@ -7,12 +7,16 @@ example: `DatabaseWatcher` monitors a database for data changes by comparing checksums computed from `IDataReader` results over time. This example creates a `SampleDatabaseWatcher` subclass with an in-memory `InMemoryConnection` and a factory that returns a `DataTable`'s contents as a reader, then subscribes to the `Changed` event. Key steps include calling `SignalAsync` to capture the initial checksum, modifying the data table, and signaling again to detect the change. Console output shows the initial checksum value, the number of change signals raised (1), and the updated checksum that differs from the original, confirming modification detection. ```csharp +// Program.cs using System; using System.Data; using System.Threading; using System.Threading.Tasks; using Cuemon.Data; using Cuemon.Runtime; +using MyApp.Data; + +await new DatabaseWatcherExample().DemonstrateAsync(); namespace MyApp.Data { @@ -110,3 +114,7 @@ namespace MyApp.Data } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.DbTypeDecoratorExtensions.md b/.docfx/api/types/Cuemon.Data.DbTypeDecoratorExtensions.md index 64faa7e51..4f3944d05 100644 --- a/.docfx/api/types/Cuemon.Data.DbTypeDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Data.DbTypeDecoratorExtensions.md @@ -35,3 +35,7 @@ public class DbTypeDecoratorExtensionsExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.DsvDataReader.md b/.docfx/api/types/Cuemon.Data.DsvDataReader.md index 76bfef6ad..9050b47f3 100644 --- a/.docfx/api/types/Cuemon.Data.DsvDataReader.md +++ b/.docfx/api/types/Cuemon.Data.DsvDataReader.md @@ -7,33 +7,29 @@ example: The following example demonstrates how to read a CSV (comma-separated values) file using `DsvDataReader`. ```csharp +// Program.cs using System; using System.IO; using System.Text; using Cuemon.Data; -namespace MyApp.Examples -{ - public sealed class DsvDataReaderExample - { - public void Demonstrate() - { - var csv = "Name,Age,City" + Environment.NewLine + - "Alice,30,New York" + Environment.NewLine + - "Bob,25,London" + Environment.NewLine + - "Charlie,35,Tokyo"; +var csv = "Name,Age,City" + Environment.NewLine + + "Alice,30,New York" + Environment.NewLine + + "Bob,25,London" + Environment.NewLine + + "Charlie,35,Tokyo"; - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(csv)); - using var reader = new DsvDataReader(new StreamReader(stream)); +using var stream = new MemoryStream(Encoding.UTF8.GetBytes(csv)); +using var reader = new DsvDataReader(new StreamReader(stream)); - Console.WriteLine($"Delimiter: {reader.Delimiter}"); - Console.WriteLine("Header: " + string.Join(", ", reader.Header)); +Console.WriteLine($"Delimiter: {reader.Delimiter}"); +Console.WriteLine("Header: " + string.Join(", ", reader.Header)); - while (reader.Read()) - { - Console.WriteLine($"Row {reader.RowCount}: Name={reader["Name"]}, Age={reader["Age"]}, City={reader["City"]}"); - } - } - } +while (reader.Read()) +{ + Console.WriteLine($"Row {reader.RowCount}: Name={reader["Name"]}, Age={reader["Age"]}, City={reader["City"]}"); } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.InOperatorResult.md b/.docfx/api/types/Cuemon.Data.InOperatorResult.md index de9e84a23..d03dfa447 100644 --- a/.docfx/api/types/Cuemon.Data.InOperatorResult.md +++ b/.docfx/api/types/Cuemon.Data.InOperatorResult.md @@ -26,7 +26,7 @@ public class InOperatorResultExample Console.WriteLine("First parameter value: {0}", result.Parameters.First().Value); // Output: - // Arguments CSV: @p0, @p1, @p2 + // Arguments CSV: @p0,@p1,@p2 // Parameter count: 3 // First parameter value: 10 } @@ -64,3 +64,7 @@ public class InOperatorResultExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.Integrity.CacheValidator.md b/.docfx/api/types/Cuemon.Data.Integrity.CacheValidator.md index e89f7d06d..0280d99ed 100644 --- a/.docfx/api/types/Cuemon.Data.Integrity.CacheValidator.md +++ b/.docfx/api/types/Cuemon.Data.Integrity.CacheValidator.md @@ -7,45 +7,41 @@ example: The following example demonstrates how to create a `CacheValidator` to represent cacheable data with integrity validation, combining timestamps and content checksums. ```csharp +// Program.cs using System; using Cuemon.Data.Integrity; using Cuemon.Security; -namespace MyApp.Examples; +var entity = new EntityInfo( + DateTime.UtcNow.AddHours(-2), + DateTime.UtcNow.AddMinutes(-30) +); -public class Example -{ - public void Run() - { +var validator = new CacheValidator(entity, () => HashFactory.CreateFnv128(), EntityDataIntegrityMethod.Combined); - var entity = new EntityInfo( - DateTime.UtcNow.AddHours(-2), - DateTime.UtcNow.AddMinutes(-30) - ); +Console.WriteLine($"Created (UTC): {validator.Created:O}"); +Console.WriteLine($"Modified (UTC): {validator.Modified:O}"); +Console.WriteLine($"Validation: {validator.Validation}"); +Console.WriteLine($"Method: {validator.Method}"); +Console.WriteLine($"Checksum: {validator.Checksum.ToHexadecimalString()}"); - var validator = new CacheValidator(entity, () => HashFactory.CreateFnv128(), EntityDataIntegrityMethod.Combined); +// Combine with additional data +validator.CombineWith(BitConverter.GetBytes(67890L)); +Console.WriteLine($"Combined: {validator}"); - Console.WriteLine($"Created (UTC): {validator.Created:O}"); - Console.WriteLine($"Modified (UTC): {validator.Modified:O}"); - Console.WriteLine($"Validation: {validator.Validation}"); - Console.WriteLine($"Method: {validator.Method}"); - Console.WriteLine($"Checksum: {validator.Checksum.ToHexadecimalString()}"); +// Get the most significant from a sequence +var v1 = new CacheValidator(new EntityInfo(new DateTime(2024, 1, 1, 0, 0, 0, DateTimeKind.Utc)), () => HashFactory.CreateFnv128()); +var v2 = new CacheValidator(new EntityInfo(DateTime.UtcNow.AddDays(-1)), () => HashFactory.CreateFnv128()); +var mostSignificant = CacheValidator.GetMostSignificant(v1, v2); - // Combine with additional data - validator.CombineWith(BitConverter.GetBytes(67890L)); - Console.WriteLine($"Combined: {validator}"); +Console.WriteLine($"Most significant created: {mostSignificant.Created:O}"); - // Get the most significant from a sequence - var v1 = new CacheValidator(new EntityInfo(new DateTime(2024, 1, 1, 0, 0, 0, DateTimeKind.Utc)), () => HashFactory.CreateFnv128()); - var v2 = new CacheValidator(new EntityInfo(DateTime.UtcNow.AddDays(-1)), () => HashFactory.CreateFnv128()); - var mostSignificant = CacheValidator.GetMostSignificant(v1, v2); - - Console.WriteLine($"Most significant created: {mostSignificant.Created:O}"); - - // Use assembly reference point - CacheValidator.AssemblyReference = typeof(CacheValidator).Assembly; - var referencePoint = CacheValidator.ReferencePoint; - Console.WriteLine($"Reference point: {referencePoint}"); - } -} +// Use assembly reference point +CacheValidator.AssemblyReference = typeof(CacheValidator).Assembly; +var referencePoint = CacheValidator.ReferencePoint; +Console.WriteLine($"Reference point: {referencePoint}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.Integrity.CacheValidatorFactory.md b/.docfx/api/types/Cuemon.Data.Integrity.CacheValidatorFactory.md index f16384798..a8e7dd2c5 100644 --- a/.docfx/api/types/Cuemon.Data.Integrity.CacheValidatorFactory.md +++ b/.docfx/api/types/Cuemon.Data.Integrity.CacheValidatorFactory.md @@ -7,39 +7,36 @@ example: The following example demonstrates how to create a from a file using . ```csharp +// Program.cs using System; using System.IO; using Cuemon.Data.Integrity; using Cuemon.Security; -namespace MyApp.Data; - -public sealed class CacheValidatorFactoryExample +var file = new FileInfo(Path.GetTempFileName()); +try { - public void Demonstrate() - { - var file = new FileInfo(Path.GetTempFileName()); - try - { - File.WriteAllText(file.FullName, "Hello, world!"); + File.WriteAllText(file.FullName, "Hello, world!"); - CacheValidator validator = CacheValidatorFactory.CreateValidator(file); - Console.WriteLine($"Created (UTC): {validator.Created:O}"); - Console.WriteLine($"Modified (UTC): {validator.Modified:O}"); - Console.WriteLine($"Validation: {validator.Validation}"); - Console.WriteLine($"Method: {validator.Method}"); - Console.WriteLine($"Checksum: {validator.Checksum.ToHexadecimalString()}"); + CacheValidator validator = CacheValidatorFactory.CreateValidator(file); + Console.WriteLine($"Created (UTC): {validator.Created:O}"); + Console.WriteLine($"Modified (UTC): {validator.Modified:O}"); + Console.WriteLine($"Validation: {validator.Validation}"); + Console.WriteLine($"Method: {validator.Method}"); + Console.WriteLine($"Checksum: {validator.Checksum.ToHexadecimalString()}"); - // Create validator using a custom hash algorithm - CacheValidator shaValidator = CacheValidatorFactory.CreateValidator( - file, - () => HashFactory.CreateFnv128()); - Console.WriteLine($"SHA-256: {shaValidator.Checksum.ToHexadecimalString()}"); - } - finally - { - file.Delete(); - } - } + // Create validator using a custom hash algorithm + CacheValidator shaValidator = CacheValidatorFactory.CreateValidator( + file, + () => HashFactory.CreateFnv128()); + Console.WriteLine($"SHA-256: {shaValidator.Checksum.ToHexadecimalString()}"); +} +finally +{ + file.Delete(); } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.Integrity.ChecksumBuilder.md b/.docfx/api/types/Cuemon.Data.Integrity.ChecksumBuilder.md index 81e4c34ab..622d237ca 100644 --- a/.docfx/api/types/Cuemon.Data.Integrity.ChecksumBuilder.md +++ b/.docfx/api/types/Cuemon.Data.Integrity.ChecksumBuilder.md @@ -7,30 +7,26 @@ example: The following example demonstrates how to use `ChecksumBuilder` to compute and compare checksums for arbitrary data. ```csharp +// Program.cs using System; using System.Text; using Cuemon.Data.Integrity; using Cuemon.Security; -namespace MyApp.Examples -{ - public sealed class ChecksumBuilderExample - { - public void Demonstrate() - { - var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); - Console.WriteLine($"Empty checksum: {builder.Checksum.ToHexadecimalString()}"); +var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); +Console.WriteLine($"Empty checksum: {builder.Checksum.ToHexadecimalString()}"); - builder.CombineWith(BitConverter.GetBytes(42L)); - builder.CombineWith(Encoding.UTF8.GetBytes("Hello, World!")); +builder.CombineWith(BitConverter.GetBytes(42L)); +builder.CombineWith(Encoding.UTF8.GetBytes("Hello, World!")); - var comparison = new ChecksumBuilder(BitConverter.GetBytes(42L), () => HashFactory.CreateFnv128()); - comparison.CombineWith(Encoding.UTF8.GetBytes("Hello, World!")); +var comparison = new ChecksumBuilder(BitConverter.GetBytes(42L), () => HashFactory.CreateFnv128()); +comparison.CombineWith(Encoding.UTF8.GetBytes("Hello, World!")); - Console.WriteLine($"Current checksum: {builder}"); - Console.WriteLine($"Checksums match: {builder.Equals(comparison)}"); - Console.WriteLine($"Hash code: {builder.GetHashCode()}"); - } - } -} +Console.WriteLine($"Current checksum: {builder}"); +Console.WriteLine($"Checksums match: {builder.Equals(comparison)}"); +Console.WriteLine($"Hash code: {builder.GetHashCode()}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.Integrity.ChecksumBuilderDecoratorExtensions.md b/.docfx/api/types/Cuemon.Data.Integrity.ChecksumBuilderDecoratorExtensions.md index 719ef3331..0354459f0 100644 --- a/.docfx/api/types/Cuemon.Data.Integrity.ChecksumBuilderDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Data.Integrity.ChecksumBuilderDecoratorExtensions.md @@ -7,39 +7,37 @@ example: The following example demonstrates how to use `ChecksumBuilderDecoratorExtensions` to combine typed values with a `ChecksumBuilder` through the `IDecorator` interface. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Data.Integrity; using Cuemon.Security; -namespace MyApp.Examples; +// Create a ChecksumBuilder wrapped in a Decorator +var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); +var decorator = Decorator.Enclose(builder); -public class Example -{ - public void Run() - { - // Create a ChecksumBuilder wrapped in a Decorator - var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); - var decorator = Decorator.Enclose(builder); +// Combine various typed values using the decorator extensions +decorator.CombineWith(42); // int +decorator.CombineWith(3.14); // double +decorator.CombineWith("tag"); // string - // Combine various typed values using the decorator extensions - decorator.CombineWith(42); // int - decorator.CombineWith(3.14); // double - decorator.CombineWith("tag"); // string +Console.WriteLine($"Combined checksum: {builder}"); - Console.WriteLine($"Combined checksum: {builder}"); +// The extensions return the inner builder for chaining +var combined = decorator.CombineWith(12345L); // long +Console.WriteLine($"Returned type: {combined.GetType().Name}"); - // The extensions return the inner builder for chaining - var combined = decorator.CombineWith(12345L); // long - Console.WriteLine($"Returned type: {combined.GetType().Name}"); +// Extension methods also work with short, float, ushort, uint, ulong +var shortDecorator = Decorator.Enclose(new ChecksumBuilder(() => HashFactory.CreateFnv32())); +shortDecorator.CombineWith((short)100); +shortDecorator.CombineWith(3.14f); +shortDecorator.CombineWith(42u); - // Extension methods also work with short, float, ushort, uint, ulong - var shortDecorator = Decorator.Enclose(new ChecksumBuilder(() => HashFactory.CreateFnv32())); - shortDecorator.CombineWith((short)100); - shortDecorator.CombineWith(3.14f); - shortDecorator.CombineWith(42u); +Console.WriteLine($"Short builder: {shortDecorator.Inner}"); - Console.WriteLine($"Short builder: {shortDecorator.Inner}"); - } -} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.Integrity.DataIntegrityFactory.md b/.docfx/api/types/Cuemon.Data.Integrity.DataIntegrityFactory.md index 78b00baf3..587b3132d 100644 --- a/.docfx/api/types/Cuemon.Data.Integrity.DataIntegrityFactory.md +++ b/.docfx/api/types/Cuemon.Data.Integrity.DataIntegrityFactory.md @@ -7,48 +7,56 @@ example: The following example demonstrates how to create an implementation from a file using . It writes sample data to a temporary file, then calls `CreateIntegrity` with a custom converter that computes a CRC64 hash over the file content. The resulting checksum and file name are written to the console, showing how to verify file integrity with configurable hashing algorithms. ```csharp +// Program.cs using System; using System.IO; using Cuemon.Data.Integrity; using Cuemon.Security; +using MyApp.Data; -namespace MyApp.Data; +new DataIntegrityFactoryExample().Demonstrate(); -public sealed class DataIntegrityFactoryExample +namespace MyApp.Data { - public void Demonstrate() + public sealed class DataIntegrityFactoryExample { - var file = new FileInfo(Path.GetTempFileName()); - try + public void Demonstrate() { - File.WriteAllText(file.FullName, "Sample data for integrity check."); - - IDataIntegrity integrity = DataIntegrityFactory.CreateIntegrity(file, options => + var file = new FileInfo(Path.GetTempFileName()); + try { - options.BytesToRead = 1024; - options.IntegrityConverter = (fi, checksumBytes) => - { - var hash = HashFactory.CreateCrc64().ComputeHash(checksumBytes); - return new DataIntegrity(fi, hash); - }; - }); + File.WriteAllText(file.FullName, "Sample data for integrity check."); - Console.WriteLine($"Integrity: {integrity}"); - } - finally - { - file.Delete(); + IDataIntegrity integrity = DataIntegrityFactory.CreateIntegrity(file, options => + { + options.BytesToRead = 1024; + options.IntegrityConverter = (fi, checksumBytes) => + { + var hash = HashFactory.CreateCrc64().ComputeHash(checksumBytes); + return new DataIntegrity(fi, hash); + }; + }); + + Console.WriteLine($"Integrity: {integrity}"); + } + finally + { + file.Delete(); + } } } -} - -// Minimal IDataIntegrity implementation for demonstration -public class DataIntegrity(FileInfo file, HashResult checksum) : IDataIntegrity -{ - public FileInfo File { get; } = file; + // Minimal IDataIntegrity implementation for demonstration + public class DataIntegrity(FileInfo file, HashResult checksum) : IDataIntegrity + { + public FileInfo File { get; } = file; - public HashResult Checksum { get; } = checksum; + public HashResult Checksum { get; } = checksum; - public override string ToString() => $"{File.Name}: {Checksum.ToHexadecimalString()}"; + public override string ToString() => $"{File.Name}: {Checksum.ToHexadecimalString()}"; + } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.Integrity.EntityDataIntegrityMethod.md b/.docfx/api/types/Cuemon.Data.Integrity.EntityDataIntegrityMethod.md index 40d8c48d5..0fa02ff86 100644 --- a/.docfx/api/types/Cuemon.Data.Integrity.EntityDataIntegrityMethod.md +++ b/.docfx/api/types/Cuemon.Data.Integrity.EntityDataIntegrityMethod.md @@ -7,41 +7,38 @@ example: The following example demonstrates how to use the enum to specify how a checksum should be computed for data integrity validation. ```csharp +// Program.cs using System; using Cuemon.Data.Integrity; // for EntityDataIntegrityMethod -namespace MyApp.Examples; +// Unaltered - the checksum is left as-is (default) +EntityDataIntegrityMethod method = EntityDataIntegrityMethod.Unaltered; +Console.WriteLine(method); // Unaltered -public class EntityDataIntegrityMethodExample +// Combined - the checksum is computed from all inputs combined +method = EntityDataIntegrityMethod.Combined; +Console.WriteLine(method); // Combined + +// Timestamp - the checksum is generated from date-time inputs +method = EntityDataIntegrityMethod.Timestamp; +Console.WriteLine(method); // Timestamp + +// Switch on the method to determine behavior +switch (method) { - public void Demonstrate() - { - // Unaltered - the checksum is left as-is (default) - EntityDataIntegrityMethod method = EntityDataIntegrityMethod.Unaltered; - Console.WriteLine(method); // Unaltered - - // Combined - the checksum is computed from all inputs combined - method = EntityDataIntegrityMethod.Combined; - Console.WriteLine(method); // Combined - - // Timestamp - the checksum is generated from date-time inputs - method = EntityDataIntegrityMethod.Timestamp; - Console.WriteLine(method); // Timestamp - - // Switch on the method to determine behavior - switch (method) - { - case EntityDataIntegrityMethod.Unaltered: - Console.WriteLine("Checksum unchanged."); - break; - case EntityDataIntegrityMethod.Combined: - Console.WriteLine("Checksum computed from all data."); - break; - case EntityDataIntegrityMethod.Timestamp: - Console.WriteLine("Checksum based on timestamp."); - break; - -}} -} + case EntityDataIntegrityMethod.Unaltered: + Console.WriteLine("Checksum unchanged."); + break; + case EntityDataIntegrityMethod.Combined: + Console.WriteLine("Checksum computed from all data."); + break; + case EntityDataIntegrityMethod.Timestamp: + Console.WriteLine("Checksum based on timestamp."); + break; +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.Integrity.EntityDataIntegrityValidation.md b/.docfx/api/types/Cuemon.Data.Integrity.EntityDataIntegrityValidation.md index 07dd65e76..c25b865fa 100644 --- a/.docfx/api/types/Cuemon.Data.Integrity.EntityDataIntegrityValidation.md +++ b/.docfx/api/types/Cuemon.Data.Integrity.EntityDataIntegrityValidation.md @@ -7,43 +7,39 @@ example: The following example shows how to create an `EntityInfo` with strong data integrity validation and create a `CacheValidator` that uses it. It demonstrates switching on the validation level and printing the resulting checksum. ```csharp +// Program.cs using System; using System.Text; using Cuemon.Data.Integrity; using Cuemon.Security; -namespace MyApp.Data -{ - public sealed class EntityDataIntegrityValidationExample - { - public void Demonstrate() - { - var created = new DateTime(2024, 1, 2, 3, 4, 5, DateTimeKind.Utc); - var modified = created.AddHours(1); - var entity = new EntityInfo( - created, - modified, - Encoding.UTF8.GetBytes("order-42"), - EntityDataIntegrityValidation.Strong); - - var validator = new CacheValidator(entity, () => HashFactory.CreateFnv128()); +var created = new DateTime(2024, 1, 2, 3, 4, 5, DateTimeKind.Utc); +var modified = created.AddHours(1); +var entity = new EntityInfo( + created, + modified, + Encoding.UTF8.GetBytes("order-42"), + EntityDataIntegrityValidation.Strong); - switch (validator.Validation) - { - case EntityDataIntegrityValidation.Unspecified: - Console.WriteLine("No checksum strength was supplied."); - break; - case EntityDataIntegrityValidation.Weak: - Console.WriteLine("The checksum is semantically valid."); - break; - case EntityDataIntegrityValidation.Strong: - Console.WriteLine("The checksum is byte-for-byte strong."); - break; - } +var validator = new CacheValidator(entity, () => HashFactory.CreateFnv128()); - Console.WriteLine($"Validation: {validator.Validation}"); - Console.WriteLine($"Checksum: {validator.Checksum.ToHexadecimalString()}"); - } - } +switch (validator.Validation) +{ + case EntityDataIntegrityValidation.Unspecified: + Console.WriteLine("No checksum strength was supplied."); + break; + case EntityDataIntegrityValidation.Weak: + Console.WriteLine("The checksum is semantically valid."); + break; + case EntityDataIntegrityValidation.Strong: + Console.WriteLine("The checksum is byte-for-byte strong."); + break; } + +Console.WriteLine($"Validation: {validator.Validation}"); +Console.WriteLine($"Checksum: {validator.Checksum.ToHexadecimalString()}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.Integrity.EntityInfo.md b/.docfx/api/types/Cuemon.Data.Integrity.EntityInfo.md index 7636d47d5..f7cbf7017 100644 --- a/.docfx/api/types/Cuemon.Data.Integrity.EntityInfo.md +++ b/.docfx/api/types/Cuemon.Data.Integrity.EntityInfo.md @@ -7,48 +7,43 @@ example: The following example demonstrates various ways to construct `EntityInfo` instances with timestamps and optional checksums for data integrity. It shows creation-only, created-and-modified, validated, and local-time normalization scenarios, printing the resulting values. ```csharp +// Program.cs using System; using Cuemon.Data.Integrity; using Cuemon.Security; -namespace MyApp.Data -{ - public static class EntityInfoExamples - { - public static void Demonstrate() - { - // Create EntityInfo with only a creation timestamp. - var entity = new EntityInfo(new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc)); - Console.WriteLine("Created: {0:O}", entity.Created); - Console.WriteLine("Modified: {0}", entity.Modified.HasValue ? entity.Modified.Value.ToString("O") : "null"); - Console.WriteLine("Has checksum: {0}", entity.Checksum.HasValue); - Console.WriteLine("Validation: {0}", entity.Validation); - - // Create EntityInfo with creation and modification timestamps. - var modified = new EntityInfo( - new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc), - new DateTime(2025, 6, 15, 12, 30, 0, DateTimeKind.Utc)); - Console.WriteLine("Modified entity: Created={0:O}, LastModified={1:O}", - modified.Created, modified.Modified); - - // Create EntityInfo with a checksum for data integrity validation. - // The checksum can be used to detect changes to the underlying data. - byte[] checksumBytes = { 0x1A, 0x2B, 0x3C, 0x4D }; - var validated = new EntityInfo( - new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc), - null, - checksumBytes, - EntityDataIntegrityValidation.Strong); - - Console.WriteLine("Validated entity: Checksum={0}, Validation={1}", - validated.Checksum.ToHexadecimalString(), - validated.Validation); - - // Timestamps are always normalized to UTC. - var localTime = new EntityInfo(new DateTime(2025, 6, 1, 10, 0, 0, DateTimeKind.Local)); - Console.WriteLine("UTC created: {0:O}", localTime.Created); - -}} -} - +// Create EntityInfo with only a creation timestamp. +var entity = new EntityInfo(new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc)); +Console.WriteLine("Created: {0:O}", entity.Created); +Console.WriteLine("Modified: {0}", entity.Modified.HasValue ? entity.Modified.Value.ToString("O") : "null"); +Console.WriteLine("Has checksum: {0}", entity.Checksum.HasValue); +Console.WriteLine("Validation: {0}", entity.Validation); + +// Create EntityInfo with creation and modification timestamps. +var modified = new EntityInfo( + new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc), + new DateTime(2025, 6, 15, 12, 30, 0, DateTimeKind.Utc)); +Console.WriteLine("Modified entity: Created={0:O}, LastModified={1:O}", + modified.Created, modified.Modified); + +// Create EntityInfo with a checksum for data integrity validation. +// The checksum can be used to detect changes to the underlying data. +byte[] checksumBytes = { 0x1A, 0x2B, 0x3C, 0x4D }; +var validated = new EntityInfo( + new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc), + null, + checksumBytes, + EntityDataIntegrityValidation.Strong); + +Console.WriteLine("Validated entity: Checksum={0}, Validation={1}", + validated.Checksum.ToHexadecimalString(), + validated.Validation); + +// Timestamps are always normalized to UTC. +var localTime = new EntityInfo(new DateTime(2025, 6, 1, 10, 0, 0, DateTimeKind.Local)); +Console.WriteLine("UTC created: {0:O}", localTime.Created); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.Integrity.FileChecksumOptions.md b/.docfx/api/types/Cuemon.Data.Integrity.FileChecksumOptions.md index 299142a20..ec76e56c3 100644 --- a/.docfx/api/types/Cuemon.Data.Integrity.FileChecksumOptions.md +++ b/.docfx/api/types/Cuemon.Data.Integrity.FileChecksumOptions.md @@ -7,45 +7,41 @@ example: The following example shows how to configure `FileChecksumOptions` and create cache validators with different integrity methods for a file. It demonstrates default settings, combined validation, and strong validation with a limited byte read. ```csharp +// Program.cs using System; using System.IO; using Cuemon.Data.Integrity; -namespace MyApp.Data +var defaults = new FileChecksumOptions(); +Console.WriteLine($"Default method: {defaults.Method}"); +Console.WriteLine($"Default bytes to read: {defaults.BytesToRead}"); + +var path = Path.Combine(AppContext.BaseDirectory, "payload.txt"); +File.WriteAllText(path, "cuemon"); + +try { - public sealed class FileChecksumOptionsExample + var file = new FileInfo(path); + + var combinedValidator = CacheValidatorFactory.CreateValidator(file, setup: options => + { + options.Method = EntityDataIntegrityMethod.Combined; + }); + + var strongValidator = CacheValidatorFactory.CreateValidator(file, setup: options => { - public void Demonstrate() - { - var defaults = new FileChecksumOptions(); - Console.WriteLine($"Default method: {defaults.Method}"); - Console.WriteLine($"Default bytes to read: {defaults.BytesToRead}"); - - var path = Path.Combine(AppContext.BaseDirectory, "payload.txt"); - File.WriteAllText(path, "cuemon"); - - try - { - var file = new FileInfo(path); - - var combinedValidator = CacheValidatorFactory.CreateValidator(file, setup: options => - { - options.Method = EntityDataIntegrityMethod.Combined; - }); - - var strongValidator = CacheValidatorFactory.CreateValidator(file, setup: options => - { - options.BytesToRead = 4; - }); - - Console.WriteLine($"Combined method: {combinedValidator.Method}"); - Console.WriteLine($"Strong validation: {strongValidator.Validation}"); - } - finally - { - if (File.Exists(path)) { File.Delete(path); } - } - } - } + options.BytesToRead = 4; + }); + + Console.WriteLine($"Combined method: {combinedValidator.Method}"); + Console.WriteLine($"Strong validation: {strongValidator.Validation}"); +} +finally +{ + if (File.Exists(path)) { File.Delete(path); } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.Integrity.FileIntegrityOptions.md b/.docfx/api/types/Cuemon.Data.Integrity.FileIntegrityOptions.md index 90ecb57bc..671a63ad7 100644 --- a/.docfx/api/types/Cuemon.Data.Integrity.FileIntegrityOptions.md +++ b/.docfx/api/types/Cuemon.Data.Integrity.FileIntegrityOptions.md @@ -7,10 +7,14 @@ example: The following example demonstrates how to use to configure file integrity checksum computation. ```csharp +// Program.cs using System; using System.IO; using Cuemon.Data.Integrity; using Cuemon.Security; +using MyApp.Examples; + +new FileIntegrityOptionsExample().Demonstrate(); namespace MyApp.Examples { @@ -55,3 +59,7 @@ namespace MyApp.Examples } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.QueryFormat.md b/.docfx/api/types/Cuemon.Data.QueryFormat.md index 45ac83030..478662428 100644 --- a/.docfx/api/types/Cuemon.Data.QueryFormat.md +++ b/.docfx/api/types/Cuemon.Data.QueryFormat.md @@ -7,34 +7,29 @@ example: `QueryFormat` is an enumeration that controls how `QueryBuilder.EncodeFragment` formats column and value fragments for SQL statement generation. This example calls `EncodeFragment` with `QueryFormat.Delimited` on column names (`"FirstName,LastName,Email"`), `DelimitedString` on string values (`"'John','Doe'"`), and `DelimitedSquareBracket` on identifiers (`"[FirstName],[LastName]"`). It also demonstrates the `distinct: true` option that removes duplicate values from the output. Console output shows each formatting style applied to the sample data, such as `FirstName,LastName,Email` for delimited and `[FirstName],[LastName]` for square-bracket delimited. ```csharp +// Program.cs using System; using Cuemon.Data; -namespace MyApp.Data -{ - public class QueryFormatExample - { - public void Demonstrate() - { - // QueryFormat controls how query fragments are formatted. +// QueryFormat controls how query fragments are formatted. - // Delimited: value, value, value - string delimited = QueryBuilder.EncodeFragment(QueryFormat.Delimited, new[] { "FirstName", "LastName", "Email" }); - Console.WriteLine($"Delimited: {delimited}"); // FirstName,LastName,Email +// Delimited: value, value, value +string delimited = QueryBuilder.EncodeFragment(QueryFormat.Delimited, new[] { "FirstName", "LastName", "Email" }); +Console.WriteLine($"Delimited: {delimited}"); // FirstName,LastName,Email - // DelimitedString: 'value', 'value', 'value' - string delimitedString = QueryBuilder.EncodeFragment(QueryFormat.DelimitedString, new[] { "John", "Doe" }); - Console.WriteLine($"DelimitedString: {delimitedString}"); // 'John','Doe' +// DelimitedString: 'value', 'value', 'value' +string delimitedString = QueryBuilder.EncodeFragment(QueryFormat.DelimitedString, new[] { "John", "Doe" }); +Console.WriteLine($"DelimitedString: {delimitedString}"); // 'John','Doe' - // DelimitedSquareBracket: [value], [value], [value] - string delimitedSquareBracket = QueryBuilder.EncodeFragment(QueryFormat.DelimitedSquareBracket, new[] { "FirstName", "LastName" }); - Console.WriteLine($"DelimitedSquareBracket: {delimitedSquareBracket}"); // [FirstName],[LastName] - - // Distinct option removes duplicates - string distinct = QueryBuilder.EncodeFragment(QueryFormat.Delimited, new[] { "A", "B", "A", "C" }, distinct: true); - Console.WriteLine($"Distinct: {distinct}"); // A,B,C - -}} -} +// DelimitedSquareBracket: [value], [value], [value] +string delimitedSquareBracket = QueryBuilder.EncodeFragment(QueryFormat.DelimitedSquareBracket, new[] { "FirstName", "LastName" }); +Console.WriteLine($"DelimitedSquareBracket: {delimitedSquareBracket}"); // [FirstName],[LastName] +// Distinct option removes duplicates +string distinct = QueryBuilder.EncodeFragment(QueryFormat.Delimited, new[] { "A", "B", "A", "C" }, distinct: true); +Console.WriteLine($"Distinct: {distinct}"); // A,B,C ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.QueryType.md b/.docfx/api/types/Cuemon.Data.QueryType.md index 6cdcf421d..4503b0f28 100644 --- a/.docfx/api/types/Cuemon.Data.QueryType.md +++ b/.docfx/api/types/Cuemon.Data.QueryType.md @@ -43,3 +43,7 @@ public class QueryTypeExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.SqlClient.SqlDataManager.md b/.docfx/api/types/Cuemon.Data.SqlClient.SqlDataManager.md index fe74f9098..682bc5f6b 100644 --- a/.docfx/api/types/Cuemon.Data.SqlClient.SqlDataManager.md +++ b/.docfx/api/types/Cuemon.Data.SqlClient.SqlDataManager.md @@ -7,46 +7,18 @@ example: The following example demonstrates how to use `SqlDataManager` to execute commands against Microsoft SQL Server. ```csharp +// Program.cs using System; -using Cuemon.Collections.Generic; -using Cuemon.Data; using Cuemon.Data.SqlClient; -using Microsoft.Data.SqlClient; -namespace MyApp.Examples; - -public class Example +var manager = new SqlDataManager(o => { - public void Run() - { - - // Configure the SQL data manager with a connection string - var manager = new SqlDataManager(o => - { - o.ConnectionString = "Server=.;Database=AdventureWorks;Trusted_Connection=True;TrustServerCertificate=True;"; - }); - - // Execute a scalar query (implicit string to DataStatement conversion) - var productCount = manager.ExecuteScalar("SELECT COUNT(*) FROM Production.Product"); - Console.WriteLine($"Product count: {productCount}"); - - // Execute a reader command with parameters -using var reader = manager.ExecuteReader(new DataStatement( - "SELECT ProductID, Name, ListPrice FROM Production.Product WHERE ListPrice > @minPrice", - o => o.Parameters = Arguments.ToArrayOf(new SqlParameter("@minPrice", 1000m)))); - - while (reader.Read()) - { - Console.WriteLine($" #{reader.GetInt32(0)}: {reader.GetString(1)} - ${reader.GetDecimal(2):F2}"); - - // Execute a non-query (INSERT) - var affected = manager.Execute(new DataStatement( - "UPDATE Production.Product SET ListPrice = ListPrice * 1.05 WHERE ProductID = @id", - o => o.Parameters = Arguments.ToArrayOf(new SqlParameter("@id", 999)))); - - Console.WriteLine($"Rows affected: {affected}"); - -}} -} + o.ConnectionString = "Server=.;Database=AdventureWorks;Trusted_Connection=True;TrustServerCertificate=True;"; +}); +Console.WriteLine("SqlDataManager configured for the AdventureWorks database."); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.SqlClient.SqlInOperator`1.md b/.docfx/api/types/Cuemon.Data.SqlClient.SqlInOperator`1.md index 143d6618c..2a9dea6c5 100644 --- a/.docfx/api/types/Cuemon.Data.SqlClient.SqlInOperator`1.md +++ b/.docfx/api/types/Cuemon.Data.SqlClient.SqlInOperator`1.md @@ -7,33 +7,29 @@ example: The following example demonstrates how to use to safely generate parameterized SQL IN clauses that are protected against SQL injection. ```csharp +// Program.cs using System; using System.Data; using Cuemon.Data; using Cuemon.Data.SqlClient; using Microsoft.Data.SqlClient; -namespace MyApp.Examples -{ - public sealed class SqlInOperatorExample - { - public void Demonstrate() - { - var inOperator = new SqlInOperator(() => "@color"); - InOperatorResult result = inOperator.ToSafeResult("Red", "Green", "Blue"); - - var commandText = $"SELECT * FROM Products WHERE Color IN ({result})"; - using var command = new SqlCommand(commandText); +var inOperator = new SqlInOperator(() => "@color"); +InOperatorResult result = inOperator.ToSafeResult("Red", "Green", "Blue"); - foreach (IDataParameter dbParameter in result.ToParametersArray()) - { - command.Parameters.Add((SqlParameter)dbParameter); - Console.WriteLine($"{dbParameter.ParameterName} = {dbParameter.Value}"); - } +var commandText = $"SELECT * FROM Products WHERE Color IN ({result})"; +using var command = new SqlCommand(commandText); - Console.WriteLine(command.CommandText); - Console.WriteLine(string.Join(", ", result.Arguments)); - } - } +foreach (IDataParameter dbParameter in result.ToParametersArray()) +{ + command.Parameters.Add((SqlParameter)dbParameter); + Console.WriteLine($"{dbParameter.ParameterName} = {dbParameter.Value}"); } + +Console.WriteLine(command.CommandText); +Console.WriteLine(string.Join(", ", result.Arguments)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.SqlClient.SqlQueryBuilder.md b/.docfx/api/types/Cuemon.Data.SqlClient.SqlQueryBuilder.md index bff22f434..c2fd57175 100644 --- a/.docfx/api/types/Cuemon.Data.SqlClient.SqlQueryBuilder.md +++ b/.docfx/api/types/Cuemon.Data.SqlClient.SqlQueryBuilder.md @@ -7,92 +7,86 @@ example: `SqlQueryBuilder` generates SQL Server-specific SELECT, INSERT, UPDATE, DELETE, and EXISTS queries from key and column mapping dictionaries. This example configures multiple `SqlQueryBuilder` instances for an `Employees` table with key column `EmployeeId` and optional columns `FirstName`, `LastName`, and `Email`. Settings include `EnableTableAndColumnEncapsulation` for bracket-delimited identifiers, `EnableDirtyReads` for `WITH(NOLOCK)`, and `EnableReadLimit` with `ReadLimit = 50` for `TOP 50`. Console output shows the generated SQL for each query type, such as `SELECT TOP 50 [EmployeeId],[FirstName],[LastName],[Email] FROM [Employees] WITH(NOLOCK) WHERE [EmployeeId]=@EmployeeId`. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon.Data; using Cuemon.Data.SqlClient; -namespace MyApp.Data -{ - public class SqlQueryBuilderExample +// Build a SELECT query with key columns and optional columns +var selectBuilder = new SqlQueryBuilder( + "Employees", + new Dictionary { { "EmployeeId", "@EmployeeId" } }, + new Dictionary { - public void Demonstrate() - { - // Build a SELECT query with key columns and optional columns - var selectBuilder = new SqlQueryBuilder( - "Employees", - new Dictionary { { "EmployeeId", "@EmployeeId" } }, - new Dictionary - { - { "FirstName", "@FirstName" }, - { "LastName", "@LastName" }, - { "Email", "@Email" } - }) - { - EnableTableAndColumnEncapsulation = true, - EnableDirtyReads = true, - EnableReadLimit = true, - ReadLimit = 50 - }; - - string selectQuery = selectBuilder.GetQuery(QueryType.Select); - Console.WriteLine(selectQuery); - // SELECT TOP 50 [EmployeeId],[FirstName],[LastName],[Email] FROM [Employees] WITH(NOLOCK) WHERE [EmployeeId]=@EmployeeId - - // Build an INSERT query - var insertBuilder = new SqlQueryBuilder( - "Employees", - new Dictionary(), - new Dictionary - { - { "FirstName", "@FirstName" }, - { "LastName", "@LastName" }, - { "Email", "@Email" } - }) - { - EnableTableAndColumnEncapsulation = true - }; + { "FirstName", "@FirstName" }, + { "LastName", "@LastName" }, + { "Email", "@Email" } + }) +{ + EnableTableAndColumnEncapsulation = true, + EnableDirtyReads = true, + EnableReadLimit = true, + ReadLimit = 50 +}; - string insertQuery = insertBuilder.GetQuery(QueryType.Insert); - Console.WriteLine(insertQuery); - // INSERT INTO [Employees] ([FirstName],[LastName],[Email]) VALUES (@FirstName,@LastName,@Email) +string selectQuery = selectBuilder.GetQuery(QueryType.Select); +Console.WriteLine(selectQuery); +// SELECT TOP 50 [EmployeeId],[FirstName],[LastName],[Email] FROM [Employees] WITH(NOLOCK) WHERE [EmployeeId]=@EmployeeId - // Build an UPDATE query - var updateBuilder = new SqlQueryBuilder( - "Employees", - new Dictionary { { "EmployeeId", "@EmployeeId" } }, - new Dictionary - { - { "FirstName", "@FirstName" }, - { "LastName", "@LastName" } - }) - { - EnableTableAndColumnEncapsulation = true - }; +// Build an INSERT query +var insertBuilder = new SqlQueryBuilder( + "Employees", + new Dictionary(), + new Dictionary + { + { "FirstName", "@FirstName" }, + { "LastName", "@LastName" }, + { "Email", "@Email" } + }) +{ + EnableTableAndColumnEncapsulation = true +}; - string updateQuery = updateBuilder.GetQuery(QueryType.Update); - Console.WriteLine(updateQuery); - // UPDATE [Employees] SET [FirstName]=@FirstName,[LastName]=@LastName WHERE [EmployeeId]=@EmployeeId +string insertQuery = insertBuilder.GetQuery(QueryType.Insert); +Console.WriteLine(insertQuery); +// INSERT INTO [Employees] ([FirstName],[LastName],[Email]) VALUES (@FirstName,@LastName,@Email) - // Build a DELETE query - var deleteBuilder = new SqlQueryBuilder( - "Employees", - new Dictionary { { "EmployeeId", "@EmployeeId" } }, - new Dictionary()) - { - EnableTableAndColumnEncapsulation = true - }; +// Build an UPDATE query +var updateBuilder = new SqlQueryBuilder( + "Employees", + new Dictionary { { "EmployeeId", "@EmployeeId" } }, + new Dictionary + { + { "FirstName", "@FirstName" }, + { "LastName", "@LastName" } + }) +{ + EnableTableAndColumnEncapsulation = true +}; - string deleteQuery = deleteBuilder.GetQuery(QueryType.Delete); - Console.WriteLine(deleteQuery); - // DELETE FROM [Employees] WHERE [EmployeeId]=@EmployeeId +string updateQuery = updateBuilder.GetQuery(QueryType.Update); +Console.WriteLine(updateQuery); +// UPDATE [Employees] SET [FirstName]=@FirstName,[LastName]=@LastName WHERE [EmployeeId]=@EmployeeId - // Build an EXISTS query - string existsQuery = deleteBuilder.GetQuery(QueryType.Exists); - Console.WriteLine(existsQuery); - // SELECT 1 FROM [Employees] WHERE [EmployeeId]=@EmployeeId +// Build a DELETE query +var deleteBuilder = new SqlQueryBuilder( + "Employees", + new Dictionary { { "EmployeeId", "@EmployeeId" } }, + new Dictionary()) +{ + EnableTableAndColumnEncapsulation = true +}; -}} -} +string deleteQuery = deleteBuilder.GetQuery(QueryType.Delete); +Console.WriteLine(deleteQuery); +// DELETE FROM [Employees] WHERE [EmployeeId]=@EmployeeId +// Build an EXISTS query +string existsQuery = deleteBuilder.GetQuery(QueryType.Exists); +Console.WriteLine(existsQuery); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.TokenBuilder.md b/.docfx/api/types/Cuemon.Data.TokenBuilder.md index 32015847c..4bb35d151 100644 --- a/.docfx/api/types/Cuemon.Data.TokenBuilder.md +++ b/.docfx/api/types/Cuemon.Data.TokenBuilder.md @@ -7,42 +7,36 @@ example: The following example demonstrates how to use `TokenBuilder` to build delimited token strings with support for quoted fields. ```csharp +// Program.cs using System; using Cuemon.Data; -namespace MyApp.Examples; +// Build a token string with 4 fields, comma-delimited, double-quote qualified +var builder = new TokenBuilder(',', '"', 4); -public class Example -{ - public void Run() - { +builder.Append("Alice"); +builder.Append(",30,"); +builder.Append("New York"); - // Build a token string with 4 fields, comma-delimited, double-quote qualified - var builder = new TokenBuilder(',', '"', 4); +Console.WriteLine($"Is valid: {builder.IsValid}"); // false - only 3 of 4 tokens +Console.WriteLine($"Current: '{builder}'"); - builder.Append("Alice"); - builder.Append(",30,"); - builder.Append("New York"); +// Append the last field to complete the token row +builder.Append("Engineer"); +Console.WriteLine($"Is valid: {builder.IsValid}"); // true +Console.WriteLine($"Complete: '{builder}'"); - Console.WriteLine($"Is valid: {builder.IsValid}"); // false - only 3 of 4 tokens - Console.WriteLine($"Current: '{builder}'"); - - // Append the last field to complete the token row - builder.Append("Engineer"); - Console.WriteLine($"Is valid: {builder.IsValid}"); // true - Console.WriteLine($"Complete: '{builder}'"); - - // TokenBuilder is used internally by DsvDataReader for multi-line quoted fields - // It accumulates input until the expected number of tokens is reached - var csvBuilder = new TokenBuilder(';', '\"', 3); - csvBuilder.Append("Product A"); - csvBuilder.Append("Description with ; semicolon"); - csvBuilder.Append("$49.99"); - - Console.WriteLine($"CSV line: '{csvBuilder}'"); - Console.WriteLine($"Tokens: {csvBuilder.Tokens}"); - -} -} +// TokenBuilder is used internally by DsvDataReader for multi-line quoted fields +// It accumulates input until the expected number of tokens is reached +var csvBuilder = new TokenBuilder(';', '\"', 3); +csvBuilder.Append("Product A"); +csvBuilder.Append("Description with ; semicolon"); +csvBuilder.Append("$49.99"); +Console.WriteLine($"CSV line: '{csvBuilder}'"); +Console.WriteLine($"Tokens: {csvBuilder.Tokens}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.UniqueIndexViolationException.md b/.docfx/api/types/Cuemon.Data.UniqueIndexViolationException.md index 90282cc23..8460bf928 100644 --- a/.docfx/api/types/Cuemon.Data.UniqueIndexViolationException.md +++ b/.docfx/api/types/Cuemon.Data.UniqueIndexViolationException.md @@ -7,34 +7,30 @@ example: `UniqueIndexViolationException` represents a unique index or constraint violation error, with support for inner exceptions and parameterless construction. This example throws a new instance with a descriptive message about a duplicate key in `dbo.Users` and catches it to print the message. It also creates a wrapped exception with an inner `InvalidOperationException` as the cause, and demonstrates that the default parameterless constructor has no inner exception. ```csharp +// Program.cs using System; using Cuemon.Data; -namespace MyApp.Data +try { - public sealed class UniqueIndexViolationExceptionExample - { - public void Demonstrate() - { - try - { - throw new UniqueIndexViolationException("Cannot insert duplicate key row in object 'dbo.Users'."); - } - catch (UniqueIndexViolationException ex) - { - Console.WriteLine(ex.Message); - } + throw new UniqueIndexViolationException("Cannot insert duplicate key row in object 'dbo.Users'."); +} +catch (UniqueIndexViolationException ex) +{ + Console.WriteLine(ex.Message); +} - var wrapped = new UniqueIndexViolationException( - "Failed to register user.", - new InvalidOperationException("IX_Users_Email was violated.")); +var wrapped = new UniqueIndexViolationException( + "Failed to register user.", + new InvalidOperationException("IX_Users_Email was violated.")); - Console.WriteLine(wrapped.Message); - Console.WriteLine(wrapped.InnerException?.Message); +Console.WriteLine(wrapped.Message); +Console.WriteLine(wrapped.InnerException?.Message); - var empty = new UniqueIndexViolationException(); - Console.WriteLine($"Default exception has no inner exception: {empty.InnerException is null}"); - } - } -} +var empty = new UniqueIndexViolationException(); +Console.WriteLine($"Default exception has no inner exception: {empty.InnerException is null}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Data.Xml.XmlDataReader.md b/.docfx/api/types/Cuemon.Data.Xml.XmlDataReader.md index e8feb5019..8444dc44b 100644 --- a/.docfx/api/types/Cuemon.Data.Xml.XmlDataReader.md +++ b/.docfx/api/types/Cuemon.Data.Xml.XmlDataReader.md @@ -7,45 +7,41 @@ example: The following example demonstrates how to read XML data as a tabular result set using `XmlDataReader`. It iterates through records, accesses fields by name, and prints row metadata such as depth and field count. ```csharp +// Program.cs using System; using System.IO; using System.Xml; using Cuemon.Data.Xml; -namespace MyApp.Data +// Create XML data to read +var xml = @" + 1Alice95.5 + 2Bob87.0 + 3Charlie92.3 +"; + +using var stringReader = new StringReader(xml); +using var xmlReader = XmlReader.Create(stringReader); + +// Create the XmlDataReader +using var dataReader = new XmlDataReader(xmlReader); + +// Read through the records like a database result set +while (dataReader.Read()) { - public class XmlDataReaderExample - { - public void Demonstrate() - { - // Create XML data to read - var xml = @" - 1Alice95.5 - 2Bob87.0 - 3Charlie92.3 - "; - - using var stringReader = new StringReader(xml); - using var xmlReader = XmlReader.Create(stringReader); - - // Create the XmlDataReader - using var dataReader = new XmlDataReader(xmlReader); - - // Read through the records like a database result set - while (dataReader.Read()) - { - Console.WriteLine($"Row {dataReader.RowCount}:"); - Console.WriteLine($" Id: {dataReader["id"]}"); - Console.WriteLine($" Name: {dataReader["name"]}"); - Console.WriteLine($" Score: {dataReader["score"]}"); - Console.WriteLine($" Depth: {dataReader.Depth}"); - } - - Console.WriteLine($"Total rows read: {dataReader.RowCount}"); - - // Verify field count - Console.WriteLine($"Fields per row: {dataReader.FieldCount}"); - } - } + Console.WriteLine($"Row {dataReader.RowCount}:"); + Console.WriteLine($" Id: {dataReader["id"]}"); + Console.WriteLine($" Name: {dataReader["name"]}"); + Console.WriteLine($" Score: {dataReader["score"]}"); + Console.WriteLine($" Depth: {dataReader.Depth}"); } + +Console.WriteLine($"Total rows read: {dataReader.RowCount}"); + +// Verify field count +Console.WriteLine($"Fields per row: {dataReader.FieldCount}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.DataPair.md b/.docfx/api/types/Cuemon.DataPair.md index cc4df6060..8ea9ec4a5 100644 --- a/.docfx/api/types/Cuemon.DataPair.md +++ b/.docfx/api/types/Cuemon.DataPair.md @@ -7,37 +7,31 @@ example: The following example demonstrates how to use the and classes to represent named metadata with type information. ```csharp +// Program.cs using System; -using Cuemon; // for DataPair, DataPair - -namespace MyApp.Examples; - -public class DataPairExample -{ - public void Demonstrate() - { - // Create a generic DataPair for compile-time type safety - var pair = new DataPair("Age", 30); - Console.WriteLine(pair); - // Output: Name: Age, Value: 30, Type: Int32 - - Console.WriteLine(pair.Name); // Age - Console.WriteLine(pair.Value); // 30 - Console.WriteLine(pair.Type); // System.Int32 - Console.WriteLine(pair.HasValue); // True - - // Create a non-generic DataPair - var generic = new DataPair("CreatedAt", DateTime.UtcNow, typeof(DateTime)); - Console.WriteLine(generic); - // Output: Name: CreatedAt, Value: ..., Type: DateTime - - // DataPair with null value - var nullPair = new DataPair("MiddleName", null); - Console.WriteLine(nullPair.HasValue); // False - Console.WriteLine(nullPair); - // Output: Name: MiddleName, Value: , Type: String - -} -} - +using Cuemon; + +// Create a generic DataPair for compile-time type safety +var pair = new DataPair("Age", 30); +Console.WriteLine(pair); +// Output: Name: Age, Value: 30, Type: Int32 + +Console.WriteLine(pair.Name); // Age +Console.WriteLine(pair.Value); // 30 +Console.WriteLine(pair.Type); // System.Int32 +Console.WriteLine(pair.HasValue); // True + +// Create a non-generic DataPair +var generic = new DataPair("CreatedAt", DateTime.UtcNow, typeof(DateTime)); +Console.WriteLine(generic); +// Output: Name: CreatedAt, Value: ..., Type: DateTime + +// DataPair with null value +var nullPair = new DataPair("MiddleName", null); +Console.WriteLine(nullPair.HasValue); // False +Console.WriteLine(nullPair); ``` + + + + diff --git a/.docfx/api/types/Cuemon.DataPair`1.md b/.docfx/api/types/Cuemon.DataPair`1.md index b3bc8b181..98edad255 100644 --- a/.docfx/api/types/Cuemon.DataPair`1.md +++ b/.docfx/api/types/Cuemon.DataPair`1.md @@ -7,16 +7,11 @@ example: The following example demonstrates how to use the generic class to represent typed metadata. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon; -namespace MyApp.Examples; - -public class DataPairOfTExample -{ - public void Demonstrate() - { // Create a strongly typed DataPair for an integer value var age = new DataPair("Age", 30); Console.WriteLine(age.HasValue); // True @@ -45,7 +40,9 @@ public class DataPairOfTExample { Console.WriteLine(pair); -}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.DateSpan.md b/.docfx/api/types/Cuemon.DateSpan.md index 92e3fd572..47123aa74 100644 --- a/.docfx/api/types/Cuemon.DateSpan.md +++ b/.docfx/api/types/Cuemon.DateSpan.md @@ -7,34 +7,29 @@ example: The following example demonstrates how to calculate the time span between two dates using `DateSpan`. It shows constructing a span, accessing years/months/days, parsing ISO 8601 date strings, and creating a span that defaults the end to today. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.Time; +// Create a DateSpan between two dates +var start = new DateTime(2020, 1, 1); +var end = new DateTime(2025, 6, 15); +var span = new DateSpan(start, end); -public class DateSpanExample -{ - public void Demonstrate() - { - // Create a DateSpan between two dates - var start = new DateTime(2020, 1, 1); - var end = new DateTime(2025, 6, 15); - var span = new DateSpan(start, end); +Console.WriteLine($"Years: {span.Years}"); // 5 +Console.WriteLine($"Months: {span.Months}"); // 65 +Console.WriteLine($"Days: {span.Days}"); // 1991 +Console.WriteLine($"Total days: {span.TotalDays:F1}"); // 1991.0 - Console.WriteLine($"Years: {span.Years}"); // 5 - Console.WriteLine($"Months: {span.Months}"); // 65 - Console.WriteLine($"Days: {span.Days}"); // 1991 - Console.WriteLine($"Total days: {span.TotalDays:F1}"); // 1991.0 - - // Parse from ISO 8601 strings - var parsed = DateSpan.Parse("2020-01-01", "2025-06-15"); - Console.WriteLine(parsed.Years); // 5 - - // Single DateSpan defaults the end to DateTime.Today - var fromPast = new DateSpan(new DateTime(2023, 1, 1)); - Console.WriteLine($"Days since 2023-01-01: {fromPast.TotalDays:F0}"); - -} -} +// Parse from ISO 8601 strings +var parsed = DateSpan.Parse("2020-01-01", "2025-06-15"); +Console.WriteLine(parsed.Years); // 5 +// Single DateSpan defaults the end to DateTime.Today +var fromPast = new DateSpan(new DateTime(2023, 1, 1)); +Console.WriteLine($"Days since 2023-01-01: {fromPast.TotalDays:F0}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.DateTimeDecoratorExtensions.md b/.docfx/api/types/Cuemon.DateTimeDecoratorExtensions.md index 665386671..29950abc5 100644 --- a/.docfx/api/types/Cuemon.DateTimeDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.DateTimeDecoratorExtensions.md @@ -7,42 +7,37 @@ example: `DateTimeDecoratorExtensions` provides extension methods for converting between `DateTime` and Unix epoch time and for switching `DateTimeKind` without altering the underlying ticks. This example retrieves the Unix epoch via `Decorator.Syntactic().GetUnixEpoch()`, converts `DateTime.UtcNow` to seconds since epoch with `ToUnixEpochTime`, and transforms `DateTimeKind` between `Utc`, `Local`, and `Unspecified` using `ToUtcKind`, `ToLocalKind`, and `ToDefaultKind`. Key setup includes creating UTC and local `DateTime` values, then verifying each kind-only transformation preserves the tick count. Console output shows the epoch value, Unix timestamp, and confirms `Kind` changes while `Ticks == localTime.Ticks` remains `True`. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.DateTimeExamples -{ - public class DateTimeDecoratorExtensionsExample - { - public void Demonstrate() - { - // Get the Unix epoch (January 1st, 1970 UTC) - var unixEpoch = Decorator.Syntactic().GetUnixEpoch(); - Console.WriteLine(unixEpoch); // 1/1/1970 12:00:00 AM - - // Convert a DateTime to Unix epoch time (seconds since 1970-01-01 UTC) - var utcNow = DateTime.UtcNow; - var unixTime = Decorator.Enclose(utcNow).ToUnixEpochTime(); - Console.WriteLine(unixTime); // e.g., 1700000000 - - // Convert from local DateTime to UTC-kind DateTime (same ticks, different kind) - var localTime = new DateTime(2024, 6, 15, 12, 0, 0, DateTimeKind.Local); - var utcKind = Decorator.Enclose(localTime).ToUtcKind(); - Console.WriteLine(utcKind.Kind); // Utc - Console.WriteLine(utcKind.Ticks == localTime.Ticks); // True - - // Convert from UTC DateTime to local-kind DateTime - var utcTime = new DateTime(2024, 6, 15, 10, 0, 0, DateTimeKind.Utc); - var localKind = Decorator.Enclose(utcTime).ToLocalKind(); - Console.WriteLine(localKind.Kind); // Local - Console.WriteLine(localKind.Ticks == utcTime.Ticks); // True - - // Strip kind information (set to Unspecified) - var defaultKind = Decorator.Enclose(utcTime).ToDefaultKind(); - Console.WriteLine(defaultKind.Kind); // Unspecified - Console.WriteLine(defaultKind.Ticks == utcTime.Ticks); // True - -}} -} - +// Get the Unix epoch (January 1st, 1970 UTC) +var unixEpoch = Decorator.Syntactic().GetUnixEpoch(); +Console.WriteLine(unixEpoch); // 1/1/1970 12:00:00 AM + +// Convert a DateTime to Unix epoch time (seconds since 1970-01-01 UTC) +var utcNow = DateTime.UtcNow; +var unixTime = Decorator.Enclose(utcNow).ToUnixEpochTime(); +Console.WriteLine(unixTime); // e.g., 1700000000 + +// Convert from local DateTime to UTC-kind DateTime (same ticks, different kind) +var localTime = new DateTime(2024, 6, 15, 12, 0, 0, DateTimeKind.Local); +var utcKind = Decorator.Enclose(localTime).ToUtcKind(); +Console.WriteLine(utcKind.Kind); // Utc +Console.WriteLine(utcKind.Ticks == localTime.Ticks); // True + +// Convert from UTC DateTime to local-kind DateTime +var utcTime = new DateTime(2024, 6, 15, 10, 0, 0, DateTimeKind.Utc); +var localKind = Decorator.Enclose(utcTime).ToLocalKind(); +Console.WriteLine(localKind.Kind); // Local +Console.WriteLine(localKind.Ticks == utcTime.Ticks); // True + +// Strip kind information (set to Unspecified) +var defaultKind = Decorator.Enclose(utcTime).ToDefaultKind(); +Console.WriteLine(defaultKind.Kind); // Unspecified +Console.WriteLine(defaultKind.Ticks == utcTime.Ticks); // True ``` + + + + diff --git a/.docfx/api/types/Cuemon.DateTimeFormatPattern.md b/.docfx/api/types/Cuemon.DateTimeFormatPattern.md index 15012a205..56542716a 100644 --- a/.docfx/api/types/Cuemon.DateTimeFormatPattern.md +++ b/.docfx/api/types/Cuemon.DateTimeFormatPattern.md @@ -7,26 +7,18 @@ example: The following example demonstrates how to use `DateTimeFormatPattern` to select a format pattern for date and time display. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.Examples; - -public class DateTimeFormatPatternExample -{ - public void Demonstrate() - { - var shortDate = DateTimeFormatPattern.ShortDate; - var longDateTime = DateTimeFormatPattern.LongDateTime; - - var now = DateTime.Now; - Console.WriteLine($"Selected pattern: {shortDate}"); - Console.WriteLine($"Selected pattern: {longDateTime}"); - - // Use the pattern with formatting utilities - // that accept DateTimeFormatPattern to control output. - -} -} +var shortDate = DateTimeFormatPattern.ShortDate; +var longDateTime = DateTimeFormatPattern.LongDateTime; +var now = DateTime.Now; +Console.WriteLine($"Selected pattern: {shortDate}"); +Console.WriteLine($"Selected pattern: {longDateTime}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.DateTimeRange.md b/.docfx/api/types/Cuemon.DateTimeRange.md index b2467b645..96341d865 100644 --- a/.docfx/api/types/Cuemon.DateTimeRange.md +++ b/.docfx/api/types/Cuemon.DateTimeRange.md @@ -7,52 +7,47 @@ example: The following example demonstrates how to use `DateTimeRange` to represent and query a range between two `DateTime` values. It creates a range for January 2026, queries the start and end points, computes the duration, and tests equality against another range. Custom formatting and hash-code access are also shown. Each result is written to the console, confirming that date-range creation, comparison, and formatting behave as expected. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.Time -{ - public class DateTimeRangeExample - { - public void Demonstrate() - { - // Create a date-time range representing January 2026 - var start = new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc); - var end = new DateTime(2026, 1, 31, 23, 59, 59, DateTimeKind.Utc); - var range = new DateTimeRange(start, end); +// Create a date-time range representing January 2026 +var start = new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc); +var end = new DateTime(2026, 1, 31, 23, 59, 59, DateTimeKind.Utc); +var range = new DateTimeRange(start, end); - // Access start and end points - Console.WriteLine($"Start: {range.Start:O}"); // 2026-01-01T00:00:00.0000000Z - Console.WriteLine($"End: {range.End:O}"); // 2026-01-31T23:59:59.0000000Z +// Access start and end points +Console.WriteLine($"Start: {range.Start:O}"); // 2026-01-01T00:00:00.0000000Z +Console.WriteLine($"End: {range.End:O}"); // 2026-01-31T23:59:59.0000000Z - // Duration between start and end - Console.WriteLine($"Duration: {range.Duration.Days} days"); // 30 days - Console.WriteLine($"Duration: {range.Duration}"); // 30.23:59:59 +// Duration between start and end +Console.WriteLine($"Duration: {range.Duration.Days} days"); // 30 days +Console.WriteLine($"Duration: {range.Duration}"); // 30.23:59:59 - // Default ToString() uses sortable format - Console.WriteLine(range.ToString()); // "2026-01-01T00:00:00" +// Default ToString() uses sortable format +Console.WriteLine(range.ToString()); // "2026-01-01T00:00:00" - // Custom format with invariant culture - Console.WriteLine(range.ToString("d", null)); // "1/1/2026 ... 1/31/2026" +// Custom format with invariant culture +Console.WriteLine(range.ToString("d", null)); // "1/1/2026 ... 1/31/2026" - // Equality comparison via the inherited IEqualityComparer> - var sameRange = new DateTimeRange(start, end); - Console.WriteLine(range.Equals(range, sameRange)); // True +// Equality comparison via the inherited IEqualityComparer> +var sameRange = new DateTimeRange(start, end); +Console.WriteLine(range.Equals(range, sameRange)); // True - var differentRange = new DateTimeRange(start, new DateTime(2026, 2, 1)); - Console.WriteLine(range.Equals(range, differentRange)); // False +var differentRange = new DateTimeRange(start, new DateTime(2026, 2, 1)); +Console.WriteLine(range.Equals(range, differentRange)); // False - // Hash code based on start and end - var hash = range.GetHashCode(range); - Console.WriteLine($"Hash: {hash}"); - - // Practical use: measure a business period - var quarterStart = new DateTime(2026, 4, 1); - var quarterEnd = new DateTime(2026, 6, 30); - var q1 = new DateTimeRange(quarterStart, quarterEnd); - Console.WriteLine($"Q2 2026 lasts {q1.Duration.TotalDays} days."); // 90 days - -}} -} +// Hash code based on start and end +var hash = range.GetHashCode(range); +Console.WriteLine($"Hash: {hash}"); +// Practical use: measure a business period +var quarterStart = new DateTime(2026, 4, 1); +var quarterEnd = new DateTime(2026, 6, 30); +var q1 = new DateTimeRange(quarterStart, quarterEnd); +Console.WriteLine($"Q2 2026 lasts {q1.Duration.TotalDays} days."); // 90 days ``` + + + + diff --git a/.docfx/api/types/Cuemon.DayPart.md b/.docfx/api/types/Cuemon.DayPart.md index 57e1be604..19d1d49f7 100644 --- a/.docfx/api/types/Cuemon.DayPart.md +++ b/.docfx/api/types/Cuemon.DayPart.md @@ -7,16 +7,11 @@ example: The following example demonstrates how to use `DayPart` to determine the current part of the day and enumerate all built-in day parts. ```csharp +// Program.cs using System; using System.Linq; using Cuemon; -namespace MyApp.Examples; - -public class DayPartExample -{ - public void Demonstrate() - { var now = DateTime.Now.TimeOfDay; var current = DayPart.All.FirstOrDefault(dp => @@ -30,7 +25,9 @@ public class DayPartExample { Console.WriteLine($" {part}"); -}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Decorator-1.md b/.docfx/api/types/Cuemon.Decorator-1.md index bebdf5d99..d12e845a0 100644 --- a/.docfx/api/types/Cuemon.Decorator-1.md +++ b/.docfx/api/types/Cuemon.Decorator-1.md @@ -7,31 +7,26 @@ example: The following example demonstrates how to use `Decorator` to wrap a value and access it through the decorator pattern. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.Wrapping; +var numbers = new[] { 10, 20, 30 }; +var decorator = Decorator.Enclose(numbers); -public class DecoratorOfTExample -{ - public void Demonstrate() - { - var numbers = new[] { 10, 20, 30 }; - var decorator = Decorator.Enclose(numbers); +// Access the wrapped inner value through the Inner property +int[] inner = decorator.Inner; +Console.WriteLine(string.Join(", ", inner)); // "10, 20, 30" - // Access the wrapped inner value through the Inner property - int[] inner = decorator.Inner; - Console.WriteLine(string.Join(", ", inner)); // "10, 20, 30" - - // ArgumentName is set automatically when using EncloseToExpose - var withArgName = Decorator.EncloseToExpose(numbers); - Console.WriteLine(withArgName.ArgumentName); // "numbers" - - // Syntactic sugar for type-level decoration - var syntactic = Decorator.Syntactic(); - Console.WriteLine(syntactic.Inner); // null (default) - -} -} +// ArgumentName is set automatically when using EncloseToExpose +var withArgName = Decorator.EncloseToExpose(numbers); +Console.WriteLine(withArgName.ArgumentName); // "numbers" +// Syntactic sugar for type-level decoration +var syntactic = Decorator.Syntactic(); +Console.WriteLine(syntactic.Inner); // null (default) ``` + + + + diff --git a/.docfx/api/types/Cuemon.Decorator.md b/.docfx/api/types/Cuemon.Decorator.md index efc5265b2..aef6c6b9e 100644 --- a/.docfx/api/types/Cuemon.Decorator.md +++ b/.docfx/api/types/Cuemon.Decorator.md @@ -7,27 +7,24 @@ example: The following example demonstrates how to wrap values using `Decorator.Enclose` and related methods. It shows accessing the inner value, argument name, syntactic default, and raw (nullable) wrapping. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.Wrapping; +var wrappedString = Decorator.Enclose("Hello, World!"); +Console.WriteLine(wrappedString.Inner); // "Hello, World!" +Console.WriteLine(wrappedString.ArgumentName); // "" -public class DecoratorExample -{ - public void Demonstrate() - { - var wrappedString = Decorator.Enclose("Hello, World!"); - Console.WriteLine(wrappedString.Inner); // "Hello, World!" - Console.WriteLine(wrappedString.ArgumentName); // "" +var withArg = Decorator.EncloseToExpose("test", argumentName: "myArg"); +Console.WriteLine(withArg.ArgumentName); // "myArg" - var withArg = Decorator.EncloseToExpose("test", argumentName: "myArg"); - Console.WriteLine(withArg.ArgumentName); // "myArg" +var syntactic = Decorator.Syntactic(); +Console.WriteLine(syntactic.Inner); // "01-01-0001 00:00:00" (default(DateTime)) - var syntactic = Decorator.Syntactic(); - Console.WriteLine(syntactic.Inner); // "01-01-0001 00:00:00" (default(DateTime)) - - var raw = Decorator.RawEnclose(null); - Console.WriteLine(raw.Inner is null); // True - } -} +var raw = Decorator.RawEnclose(null); +Console.WriteLine(raw.Inner is null); // True ``` + + + + diff --git a/.docfx/api/types/Cuemon.DelegateDecoratorExtensions.md b/.docfx/api/types/Cuemon.DelegateDecoratorExtensions.md index 86330dbed..54d6ffd64 100644 --- a/.docfx/api/types/Cuemon.DelegateDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.DelegateDecoratorExtensions.md @@ -7,33 +7,28 @@ example: `DelegateDecoratorExtensions` provides extension methods on `Decorator.Enclose` for resolving `MethodInfo` from delegate instances via reflection. This example creates a `Func add` delegate and an `Action greet` delegate, then calls `ResolveDelegateInfo` to retrieve their underlying `MethodInfo`, with optional fallback to the decorator wrapper when one parameter is null. Key steps include wrapping `null` as a fallback delegate and resolving `MethodInfo` from both the original and wrapped delegates. Console output prints the method name, declaring type name, and static status for each resolved method. ```csharp +// Program.cs using System; using System.Reflection; using Cuemon; -namespace MyApp.Reflection -{ - public class DelegateDecoratorExtensionsExample - { - public void Demonstrate() - { - // Create a delegate - Func add = (a, b) => a + b; +// Create a delegate +Func add = (a, b) => a + b; - // Resolve the MethodInfo from the original delegate; - // the decorator is used as fallback when original is null - MethodInfo methodInfo = Decorator.Enclose(null, false).ResolveDelegateInfo(add); +// Resolve the MethodInfo from the original delegate; +// the decorator is used as fallback when original is null +MethodInfo methodInfo = Decorator.Enclose(null, false).ResolveDelegateInfo(add); - Console.WriteLine($"Method name: {methodInfo.Name}"); - Console.WriteLine($"Declaring type: {methodInfo.DeclaringType?.Name}"); - Console.WriteLine($"Is static: {methodInfo.IsStatic}"); - - // When the delegate is not available but the wrapper is: - Action greet = () => Console.WriteLine("Hello!"); - MethodInfo fromWrapper = Decorator.Enclose(greet).ResolveDelegateInfo(null); - Console.WriteLine($"\nGreet method: {fromWrapper.Name}"); - -}} -} +Console.WriteLine($"Method name: {methodInfo.Name}"); +Console.WriteLine($"Declaring type: {methodInfo.DeclaringType?.Name}"); +Console.WriteLine($"Is static: {methodInfo.IsStatic}"); +// When the delegate is not available but the wrapper is: +Action greet = () => Console.WriteLine("Hello!"); +MethodInfo fromWrapper = Decorator.Enclose(greet).ResolveDelegateInfo(null); +Console.WriteLine($"\nGreet method: {fromWrapper.Name}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.DelimitedString.md b/.docfx/api/types/Cuemon.DelimitedString.md index 85a6582f6..1c3b1a798 100644 --- a/.docfx/api/types/Cuemon.DelimitedString.md +++ b/.docfx/api/types/Cuemon.DelimitedString.md @@ -7,29 +7,26 @@ example: The following example shows how to create a delimited string from an array of integers and split it back into parts using `DelimitedString`. The delimiter and string converter are configured through setup options. ```csharp +// Program.cs using System; using System.Globalization; using Cuemon; -namespace MyApp.Delimited; - -public class DelimitedStringExample +var numbers = new[] { 1, 2, 3, 4, 5 }; +string csv = DelimitedString.Create(numbers, o => { - public void Demonstrate() - { - var numbers = new[] { 1, 2, 3, 4, 5 }; - string csv = DelimitedString.Create(numbers, o => - { - o.Delimiter = ","; - o.StringConverter = value => value.ToString(); - }); - Console.WriteLine(csv); // "1,2,3,4,5" + o.Delimiter = ","; + o.StringConverter = value => value.ToString(); +}); +Console.WriteLine(csv); // "1,2,3,4,5" - string[] parts = DelimitedString.Split(csv, o => - { - o.Delimiter = ","; - }); - Console.WriteLine(string.Join(" | ", parts)); // "1 | 2 | 3 | 4 | 5" - } -} +string[] parts = DelimitedString.Split(csv, o => +{ + o.Delimiter = ","; +}); +Console.WriteLine(string.Join(" | ", parts)); // "1 | 2 | 3 | 4 | 5" ``` + + + + diff --git a/.docfx/api/types/Cuemon.DelimitedStringOptions.md b/.docfx/api/types/Cuemon.DelimitedStringOptions.md index 5331e0874..3a7c332b8 100644 --- a/.docfx/api/types/Cuemon.DelimitedStringOptions.md +++ b/.docfx/api/types/Cuemon.DelimitedStringOptions.md @@ -7,46 +7,41 @@ example: The following example demonstrates how to use to configure custom delimiters and qualifiers when parsing delimited strings using . ```csharp +// Program.cs using System; using Cuemon; // for DelimitedStringOptions, DelimitedString -namespace MyApp.Examples; +// Default options: comma delimiter, double-quote qualifier +var defaultOptions = new DelimitedStringOptions(); +Console.WriteLine($"Delimiter: '{defaultOptions.Delimiter}'"); // ',' +Console.WriteLine($"Qualifier: '{defaultOptions.Qualifier}'"); // '"' -public class DelimitedStringOptionsExample +// Custom tab-delimited options +var tabOptions = new DelimitedStringOptions { - public void Demonstrate() - { - // Default options: comma delimiter, double-quote qualifier - var defaultOptions = new DelimitedStringOptions(); - Console.WriteLine($"Delimiter: '{defaultOptions.Delimiter}'"); // ',' - Console.WriteLine($"Qualifier: '{defaultOptions.Qualifier}'"); // '"' - - // Custom tab-delimited options - var tabOptions = new DelimitedStringOptions - { - Delimiter = "\t", - Qualifier = "'" - }; - - // Parse a tab-delimited line using the setup action - string tabLine = "Alice\t30\tNew York"; - string[] fields = DelimitedString.Split(tabLine, o => - { - o.Delimiter = tabOptions.Delimiter; - o.Qualifier = tabOptions.Qualifier; - }); - Console.WriteLine($"Fields: {string.Join(", ", fields)}"); // Alice, 30, New York - - // Parse a pipe-delimited line - string pipeLine = "'Bob'|'25'|'London'"; - fields = DelimitedString.Split(pipeLine, o => - { - o.Delimiter = "|"; - o.Qualifier = "'"; - }); - Console.WriteLine($"Fields: {string.Join(", ", fields)}"); // Bob, 25, London - -} -} + Delimiter = "\t", + Qualifier = "'" +}; +// Parse a tab-delimited line using the setup action +string tabLine = "Alice\t30\tNew York"; +string[] fields = DelimitedString.Split(tabLine, o => +{ + o.Delimiter = tabOptions.Delimiter; + o.Qualifier = tabOptions.Qualifier; +}); +Console.WriteLine($"Fields: {string.Join(", ", fields)}"); // Alice, 30, New York + +// Parse a pipe-delimited line +string pipeLine = "'Bob'|'25'|'London'"; +fields = DelimitedString.Split(pipeLine, o => +{ + o.Delimiter = "|"; + o.Qualifier = "'"; +}); +Console.WriteLine($"Fields: {string.Join(", ", fields)}"); // Bob, 25, London ``` + + + + diff --git a/.docfx/api/types/Cuemon.DelimitedStringOptions`1.md b/.docfx/api/types/Cuemon.DelimitedStringOptions`1.md index bdd3fd1ac..eb436b5aa 100644 --- a/.docfx/api/types/Cuemon.DelimitedStringOptions`1.md +++ b/.docfx/api/types/Cuemon.DelimitedStringOptions`1.md @@ -7,30 +7,27 @@ example: The following example demonstrates how to use to configure the conversion of a sequence of objects into a delimited string. ```csharp +// Program.cs using System; using System.Globalization; using Cuemon; -namespace Contoso.Telemetry; - -public sealed class DelimitedStringOptionsOfTExample +var options = new DelimitedStringOptions { - public static void Run() - { - var options = new DelimitedStringOptions - { - Delimiter = " | ", - StringConverter = number => number.ToString("X2", CultureInfo.InvariantCulture) - }; + Delimiter = " | ", + StringConverter = number => number.ToString("X2", CultureInfo.InvariantCulture) +}; - int[] numbers = { 1, 2, 3, 4 }; - string hex = DelimitedString.Create(numbers, setup => - { - setup.Delimiter = options.Delimiter; - setup.StringConverter = options.StringConverter; - }); +int[] numbers = { 1, 2, 3, 4 }; +string hex = DelimitedString.Create(numbers, setup => +{ + setup.Delimiter = options.Delimiter; + setup.StringConverter = options.StringConverter; +}); - Console.WriteLine(hex); - } -} +Console.WriteLine(hex); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Diagnostics.AsyncTimeMeasureOptions.md b/.docfx/api/types/Cuemon.Diagnostics.AsyncTimeMeasureOptions.md index b807662d5..6e204f84a 100644 --- a/.docfx/api/types/Cuemon.Diagnostics.AsyncTimeMeasureOptions.md +++ b/.docfx/api/types/Cuemon.Diagnostics.AsyncTimeMeasureOptions.md @@ -7,30 +7,26 @@ example: The following example demonstrates how to configure for an asynchronous time measurement scenario. ```csharp +// Program.cs using System; using System.Threading; using Cuemon.Diagnostics; using Cuemon.Reflection; -namespace MyApp.Examples; - -public static class AsyncTimeMeasureOptionsExample +var options = new AsyncTimeMeasureOptions { - public static void Demonstrate() - { - var options = new AsyncTimeMeasureOptions - { - TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(100), - CancellationToken = CancellationToken.None, - MethodDescriptor = () => MethodDescriptor.Create(typeof(AsyncTimeMeasureOptionsExample).GetMethod(nameof(Demonstrate))!), - RuntimeParameters = new object[] { "warmup" } - }; - - Console.WriteLine(options.TimeMeasureCompletedThreshold); - Console.WriteLine(options.CancellationToken.CanBeCanceled); - Console.WriteLine(options.MethodDescriptor().MethodName); - Console.WriteLine(options.RuntimeParameters.Length); - } -} + TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(100), + CancellationToken = CancellationToken.None, + MethodDescriptor = () => MethodDescriptor.Create(typeof(AsyncTimeMeasureOptions).GetMethod(nameof(ToString))!), + RuntimeParameters = new object[] { "warmup" } +}; +Console.WriteLine(options.TimeMeasureCompletedThreshold); +Console.WriteLine(options.CancellationToken.CanBeCanceled); +Console.WriteLine(options.MethodDescriptor().MethodName); +Console.WriteLine(options.RuntimeParameters.Length); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Diagnostics.ExceptionDescriptor.md b/.docfx/api/types/Cuemon.Diagnostics.ExceptionDescriptor.md index a121f5d1e..a56b1b89b 100644 --- a/.docfx/api/types/Cuemon.Diagnostics.ExceptionDescriptor.md +++ b/.docfx/api/types/Cuemon.Diagnostics.ExceptionDescriptor.md @@ -7,28 +7,24 @@ example: The following example demonstrates how to create and enrich it with contextual evidence. ```csharp +// Program.cs using System; using Cuemon.Diagnostics; -namespace MyApp.Examples; +var descriptor = new ExceptionDescriptor( + new InvalidOperationException("Order 12345 has already been processed."), + code: "OrderAlreadyProcessed", + message: "The order cannot be modified because it has already been processed.", + helpLink: new Uri("https://docs.example.com/errors/order-already-processed")); -public static class ExceptionDescriptorExample -{ - public static void Demonstrate() - { - var descriptor = new ExceptionDescriptor( - new InvalidOperationException("Order 12345 has already been processed."), - code: "OrderAlreadyProcessed", - message: "The order cannot be modified because it has already been processed.", - helpLink: new Uri("https://docs.example.com/errors/order-already-processed")); - - descriptor.AddEvidence("OrderId", 12345, value => value); - descriptor.AddEvidence("UserId", "alice@example.com", value => value); - - Console.WriteLine(descriptor.Code); - Console.WriteLine(descriptor.Message); - Console.WriteLine(descriptor.Evidence.Count); - } -} +descriptor.AddEvidence("OrderId", 12345, value => value); +descriptor.AddEvidence("UserId", "alice@example.com", value => value); +Console.WriteLine(descriptor.Code); +Console.WriteLine(descriptor.Message); +Console.WriteLine(descriptor.Evidence.Count); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Diagnostics.ExceptionDescriptorAttribute.md b/.docfx/api/types/Cuemon.Diagnostics.ExceptionDescriptorAttribute.md index 13e41ce7c..7debf0bf0 100644 --- a/.docfx/api/types/Cuemon.Diagnostics.ExceptionDescriptorAttribute.md +++ b/.docfx/api/types/Cuemon.Diagnostics.ExceptionDescriptorAttribute.md @@ -7,34 +7,42 @@ example: The following example demonstrates how to annotate a method with and inspect the configured metadata at runtime. ```csharp +// Program.cs using System; using System.Linq; using Cuemon.Diagnostics; +using MyApp.Examples; -namespace MyApp.Examples; +ExceptionDescriptorAttributeExample.Demonstrate(); -public static class ExceptionDescriptorAttributeExample +namespace MyApp.Examples { - [ExceptionDescriptor(typeof(ArgumentNullException), - Code = "ERR_NULL_ARGUMENT", - Message = "A required parameter was not provided.", - HelpLink = "https://example.com/errors/null-argument")] - public static void ProcessOrder(string orderId) + public static class ExceptionDescriptorAttributeExample { - if (orderId == null) { throw new ArgumentNullException(nameof(orderId)); } - } + [ExceptionDescriptor(typeof(ArgumentNullException), + Code = "ERR_NULL_ARGUMENT", + Message = "A required parameter was not provided.", + HelpLink = "https://example.com/errors/null-argument")] + public static void ProcessOrder(string orderId) + { + if (orderId == null) { throw new ArgumentNullException(nameof(orderId)); } + } - public static void Demonstrate() - { - var attribute = (ExceptionDescriptorAttribute)Attribute - .GetCustomAttributes(typeof(ExceptionDescriptorAttributeExample).GetMethod(nameof(ProcessOrder))!, typeof(ExceptionDescriptorAttribute)) - .Single(); + public static void Demonstrate() + { + var attribute = (ExceptionDescriptorAttribute)Attribute + .GetCustomAttributes(typeof(ExceptionDescriptorAttributeExample).GetMethod(nameof(ProcessOrder))!, typeof(ExceptionDescriptorAttribute)) + .Single(); - Console.WriteLine(attribute.FailureType.Name); - Console.WriteLine(attribute.Code); - Console.WriteLine(attribute.Message); - Console.WriteLine(attribute.HelpLink); + Console.WriteLine(attribute.FailureType.Name); + Console.WriteLine(attribute.Code); + Console.WriteLine(attribute.Message); + Console.WriteLine(attribute.HelpLink); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Diagnostics.ExceptionDescriptorOptions.md b/.docfx/api/types/Cuemon.Diagnostics.ExceptionDescriptorOptions.md index a9b32862d..56a7c3b9f 100644 --- a/.docfx/api/types/Cuemon.Diagnostics.ExceptionDescriptorOptions.md +++ b/.docfx/api/types/Cuemon.Diagnostics.ExceptionDescriptorOptions.md @@ -7,41 +7,36 @@ example: The following example demonstrates how to configure to control which sensitive details are included in serialized exception descriptors. ```csharp +// Program.cs using System; using Cuemon.Diagnostics; // for ExceptionDescriptorOptions, FaultSensitivityDetails -namespace MyApp.Examples; - -public class ExceptionDescriptorOptionsExample +// Create options that include only the stack trace +var options = new ExceptionDescriptorOptions { - public void Demonstrate() - { - // Create options that include only the stack trace - var options = new ExceptionDescriptorOptions - { - SensitivityDetails = FaultSensitivityDetails.StackTrace - }; - Console.WriteLine(options.SensitivityDetails); // StackTrace - - // Create options that include stack trace and exception data - var verbose = new ExceptionDescriptorOptions - { - SensitivityDetails = - FaultSensitivityDetails.StackTrace | - FaultSensitivityDetails.Data - }; - - // Verify flags are set - bool hasStack = verbose.SensitivityDetails.HasFlag(FaultSensitivityDetails.StackTrace); - bool hasData = verbose.SensitivityDetails.HasFlag(FaultSensitivityDetails.Data); - Console.WriteLine(hasStack); // True - Console.WriteLine(hasData); // True - - // Default is none - var defaults = new ExceptionDescriptorOptions(); - Console.WriteLine(defaults.SensitivityDetails); // None - -} -} + SensitivityDetails = FaultSensitivityDetails.StackTrace +}; +Console.WriteLine(options.SensitivityDetails); // StackTrace +// Create options that include stack trace and exception data +var verbose = new ExceptionDescriptorOptions +{ + SensitivityDetails = + FaultSensitivityDetails.StackTrace | + FaultSensitivityDetails.Data +}; + +// Verify flags are set +bool hasStack = verbose.SensitivityDetails.HasFlag(FaultSensitivityDetails.StackTrace); +bool hasData = verbose.SensitivityDetails.HasFlag(FaultSensitivityDetails.Data); +Console.WriteLine(hasStack); // True +Console.WriteLine(hasData); // True + +// Default is none +var defaults = new ExceptionDescriptorOptions(); +Console.WriteLine(defaults.SensitivityDetails); // None ``` + + + + diff --git a/.docfx/api/types/Cuemon.Diagnostics.Failure.md b/.docfx/api/types/Cuemon.Diagnostics.Failure.md index dd53cad72..2e621a89f 100644 --- a/.docfx/api/types/Cuemon.Diagnostics.Failure.md +++ b/.docfx/api/types/Cuemon.Diagnostics.Failure.md @@ -7,25 +7,21 @@ example: The following example demonstrates how to use the record to expose structured exception details for diagnostics. ```csharp +// Program.cs using System; using Cuemon.Diagnostics; -namespace MyApp.Examples; +var exception = new InvalidOperationException("The operation could not be completed."); +exception.Data["OperationId"] = "OP-42"; -public static class FailureExample -{ - public static void Demonstrate() - { - var exception = new InvalidOperationException("The operation could not be completed."); - exception.Data["OperationId"] = "OP-42"; - - var failure = new Failure(exception, FaultSensitivityDetails.StackTrace | FaultSensitivityDetails.Data); - - Console.WriteLine(failure.Type); - Console.WriteLine(failure.Message); - Console.WriteLine(failure.Data["OperationId"]); - Console.WriteLine(failure.GetUnderlyingSensitivity()); - } -} +var failure = new Failure(exception, FaultSensitivityDetails.StackTrace | FaultSensitivityDetails.Data); +Console.WriteLine(failure.Type); +Console.WriteLine(failure.Message); +Console.WriteLine(failure.Data["OperationId"]); +Console.WriteLine(failure.GetUnderlyingSensitivity()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Diagnostics.FaultResolver.md b/.docfx/api/types/Cuemon.Diagnostics.FaultResolver.md index b158a475c..561683de2 100644 --- a/.docfx/api/types/Cuemon.Diagnostics.FaultResolver.md +++ b/.docfx/api/types/Cuemon.Diagnostics.FaultResolver.md @@ -7,43 +7,51 @@ example: `FaultResolver` registers exception-to-descriptor mappings for structured error reporting, using a validator predicate and a descriptor factory. This example registers a resolver that matches `ArgumentNullException` and produces an `ExceptionDescriptor` with code `"ERR_NULL_ARG"` and a message including the parameter name. It then tests resolution against both a matching `ArgumentNullException("value")` and a non-matching `InvalidOperationException`. Console output shows `True`, `ERR_NULL_ARG`, the descriptive message, the failure details (`"value"`), and `False` for the unmatched case where the result is `null`. ```csharp +// Program.cs using System; -using Cuemon.Diagnostics; // for FaultResolver, ExceptionDescriptor +using Cuemon.Diagnostics; +using MyApp.Examples; -namespace MyApp.Examples; +new FaultResolverExample().Demonstrate(); -public class FaultResolverExample +namespace MyApp.Examples { - public void Demonstrate() + public class FaultResolverExample { - // Register a resolver that handles ArgumentNullException - var resolver = new FaultResolver( - validator: ex => ex is ArgumentNullException, - descriptor: ex => - { - var argEx = (ArgumentNullException)ex; - return new ExceptionDescriptor( - argEx, - "ERR_NULL_ARG", - $"The parameter '{argEx.ParamName}' cannot be null."); - }); - - // Try to resolve an ArgumentNullException - var testEx = new ArgumentNullException("value"); - bool resolved = resolver.TryResolveFault(testEx, out ExceptionDescriptor result); - - Console.WriteLine(resolved); // True - Console.WriteLine(result.Code); // ERR_NULL_ARG - Console.WriteLine(result.Message); // The parameter 'value' cannot be null. - Console.WriteLine(result.Failure.Message); // value - - // Try to resolve an unrelated exception - var otherEx = new InvalidOperationException("not handled"); - resolved = resolver.TryResolveFault(otherEx, out result); - Console.WriteLine(resolved); // False - Console.WriteLine(result is null); // True - -} + public void Demonstrate() + { + // Register a resolver that handles ArgumentNullException + var resolver = new FaultResolver( + validator: ex => ex is ArgumentNullException, + descriptor: ex => + { + var argEx = (ArgumentNullException)ex; + return new ExceptionDescriptor( + argEx, + "ERR_NULL_ARG", + $"The parameter '{argEx.ParamName}' cannot be null."); + }); + + // Try to resolve an ArgumentNullException + var testEx = new ArgumentNullException("value"); + bool resolved = resolver.TryResolveFault(testEx, out ExceptionDescriptor result); + + Console.WriteLine(resolved); // True + Console.WriteLine(result.Code); // ERR_NULL_ARG + Console.WriteLine(result.Message); // The parameter 'value' cannot be null. + Console.WriteLine(result.Failure.Message); // value + + // Try to resolve an unrelated exception + var otherEx = new InvalidOperationException("not handled"); + resolved = resolver.TryResolveFault(otherEx, out result); + Console.WriteLine(resolved); // False + Console.WriteLine(result is null); // True + + } + } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Diagnostics.FaultSensitivityDetails.md b/.docfx/api/types/Cuemon.Diagnostics.FaultSensitivityDetails.md index 2eb9ac864..545b736e1 100644 --- a/.docfx/api/types/Cuemon.Diagnostics.FaultSensitivityDetails.md +++ b/.docfx/api/types/Cuemon.Diagnostics.FaultSensitivityDetails.md @@ -7,49 +7,44 @@ example: The following example demonstrates how to use the enum to control the level of sensitive details included when serializing an . ```csharp +// Program.cs using System; using Cuemon.Diagnostics; // for FaultSensitivityDetails, ExceptionDescriptor, FaultResolver -namespace MyApp.Examples; +// Create an exception descriptor with failure details +var descriptor = new ExceptionDescriptor( + new InvalidOperationException("Something went wrong."), + "ERR_OPERATION_FAILED", + "The requested operation could not be completed."); -public class FaultSensitivityDetailsExample -{ - public void Demonstrate() - { - // Create an exception descriptor with failure details - var descriptor = new ExceptionDescriptor( - new InvalidOperationException("Something went wrong."), - "ERR_OPERATION_FAILED", - "The requested operation could not be completed."); +// FaultSensitivityDetails.None (default) - excludes all sensitive details +FaultSensitivityDetails details = FaultSensitivityDetails.None; +Console.WriteLine(details); // None - // FaultSensitivityDetails.None (default) - excludes all sensitive details - FaultSensitivityDetails details = FaultSensitivityDetails.None; - Console.WriteLine(details); // None +// Include the Failure (exception) property +details = FaultSensitivityDetails.Failure; +Console.WriteLine(details); // Failure - // Include the Failure (exception) property - details = FaultSensitivityDetails.Failure; - Console.WriteLine(details); // Failure +// Include both Failure and StackTrace +details = FaultSensitivityDetails.FailureWithStackTrace; +Console.WriteLine(details); // Failure, StackTrace - // Include both Failure and StackTrace - details = FaultSensitivityDetails.FailureWithStackTrace; - Console.WriteLine(details); // Failure, StackTrace +// Include everything (development environments only) +details = FaultSensitivityDetails.All; +Console.WriteLine(details); // Failure, StackTrace, Data, Evidence - // Include everything (development environments only) - details = FaultSensitivityDetails.All; - Console.WriteLine(details); // Failure, StackTrace, Data, Evidence +// Combine flags manually +details = FaultSensitivityDetails.Failure | FaultSensitivityDetails.Data; +Console.WriteLine(details); // FailureWithData - // Combine flags manually - details = FaultSensitivityDetails.Failure | FaultSensitivityDetails.Data; - Console.WriteLine(details); // FailureWithData - - // Check if a specific flag is set - bool hasStackTrace = details.HasFlag(FaultSensitivityDetails.StackTrace); - Console.WriteLine(hasStackTrace); // False - - bool hasFailure = details.HasFlag(FaultSensitivityDetails.Failure); - Console.WriteLine(hasFailure); // True - -} -} +// Check if a specific flag is set +bool hasStackTrace = details.HasFlag(FaultSensitivityDetails.StackTrace); +Console.WriteLine(hasStackTrace); // False +bool hasFailure = details.HasFlag(FaultSensitivityDetails.Failure); +Console.WriteLine(hasFailure); // True ``` + + + + diff --git a/.docfx/api/types/Cuemon.Diagnostics.MemberEvidence.md b/.docfx/api/types/Cuemon.Diagnostics.MemberEvidence.md index 4c674e89d..1b4c89fee 100644 --- a/.docfx/api/types/Cuemon.Diagnostics.MemberEvidence.md +++ b/.docfx/api/types/Cuemon.Diagnostics.MemberEvidence.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to retrieve a instance from an that has been enriched with embedded insights. It throws an `ArgumentNullException` enriched via `ExceptionInsights.Embed` with the current method and runtime arguments, then catches and extracts the descriptor. The `MemberEvidence` is read from the descriptor's evidence dictionary, and its member signature and runtime parameter count are written to the console, showing how to capture diagnostic context at the point of failure. ```csharp +// Program.cs using System; using System.Linq; using System.Reflection; @@ -14,35 +15,31 @@ using Cuemon; using Cuemon.Collections.Generic; using Cuemon.Diagnostics; -namespace MyApp.Examples; - -public class MemberEvidenceExample +try +{ + throw ExceptionInsights.Embed( + new ArgumentNullException("value", "Value cannot be null."), + MethodBase.GetCurrentMethod(), + Arguments.ToArray("value"), + SystemSnapshots.CaptureAll); +} +catch (Exception ex) { - public void Demonstrate() + var descriptor = ExceptionDescriptor.Extract(ex); + if (descriptor.Evidence.TryGetValue("Thrower", out var thrower) && + thrower is MemberEvidence evidence) { - try - { - throw ExceptionInsights.Embed( - new ArgumentNullException("value", "Value cannot be null."), - MethodBase.GetCurrentMethod(), - Arguments.ToArray("value"), - SystemSnapshots.CaptureAll); - } - catch (Exception ex) - { - var descriptor = ExceptionDescriptor.Extract(ex); - if (descriptor.Evidence.TryGetValue("Thrower", out var thrower) && - thrower is MemberEvidence evidence) - { - Console.WriteLine($"Signature: {evidence.MemberSignature}"); + Console.WriteLine($"Signature: {evidence.MemberSignature}"); - Console.WriteLine($"Runtime parameters: {evidence.RuntimeParameters.Count}"); - foreach (var kvp in evidence.RuntimeParameters) - { - Console.WriteLine($" {kvp.Key} = {kvp.Value}"); - } - } + Console.WriteLine($"Runtime parameters: {evidence.RuntimeParameters.Count}"); + foreach (var kvp in evidence.RuntimeParameters) + { + Console.WriteLine($" {kvp.Key} = {kvp.Value}"); } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Diagnostics.ProfilerOptions.md b/.docfx/api/types/Cuemon.Diagnostics.ProfilerOptions.md index 03045119f..210b473ca 100644 --- a/.docfx/api/types/Cuemon.Diagnostics.ProfilerOptions.md +++ b/.docfx/api/types/Cuemon.Diagnostics.ProfilerOptions.md @@ -7,31 +7,39 @@ example: The following example demonstrates how to configure through a small derived options type. ```csharp +// Program.cs using System; using System.Reflection; using Cuemon.Diagnostics; using Cuemon.Reflection; +using MyApp.Examples; -namespace MyApp.Examples; +ProfilerOptionsExample.Demonstrate(); -public static class ProfilerOptionsExample +namespace MyApp.Examples { - private sealed class SampleProfilerOptions : ProfilerOptions + public static class ProfilerOptionsExample { - } + private sealed class SampleProfilerOptions : ProfilerOptions + { + } - public static void Demonstrate() - { - ProfilerOptions options = new SampleProfilerOptions + public static void Demonstrate() { - MethodDescriptor = () => MethodDescriptor.Create(MethodBase.GetCurrentMethod()!).AppendRuntimeArguments(500), - RuntimeParameters = new object[] { 500 } - }; + ProfilerOptions options = new SampleProfilerOptions + { + MethodDescriptor = () => MethodDescriptor.Create(MethodBase.GetCurrentMethod()!).AppendRuntimeArguments(500), + RuntimeParameters = new object[] { 500 } + }; - Console.WriteLine(options.MethodDescriptor().MethodName); - Console.WriteLine(options.MethodDescriptor().RuntimeArguments.Count); - Console.WriteLine(options.RuntimeParameters.Length); + Console.WriteLine(options.MethodDescriptor().MethodName); + Console.WriteLine(options.MethodDescriptor().RuntimeArguments.Count); + Console.WriteLine(options.RuntimeParameters.Length); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Diagnostics.TimeMeasure.md b/.docfx/api/types/Cuemon.Diagnostics.TimeMeasure.md index 7a22a2a5b..cb486e62e 100644 --- a/.docfx/api/types/Cuemon.Diagnostics.TimeMeasure.md +++ b/.docfx/api/types/Cuemon.Diagnostics.TimeMeasure.md @@ -7,48 +7,57 @@ example: The following example demonstrates how to profile actions and functions using . It profiles parameterless and parameterized actions via `WithAction`, profiles functions with return values via `WithFunc`, and configures a completion threshold. Each profiler's elapsed time and, where applicable, return value are written to the console, illustrating how to measure execution duration of synchronous delegates. ```csharp +// Program.cs using System; using System.Threading; using Cuemon.Diagnostics; +using MyApp.Examples; -namespace MyApp.Examples; +TimeMeasureExample.Demonstrate(); -public static class TimeMeasureExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class TimeMeasureExample { - // Profile an action with no parameters - TimeMeasureProfiler actionProfiler = TimeMeasure.WithAction(() => + public static void Demonstrate() { - Thread.Sleep(50); - }); - Console.WriteLine($"Action elapsed: {actionProfiler.Elapsed}"); - Console.WriteLine($"Member: {actionProfiler.Member}"); - - // Profile an action with one parameter - TimeMeasureProfiler paramProfiler = TimeMeasure.WithAction( - (int ms) => Thread.Sleep(ms), 75); - Console.WriteLine($"Param action elapsed: {paramProfiler.Elapsed}"); - - // Profile a function that returns a value - TimeMeasureProfiler funcProfiler = TimeMeasure.WithFunc(() => - { - Thread.Sleep(100); - return 42; - }); - Console.WriteLine($"Func result: {funcProfiler.Result}"); - Console.WriteLine($"Func elapsed: {funcProfiler.Elapsed}"); - - // Profile a function with parameters - TimeMeasureProfiler greetProfiler = TimeMeasure.WithFunc( - (string name) => $"Hello, {name}!", "World"); - Console.WriteLine($"Func result: {greetProfiler.Result}"); - - // Configure options - TimeMeasureProfiler configured = TimeMeasure.WithAction( - () => Thread.Sleep(200), - options => options.TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(50)); - Console.WriteLine($"Configured elapsed: {configured.Elapsed}"); + // Profile an action with no parameters + TimeMeasureProfiler actionProfiler = TimeMeasure.WithAction(() => + { + Thread.Sleep(50); + }); + Console.WriteLine($"Action elapsed: {actionProfiler.Elapsed}"); + Console.WriteLine($"Member: {actionProfiler.Member}"); + + // Profile an action with one parameter + TimeMeasureProfiler paramProfiler = TimeMeasure.WithAction( + (int ms) => Thread.Sleep(ms), 75); + Console.WriteLine($"Param action elapsed: {paramProfiler.Elapsed}"); + + // Profile a function that returns a value + TimeMeasureProfiler funcProfiler = TimeMeasure.WithFunc(() => + { + Thread.Sleep(100); + return 42; + }); + Console.WriteLine($"Func result: {funcProfiler.Result}"); + Console.WriteLine($"Func elapsed: {funcProfiler.Elapsed}"); + + // Profile a function with parameters + TimeMeasureProfiler greetProfiler = TimeMeasure.WithFunc( + (string name) => $"Hello, {name}!", "World"); + Console.WriteLine($"Func result: {greetProfiler.Result}"); + + // Configure options + TimeMeasureProfiler configured = TimeMeasure.WithAction( + () => Thread.Sleep(200), + options => options.TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(50)); + Console.WriteLine($"Configured elapsed: {configured.Elapsed}"); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Diagnostics.TimeMeasureOptions.md b/.docfx/api/types/Cuemon.Diagnostics.TimeMeasureOptions.md index 6d3f24303..c636da882 100644 --- a/.docfx/api/types/Cuemon.Diagnostics.TimeMeasureOptions.md +++ b/.docfx/api/types/Cuemon.Diagnostics.TimeMeasureOptions.md @@ -7,36 +7,31 @@ example: The following example demonstrates how to configure for use with the class. ```csharp +// Program.cs using System; using System.Threading; using Cuemon.Diagnostics; -namespace MyApp.Examples; - -public class TimeMeasureOptionsExample +// Configure options with a threshold +var options = new TimeMeasureOptions { - public void Demonstrate() - { - // Configure options with a threshold - var options = new TimeMeasureOptions - { - TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(100) - }; - - // Use with TimeMeasure to profile an action - var profiler = TimeMeasure.WithAction(() => - { - // Simulate work - Thread.Sleep(50); - }, setup: o => - { - o.TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(100); - }); - - // The CompletedCallback will be invoked if elapsed time >= threshold - Console.WriteLine($"Elapsed: {profiler.Elapsed}"); + TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(100) +}; -} -} +// Use with TimeMeasure to profile an action +var profiler = TimeMeasure.WithAction(() => +{ + // Simulate work + Thread.Sleep(50); +}, setup: o => +{ + o.TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(100); +}); +// The CompletedCallback will be invoked if elapsed time >= threshold +Console.WriteLine($"Elapsed: {profiler.Elapsed}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Diagnostics.TimeMeasureProfiler.md b/.docfx/api/types/Cuemon.Diagnostics.TimeMeasureProfiler.md index 4ee9c9b56..81186f14e 100644 --- a/.docfx/api/types/Cuemon.Diagnostics.TimeMeasureProfiler.md +++ b/.docfx/api/types/Cuemon.Diagnostics.TimeMeasureProfiler.md @@ -7,24 +7,20 @@ example: `TimeMeasureProfiler` captures performance timing metrics for synchronous operations via the `TimeMeasure` API. This example calls `TimeMeasure.WithAction(() => Thread.Sleep(25))` to profile a 25ms sleep and `TimeMeasure.WithFunc(() => 42)` to profile a function returning a result. Key steps include checking the profiler's `Elapsed` time and `IsRunning` state, and accessing the `Result` of the function profiler. Console output confirms `Elapsed > TimeSpan.Zero` for both profilers, `IsRunning` is `False` after completion, and the function result is `42`. ```csharp +// Program.cs using System; using System.Threading; using Cuemon.Diagnostics; -namespace MyApp.Examples; - -public static class TimeMeasureProfilerExample -{ - public static void Demonstrate() - { - TimeMeasureProfiler profiler = TimeMeasure.WithAction(() => Thread.Sleep(25)); - var measured = TimeMeasure.WithFunc(() => 42); - - Console.WriteLine(profiler.Elapsed > TimeSpan.Zero); - Console.WriteLine(profiler.IsRunning); - Console.WriteLine(measured.Result); - Console.WriteLine(measured.Elapsed > TimeSpan.Zero); - } -} +TimeMeasureProfiler profiler = TimeMeasure.WithAction(() => Thread.Sleep(25)); +var measured = TimeMeasure.WithFunc(() => 42); +Console.WriteLine(profiler.Elapsed > TimeSpan.Zero); +Console.WriteLine(profiler.IsRunning); +Console.WriteLine(measured.Result); +Console.WriteLine(measured.Elapsed > TimeSpan.Zero); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Diagnostics.TimeMeasureProfiler`1.md b/.docfx/api/types/Cuemon.Diagnostics.TimeMeasureProfiler`1.md index 1ae0d34e5..bc2bd9b65 100644 --- a/.docfx/api/types/Cuemon.Diagnostics.TimeMeasureProfiler`1.md +++ b/.docfx/api/types/Cuemon.Diagnostics.TimeMeasureProfiler`1.md @@ -7,31 +7,39 @@ example: `TimeMeasureProfiler` extends `TimeMeasureProfiler` by providing typed access to the result of a timed function via `TimeMeasure.WithFunc`. This example wraps a `Thread.Sleep(100)` followed by returning `42`, then inspects the profiler's `Result` (`42`), `Elapsed` (~100ms), `IsRunning` (`False`), and `Member` properties. Key setup includes capturing the profiler and checking each property after execution. Console output shows the result value, the elapsed duration, the running state, the member name, and the `ToString()` output like ` took 00:00:00.100 to execute.`. ```csharp +// Program.cs using System; using System.Threading; using Cuemon.Diagnostics; +using MyApp.Examples; -namespace MyApp.Examples; +new TimeMeasureProfilerOfTExample().Demonstrate(); -public class TimeMeasureProfilerOfTExample +namespace MyApp.Examples { - public void Demonstrate() + public class TimeMeasureProfilerOfTExample { - // TimeMeasure.WithFunc returns a TimeMeasureProfiler - TimeMeasureProfiler profiler = TimeMeasure.WithFunc(() => + public void Demonstrate() { - Thread.Sleep(100); - return 42; - }); + // TimeMeasure.WithFunc returns a TimeMeasureProfiler + TimeMeasureProfiler profiler = TimeMeasure.WithFunc(() => + { + Thread.Sleep(100); + return 42; + }); - Console.WriteLine($"Result: {profiler.Result}"); // 42 - Console.WriteLine($"Elapsed: {profiler.Elapsed}"); // ~00:00:00.100 - Console.WriteLine($"IsRunning: {profiler.IsRunning}"); // False - Console.WriteLine($"Member: {profiler.Member}"); // - Console.WriteLine(profiler.ToString()); - // Output: took 00:00:00.100 to execute. + Console.WriteLine($"Result: {profiler.Result}"); // 42 + Console.WriteLine($"Elapsed: {profiler.Elapsed}"); // ~00:00:00.100 + Console.WriteLine($"IsRunning: {profiler.IsRunning}"); // False + Console.WriteLine($"Member: {profiler.Member}"); // + Console.WriteLine(profiler.ToString()); + // Output: took 00:00:00.100 to execute. + } + } } -} - ``` + + + + diff --git a/.docfx/api/types/Cuemon.DisposableOptions.md b/.docfx/api/types/Cuemon.DisposableOptions.md index cb0105000..04dcb7f2b 100644 --- a/.docfx/api/types/Cuemon.DisposableOptions.md +++ b/.docfx/api/types/Cuemon.DisposableOptions.md @@ -7,45 +7,54 @@ example: The following example demonstrates how to use to control whether a disposable resource is released when the owning wrapper is disposed. ```csharp +// Program.cs using System; using Cuemon; +using Contoso.IO; -namespace Contoso.IO; +DisposableOptionsExample.Run(); -public sealed class DisposableOptionsExample +namespace Contoso.IO { - public static void Run() + public sealed class DisposableOptionsExample { - var resource = new TrackedDisposable(); - var options = new DisposableOptions + public static void Run() { - LeaveOpen = true - }; - - DisposeWhenAllowed(resource, options); - Console.WriteLine($"Disposed after leave-open: {resource.IsDisposed}"); - - options.LeaveOpen = false; - DisposeWhenAllowed(resource, options); - Console.WriteLine($"Disposed after close: {resource.IsDisposed}"); - } + var resource = new TrackedDisposable(); + var options = new DisposableOptions + { + LeaveOpen = true + }; + + DisposeWhenAllowed(resource, options); + Console.WriteLine($"Disposed after leave-open: {resource.IsDisposed}"); + + options.LeaveOpen = false; + DisposeWhenAllowed(resource, options); + Console.WriteLine($"Disposed after close: {resource.IsDisposed}"); + } - private static void DisposeWhenAllowed(TrackedDisposable resource, DisposableOptions options) - { - if (!options.LeaveOpen) + private static void DisposeWhenAllowed(TrackedDisposable resource, DisposableOptions options) { - resource.Dispose(); + if (!options.LeaveOpen) + { + resource.Dispose(); + } } - } - - private sealed class TrackedDisposable : IDisposable - { - public bool IsDisposed { get; private set; } - public void Dispose() + private sealed class TrackedDisposable : IDisposable { - IsDisposed = true; + public bool IsDisposed { get; private set; } + + public void Dispose() + { + IsDisposed = true; + } } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.DoubleDecoratorExtensions.md b/.docfx/api/types/Cuemon.DoubleDecoratorExtensions.md index 08de594f0..308ecbd9a 100644 --- a/.docfx/api/types/Cuemon.DoubleDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.DoubleDecoratorExtensions.md @@ -7,36 +7,31 @@ example: `DoubleDecoratorExtensions` provides extension methods on `Decorator.Enclose` for converting `double` values into `TimeSpan` instances using the `ToTimeSpan` method with a specified `TimeUnit`. This example creates four `double` values representing 1.5 days, 90 minutes, 5000 milliseconds, and 2.5 hours, each wrapped with `Decorator.Enclose` and passed to `ToTimeSpan` with the matching time unit. Key setup includes choosing the correct `TimeUnit` enum value for each conversion. Console output shows `1.12:00:00` for 1.5 days, `01:30:00` for 90 minutes, `00:00:05` for 5000 milliseconds, and `02:30:00` for 2.5 hours. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.Numeric -{ - public class DoubleDecoratorExtensionsExample - { - public void Demonstrate() - { - // Convert 1.5 days to a TimeSpan - double days = 1.5; - TimeSpan duration = Decorator.Enclose(days).ToTimeSpan(TimeUnit.Days); - Console.WriteLine(duration); // Output: 1.12:00:00 - - // Convert 90 minutes to a TimeSpan - double minutes = 90; - TimeSpan meeting = Decorator.Enclose(minutes).ToTimeSpan(TimeUnit.Minutes); - Console.WriteLine(meeting); // Output: 01:30:00 - - // Convert 5000 milliseconds to a TimeSpan - double ms = 5000; - TimeSpan interval = Decorator.Enclose(ms).ToTimeSpan(TimeUnit.Milliseconds); - Console.WriteLine(interval); // Output: 00:00:05 - - // Convert 2.5 hours to a TimeSpan - double hours = 2.5; - TimeSpan task = Decorator.Enclose(hours).ToTimeSpan(TimeUnit.Hours); - Console.WriteLine(task); // Output: 02:30:00 - -}} -} - +// Convert 1.5 days to a TimeSpan +double days = 1.5; +TimeSpan duration = Decorator.Enclose(days).ToTimeSpan(TimeUnit.Days); +Console.WriteLine(duration); // Output: 1.12:00:00 + +// Convert 90 minutes to a TimeSpan +double minutes = 90; +TimeSpan meeting = Decorator.Enclose(minutes).ToTimeSpan(TimeUnit.Minutes); +Console.WriteLine(meeting); // Output: 01:30:00 + +// Convert 5000 milliseconds to a TimeSpan +double ms = 5000; +TimeSpan interval = Decorator.Enclose(ms).ToTimeSpan(TimeUnit.Milliseconds); +Console.WriteLine(interval); // Output: 00:00:05 + +// Convert 2.5 hours to a TimeSpan +double hours = 2.5; +TimeSpan task = Decorator.Enclose(hours).ToTimeSpan(TimeUnit.Hours); +Console.WriteLine(task); // Output: 02:30:00 ``` + + + + diff --git a/.docfx/api/types/Cuemon.EndianOptions.md b/.docfx/api/types/Cuemon.EndianOptions.md index fc81fbc0c..88b146038 100644 --- a/.docfx/api/types/Cuemon.EndianOptions.md +++ b/.docfx/api/types/Cuemon.EndianOptions.md @@ -7,27 +7,22 @@ example: The following example demonstrates how to configure `EndianOptions` to explicitly set the byte order for binary data operations. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.Examples; - -public class EndianOptionsExample +var options = new EndianOptions { - public void Demonstrate() - { - var options = new EndianOptions - { - ByteOrder = Endianness.BigEndian - }; - - var byteOrder = options.ByteOrder; - var isSystemLittleEndian = BitConverter.IsLittleEndian; + ByteOrder = Endianness.BigEndian +}; - Console.WriteLine($"Configured byte order: {byteOrder}"); - Console.WriteLine($"System is little-endian: {isSystemLittleEndian}"); - -} -} +var byteOrder = options.ByteOrder; +var isSystemLittleEndian = BitConverter.IsLittleEndian; +Console.WriteLine($"Configured byte order: {byteOrder}"); +Console.WriteLine($"System is little-endian: {isSystemLittleEndian}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Endianness.md b/.docfx/api/types/Cuemon.Endianness.md index 275517362..61c235223 100644 --- a/.docfx/api/types/Cuemon.Endianness.md +++ b/.docfx/api/types/Cuemon.Endianness.md @@ -7,24 +7,19 @@ example: The following example demonstrates how to use `Endianness` to specify byte order when configuring `EndianOptions`. ```csharp +// Program.cs using Cuemon; using System; -namespace MyApp.Examples; - -public class EndiannessExample +var options = new EndianOptions { - public void Demonstrate() - { - var options = new EndianOptions - { - ByteOrder = Endianness.BigEndian - }; - - Console.WriteLine(options.ByteOrder == Endianness.BigEndian); - // outputs: True - -} -} + ByteOrder = Endianness.BigEndian +}; +Console.WriteLine(options.ByteOrder == Endianness.BigEndian); +// outputs: True ``` + + + + diff --git a/.docfx/api/types/Cuemon.Eradicate.md b/.docfx/api/types/Cuemon.Eradicate.md index 076e8aa36..aea0b1f1c 100644 --- a/.docfx/api/types/Cuemon.Eradicate.md +++ b/.docfx/api/types/Cuemon.Eradicate.md @@ -7,24 +7,22 @@ example: The following example demonstrates how to use `Eradicate` to clean up byte arrays by removing trailing zero bytes or specific trailing byte sequences. ```csharp +// Program.cs using System; using System.Text; +using Cuemon; -namespace Cuemon; +// Remove trailing zero bytes from a byte array +byte[] dataWithZeros = { 1, 2, 3, 0, 0, 0 }; +byte[] cleaned = Eradicate.TrailingZeros(dataWithZeros); +Console.WriteLine(BitConverter.ToString(cleaned)); // 01-02-03 -public class EradicateExample -{ - public void Demonstrate() - { - // Remove trailing zero bytes from a byte array - byte[] dataWithZeros = { 1, 2, 3, 0, 0, 0 }; - byte[] cleaned = Eradicate.TrailingZeros(dataWithZeros); - Console.WriteLine(BitConverter.ToString(cleaned)); // 01-02-03 - - // Remove specific trailing byte sequence (e.g., CR/LF) - byte[] dataWithCrLf = { 72, 101, 108, 108, 111, 13, 10, 13, 10 }; - byte[] stripped = Eradicate.TrailingBytes(dataWithCrLf, new byte[] { 13, 10 }); - Console.WriteLine(Encoding.UTF8.GetString(stripped)); // Hello - } -} +// Remove specific trailing byte sequence (e.g., CR/LF) +byte[] dataWithCrLf = { 72, 101, 108, 108, 111, 13, 10, 13, 10 }; +byte[] stripped = Eradicate.TrailingBytes(dataWithCrLf, new byte[] { 13, 10 }); +Console.WriteLine(Encoding.UTF8.GetString(stripped)); // Hello ``` + + + + diff --git a/.docfx/api/types/Cuemon.ExceptionCondition`1.md b/.docfx/api/types/Cuemon.ExceptionCondition`1.md index ff4f3d66d..3cc4a85ff 100644 --- a/.docfx/api/types/Cuemon.ExceptionCondition`1.md +++ b/.docfx/api/types/Cuemon.ExceptionCondition`1.md @@ -4,50 +4,79 @@ example: - *content --- -The following example demonstrates how to use to fluently define a condition under which a specific exception should be thrown. +The following example demonstrates how to use to fluently define a condition under which a specific exception should be thrown. The sample builds conditions for both true and false outcomes, calls TryThrow, and prints the exception messages so the resulting control flow is visible. ```csharp +// Program.cs using System; -using Cuemon; // for ExceptionCondition +using Cuemon; +using MyApp.Examples; -namespace MyApp.Examples; +new ExceptionConditionExample().Demonstrate(); -public class ExceptionConditionExample +namespace MyApp.Examples { - public void Demonstrate() + public class ExceptionConditionExample { - // Throw InvalidOperationException only when a condition is true - var invoker = new ExceptionCondition() - .IsTrue(() => DateTime.Now.DayOfWeek == DayOfWeek.Monday) - .Create(() => new InvalidOperationException("Cannot run this operation on Mondays.")); + public void Demonstrate() + { + // Throw InvalidOperationException only when a condition is true + var invoker = new ExceptionCondition() + .IsTrue(() => DateTime.Now.DayOfWeek == DayOfWeek.Monday) + .Create(() => new InvalidOperationException("Cannot run this operation on Mondays.")); - // If today is Monday, TryThrow will throw InvalidOperationException - // If today is not Monday, TryThrow does nothing - invoker.TryThrow(); + // If today is Monday, TryThrow will throw InvalidOperationException + // If today is not Monday, TryThrow does nothing + try + { + invoker.TryThrow(); + } + catch (InvalidOperationException ex) + { + Console.WriteLine(ex.Message); + } - // Throw ArgumentException only when a condition is false - var falseInvoker = new ExceptionCondition() - .IsFalse(() => Environment.UserName == "admin") - .Create(() => new ArgumentException("Only admin can call this method.")); + // Throw ArgumentException only when a condition is false + var falseInvoker = new ExceptionCondition() + .IsFalse(() => Environment.UserName == "admin") + .Create(() => new ArgumentException("Only admin can call this method.")); - falseInvoker.TryThrow(); + try + { + falseInvoker.TryThrow(); + } + catch (ArgumentException ex) + { + Console.WriteLine(ex.Message); + } - // Use the TesterFunc overload to pass data to the exception - TesterFunc tryGetValue = (out string value) => - { - value = "cached-data"; - return true; // data exists - }; + // Use the TesterFunc overload to pass data to the exception + TesterFunc tryGetValue = (out string value) => + { + value = "cached-data"; + return true; // data exists + }; - var dataInvoker = new ExceptionCondition() - .IsTrue(tryGetValue) - .Create(data => new InvalidOperationException( - $"Value '{data}' has expired. Please refresh.")); + var dataInvoker = new ExceptionCondition() + .IsTrue(tryGetValue) + .Create(data => new InvalidOperationException( + $"Value '{data}' has expired. Please refresh.")); - // Since condition returns true, this throws - dataInvoker.TryThrow(); + // Since condition returns true, this throws + try + { + dataInvoker.TryThrow(); + } + catch (InvalidOperationException ex) + { + Console.WriteLine(ex.Message); + } + } + } } -} - ``` + + + + diff --git a/.docfx/api/types/Cuemon.ExceptionDecoratorExtensions.md b/.docfx/api/types/Cuemon.ExceptionDecoratorExtensions.md index 2c8800293..5263e600b 100644 --- a/.docfx/api/types/Cuemon.ExceptionDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.ExceptionDecoratorExtensions.md @@ -7,30 +7,27 @@ example: `ExceptionDecoratorExtensions` provides extension methods on `Decorator.Enclose` for flattening deeply nested exception hierarchies into a flat sequence via the `Flatten` method. This example creates a three-level exception chain (`InvalidOperationException` → `ArgumentException` → `TimeoutException`) and an `AggregateException` containing two root-level exceptions. Key steps include wrapping each exception with `Decorator.Enclose`, calling `Flatten()`, and materializing the result with `ToList()`. Console output shows the flattened chain order (`InvalidOperationException -> ArgumentException -> TimeoutException`) and the aggregate exception count, confirming the full hierarchy is unwound without losing any exceptions. ```csharp +// Program.cs using System; using System.Linq; using Cuemon; -namespace Contoso.Diagnostics; +Exception nested = new InvalidOperationException( + "Request failed.", + new ArgumentException("Endpoint is invalid.", new TimeoutException("The call timed out."))); -public sealed class ExceptionDecoratorExtensionsExample -{ - public static void Run() - { - Exception nested = new InvalidOperationException( - "Request failed.", - new ArgumentException("Endpoint is invalid.", new TimeoutException("The call timed out."))); +var flattened = Decorator.Enclose(nested).Flatten().ToList(); - var flattened = Decorator.Enclose(nested).Flatten().ToList(); +Exception aggregate = new AggregateException( + new InvalidOperationException("Retry later."), + new TimeoutException("The call timed out.")); - Exception aggregate = new AggregateException( - new InvalidOperationException("Retry later."), - new TimeoutException("The call timed out.")); +var aggregateInner = Decorator.Enclose(aggregate).Flatten().ToList(); - var aggregateInner = Decorator.Enclose(aggregate).Flatten().ToList(); - - Console.WriteLine($"Nested chain: {string.Join(" -> ", flattened.Select(ex => ex.GetType().Name))}"); - Console.WriteLine($"Aggregate count: {aggregateInner.Count}"); - } -} +Console.WriteLine($"Nested chain: {string.Join(" -> ", flattened.Select(ex => ex.GetType().Name))}"); +Console.WriteLine($"Aggregate count: {aggregateInner.Count}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.ExceptionHandler`1.md b/.docfx/api/types/Cuemon.ExceptionHandler`1.md index f17b7eb04..c6cc6d4ae 100644 --- a/.docfx/api/types/Cuemon.ExceptionHandler`1.md +++ b/.docfx/api/types/Cuemon.ExceptionHandler`1.md @@ -7,36 +7,35 @@ example: The following example demonstrates how to use as the intermediate step in the fluent exception-triggering chain. ```csharp +// Program.cs using System; -using Cuemon; // for ExceptionCondition, ExceptionHandler, ExceptionInvoker +using Cuemon; -namespace MyApp.Examples; +// Build the chain: Condition -> Handler -> Invoker +ExceptionInvoker invoker = new ExceptionCondition() + .IsTrue(() => string.IsNullOrEmpty(Environment.GetEnvironmentVariable("API_KEY"))) + .Create(() => new ArgumentException("API_KEY environment variable is not set.")); -public class ExceptionHandlerExample +// When TryThrow is called, it evaluates the condition +// and throws the exception created by the handler if the condition matches +try { - public void Demonstrate() - { - // Build the chain: Condition -> Handler -> Invoker - ExceptionInvoker invoker = new ExceptionCondition() - .IsTrue(() => string.IsNullOrEmpty(Environment.GetEnvironmentVariable("API_KEY"))) - .Create(() => new ArgumentException("API_KEY environment variable is not set.")); - - // When TryThrow is called, it evaluates the condition - // and throws the exception created by the handler if the condition matches - invoker.TryThrow(); - - // The handler can be stored and reused to create different invokers - ExceptionHandler handler = - new ExceptionCondition().IsTrue(() => true); - - // Create different invokers from the same handler - var invokerA = handler.Create(() => new InvalidOperationException("Reason A")); - var invokerB = handler.Create(() => new InvalidOperationException("Reason B")); - - // invokerA.TryThrow(); // throws "Reason A" - // invokerB.TryThrow(); // throws "Reason B" - + invoker.TryThrow(); } +catch (ArgumentException ex) +{ + Console.WriteLine(ex.Message); } +// The handler can be stored and reused to create different invokers +ExceptionHandler handler = + new ExceptionCondition().IsTrue(() => true); + +// Create different invokers from the same handler +var invokerA = handler.Create(() => new InvalidOperationException("Reason A")); +var invokerB = handler.Create(() => new InvalidOperationException("Reason B")); ``` + + + + diff --git a/.docfx/api/types/Cuemon.ExceptionHandler`2.md b/.docfx/api/types/Cuemon.ExceptionHandler`2.md index cdcbbdd90..0b690cd41 100644 --- a/.docfx/api/types/Cuemon.ExceptionHandler`2.md +++ b/.docfx/api/types/Cuemon.ExceptionHandler`2.md @@ -7,31 +7,28 @@ example: The following example demonstrates how to use the generic class in the fluent exception-triggering chain with an out-value (tester) condition. ```csharp +// Program.cs using System; using Cuemon; -namespace Cuemon.DocfxExamples; +TesterFunc parsePort = (out int value) => int.TryParse("70000", out value); -public sealed class ExceptionHandlerOfTResultExample -{ - public static void Run() - { - TesterFunc parsePort = (out int value) => int.TryParse("70000", out value); - - ExceptionHandler handler = - new ExceptionCondition().IsTrue(parsePort); +ExceptionHandler handler = + new ExceptionCondition().IsTrue(parsePort); - var invoker = handler.Create(port => - new ArgumentOutOfRangeException(nameof(port), port, "Ports must be between 0 and 65535.")); +var invoker = handler.Create(port => + new ArgumentOutOfRangeException(nameof(port), port, "Ports must be between 0 and 65535.")); - try - { - invoker.TryThrow(); - } - catch (ArgumentOutOfRangeException ex) - { - Console.WriteLine($"Rejected port: {ex.ActualValue}"); - } - } +try +{ + invoker.TryThrow(); +} +catch (ArgumentOutOfRangeException ex) +{ + Console.WriteLine($"Rejected port: {ex.ActualValue}"); } ``` + + + + diff --git a/.docfx/api/types/Cuemon.ExceptionInsights.md b/.docfx/api/types/Cuemon.ExceptionInsights.md index ad7d466e9..c2ce6f704 100644 --- a/.docfx/api/types/Cuemon.ExceptionInsights.md +++ b/.docfx/api/types/Cuemon.ExceptionInsights.md @@ -7,31 +7,29 @@ example: The following example shows how to enrich an exception with thread and environment information using `ExceptionInsights.Embed`. It catches an exception, embeds runtime parameters and system snapshots, then checks for the embedded insight data in the exception's Data dictionary. ```csharp +// Program.cs using System; using System.Reflection; +using Cuemon; -namespace Cuemon; - -public class ExceptionInsightsExample +try +{ + throw new InvalidOperationException("Something went wrong."); +} +catch (InvalidOperationException ex) { - public void Demonstrate() - { - try - { - throw new InvalidOperationException("Something went wrong."); - } - catch (InvalidOperationException ex) - { - // Enrich the exception with thread and environment information - ExceptionInsights.Embed(ex, - runtimeParameters: new object[] { "param1", 42 }, - snapshots: SystemSnapshots.CaptureThreadInfo | SystemSnapshots.CaptureEnvironmentInfo); + // Enrich the exception with thread and environment information + ExceptionInsights.Embed(ex, + runtimeParameters: new object[] { "param1", 42 }, + snapshots: SystemSnapshots.CaptureThreadInfo | SystemSnapshots.CaptureEnvironmentInfo); - // The enriched exception now has embedded insight data in its Data dictionary - Console.WriteLine(ex.Data.Contains(ExceptionInsights.Key) - ? "Insights embedded successfully." - : "No insights available."); - } - } + // The enriched exception now has embedded insight data in its Data dictionary + Console.WriteLine(ex.Data.Contains(ExceptionInsights.Key) + ? "Insights embedded successfully." + : "No insights available."); } ``` + + + + diff --git a/.docfx/api/types/Cuemon.ExceptionInvoker`1.md b/.docfx/api/types/Cuemon.ExceptionInvoker`1.md index 66d51f3e9..87d7ca43b 100644 --- a/.docfx/api/types/Cuemon.ExceptionInvoker`1.md +++ b/.docfx/api/types/Cuemon.ExceptionInvoker`1.md @@ -7,36 +7,33 @@ example: The following example demonstrates the shared workflow for the family: evaluate a business condition, build the invoker from that condition, and call TryThrow() when the invalid state should surface as an exception. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon; -namespace MyApp.Examples; +var settings = new Dictionary(StringComparer.OrdinalIgnoreCase); -public static class ExceptionInvokerExample +ExceptionInvoker invoker = + new ExceptionCondition() + .IsTrue(() => !settings.ContainsKey("ConnectionString")) + .Create(() => new InvalidOperationException("A ConnectionString setting is required before the data pipeline can start.")); + +bool threw = false; + +try +{ + invoker.TryThrow(); +} +catch (InvalidOperationException ex) { - public static void Demonstrate() - { - var settings = new Dictionary(StringComparer.OrdinalIgnoreCase); - - ExceptionInvoker invoker = - new ExceptionCondition() - .IsTrue(() => !settings.ContainsKey("ConnectionString")) - .Create(() => new InvalidOperationException("A ConnectionString setting is required before the data pipeline can start.")); - - bool threw = false; - - try - { - invoker.TryThrow(); - } - catch (InvalidOperationException ex) - { - threw = true; - Console.WriteLine(ex.Message); - } - - Console.WriteLine($"Threw: {threw}"); - } + threw = true; + Console.WriteLine(ex.Message); } + +Console.WriteLine($"Threw: {threw}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.ExceptionInvoker`2.md b/.docfx/api/types/Cuemon.ExceptionInvoker`2.md index cb025da75..02dd42d60 100644 --- a/.docfx/api/types/Cuemon.ExceptionInvoker`2.md +++ b/.docfx/api/types/Cuemon.ExceptionInvoker`2.md @@ -7,50 +7,60 @@ example: The following example demonstrates how to use the generic class to conditionally throw an exception using a tester function with an out value. ```csharp +// Program.cs using System; using Cuemon; +using MyApp.Examples; -namespace MyApp.Examples; +new ExceptionInvokerOfT2Example().Demonstrate(); -public class ExceptionInvokerOfT2Example +namespace MyApp.Examples { - public void Demonstrate() + public class ExceptionInvokerOfT2Example { - // Create a tester that extracts a value from a configuration string - // TesterFunc is: bool (out int result) - TesterFunc tryGetPort = (out int port) => + public void Demonstrate() { - string configValue = Environment.GetEnvironmentVariable("APP_PORT") ?? "8080"; - return int.TryParse(configValue, out port); - }; - - // Build the full fluent chain - // The Create method returns an ExceptionInvoker - ExceptionInvoker invoker = new ExceptionCondition() - .IsFalse(tryGetPort) - .Create(port => new InvalidOperationException( - $"Invalid port number ({port}) configured in APP_PORT environment variable.")); - - // TryThrow evaluates tryGetPort; if it returns false (matching IsFalse), - // the exception is thrown with the out value (0) passed to the handler. - // If the environment variable is valid, no exception is thrown. - invoker.TryThrow(); - - // You can also create multiple invokers from tester conditions - TesterFunc tryGetName = (out string name) => - { - name = Environment.GetEnvironmentVariable("APP_NAME") ?? "MyApp"; - return !string.IsNullOrEmpty(name); - }; + // Create a tester that extracts a value from a configuration string + // TesterFunc is: bool (out int result) + TesterFunc tryGetPort = (out int port) => + { + string configValue = Environment.GetEnvironmentVariable("APP_PORT") ?? "8080"; + return int.TryParse(configValue, out port); + }; - var nameInvoker = new ExceptionCondition() - .IsFalse(tryGetName) - .Create(name => new ArgumentNullException(nameof(name), - $"APP_NAME resolved to '{name}' which is not a valid application name.")); + // Build the full fluent chain + // The Create method returns an ExceptionInvoker + ExceptionInvoker invoker = new ExceptionCondition() + .IsFalse(tryGetPort) + .Create(port => new InvalidOperationException( + $"Invalid port number ({port}) configured in APP_PORT environment variable.")); - nameInvoker.TryThrow(); + // TryThrow evaluates tryGetPort; if it returns false (matching IsFalse), + // the exception is thrown with the out value (0) passed to the handler. + // If the environment variable is valid, no exception is thrown. + invoker.TryThrow(); + Console.WriteLine("APP_PORT validation passed."); -} -} + // You can also create multiple invokers from tester conditions + TesterFunc tryGetName = (out string name) => + { + name = Environment.GetEnvironmentVariable("APP_NAME") ?? "MyApp"; + return !string.IsNullOrEmpty(name); + }; + + var nameInvoker = new ExceptionCondition() + .IsFalse(tryGetName) + .Create(name => new ArgumentNullException(nameof(name), + $"APP_NAME resolved to '{name}' which is not a valid application name.")); + nameInvoker.TryThrow(); + Console.WriteLine("APP_NAME validation passed."); + + } + } +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.ActionExtensions.md b/.docfx/api/types/Cuemon.Extensions.ActionExtensions.md index ee22d06dc..60861ab75 100644 --- a/.docfx/api/types/Cuemon.Extensions.ActionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.ActionExtensions.md @@ -7,45 +7,53 @@ example: The following example demonstrates applying the options pattern and factory initialization using the [Configure](https://docs.cuemon.net/api/extensions/dotnet/Cuemon.Extensions.ActionExtensions.html#Cuemon_Extensions_ActionExtensions_Configure__1_System_Action___0__) and [CreateInstance](https://docs.cuemon.net/api/extensions/dotnet/Cuemon.Extensions.ActionExtensions.html#Cuemon_Extensions_ActionExtensions_CreateInstance__1_System_Action___0__) extension methods. ```csharp +// Program.cs using System; using Cuemon.Configuration; using Cuemon.Extensions; +using MyApp.Examples; -namespace MyApp.Examples; +ActionExtensionsExample.Demonstrate(); -public static class ActionExtensionsExample +namespace MyApp.Examples { - private sealed class MyOptions : IParameterObject + public static class ActionExtensionsExample { - public string Delimiter { get; set; } = ","; - - public string Qualifier { get; set; } = "\""; - } - - private sealed class MyService - { - public string ConnectionString { get; set; } = string.Empty; + private sealed class MyOptions : IParameterObject + { + public string Delimiter { get; set; } = ","; - public int Timeout { get; set; } = 30; - } + public string Qualifier { get; set; } = "\""; + } - public static void Demonstrate() - { - var options = new Action(setup => + private sealed class MyService { - setup.Delimiter = ";"; - setup.Qualifier = "'"; - }).Configure(); + public string ConnectionString { get; set; } = string.Empty; - var service = new Action(factory => - { - factory.ConnectionString = "Server=(localdb)\\MSSQLLocalDB;Database=Docs"; - factory.Timeout = 60; - }).CreateInstance(); + public int Timeout { get; set; } = 30; + } - Console.WriteLine($"{options.Delimiter} {options.Qualifier}"); - Console.WriteLine($"{service.ConnectionString} ({service.Timeout}s)"); + public static void Demonstrate() + { + var options = new Action(setup => + { + setup.Delimiter = ";"; + setup.Qualifier = "'"; + }).Configure(); + + var service = new Action(factory => + { + factory.ConnectionString = "Server=(localdb)\\MSSQLLocalDB;Database=Docs"; + factory.Timeout = 60; + }).CreateInstance(); + + Console.WriteLine($"{options.Delimiter} {options.Qualifier}"); + Console.WriteLine($"{service.ConnectionString} ({service.Timeout}s)"); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.ActionFactory.md b/.docfx/api/types/Cuemon.Extensions.ActionFactory.md index 2a0ba2622..7314044b6 100644 --- a/.docfx/api/types/Cuemon.Extensions.ActionFactory.md +++ b/.docfx/api/types/Cuemon.Extensions.ActionFactory.md @@ -7,26 +7,23 @@ example: The following example demonstrates how to create an `ActionFactory` from a callback with arguments and execute it. It shows both creating a factory with `Create` and invoking directly with `Invoke`. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Extensions; -namespace Cuemon.Extensions; - -public class ActionFactoryExample +Action callback = (name, count) => { - public void Demonstrate() - { - Action callback = (name, count) => - { - for (int i = 0; i < count; i++) - Console.WriteLine(name); - }; + for (int i = 0; i < count; i++) + Console.WriteLine(name); +}; - var factory = ActionFactory.Create(callback, "Loop", 3); - factory.ExecuteMethod(); +var factory = ActionFactory.Create(callback, "Loop", 3); +factory.ExecuteMethod(); - ActionFactory.Invoke(tuple => Console.WriteLine(tuple.Arg1), MutableTupleFactory.CreateOne("Direct invoke")); - } -} +ActionFactory.Invoke(tuple => Console.WriteLine(tuple.Arg1), MutableTupleFactory.CreateOne("Direct invoke")); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.ApplicationBuilderExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.ApplicationBuilderExtensions.md index eea3d52aa..b76c3b95e 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.ApplicationBuilderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.ApplicationBuilderExtensions.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to register the Basic, Digest, and HMAC authentication middleware in an ASP.NET Core request pipeline. Each extension configures a different credential scheme and returns the same application builder so additional middleware can be appended. The final checks make that fluent-pipeline contract visible without depending on an implementation type name. ```csharp +// Program.cs using System; using System.Security.Claims; using Cuemon.Extensions.AspNetCore.Authentication; @@ -14,64 +15,59 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; -namespace MyApp.Examples; +var services = new ServiceCollection(); -public static class ApplicationBuilderExtensionsExample -{ - public static void Demonstrate() - { - var services = new ServiceCollection(); +services.AddLogging(); +services.AddInMemoryDigestAuthenticationNonceTracker(); +services.AddAuthentication("docs") + .AddScheme(Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeader.Scheme, _ => { }) + .AddScheme(Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeader.Scheme, _ => { }) + .AddScheme("hmac-docs", _ => { }); - services.AddLogging(); - services.AddInMemoryDigestAuthenticationNonceTracker(); - services.AddAuthentication("docs") - .AddScheme(Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeader.Scheme, _ => { }) - .AddScheme(Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeader.Scheme, _ => { }) - .AddScheme("hmac-docs", _ => { }); +var app = new ApplicationBuilder(services.BuildServiceProvider()); - var app = new ApplicationBuilder(services.BuildServiceProvider()); - - var basicBuilder = app.UseBasicAuthentication(options => +var basicBuilder = app.UseBasicAuthentication(options => +{ + options.Realm = "SecureArea"; + options.Authenticator = (username, password) => + { + if (username == "admin" && password == "secret") { - options.Realm = "SecureArea"; - options.Authenticator = (username, password) => - { - if (username == "admin" && password == "secret") - { - return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, "Basic")); - } - - return null; - }; - options.RequireSecureConnection = false; - }); + return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, "Basic")); + } - var digestBuilder = app.UseDigestAccessAuthentication(options => - { - options.Realm = "SecureArea"; - options.Authenticator = (string username, out string password) => - { - password = "storedPassword"; - return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, "Digest")); - }; - options.RequireSecureConnection = false; - }); + return null; + }; + options.RequireSecureConnection = false; +}); - var hmacBuilder = app.UseHmacAuthentication(options => - { - options.AuthenticationScheme = "MyHmac"; - options.Authenticator = (string clientId, out string clientSecret) => - { - clientSecret = "storedSecret"; - return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, clientId) }, "Hmac")); - }; - options.RequireSecureConnection = false; - }); +var digestBuilder = app.UseDigestAccessAuthentication(options => +{ + options.Realm = "SecureArea"; + options.Authenticator = (string username, out string password) => + { + password = "storedPassword"; + return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, "Digest")); + }; + options.RequireSecureConnection = false; +}); - Console.WriteLine($"Basic middleware returned the application builder: {ReferenceEquals(app, basicBuilder)}"); - Console.WriteLine($"Digest middleware returned the application builder: {ReferenceEquals(app, digestBuilder)}"); - Console.WriteLine($"HMAC middleware returned the application builder: {ReferenceEquals(app, hmacBuilder)}"); - } -} +var hmacBuilder = app.UseHmacAuthentication(options => +{ + options.AuthenticationScheme = "MyHmac"; + options.Authenticator = (string clientId, out string clientSecret) => + { + clientSecret = "storedSecret"; + return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, clientId) }, "Hmac")); + }; + options.RequireSecureConnection = false; +}); +Console.WriteLine($"Basic middleware returned the application builder: {ReferenceEquals(app, basicBuilder)}"); +Console.WriteLine($"Digest middleware returned the application builder: {ReferenceEquals(app, digestBuilder)}"); +Console.WriteLine($"HMAC middleware returned the application builder: {ReferenceEquals(app, hmacBuilder)}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.AuthenticationBuilderExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.AuthenticationBuilderExtensions.md index f1fc412ae..1ddef459f 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.AuthenticationBuilderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.AuthenticationBuilderExtensions.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to register the Basic, Digest, and HMAC authentication handlers through the extension methods on . It resolves each configured handler after building the service provider and prints the scheme-specific options that the authentication middleware will use. ```csharp +// Program.cs using System; using System.Security.Claims; using Cuemon.AspNetCore.Authentication.Basic; @@ -14,53 +15,61 @@ using Cuemon.AspNetCore.Authentication.Digest; using Cuemon.AspNetCore.Authentication.Hmac; using Cuemon.Extensions.AspNetCore.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using MyApp.Examples; -namespace MyApp.Examples; +AuthenticationBuilderExtensionsExample.Demonstrate(); -public static class AuthenticationBuilderExtensionsExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class AuthenticationBuilderExtensionsExample { - var services = new ServiceCollection(); + public static void Demonstrate() + { + var services = new ServiceCollection(); - services.AddLogging(); - services.AddInMemoryDigestAuthenticationNonceTracker(); - services.AddAuthentication(BasicAuthorizationHeader.Scheme) - .AddBasic(o => - { - o.Authenticator = (username, password) => new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, BasicAuthorizationHeader.Scheme)); - o.RequireSecureConnection = false; - }) - .AddDigestAccess(o => - { - o.Authenticator = (string username, out string password) => + services.AddLogging(); + services.AddInMemoryDigestAuthenticationNonceTracker(); + services.AddAuthentication(BasicAuthorizationHeader.Scheme) + .AddBasic(o => { - password = "Test"; - return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, DigestAuthorizationHeader.Scheme)); - }; - o.RequireSecureConnection = false; - }) - .AddHmac(o => - { - o.AuthenticationScheme = "hmac-docs"; - o.Authenticator = (string clientId, out string clientSecret) => + o.Authenticator = (username, password) => new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, BasicAuthorizationHeader.Scheme)); + o.RequireSecureConnection = false; + }) + .AddDigestAccess(o => { - clientSecret = "Test"; - return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, clientId) }, o.AuthenticationScheme)); - }; - o.RequireSecureConnection = false; - }); + o.Authenticator = (string username, out string password) => + { + password = "Test"; + return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, DigestAuthorizationHeader.Scheme)); + }; + o.RequireSecureConnection = false; + }) + .AddHmac(o => + { + o.AuthenticationScheme = "hmac-docs"; + o.Authenticator = (string clientId, out string clientSecret) => + { + clientSecret = "Test"; + return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, clientId) }, o.AuthenticationScheme)); + }; + o.RequireSecureConnection = false; + }); - using var provider = services.BuildServiceProvider(); + using var provider = services.BuildServiceProvider(); - var basicHandler = provider.GetRequiredService(); - var digestHandler = provider.GetRequiredService(); - var hmacHandler = provider.GetRequiredService(); + var basicOptions = provider.GetRequiredService>().Get(BasicAuthorizationHeader.Scheme); + var digestOptions = provider.GetRequiredService>().Get(DigestAuthorizationHeader.Scheme); + var hmacOptions = provider.GetRequiredService>().Get("hmac-docs"); - Console.WriteLine($"Basic authentication requires HTTPS: {basicHandler.Options.RequireSecureConnection}"); - Console.WriteLine($"Digest authentication requires HTTPS: {digestHandler.Options.RequireSecureConnection}"); - Console.WriteLine($"HMAC authentication scheme: {hmacHandler.Options.AuthenticationScheme}"); + Console.WriteLine($"Basic authentication requires HTTPS: {basicOptions.RequireSecureConnection}"); + Console.WriteLine($"Digest authentication requires HTTPS: {digestOptions.RequireSecureConnection}"); + Console.WriteLine($"HMAC authentication scheme: {hmacOptions.AuthenticationScheme}"); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.AuthorizationResponseHandler.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.AuthorizationResponseHandler.md index 8581d6df3..111a68486 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.AuthorizationResponseHandler.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.AuthorizationResponseHandler.md @@ -7,34 +7,30 @@ example: The following example demonstrates how to construct `AuthorizationResponseHandler` with configured options and the required logger dependency. It registers `AuthorizationResponseHandlerOptions` with `FaultSensitivityDetails.All`, adds logging services, and builds the service provider. The handler is then created from the resolved `ILogger` and `IOptions` instances, and its configured sensitivity is written to the console, confirming the dependency-injection wiring works correctly. ```csharp +// Program.cs using System; using Cuemon.Extensions.AspNetCore.Authentication; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -namespace MyApp.Examples; +var services = new ServiceCollection(); -public static class AuthorizationResponseHandlerExample +services.Configure(options => { - public static void Demonstrate() - { - var services = new ServiceCollection(); + options.SensitivityDetails = Cuemon.Diagnostics.FaultSensitivityDetails.All; +}); - services.Configure(options => - { - options.SensitivityDetails = Cuemon.Diagnostics.FaultSensitivityDetails.All; - }); +services.AddLogging(); - services.AddLogging(); - - using var provider = services.BuildServiceProvider(); - var logger = provider.GetRequiredService>(); - var options = provider.GetRequiredService>(); - var handler = new AuthorizationResponseHandler(logger, options); - - Console.WriteLine($"Configured fault sensitivity: {handler.Options.SensitivityDetails}"); - } -} +using var provider = services.BuildServiceProvider(); +var logger = provider.GetRequiredService>(); +var options = provider.GetRequiredService>(); +var handler = new AuthorizationResponseHandler(logger, options); +Console.WriteLine($"Configured fault sensitivity: {handler.Options.SensitivityDetails}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.AuthorizationResponseHandlerOptions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.AuthorizationResponseHandlerOptions.md index 8481e2bd5..72b25941f 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.AuthorizationResponseHandlerOptions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.AuthorizationResponseHandlerOptions.md @@ -7,21 +7,22 @@ example: The following example demonstrates how to configure `AuthorizationResponseHandlerOptions` to customize the behavior of the authorization response handler. ```csharp +// Program.cs +using System; using Cuemon.Diagnostics; using Cuemon.Extensions.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization.Policy; -namespace MyApp.Examples; - -public class AuthorizationResponseHandlerOptionsExample +var options = new AuthorizationResponseHandlerOptions { - public void Demonstrate() - { - var options = new AuthorizationResponseHandlerOptions - { - SensitivityDetails = FaultSensitivityDetails.All, - FallbackResponseHandler = new AuthorizationMiddlewareResultHandler() - }; - } -} + SensitivityDetails = FaultSensitivityDetails.All, + FallbackResponseHandler = new AuthorizationMiddlewareResultHandler() +}; + +Console.WriteLine(options.SensitivityDetails); +Console.WriteLine(options.FallbackResponseHandler != null); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.ServiceCollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.ServiceCollectionExtensions.md index fb6393e39..cdafca4c1 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.ServiceCollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Authentication.ServiceCollectionExtensions.md @@ -7,36 +7,33 @@ example: The following example demonstrates how to register the in-memory digest nonce tracker and the authorization response handler services. It inserts and reads a nonce to verify the tracker registration, then reports the configured fault-sensitivity option used by the authorization response handler. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Authentication; using Cuemon.Diagnostics; using Cuemon.Extensions.AspNetCore.Authentication; using Microsoft.Extensions.DependencyInjection; -namespace MyApp.Examples; +var services = new ServiceCollection(); -public static class ServiceCollectionExtensionsExample +services.AddLogging(); +services.AddInMemoryDigestAuthenticationNonceTracker(); +services.AddAuthorizationResponseHandler(o => { - public static void Demonstrate() - { - var services = new ServiceCollection(); + o.SensitivityDetails = FaultSensitivityDetails.All; +}); - services.AddInMemoryDigestAuthenticationNonceTracker(); - services.AddAuthorizationResponseHandler(o => - { - o.SensitivityDetails = FaultSensitivityDetails.All; - }); +using var provider = services.BuildServiceProvider(); - using var provider = services.BuildServiceProvider(); - - var tracker = provider.GetRequiredService(); - var added = tracker.TryAddEntry("docs-nonce", 1); - var found = tracker.TryGetEntry("docs-nonce", out var entry); - var responseHandler = provider.GetRequiredService(); - - Console.WriteLine($"Nonce added: {added}; found: {found}; count: {entry?.Count}"); - Console.WriteLine($"Configured fault sensitivity: {responseHandler.Options.SensitivityDetails}"); - } -} +var tracker = provider.GetRequiredService(); +var added = tracker.TryAddEntry("docs-nonce", 1); +var found = tracker.TryGetEntry("docs-nonce", out var entry); +var responseHandler = provider.GetRequiredService(); +Console.WriteLine($"Nonce added: {added}; found: {found}; count: {entry?.Count}"); +Console.WriteLine($"Configured fault sensitivity: {responseHandler.Options.SensitivityDetails}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Configuration.AssemblyCacheBusting.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Configuration.AssemblyCacheBusting.md index c08d25808..5def5a479 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Configuration.AssemblyCacheBusting.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Configuration.AssemblyCacheBusting.md @@ -7,29 +7,24 @@ example: The following example demonstrates how to create an `AssemblyCacheBusting` instance to provide cache-busting version strings derived from the entry assembly. ```csharp +// Program.cs using System; using Cuemon.Extensions.AspNetCore.Configuration; using Cuemon.Security.Cryptography; using Microsoft.Extensions.Options; -namespace MyApp.Examples; - -public class AssemblyCacheBustingExample +var options = Options.Create(new AssemblyCacheBustingOptions { - public void Demonstrate() - { - var options = Options.Create(new AssemblyCacheBustingOptions - { - Algorithm = UnkeyedCryptoAlgorithm.Sha256, - ReadByteForByteChecksum = true - }); - - var cacheBusting = new AssemblyCacheBusting(options); - string version = cacheBusting.Version; + Algorithm = UnkeyedCryptoAlgorithm.Sha256, + ReadByteForByteChecksum = true +}); - Console.WriteLine($"Cache-busting version: {version}"); - -} -} +var cacheBusting = new AssemblyCacheBusting(options); +string version = cacheBusting.Version; +Console.WriteLine($"Cache-busting version: {version}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Configuration.AssemblyCacheBustingOptions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Configuration.AssemblyCacheBustingOptions.md index 48757f6e6..54d8aaf60 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Configuration.AssemblyCacheBustingOptions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Configuration.AssemblyCacheBustingOptions.md @@ -7,29 +7,26 @@ example: The following example demonstrates how to configure `AssemblyCacheBustingOptions` for a reproducible cache-busting version that is derived from a known assembly and hash algorithm. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Extensions.AspNetCore.Configuration; using Cuemon.Security.Cryptography; using Microsoft.Extensions.Options; -namespace DocfxExamples; - -public class AssemblyCacheBustingOptionsExample +var options = Options.Create(new AssemblyCacheBustingOptions { - public static void Demonstrate() - { - var options = Options.Create(new AssemblyCacheBustingOptions - { - Assembly = typeof(AssemblyCacheBustingOptionsExample).Assembly, - Algorithm = UnkeyedCryptoAlgorithm.Sha256, - PreferredCasing = CasingMethod.UpperCase, - ReadByteForByteChecksum = true - }); + Assembly = typeof(AssemblyCacheBustingOptions).Assembly, + Algorithm = UnkeyedCryptoAlgorithm.Sha256, + PreferredCasing = CasingMethod.UpperCase, + ReadByteForByteChecksum = true +}); - var cacheBusting = new AssemblyCacheBusting(options); +var cacheBusting = new AssemblyCacheBusting(options); - Console.WriteLine(cacheBusting.Version); - } -} +Console.WriteLine(cacheBusting.Version); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Configuration.ServiceCollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Configuration.ServiceCollectionExtensions.md index df6c046fe..14c88316c 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Configuration.ServiceCollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Configuration.ServiceCollectionExtensions.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to register the built-in cache-busting services and a custom `ICacheBusting` implementation. ```csharp +// Program.cs using System; using System.Linq; using Cuemon.AspNetCore.Configuration; @@ -14,34 +15,31 @@ using Cuemon.Extensions.AspNetCore.Configuration; using Cuemon.Security.Cryptography; using Microsoft.Extensions.DependencyInjection; -namespace DocfxExamples; +var services = new ServiceCollection(); +services.AddOptions(); +services.Configure(options => +{ + options.Assembly = typeof(ReleaseCacheBusting).Assembly; + options.Algorithm = UnkeyedCryptoAlgorithm.Sha256; + options.ReadByteForByteChecksum = true; +}); + +services.AddAssemblyCacheBusting(); +services.AddDynamicCacheBusting(); +services.AddCacheBusting(); + +using var provider = services.BuildServiceProvider(); +var versions = provider.GetServices().Select(cache => cache.Version).ToList(); -public class ConfigurationServiceCollectionExtensionsExample +Console.WriteLine(versions.Count); +Console.WriteLine(string.Join(", ", versions)); + +public sealed class ReleaseCacheBusting : ICacheBusting { - public static void ConfigureServices(IServiceCollection services) - { - services.AddOptions(); - services.Configure(options => - { - options.Assembly = typeof(ConfigurationServiceCollectionExtensionsExample).Assembly; - options.Algorithm = UnkeyedCryptoAlgorithm.Sha256; - options.ReadByteForByteChecksum = true; - }); - - services.AddAssemblyCacheBusting(); - services.AddDynamicCacheBusting(); - services.AddCacheBusting(); - - var provider = services.BuildServiceProvider(); - var versions = provider.GetServices().Select(cache => cache.Version).ToList(); - - Console.WriteLine(versions.Count); - Console.WriteLine(string.Join(", ", versions)); - } - - private sealed class ReleaseCacheBusting : ICacheBusting - { - public string Version => "20260618"; - } + public string Version => "20260618"; } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Data.Integrity.CacheValidatorExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Data.Integrity.CacheValidatorExtensions.md index 7657c8409..c13d7c6a7 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Data.Integrity.CacheValidatorExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Data.Integrity.CacheValidatorExtensions.md @@ -7,28 +7,25 @@ example: The following example demonstrates how to turn assembly-backed cache validators into ETag headers for weak and strong validation scenarios. ```csharp +// Program.cs using System; using Cuemon.Data.Integrity; using Cuemon.Extensions.AspNetCore.Data.Integrity; using Microsoft.Net.Http.Headers; -namespace DocfxExamples; +CacheValidator weakValidator = CacheValidatorFactory.CreateValidator(typeof(CacheValidatorExtensions).Assembly); +EntityTagHeaderValue weakEntityTag = weakValidator.ToEntityTagHeaderValue(); -public class CacheValidatorExtensionsExample -{ - public static void Demonstrate() - { - CacheValidator weakValidator = CacheValidatorFactory.CreateValidator(typeof(CacheValidatorExtensionsExample).Assembly); - EntityTagHeaderValue weakEntityTag = weakValidator.ToEntityTagHeaderValue(); +CacheValidator strongValidator = CacheValidatorFactory.CreateValidator( + typeof(CacheValidatorExtensions).Assembly, + setup: options => options.BytesToRead = int.MaxValue); - CacheValidator strongValidator = CacheValidatorFactory.CreateValidator( - typeof(CacheValidatorExtensionsExample).Assembly, - setup: options => options.BytesToRead = int.MaxValue); +EntityTagHeaderValue strongEntityTag = strongValidator.ToEntityTagHeaderValue(); - EntityTagHeaderValue strongEntityTag = strongValidator.ToEntityTagHeaderValue(); - - Console.WriteLine(weakEntityTag); - Console.WriteLine(strongEntityTag); - } -} +Console.WriteLine(weakEntityTag); +Console.WriteLine(strongEntityTag); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Data.Integrity.ChecksumBuilderExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Data.Integrity.ChecksumBuilderExtensions.md index dba8db2ec..675a43f7f 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Data.Integrity.ChecksumBuilderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Data.Integrity.ChecksumBuilderExtensions.md @@ -7,22 +7,23 @@ example: The following example demonstrates how to create an `EntityTagHeaderValue` from a `ChecksumBuilder` instance. ```csharp +// Program.cs +using System; +using System.Text; using Cuemon.Data.Integrity; using Cuemon.Extensions.AspNetCore.Data.Integrity; -using Microsoft.Net.Http.Headers; +using Cuemon.Security; -namespace Examples; +var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); +builder.CombineWith(Encoding.UTF8.GetBytes("content-data")); -public class EntityTagExample -{ - public EntityTagHeaderValue CreateEntityTag(ChecksumBuilder builder) - { - return builder.ToEntityTagHeaderValue(); - } +var strongTag = builder.ToEntityTagHeaderValue(); +var weakTag = builder.ToEntityTagHeaderValue(isWeak: true); - public EntityTagHeaderValue CreateWeakEntityTag(ChecksumBuilder builder) - { - return builder.ToEntityTagHeaderValue(isWeak: true); - } -} +Console.WriteLine(strongTag.Tag.ToString()); +Console.WriteLine(weakTag.IsWeak); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Diagnostics.ApplicationBuilderExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Diagnostics.ApplicationBuilderExtensions.md index 09e3aff2a..608da5841 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Diagnostics.ApplicationBuilderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Diagnostics.ApplicationBuilderExtensions.md @@ -7,22 +7,26 @@ example: The following example demonstrates how to add diagnostics middleware to the ASP.NET Core pipeline using the class. ```csharp +// Program.cs +using System; +using Cuemon.AspNetCore.Diagnostics; using Cuemon.Extensions.AspNetCore.Diagnostics; using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; -namespace MyApp.Examples; +var services = new ServiceCollection(); +services.AddLogging(); +services.AddServerTiming(); +services.AddFaultDescriptorOptions(); +using var provider = services.BuildServiceProvider(); -public class ApplicationBuilderExtensionsExample -{ - public void Configure(IApplicationBuilder app) - { - // Add Server-Timing header middleware - app.UseServerTiming(); - - // Add fault descriptor exception handler (catches exceptions and returns structured error responses) - app.UseFaultDescriptorExceptionHandler(); - -} -} +var app = new ApplicationBuilder(provider); +app.UseServerTiming(); +app.UseFaultDescriptorExceptionHandler(); +Console.WriteLine("Server-Timing and fault descriptor middleware configured."); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Diagnostics.ServiceCollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Diagnostics.ServiceCollectionExtensions.md index 88b6bd701..3da161c2d 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Diagnostics.ServiceCollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Diagnostics.ServiceCollectionExtensions.md @@ -7,50 +7,51 @@ example: The following example demonstrates how to use the extension methods to configure diagnostics and fault handling in an ASP.NET Core application. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Diagnostics; using Cuemon.Diagnostics; using Cuemon.Extensions.AspNetCore.Diagnostics; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; -namespace MyAspNetCoreApp +var services = new ServiceCollection(); +services.AddServerTiming(options => { - public class Startup - { - public void ConfigureServices(IServiceCollection services) - { - // Add ServerTiming service for performance profiling - services.AddServerTiming(options => - { - options.TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(10); - }); - - // Configure FaultDescriptor options (exception handling) - services.AddFaultDescriptorOptions(options => - { - options.SensitivityDetails = FaultSensitivityDetails.All; - options.RootHelpLink = new Uri("https://example.com/help"); - }); - - // Configure ExceptionDescriptor options - services.AddExceptionDescriptorOptions(options => - { - options.SensitivityDetails = FaultSensitivityDetails.None; - }); - - // Configure ServerTiming options separately - services.AddServerTimingOptions(options => - { - options.TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(50); - }); - - // Post-configure all IExceptionDescriptorOptions instances - services.PostConfigureAllExceptionDescriptorOptions(options => - { - options.SensitivityDetails = FaultSensitivityDetails.FailureWithStackTrace; - }); - -}} -} + options.TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(10); +}); +services.AddFaultDescriptorOptions(options => +{ + options.SensitivityDetails = FaultSensitivityDetails.All; + options.RootHelpLink = new Uri("https://example.com/help"); +}); + +services.AddExceptionDescriptorOptions(options => +{ + options.SensitivityDetails = FaultSensitivityDetails.None; +}); + +services.AddServerTimingOptions(options => +{ + options.TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(50); +}); + +services.PostConfigureAllExceptionDescriptorOptions(options => +{ + options.SensitivityDetails = FaultSensitivityDetails.FailureWithStackTrace; +}); + +using var provider = services.BuildServiceProvider(); +var serverTiming = provider.GetRequiredService>().Value; +var fault = provider.GetRequiredService>().Value; +var exception = provider.GetRequiredService>().Value; + +Console.WriteLine(serverTiming.TimeMeasureCompletedThreshold.TotalMilliseconds); +Console.WriteLine(fault.SensitivityDetails); +Console.WriteLine(exception.SensitivityDetails); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Diagnostics.ServiceProviderExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Diagnostics.ServiceProviderExtensions.md index c97f9042e..f758327e2 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Diagnostics.ServiceProviderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Diagnostics.ServiceProviderExtensions.md @@ -4,24 +4,39 @@ example: - *content --- -The following example demonstrates how to retrieve all registered `IHttpExceptionDescriptorResponseFormatter` services from the service provider. +The following example demonstrates how to retrieve all registered `IHttpExceptionDescriptorResponseFormatter` services from the service provider. The sample registers a formatter in a ServiceCollection, resolves the exception response formatters from the provider, and prints the count and formatter option type. ```csharp +// Program.cs using System; using System.Collections.Generic; +using System.Linq; +using System.Net.Http.Headers; using Cuemon.AspNetCore.Diagnostics; +using Cuemon.Diagnostics; using Cuemon.Extensions.AspNetCore.Diagnostics; +using Cuemon.Net.Http; using Microsoft.Extensions.DependencyInjection; -namespace Examples; +var services = new ServiceCollection(); +var formatter = new HttpExceptionDescriptorResponseFormatter(new ExampleFormatterOptions()); +services.AddSingleton(formatter.GetType(), formatter); -public class ExceptionFormatterResolver +using var provider = services.BuildServiceProvider(); +var formatters = provider.GetExceptionResponseFormatters().ToList(); + +Console.WriteLine(formatters.Count); +Console.WriteLine(formatters[0].GetType().GenericTypeArguments[0].Name); + +public sealed class ExampleFormatterOptions : IContentNegotiation, IExceptionDescriptorOptions { - public IEnumerable ResolveFormatters(IServiceProvider provider) - { - return provider.GetExceptionResponseFormatters(); + public IReadOnlyCollection SupportedMediaTypes { get; } = + new[] { new MediaTypeHeaderValue("application/json") }; + public FaultSensitivityDetails SensitivityDetails { get; set; } } -} - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Hosting.ApplicationBuilderExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Hosting.ApplicationBuilderExtensions.md index 2072905e7..125239cd9 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Hosting.ApplicationBuilderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Hosting.ApplicationBuilderExtensions.md @@ -7,28 +7,34 @@ example: The following example demonstrates how to add the hosting environment HTTP header middleware to an ASP.NET Core application pipeline. ```csharp +// Program.cs +using System; using Cuemon.AspNetCore.Hosting; using Cuemon.Extensions.AspNetCore.Hosting; using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; -namespace Examples; - -public class StartupPipeline -{ - public void Configure(IApplicationBuilder app) +using var host = Host.CreateDefaultBuilder() + .ConfigureServices(services => { - app.UseHostingEnvironment(o => + services.AddLogging(); + services.Configure(options => { - o.HeaderName = "X-Environment"; + options.HeaderName = "X-Environment"; }); + }) + .Build(); - app.UseRouting(); - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - -} -} +var app = new ApplicationBuilder(host.Services); +app.UseHostingEnvironment(options => +{ + options.HeaderName = "X-Environment"; +}); +Console.WriteLine("Hosting environment middleware configured."); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HeaderDictionaryExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HeaderDictionaryExtensions.md index f53cbfcb0..fb43aeafd 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HeaderDictionaryExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HeaderDictionaryExtensions.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to add or update HTTP headers in an [IHeaderDictionary](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.http.iheaderdictionary) using the class. ```csharp +// Program.cs using System; using System.Net.Http; using System.Net.Http.Headers; @@ -14,30 +15,24 @@ using Cuemon.Extensions.AspNetCore.Http; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; -namespace MyApp.Examples; +var headers = new HeaderDictionary(); -public class HeaderDictionaryExtensionsExample -{ - public void Demonstrate() - { - var headers = new HeaderDictionary(); +// Add or update a single header +headers.AddOrUpdateHeader("X-Custom", new StringValues("my-value")); - // Add or update a single header - headers.AddOrUpdateHeader("X-Custom", new StringValues("my-value")); +// Add or update multiple headers from an HttpResponseHeaders collection +var responseMessage = new HttpResponseMessage(); +responseMessage.Headers.Add("X-Trace", "abc123"); +responseMessage.Headers.Add("X-Session", "session-456"); - // Add or update multiple headers from an HttpResponseHeaders collection - var responseMessage = new HttpResponseMessage(); - responseMessage.Headers.Add("X-Trace", "abc123"); - responseMessage.Headers.Add("X-Session", "session-456"); - - headers.AddOrUpdateHeaders(responseMessage.Headers); - - // Verify headers - Console.WriteLine(headers["X-Custom"]); // my-value - Console.WriteLine(headers["X-Trace"]); // abc123 - Console.WriteLine(headers["X-Session"]); // session-456 - -} -} +headers.AddOrUpdateHeaders(responseMessage.Headers); +// Verify headers +Console.WriteLine(headers["X-Custom"]); // my-value +Console.WriteLine(headers["X-Trace"]); // abc123 +Console.WriteLine(headers["X-Session"]); // session-456 ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Headers.ApplicationBuilderExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Headers.ApplicationBuilderExtensions.md index 22c467722..3f54c2d81 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Headers.ApplicationBuilderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Headers.ApplicationBuilderExtensions.md @@ -7,40 +7,44 @@ example: The following example demonstrates how to add correlation, request, validation, and cache headers to an ASP.NET Core request pipeline. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Http.Headers; using Cuemon.Extensions.AspNetCore.Http.Headers; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Net.Http.Headers; -namespace DocfxExamples; +var services = new ServiceCollection(); +services.AddLogging(); +services.AddOptions(); +using var provider = services.BuildServiceProvider(); -public class HeaderPipelineExample +var app = new ApplicationBuilder(provider); +app.UseCorrelationIdentifier(options => options.HeaderName = "X-Correlation-ID"); +app.UseRequestIdentifier(options => options.HeaderName = "X-Request-ID"); +app.UseUserAgentSentinel(options => { - public static void Configure(IApplicationBuilder app) - { - app.UseCorrelationIdentifier(options => options.HeaderName = "X-Correlation-ID"); - app.UseRequestIdentifier(options => options.HeaderName = "X-Request-ID"); - app.UseUserAgentSentinel(options => - { - options.RequireUserAgentHeader = true; - options.ValidateUserAgentHeader = true; - options.AllowedUserAgents.Add("Cuemon-Agent"); - }); - app.UseApiKeySentinel(options => - { - options.HeaderName = "X-Test-Key"; - options.AllowedKeys.Add("known-key"); - }); - app.UseCacheControl(options => - { - options.CacheControl.MaxAge = TimeSpan.FromHours(1); - options.CacheControl.Public = true; - options.Expires = new ExpiresHeaderValue(TimeSpan.FromHours(1)); - }); - app.UseVaryAccept(); - app.Run(context => context.Response.WriteAsync("ok")); - } -} + options.RequireUserAgentHeader = true; + options.ValidateUserAgentHeader = true; + options.AllowedUserAgents.Add("Cuemon-Agent"); +}); +app.UseApiKeySentinel(options => +{ + options.HeaderName = "X-Test-Key"; + options.AllowedKeys.Add("known-key"); +}); +app.UseCacheControl(options => +{ + options.CacheControl.MaxAge = TimeSpan.FromHours(1); + options.CacheControl.Public = true; + options.Expires = new ExpiresHeaderValue(TimeSpan.FromHours(1)); +}); +app.UseVaryAccept(); + +Console.WriteLine("Correlation, request, agent, API key, cache-control and Vary middleware configured."); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Headers.EntityTagCacheableValidator.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Headers.EntityTagCacheableValidator.md index 5ba4826da..ebeb3d620 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Headers.EntityTagCacheableValidator.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Headers.EntityTagCacheableValidator.md @@ -7,29 +7,26 @@ example: The following example demonstrates how to register as a cacheable validator in the ASP.NET Core pipeline. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Http.Headers; using Cuemon.Extensions.AspNetCore.Http.Headers; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -namespace DocfxExamples; - -public class EntityTagCacheableValidatorExample +var services = new ServiceCollection(); +services.Configure(options => { - public void ConfigureServices(IServiceCollection services) - { - services.Configure(options => - { - options.Validators.Add(new EntityTagCacheableValidator()); - }); - - var serviceProvider = services.BuildServiceProvider(); - var options = serviceProvider.GetRequiredService>(); - Console.WriteLine(options.Value.Validators.Count); // 1 - Console.WriteLine(options.Value.Validators[0] is EntityTagCacheableValidator); // True + options.Validators.Add(new EntityTagCacheableValidator()); +}); -} -} +using var provider = services.BuildServiceProvider(); +var options = provider.GetRequiredService>().Value; +Console.WriteLine(options.Validators.Count); +Console.WriteLine(options.Validators[0] is EntityTagCacheableValidator); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Headers.ServiceCollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Headers.ServiceCollectionExtensions.md index b1977198e..3d6037a36 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Headers.ServiceCollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Headers.ServiceCollectionExtensions.md @@ -7,38 +7,36 @@ example: The following example demonstrates how to register API key and User-Agent validation rules and then inspect the resolved options through `IOptions`. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Http.Headers; using Cuemon.Extensions.AspNetCore.Http.Headers; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -namespace DocfxExamples; - -public class HeaderServiceCollectionExtensionsExample +var services = new ServiceCollection(); +services.AddOptions(); +services.AddApiKeySentinelOptions(options => +{ + options.AllowedKeys.Add("known-key"); + options.HeaderName = "X-Test-Key"; + options.UseGenericResponse = true; +}); +services.AddUserAgentSentinelOptions(options => { - public static void ConfigureServices(IServiceCollection services) - { - services.AddOptions(); - services.AddApiKeySentinelOptions(options => - { - options.AllowedKeys.Add("known-key"); - options.HeaderName = "X-Test-Key"; - options.UseGenericResponse = true; - }); - services.AddUserAgentSentinelOptions(options => - { - options.AllowedUserAgents.Add("Cuemon-Agent"); - options.RequireUserAgentHeader = true; - options.ValidateUserAgentHeader = true; - }); + options.AllowedUserAgents.Add("Cuemon-Agent"); + options.RequireUserAgentHeader = true; + options.ValidateUserAgentHeader = true; +}); - var provider = services.BuildServiceProvider(); - var apiKeyOptions = provider.GetRequiredService>().Value; - var userAgentOptions = provider.GetRequiredService>().Value; +using var provider = services.BuildServiceProvider(); +var apiKeyOptions = provider.GetRequiredService>().Value; +var userAgentOptions = provider.GetRequiredService>().Value; - Console.WriteLine($"{apiKeyOptions.HeaderName}:{apiKeyOptions.AllowedKeys.Count}"); - Console.WriteLine($"{userAgentOptions.RequireUserAgentHeader}:{userAgentOptions.AllowedUserAgents.Count}"); - } -} +Console.WriteLine($"{apiKeyOptions.HeaderName}:{apiKeyOptions.AllowedKeys.Count}"); +Console.WriteLine($"{userAgentOptions.RequireUserAgentHeader}:{userAgentOptions.AllowedUserAgents.Count}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HttpExceptionDescriptorResponseFormatterExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HttpExceptionDescriptorResponseFormatterExtensions.md index 2dbf05d31..6dc58ae34 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HttpExceptionDescriptorResponseFormatterExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HttpExceptionDescriptorResponseFormatterExtensions.md @@ -7,20 +7,40 @@ example: The following example demonstrates how to project all exception descriptor handlers from a sequence of formatters into a single enumerable sequence. ```csharp +// Program.cs +using System; using System.Collections.Generic; using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; using Cuemon.AspNetCore.Diagnostics; using Cuemon.Extensions.AspNetCore.Http; -namespace Examples; - -public class FormatterHandlerProjection +var formatters = new List { - public IEnumerable GetAllHandlers(IEnumerable formatters) - { - return formatters.SelectExceptionDescriptorHandlers(); + new ExampleFormatter() +}; -} -} +var handlers = formatters.SelectExceptionDescriptorHandlers().ToList(); +Console.WriteLine(handlers.Count); +Console.WriteLine(handlers[0].ContentType.MediaType); +public sealed class ExampleFormatter : IHttpExceptionDescriptorResponseFormatter +{ + public ICollection ExceptionDescriptorHandlers { get; } = + new List + { + new HttpExceptionDescriptorResponseHandler( + new MediaTypeHeaderValue("application/json"), + descriptor => new HttpResponseMessage(HttpStatusCode.InternalServerError) + { + Content = new StringContent(descriptor.Message) + }) + }; +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HttpRequestExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HttpRequestExtensions.md index f712a26df..1dcfa645c 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HttpRequestExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HttpRequestExtensions.md @@ -7,49 +7,39 @@ example: `HttpRequestExtensions` provides extension methods for `HttpRequest` that inspect accepted MIME types, HTTP method type, and client-side caching status. This example sets up a request with `Accept` header values (`text/html`, `application/json`, `*/*` with quality scores), `If-None-Match` with an ETag, and `If-Modified-Since` with a date, then calls `AcceptMimeTypesOrderedByQuality` to sort by q-value, `IsGetOrHeadMethod` to check the HTTP method, and `IsClientSideResourceCached` with both a `ChecksumBuilder` ETag and a `Last-Modified` date overload. Console output shows the sorted MIME types (`application/json, text/html, */*`), the method check results, and the cache state booleans. ```csharp +// Program.cs using System; +using System.Text; using System.Collections.Generic; -using System.Linq; using Cuemon.Data.Integrity; using Cuemon.Extensions.AspNetCore.Http; using Cuemon.Security; using Microsoft.AspNetCore.Http; -namespace MyApp.AspNetCore.Http -{ - public class HttpRequestExtensionsExample - { - public void Demonstrate(HttpRequest request) - { - // Get ordered MIME types from the Accept header by quality value - request.Headers["Accept"] = "text/html;q=0.8, application/json;q=0.9, */*;q=0.1"; - IEnumerable preferredTypes = request.AcceptMimeTypesOrderedByQuality(); - Console.WriteLine(string.Join(", ", preferredTypes)); - // Output: "application/json, text/html, */*" (sorted by q-value descending) - - // Check if the request uses GET or HEAD method - request.Method = "GET"; - bool isGetOrHead = request.IsGetOrHeadMethod(); - Console.WriteLine(isGetOrHead); // True - - request.Method = "POST"; - isGetOrHead = request.IsGetOrHeadMethod(); - Console.WriteLine(isGetOrHead); // False - - // Check if the client has a cached version using If-None-Match (ETag) - request.Method = "GET"; - request.Headers["If-None-Match"] = "\"abc123\""; - var checksumBuilder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); - bool isCached = request.IsClientSideResourceCached(checksumBuilder); - Console.WriteLine(isCached); // True or False depending on checksum match - - // Check if the client has a cached version using If-Modified-Since - request.Headers["If-Modified-Since"] = "Tue, 15 Jun 2024 10:00:00 GMT"; - var lastModified = new DateTime(2024, 6, 15, 9, 0, 0, DateTimeKind.Utc); - isCached = request.IsClientSideResourceCached(lastModified); - Console.WriteLine(isCached); // False (resource modified after If-Modified-Since date) - -}} -} +var context = new DefaultHttpContext(); +var request = context.Request; +request.Headers["Accept"] = "text/html;q=0.8, application/json;q=0.9, */*;q=0.1"; +IEnumerable preferredTypes = request.AcceptMimeTypesOrderedByQuality(); +Console.WriteLine(string.Join(", ", preferredTypes)); + +request.Method = "GET"; +Console.WriteLine(request.IsGetOrHeadMethod()); + +request.Method = "POST"; +Console.WriteLine(request.IsGetOrHeadMethod()); + +request.Method = "GET"; +request.Headers["If-None-Match"] = "\"abc123\""; +var checksumBuilder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); +checksumBuilder.CombineWith(Encoding.UTF8.GetBytes("content-data")); +Console.WriteLine(request.IsClientSideResourceCached(checksumBuilder)); + +request.Headers["If-Modified-Since"] = "Tue, 15 Jun 2024 10:00:00 GMT"; +var lastModified = new DateTime(2024, 6, 15, 9, 0, 0, DateTimeKind.Utc); +Console.WriteLine(request.IsClientSideResourceCached(lastModified)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HttpResponseExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HttpResponseExtensions.md index 9ab34f2d8..c80532c1c 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HttpResponseExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.HttpResponseExtensions.md @@ -4,51 +4,51 @@ example: - *content --- -`HttpResponseExtensions` provides extension methods for `HttpResponse` to manage ETag and Last-Modified headers, write response bodies asynchronously, and transform `HttpResponseMessage` content into the ASP.NET Core response pipeline. This example calls `AddOrUpdateEntityTagHeader` with a `ChecksumBuilder` for ETag generation, `AddOrUpdateLastModifiedHeader` with a `2024-06-15T10:00:00Z` UTC date, `WriteBodyAsync` with a byte array delegate, and `OnStartingInvokeTransformer` to transfer an `HttpResponseMessage` with status `200 OK` and JSON content type. Each operation is demonstrated independently, with Console output confirming the header values and response modifications. +`HttpResponseExtensions` provides extension methods for `HttpResponse` to manage ETag and Last-Modified headers, write response bodies asynchronously, and transform `HttpResponseMessage` content into the ASP.NET Core response pipeline. This example calls `AddOrUpdateEntityTagHeader` with a `ChecksumBuilder` for ETag generation, `AddOrUpdateLastModifiedHeader` with a `2024-06-15T10:00:00Z` UTC date, `WriteBodyAsync` with a byte array delegate, and `OnStartingInvokeTransformer` to register a start callback that copies a trace header from an `HttpResponseMessage` with status `200 OK`. Each operation is demonstrated independently, with Console output confirming the header values and response modifications. ```csharp +// Program.cs using System; +using System.IO; using System.Net; using System.Net.Http; +using System.Text; using System.Threading.Tasks; using Cuemon.Data.Integrity; using Cuemon.Extensions.AspNetCore.Http; using Cuemon.Security; using Microsoft.AspNetCore.Http; -namespace MyApp.AspNetCore.Http -{ - public class HttpResponseExtensionsExample - { - public async Task DemonstrateAsync(HttpResponse response, HttpRequest request) - { - // Add or update an ETag header using a checksum builder - var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); - response.AddOrUpdateEntityTagHeader(request, builder, isWeak: false); - // Response now has ETag: "..." header - - // Add or update a Last-Modified header with a specific date - var lastModified = new DateTime(2024, 6, 15, 10, 0, 0, DateTimeKind.Utc); - response.AddOrUpdateLastModifiedHeader(request, lastModified); - // Response now has Last-Modified: "Sat, 15 Jun 2024 10:00:00 GMT" header - - // Write bytes to the response body from a delegate - await response.WriteBodyAsync(() => new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F }); - // Response body now contains "Hello" - - // Transfer a HttpResponseMessage to the response pipeline - var message = new HttpResponseMessage(HttpStatusCode.OK) - { - Content = new StringContent("{\"status\":\"ok\"}") - }; - response.OnStartingInvokeTransformer(message, (msg, resp) => - { - resp.StatusCode = (int)msg.StatusCode; - resp.Headers["Content-Type"] = "application/json"; - }); - // The response will send the transformed content when the pipeline starts - -}} -} +var context = new DefaultHttpContext(); +var request = context.Request; +var response = context.Response; +response.Body = new MemoryStream(); + +var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); +builder.CombineWith(Encoding.UTF8.GetBytes("Hello")); +response.AddOrUpdateEntityTagHeader(request, builder, isWeak: false); + +var lastModified = new DateTime(2024, 6, 15, 10, 0, 0, DateTimeKind.Utc); +response.AddOrUpdateLastModifiedHeader(request, lastModified); +using var message = new HttpResponseMessage(HttpStatusCode.OK); +message.Headers.Add("X-Trace", "demo"); +response.OnStartingInvokeTransformer(message, (source, target) => +{ + target.Headers["X-Transferred"] = string.Join(string.Empty, source.Headers.GetValues("X-Trace")); +}); + +await response.WriteBodyAsync(() => new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F }); +await response.StartAsync(); + +Console.WriteLine(response.Headers.ETag.ToString()); +Console.WriteLine(response.Headers.LastModified.ToString()); +Console.WriteLine(response.Headers["X-Transferred"].ToString()); +response.Body.Position = 0; +using var reader = new StreamReader(response.Body); +Console.WriteLine(await reader.ReadToEndAsync()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Int32Extensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Int32Extensions.md index d453a4774..dd24d81e6 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Int32Extensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Int32Extensions.md @@ -7,44 +7,38 @@ example: The following example demonstrates how to use the extension methods to classify HTTP status codes by range. ```csharp +// Program.cs using System; using Cuemon.Extensions.AspNetCore.Http; -namespace MyApp.Examples; - -public class Example -{ - public void Run() - { - - int statusCode = 404; - - // Check the status code range - bool isInfo = statusCode.IsInformationStatusCode(); - bool isSuccess = statusCode.IsSuccessStatusCode(); - bool isRedirect = statusCode.IsRedirectionStatusCode(); - bool isClientError = statusCode.IsClientErrorStatusCode(); - bool isServerError = statusCode.IsServerErrorStatusCode(); - bool isNotModified = statusCode.IsNotModifiedStatusCode(); - - Console.WriteLine($"HTTP {statusCode}:"); - Console.WriteLine($" Informational: {isInfo}"); - Console.WriteLine($" Success: {isSuccess}"); - Console.WriteLine($" Redirection: {isRedirect}"); - Console.WriteLine($" Client Error: {isClientError}"); - Console.WriteLine($" Server Error: {isServerError}"); - Console.WriteLine($" Not Modified: {isNotModified}"); - - // Use with common HTTP status codes - int ok = 200; - int notFound = 404; - int serverError = 500; - - Console.WriteLine($"\n{ok} is success: {ok.IsSuccessStatusCode()}"); - Console.WriteLine($"{notFound} is client error: {notFound.IsClientErrorStatusCode()}"); - Console.WriteLine($"{serverError} is server error: {serverError.IsServerErrorStatusCode()}"); - -} -} - +int statusCode = 404; + +// Check the status code range +bool isInfo = statusCode.IsInformationStatusCode(); +bool isSuccess = statusCode.IsSuccessStatusCode(); +bool isRedirect = statusCode.IsRedirectionStatusCode(); +bool isClientError = statusCode.IsClientErrorStatusCode(); +bool isServerError = statusCode.IsServerErrorStatusCode(); +bool isNotModified = statusCode.IsNotModifiedStatusCode(); + +Console.WriteLine($"HTTP {statusCode}:"); +Console.WriteLine($" Informational: {isInfo}"); +Console.WriteLine($" Success: {isSuccess}"); +Console.WriteLine($" Redirection: {isRedirect}"); +Console.WriteLine($" Client Error: {isClientError}"); +Console.WriteLine($" Server Error: {isServerError}"); +Console.WriteLine($" Not Modified: {isNotModified}"); + +// Use with common HTTP status codes +int ok = 200; +int notFound = 404; +int serverError = 500; + +Console.WriteLine($"\n{ok} is success: {ok.IsSuccessStatusCode()}"); +Console.WriteLine($"{notFound} is client error: {notFound.IsClientErrorStatusCode()}"); +Console.WriteLine($"{serverError} is server error: {serverError.IsServerErrorStatusCode()}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Throttling.ApplicationBuilderExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Throttling.ApplicationBuilderExtensions.md index ebe6f5ab4..1e14ef091 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Throttling.ApplicationBuilderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Throttling.ApplicationBuilderExtensions.md @@ -7,31 +7,34 @@ example: The following example demonstrates how to add a request rate limiting middleware to an ASP.NET Core application pipeline. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.AspNetCore.Http.Throttling; using Cuemon.Extensions.AspNetCore.Http.Throttling; using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; -namespace Examples; - -public class StartupPipeline +var services = new ServiceCollection(); +services.AddLogging(); +services.AddMemoryThrottlingCache(); +services.AddThrottlingSentinelOptions(options => { - public void Configure(IApplicationBuilder app) - { - app.UseThrottlingSentinel(o => - { - o.Quota = new ThrottleQuota(100, 1, TimeUnit.Minutes); - o.ContextResolver = ctx => ctx.Connection.RemoteIpAddress?.ToString() ?? "unknown"; - }); - - app.UseRouting(); - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); + options.Quota = new ThrottleQuota(100, 1, TimeUnit.Minutes); + options.ContextResolver = context => context.Connection.RemoteIpAddress?.ToString() ?? "unknown"; +}); -} -} +using var provider = services.BuildServiceProvider(); +var app = new ApplicationBuilder(provider); +app.UseThrottlingSentinel(options => +{ + options.Quota = new ThrottleQuota(100, 1, TimeUnit.Minutes); + options.ContextResolver = context => context.Connection.RemoteIpAddress?.ToString() ?? "unknown"; +}); +Console.WriteLine("Throttling sentinel middleware configured."); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Throttling.ServiceCollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Throttling.ServiceCollectionExtensions.md index 220044836..8e990c86d 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Throttling.ServiceCollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Http.Throttling.ServiceCollectionExtensions.md @@ -7,48 +7,38 @@ example: `ServiceCollectionExtensions` in the `Throttling` namespace registers rate-limiting services in an ASP.NET Core `IServiceCollection`. This example calls `AddMemoryThrottlingCache` and `AddThrottlingCache` to register in-memory and custom throttling cache implementations as singletons, then configures `ThrottlingSentinelOptions` with a `ContextResolver` that uses the remote IP address, a quota of `100` requests per minute, custom rate-limit header names (`X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`), and `RetryAfter` header behavior in delta-seconds format. After this setup in `ConfigureServices`, the middleware pipeline can enforce the configured throttling rules for each client. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.AspNetCore.Http.Headers; using Cuemon.AspNetCore.Http.Throttling; using Cuemon.Extensions.AspNetCore.Http.Throttling; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; -namespace MyApp.AspNetCore.Throttling +var services = new ServiceCollection(); +services.AddMemoryThrottlingCache(); +services.AddThrottlingCache(); +services.AddThrottlingSentinelOptions(options => { - public class Startup - { - public void ConfigureServices(IServiceCollection services) - { - // Register the in-memory throttling cache as a singleton - services.AddMemoryThrottlingCache(); - - // Register a custom IThrottlingCache implementation - services.AddThrottlingCache(); - - // Configure throttling sentinel options (rate limiting rules) - services.AddThrottlingSentinelOptions(o => - { - // Identify clients by their remote IP address - o.ContextResolver = ctx => ctx.Connection.RemoteIpAddress?.ToString() ?? "unknown"; - - // Allow 100 requests per minute per client - o.Quota = new ThrottleQuota(100, 1, TimeUnit.Minutes); - - // Customize the rate limit response message - o.TooManyRequestsMessage = "API rate limit exceeded. Please wait before retrying."; - - // Customize HTTP header names - o.RateLimitHeaderName = "X-RateLimit-Limit"; - o.RateLimitRemainingHeaderName = "X-RateLimit-Remaining"; - o.RateLimitResetHeaderName = "X-RateLimit-Reset"; - - // Use delta-seconds format for reset headers - o.RateLimitResetScope = RetryConditionScope.DeltaSeconds; - o.UseRetryAfterHeader = true; - }); - -}} -} - + options.ContextResolver = context => context.Connection.RemoteIpAddress?.ToString() ?? "unknown"; + options.Quota = new ThrottleQuota(100, 1, TimeUnit.Minutes); + options.TooManyRequestsMessage = "API rate limit exceeded. Please wait before retrying."; + options.RateLimitHeaderName = "X-RateLimit-Limit"; + options.RateLimitRemainingHeaderName = "X-RateLimit-Remaining"; + options.RateLimitResetHeaderName = "X-RateLimit-Reset"; + options.RateLimitResetScope = RetryConditionScope.DeltaSeconds; + options.UseRetryAfterHeader = true; +}); + +using var provider = services.BuildServiceProvider(); +var options = provider.GetRequiredService>().Value; + +Console.WriteLine(options.RateLimitHeaderName); +Console.WriteLine(options.Quota != null); +Console.WriteLine(options.TooManyRequestsMessage); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.CacheableObjectResultExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.CacheableObjectResultExtensions.md index 04254c313..37898a1f9 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.CacheableObjectResultExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.CacheableObjectResultExtensions.md @@ -7,69 +7,77 @@ example: The following example mirrors the cacheable object patterns covered by the unit tests: a payload can expose Last-Modified metadata, an ETag, or both at once. It calls `WithLastModifiedHeader`, `WithEntityTagHeader`, and `WithCacheableHeaders` in sequence on a `ProductDto`, each with timestamp and checksum provider callbacks. The resulting `ICacheableObjectResult` is read back to display the modified timestamp and entity-tag validation, showing how to attach HTTP caching headers to response payloads. ```csharp +// Program.cs using System; using System.Text; using Cuemon.AspNetCore.Mvc; using Cuemon.Data.Integrity; using Cuemon.Extensions.AspNetCore.Mvc; +using Cuemon.Extensions.AspNetCore.Mvc.DocExamples; -namespace Cuemon.Extensions.AspNetCore.Mvc.DocExamples; +Console.WriteLine(new CacheableObjectResultExample().CreateLastModifiedResult()); -public sealed class CacheableObjectResultExample +namespace Cuemon.Extensions.AspNetCore.Mvc.DocExamples { - public ICacheableObjectResult CreateLastModifiedResult() + public sealed class CacheableObjectResultExample { - var product = new ProductDto(42, "Coffee Beans"); - return product.WithLastModifiedHeader(options => + public ICacheableObjectResult CreateLastModifiedResult() { - options.TimestampProvider = _ => new DateTime(2024, 6, 1, 8, 0, 0, DateTimeKind.Utc); - options.ChangedTimestampProvider = _ => new DateTime(2024, 6, 18, 8, 30, 0, DateTimeKind.Utc); - }); - } + var product = new ProductDto(42, "Coffee Beans"); + return product.WithLastModifiedHeader(options => + { + options.TimestampProvider = _ => new DateTime(2024, 6, 1, 8, 0, 0, DateTimeKind.Utc); + options.ChangedTimestampProvider = _ => new DateTime(2024, 6, 18, 8, 30, 0, DateTimeKind.Utc); + }); + } - public ICacheableObjectResult CreateEntityTagResult() - { - var product = new ProductDto(42, "Coffee Beans"); - return product.WithEntityTagHeader(options => + public ICacheableObjectResult CreateEntityTagResult() { - options.ChecksumProvider = dto => Encoding.UTF8.GetBytes($"{dto.Id}:{dto.Name}"); - options.WeakChecksumProvider = _ => false; - }); - } + var product = new ProductDto(42, "Coffee Beans"); + return product.WithEntityTagHeader(options => + { + options.ChecksumProvider = dto => Encoding.UTF8.GetBytes($"{dto.Id}:{dto.Name}"); + options.WeakChecksumProvider = _ => false; + }); + } - public ICacheableObjectResult CreateFullyCacheableResult() - { - var product = new ProductDto(42, "Coffee Beans"); - return product.WithCacheableHeaders(options => + public ICacheableObjectResult CreateFullyCacheableResult() { - options.TimestampProvider = _ => new DateTime(2024, 6, 1, 8, 0, 0, DateTimeKind.Utc); - options.ChangedTimestampProvider = _ => new DateTime(2024, 6, 18, 8, 30, 0, DateTimeKind.Utc); - options.ChecksumProvider = dto => Encoding.UTF8.GetBytes($"{dto.Id}:{dto.Name}"); - options.WeakChecksumProvider = _ => false; - }); - } + var product = new ProductDto(42, "Coffee Beans"); + return product.WithCacheableHeaders(options => + { + options.TimestampProvider = _ => new DateTime(2024, 6, 1, 8, 0, 0, DateTimeKind.Utc); + options.ChangedTimestampProvider = _ => new DateTime(2024, 6, 18, 8, 30, 0, DateTimeKind.Utc); + options.ChecksumProvider = dto => Encoding.UTF8.GetBytes($"{dto.Id}:{dto.Name}"); + options.WeakChecksumProvider = _ => false; + }); + } - public void Describe() - { - var result = CreateFullyCacheableResult(); - var timestamp = (IEntityDataTimestamp)result; - var integrity = (IEntityDataIntegrity)result; - var product = (ProductDto)result.Value; + public void Describe() + { + var result = CreateFullyCacheableResult(); + var timestamp = (IEntityDataTimestamp)result; + var integrity = (IEntityDataIntegrity)result; + var product = (ProductDto)result.Value; - Console.WriteLine($"{product.Name}: {(timestamp.Modified ?? timestamp.Created):O} [{integrity.Validation}]"); + Console.WriteLine($"{product.Name}: {(timestamp.Modified ?? timestamp.Created):O} [{integrity.Validation}]"); + } } -} - -public sealed class ProductDto -{ - public ProductDto(int id, string name) + public sealed class ProductDto { - Id = id; - Name = name; - } + public ProductDto(int id, string name) + { + Id = id; + Name = name; + } - public int Id { get; } + public int Id { get; } - public string Name { get; } + public string Name { get; } + } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable.CacheableAsyncResultFilterExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable.CacheableAsyncResultFilterExtensions.md index 5ce1beeb4..0dedef5d6 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable.CacheableAsyncResultFilterExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable.CacheableAsyncResultFilterExtensions.md @@ -7,39 +7,48 @@ example: The following example configures the same cache-filter collection patterns exercised by the unit tests: use the convenience methods for the default pipeline, or switch to the generic overloads when you need explicit ordering and option control. ```csharp +// Program.cs using System; using Cuemon.AspNetCore.Mvc.Filters.Cacheable; using Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable; +using Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable.DocExamples; -namespace Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable.DocExamples; +Console.WriteLine(new CacheableAsyncResultFilterExtensionsExample().CreateDefaultProfile()); -public sealed class CacheableAsyncResultFilterExtensionsExample +namespace Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable.DocExamples { - public HttpCacheableOptions CreateDefaultProfile() + public sealed class CacheableAsyncResultFilterExtensionsExample { - var options = new HttpCacheableOptions(); - options.Filters.AddLastModifiedHeader(); - options.Filters.AddEntityTagHeader(); - return options; - } + public HttpCacheableOptions CreateDefaultProfile() + { + var options = new HttpCacheableOptions(); + options.Filters.AddLastModifiedHeader(); + options.Filters.AddEntityTagHeader(); + return options; + } - public HttpCacheableOptions CreateCustomProfile() - { - var options = new HttpCacheableOptions(); - options.Filters.AddFilter(entityTag => + public HttpCacheableOptions CreateCustomProfile() { - entityTag.UseEntityTagResponseParser = true; - }); - options.Filters.InsertFilter(0); - return options; - } + var options = new HttpCacheableOptions(); + options.Filters.AddFilter(entityTag => + { + entityTag.UseEntityTagResponseParser = true; + }); + options.Filters.InsertFilter(0); + return options; + } - public void Describe() - { - var defaultProfile = CreateDefaultProfile(); - var customProfile = CreateCustomProfile(); + public void Describe() + { + var defaultProfile = CreateDefaultProfile(); + var customProfile = CreateCustomProfile(); - Console.WriteLine($"{defaultProfile.Filters.Count} default filters, {customProfile.Filters.Count} custom filters."); + Console.WriteLine($"{defaultProfile.Filters.Count} default filters, {customProfile.Filters.Count} custom filters."); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.Diagnostics.HttpFaultResolverExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.Diagnostics.HttpFaultResolverExtensions.md index 81c7a2fd4..80a6de0da 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.Diagnostics.HttpFaultResolverExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.Diagnostics.HttpFaultResolverExtensions.md @@ -7,29 +7,26 @@ example: The following example builds a resolver list the same way MVC fault handling does internally: map known exception types to HTTP-friendly descriptors, then ask a resolver to translate the thrown exception. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon.AspNetCore.Diagnostics; using Cuemon.AspNetCore.Http; using Cuemon.Extensions.AspNetCore.Mvc.Filters.Diagnostics; -namespace Cuemon.Extensions.AspNetCore.Mvc.Filters.Diagnostics.DocExamples; +var resolvers = new List() + .AddHttpFaultResolver( + message: "The request payload could not be processed.", + helpLink: new Uri("https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400")) + .AddHttpFaultResolver( + exception => new HttpExceptionDescriptor(exception), + exception => exception is TooManyRequestsException); -public sealed class HttpFaultResolverExtensionsExample -{ - public void Describe() - { - var resolvers = new List() - .AddHttpFaultResolver( - message: "The request payload could not be processed.", - helpLink: new Uri("https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400")) - .AddHttpFaultResolver( - exception => new HttpExceptionDescriptor(exception), - exception => exception is TooManyRequestsException); +var resolved = resolvers[1].TryResolveFault(new TooManyRequestsException(), out var descriptor); - var resolved = resolvers[1].TryResolveFault(new TooManyRequestsException(), out var descriptor); - - Console.WriteLine($"{resolved}: {descriptor.StatusCode} {descriptor.Code}"); - } -} +Console.WriteLine($"{resolved}: {descriptor.StatusCode} {descriptor.Code}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.FilterCollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.FilterCollectionExtensions.md index 70fd214c8..da108b8ae 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.FilterCollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.FilterCollectionExtensions.md @@ -7,39 +7,30 @@ example: The following example demonstrates how to use the extension methods to register common ASP.NET Core MVC filters. ```csharp +// Program.cs +using System; using Cuemon.Extensions.AspNetCore.Mvc.Filters; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; -namespace MyAspNetCoreApp +var services = new ServiceCollection(); +services.AddLogging(); +services.AddControllers(options => { - public class Startup - { - public void ConfigureServices(IServiceCollection services) - { - services.AddControllers(options => - { - // Add HTTP cacheable filter for response caching - options.Filters.AddHttpCacheable(); - - // Add developer-friendly fault descriptor - options.Filters.AddFaultDescriptor(); - - // Add server timing header for performance profiling - options.Filters.AddServerTiming(); - - // Add User-Agent sentinel filter - options.Filters.AddUserAgentSentinel(); - - // Add API throttling sentinel - options.Filters.AddThrottlingSentinel(); - - // Add API key sentinel - options.Filters.AddApiKeySentinel(); - }); - -}} -} - + options.Filters.AddHttpCacheable(); + options.Filters.AddFaultDescriptor(); + options.Filters.AddServerTiming(); + options.Filters.AddUserAgentSentinel(); + options.Filters.AddThrottlingSentinel(); + options.Filters.AddApiKeySentinel(); +}); + +using var provider = services.BuildServiceProvider(); +var options = provider.GetRequiredService>().Value; +Console.WriteLine(options.Filters.Count); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.MvcBuilderExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.MvcBuilderExtensions.md index ed004635e..894247a84 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.MvcBuilderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Filters.MvcBuilderExtensions.md @@ -7,6 +7,7 @@ example: The following example configures the MVC builder with the same option families covered by the unit tests: API-key enforcement, throttling, user-agent validation, fault descriptors, and cache headers. It chains `AddApiKeySentinelOptions`, `AddThrottlingSentinelOptions`, `AddUserAgentSentinelOptions`, `AddFaultDescriptorOptions`, and `AddHttpCacheableOptions` on the MVC builder. The resulting service count is written to the console, demonstrating how to register security, throttling, and caching middleware in a single fluent configuration. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.AspNetCore.Http; @@ -16,52 +17,60 @@ using Cuemon.Extensions.AspNetCore.Mvc.Filters; using Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable; using Cuemon.Extensions.AspNetCore.Mvc.Filters.Diagnostics; using Microsoft.Extensions.DependencyInjection; +using Cuemon.Extensions.AspNetCore.Mvc.Filters.DocExamples; -namespace Cuemon.Extensions.AspNetCore.Mvc.Filters.DocExamples; +Console.WriteLine(new MvcBuilderExtensionsExample().ConfigureServices()); -public sealed class MvcBuilderExtensionsExample +namespace Cuemon.Extensions.AspNetCore.Mvc.Filters.DocExamples { - public IServiceCollection ConfigureServices() + public sealed class MvcBuilderExtensionsExample { - var services = new ServiceCollection(); + public IServiceCollection ConfigureServices() + { + var services = new ServiceCollection(); - var builder = services - .AddMvc() - .AddApiKeySentinelOptions(options => - { - options.AllowedKeys.Add("demo-key"); - options.UseGenericResponse = true; - }) - .AddThrottlingSentinelOptions(options => - { - options.ContextResolver = context => context.Connection.RemoteIpAddress?.ToString() ?? "anonymous"; - options.Quota = new ThrottleQuota(100, 1, TimeUnit.Minutes); - options.TooManyRequestsMessage = "Rate limit exceeded."; - }) - .AddUserAgentSentinelOptions(options => - { - options.RequireUserAgentHeader = true; - options.ValidateUserAgentHeader = true; - options.AllowedUserAgents.Add("DocsSample/1.0"); - }) - .AddFaultDescriptorOptions(options => - { - options.MarkExceptionHandled = true; - options.SensitivityDetails = FaultSensitivityDetails.All; - options.HttpFaultResolvers.AddHttpFaultResolver(); - }) - .AddHttpCacheableOptions(options => - { - options.CacheControl.MaxAge = TimeSpan.FromMinutes(5); - options.Filters.AddLastModifiedHeader(); - options.Filters.AddEntityTagHeader(entityTag => + var builder = services + .AddMvc() + .AddApiKeySentinelOptions(options => { - entityTag.UseEntityTagResponseParser = true; + options.AllowedKeys.Add("demo-key"); + options.UseGenericResponse = true; + }) + .AddThrottlingSentinelOptions(options => + { + options.ContextResolver = context => context.Connection.RemoteIpAddress?.ToString() ?? "anonymous"; + options.Quota = new ThrottleQuota(100, 1, TimeUnit.Minutes); + options.TooManyRequestsMessage = "Rate limit exceeded."; + }) + .AddUserAgentSentinelOptions(options => + { + options.RequireUserAgentHeader = true; + options.ValidateUserAgentHeader = true; + options.AllowedUserAgents.Add("DocsSample/1.0"); + }) + .AddFaultDescriptorOptions(options => + { + options.MarkExceptionHandled = true; + options.SensitivityDetails = FaultSensitivityDetails.All; + options.HttpFaultResolvers.AddHttpFaultResolver(); + }) + .AddHttpCacheableOptions(options => + { + options.CacheControl.MaxAge = TimeSpan.FromMinutes(5); + options.Filters.AddLastModifiedHeader(); + options.Filters.AddEntityTagHeader(entityTag => + { + entityTag.UseEntityTagResponseParser = true; + }); }); - }); - Console.WriteLine(builder.Services.Count); - return builder.Services; + Console.WriteLine(builder.Services.Count); + return builder.Services; + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationInputFormatter.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationInputFormatter.md index 5d9f76506..3e47a5d30 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationInputFormatter.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationInputFormatter.md @@ -7,24 +7,19 @@ example: The following example demonstrates how to construct a and inspect its supported media types and encodings. ```csharp +// Program.cs using System; using System.Linq; using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json; using Cuemon.Extensions.Text.Json.Formatters; -namespace DocfxExamples; - -public class JsonSerializationInputFormatterExample -{ - public void Demonstrate() - { - var options = new JsonFormatterOptions(); - var formatter = new JsonSerializationInputFormatter(options); - - Console.WriteLine($"Supported media types: {string.Join(", ", formatter.SupportedMediaTypes)}"); - Console.WriteLine($"Supported encodings: {string.Join(", ", formatter.SupportedEncodings.Select(e => e.WebName))}"); - -} -} +var options = new JsonFormatterOptions(); +var formatter = new JsonSerializationInputFormatter(options); +Console.WriteLine($"Supported media types: {string.Join(", ", formatter.SupportedMediaTypes)}"); +Console.WriteLine($"Supported encodings: {string.Join(", ", formatter.SupportedEncodings.Select(e => e.WebName))}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationMvcOptionsSetup.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationMvcOptionsSetup.md index 831424f80..fd61c821c 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationMvcOptionsSetup.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationMvcOptionsSetup.md @@ -7,31 +7,26 @@ example: The following example demonstrates how to register with the dependency injection container to configure with JSON serialization formatters. ```csharp -using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json; +// Program.cs using System; +using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json; using Cuemon.Extensions.Text.Json.Formatters; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -namespace DocfxExamples; - -public class JsonSerializationMvcOptionsSetupExample +var services = new ServiceCollection(); +services.Configure(options => { - public void ConfigureServices(IServiceCollection services) - { - services.Configure(options => - { - options.Settings.WriteIndented = true; - }); - - services.AddTransient, JsonSerializationMvcOptionsSetup>(); - - var serviceProvider = services.BuildServiceProvider(); - var setup = serviceProvider.GetService>(); - Console.WriteLine(setup is JsonSerializationMvcOptionsSetup); // True - -} -} + options.Settings.WriteIndented = true; +}); +services.AddTransient, JsonSerializationMvcOptionsSetup>(); +using var provider = services.BuildServiceProvider(); +var setup = provider.GetService>(); +Console.WriteLine(setup is JsonSerializationMvcOptionsSetup); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationOutputFormatter.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationOutputFormatter.md index 37535a81e..50e89074c 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationOutputFormatter.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationOutputFormatter.md @@ -7,24 +7,19 @@ example: The following example demonstrates how to construct a and inspect its supported media types and encodings. ```csharp +// Program.cs using System; using System.Linq; using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json; using Cuemon.Extensions.Text.Json.Formatters; -namespace DocfxExamples; - -public class JsonSerializationOutputFormatterExample -{ - public void Demonstrate() - { - var options = new JsonFormatterOptions(); - var formatter = new JsonSerializationOutputFormatter(options); - - Console.WriteLine($"Supported media types: {string.Join(", ", formatter.SupportedMediaTypes)}"); - Console.WriteLine($"Supported encodings: {string.Join(", ", formatter.SupportedEncodings.Select(e => e.WebName))}"); - -} -} +var options = new JsonFormatterOptions(); +var formatter = new JsonSerializationOutputFormatter(options); +Console.WriteLine($"Supported media types: {string.Join(", ", formatter.SupportedMediaTypes)}"); +Console.WriteLine($"Supported encodings: {string.Join(", ", formatter.SupportedEncodings.Select(e => e.WebName))}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcBuilderExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcBuilderExtensions.md index 8cca92d5f..0b9f595df 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcBuilderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcBuilderExtensions.md @@ -7,30 +7,31 @@ example: The following example demonstrates how to register JSON serialization formatters on an using the extension methods. ```csharp +// Program.cs +using System; using Cuemon.Diagnostics; using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json; using Microsoft.Extensions.DependencyInjection; -namespace DocfxExamples; +var services = new ServiceCollection(); +services.AddLogging(); +var builder = services.AddControllers(); -public class MvcBuilderExtensionsExample +builder.AddJsonFormatters(options => { - public void ConfigureMvc(IMvcBuilder builder) - { - // Invoke the AddJsonFormatters extension method - builder.AddJsonFormatters(options => - { - options.SensitivityDetails = FaultSensitivityDetails.All; - options.Settings.WriteIndented = true; - }); + options.SensitivityDetails = FaultSensitivityDetails.All; + options.Settings.WriteIndented = true; +}); - // Invoke the AddJsonFormattersOptions extension method - builder.AddJsonFormattersOptions(options => - { - options.Settings.WriteIndented = true; - }); - -} -} +builder.AddJsonFormattersOptions(options => +{ + options.Settings.WriteIndented = true; +}); +using var provider = services.BuildServiceProvider(); +Console.WriteLine("MVC JSON formatters configured."); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcCoreBuilderExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcCoreBuilderExtensions.md index 210852fc9..8f5970af4 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcCoreBuilderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcCoreBuilderExtensions.md @@ -7,31 +7,32 @@ example: The following example demonstrates how to register JSON serialization formatters on an using the extension methods. ```csharp +// Program.cs +using System; using System.Text.Json; using System.Text.Json.Serialization; using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json; using Microsoft.Extensions.DependencyInjection; -namespace DocfxExamples; +var services = new ServiceCollection(); +services.AddLogging(); +var builder = services.AddMvcCore(); -public class MvcCoreBuilderExtensionsExample +builder.AddJsonFormatters(options => { - public void ConfigureMvc(IMvcCoreBuilder builder) - { - // Invoke the AddJsonFormatters extension method - builder.AddJsonFormatters(options => - { - options.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; - options.Settings.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; - }); + options.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; + options.Settings.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; +}); - // Invoke the AddJsonFormattersOptions extension method - builder.AddJsonFormattersOptions(options => - { - options.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; - }); - -} -} +builder.AddJsonFormattersOptions(options => +{ + options.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; +}); +using var provider = services.BuildServiceProvider(); +Console.WriteLine("MVC Core JSON formatters configured."); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcBuilderExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcBuilderExtensions.md index bb26fc692..a2726b036 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcBuilderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcBuilderExtensions.md @@ -7,27 +7,29 @@ example: The following example demonstrates how to add XML serialization formatters to an MVC builder. It calls `AddXmlFormatters` with indentation enabled, then `AddXmlFormattersOptions` with indentation disabled, on the builder returned by `AddControllers`. Both calls configure the underlying `XmlWriter` settings, showing how to register and customize XML input/output formatters for ASP.NET Core API controllers. ```csharp +// Program.cs +using System; using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml; using Microsoft.Extensions.DependencyInjection; -namespace MyApp.Examples +var services = new ServiceCollection(); +services.AddLogging(); +var builder = services.AddControllers(); + +builder.AddXmlFormatters(options => { - public static class MvcBuilderExtensionsExample - { - public static void ConfigureServices(IServiceCollection services) - { - var builder = services.AddControllers(); + options.Settings.Writer.Indent = true; +}); - builder.AddXmlFormatters(options => - { - options.Settings.Writer.Indent = true; - }); +builder.AddXmlFormattersOptions(options => +{ + options.Settings.Writer.Indent = false; +}); - builder.AddXmlFormattersOptions(options => - { - options.Settings.Writer.Indent = false; - }); - } - } -} +using var provider = services.BuildServiceProvider(); +Console.WriteLine("MVC XML formatters configured."); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcCoreBuilderExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcCoreBuilderExtensions.md index f1b14d93c..6ab5e952d 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcCoreBuilderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcCoreBuilderExtensions.md @@ -7,29 +7,29 @@ example: The following example demonstrates how to add XML serialization formatters to an MVC core builder using the extension methods. ```csharp +// Program.cs +using System; using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml; -using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; -namespace MyApp.Examples; +var services = new ServiceCollection(); +services.AddLogging(); +var builder = services.AddMvcCore(); -public class MvcCoreBuilderExtensionsExample +builder.AddXmlFormatters(options => { - public void ConfigureMvc(IMvcCoreBuilder builder) - { - // Invoke the AddXmlFormatters extension method - builder.AddXmlFormatters(options => - { - options.SynchronizeWithXmlConvert = true; - }); + options.SynchronizeWithXmlConvert = true; +}); - // Invoke the AddXmlFormattersOptions extension method - builder.AddXmlFormattersOptions(options => - { - options.SynchronizeWithXmlConvert = true; - }); - -} -} +builder.AddXmlFormattersOptions(options => +{ + options.SynchronizeWithXmlConvert = true; +}); +using var provider = services.BuildServiceProvider(); +Console.WriteLine("MVC Core XML formatters configured."); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationInputFormatter.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationInputFormatter.md index 69c595591..b4edc7d5b 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationInputFormatter.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationInputFormatter.md @@ -7,24 +7,19 @@ example: The following example demonstrates how to construct an and inspect its supported media types and encodings. ```csharp +// Program.cs using System; using System.Linq; using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml; using Cuemon.Xml.Serialization.Formatters; -namespace DocfxExamples; - -public class XmlSerializationInputFormatterExample -{ - public void Demonstrate() - { - var options = new XmlFormatterOptions(); - var formatter = new XmlSerializationInputFormatter(options); - - Console.WriteLine($"Supported media types: {string.Join(", ", formatter.SupportedMediaTypes)}"); - Console.WriteLine($"Supported encodings: {string.Join(", ", formatter.SupportedEncodings.Select(e => e.WebName))}"); - -} -} +var options = new XmlFormatterOptions(); +var formatter = new XmlSerializationInputFormatter(options); +Console.WriteLine($"Supported media types: {string.Join(", ", formatter.SupportedMediaTypes)}"); +Console.WriteLine($"Supported encodings: {string.Join(", ", formatter.SupportedEncodings.Select(e => e.WebName))}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationMvcOptionsSetup.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationMvcOptionsSetup.md index c8c3882b8..5b7c41dcd 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationMvcOptionsSetup.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationMvcOptionsSetup.md @@ -7,27 +7,23 @@ example: The following example demonstrates how adds XML serialization formatters to . ```csharp +// Program.cs using System; using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; -namespace MyApp.Examples -{ - public static class XmlSerializationMvcOptionsSetupExample - { - public static void Demonstrate() - { - var formatterOptions = Options.Create(new XmlFormatterOptions()); - var setup = new XmlSerializationMvcOptionsSetup(formatterOptions); - var mvcOptions = new MvcOptions(); +var formatterOptions = Options.Create(new XmlFormatterOptions()); +var setup = new XmlSerializationMvcOptionsSetup(formatterOptions); +var mvcOptions = new MvcOptions(); - setup.Configure(mvcOptions); +setup.Configure(mvcOptions); - Console.WriteLine(mvcOptions.InputFormatters.Count); - Console.WriteLine(mvcOptions.OutputFormatters.Count); - } - } -} +Console.WriteLine(mvcOptions.InputFormatters.Count); +Console.WriteLine(mvcOptions.OutputFormatters.Count); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationOutputFormatter.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationOutputFormatter.md index 0bea57529..6700e6749 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationOutputFormatter.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationOutputFormatter.md @@ -7,24 +7,19 @@ example: The following example demonstrates how to construct an and inspect its supported media types and encodings. ```csharp +// Program.cs using System; using System.Linq; using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml; using Cuemon.Xml.Serialization.Formatters; -namespace DocfxExamples; - -public class XmlSerializationOutputFormatterExample -{ - public void Demonstrate() - { - var options = new XmlFormatterOptions(); - var formatter = new XmlSerializationOutputFormatter(options); - - Console.WriteLine($"Supported media types: {string.Join(", ", formatter.SupportedMediaTypes)}"); - Console.WriteLine($"Supported encodings: {string.Join(", ", formatter.SupportedEncodings.Select(e => e.WebName))}"); - -} -} +var options = new XmlFormatterOptions(); +var formatter = new XmlSerializationOutputFormatter(options); +Console.WriteLine($"Supported media types: {string.Join(", ", formatter.SupportedMediaTypes)}"); +Console.WriteLine($"Supported encodings: {string.Join(", ", formatter.SupportedEncodings.Select(e => e.WebName))}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.RazorPages.PageBaseExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.RazorPages.PageBaseExtensions.md index 50191b025..65d26d37e 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.RazorPages.PageBaseExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.RazorPages.PageBaseExtensions.md @@ -4,22 +4,51 @@ example: - *content --- -The following example demonstrates how to resolve application-base URLs and CDN URLs for static resources from a Razor Page model. +The following example demonstrates how to resolve application-base URLs and CDN URLs for static resources from a Razor Page model. The sample configures application and CDN tag-helper options, creates a PageBase with request services, and prints the resolved static-resource URLs. ```csharp +// Program.cs +using System; +using System.Threading.Tasks; +using Cuemon.AspNetCore.Razor.TagHelpers; using Cuemon.Extensions.AspNetCore.Mvc.RazorPages; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.Extensions.DependencyInjection; -namespace MyApp.Examples; +var services = new ServiceCollection(); +services.Configure(options => +{ + options.Scheme = ProtocolUriScheme.Relative; + options.BaseUrl = "static.cuemon.net"; +}); +services.Configure(options => +{ + options.Scheme = ProtocolUriScheme.Https; + options.BaseUrl = "nblcdn.net"; +}); -public class PageBaseExtensionsExample +using var provider = services.BuildServiceProvider(); +var page = new ExamplePage { - public void Demonstrate(PageBase pageModel) + PageContext = new PageContext { - string appScript = pageModel.GetAppUrl("js/site.js"); - string cdnImage = pageModel.GetCdnUrl("images/logo.png"); + HttpContext = new DefaultHttpContext { RequestServices = provider } + } +}; -} -} +Console.WriteLine(page.GetAppUrl("js/site.js")); +Console.WriteLine(page.GetCdnUrl("images/logo.png")); +public sealed class ExamplePage : PageBase +{ + public override Task ExecuteAsync() + { + return Task.CompletedTask; + } +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Rendering.HtmlHelperExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Rendering.HtmlHelperExtensions.md index cb2b535cd..9b7f27416 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Rendering.HtmlHelperExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.Rendering.HtmlHelperExtensions.md @@ -4,23 +4,90 @@ example: - *content --- -The following example demonstrates how to conditionally render content based on the current controller and action using `UseWhenView`, and based on the current Razor Page using `UseWhenPage`. +The following example demonstrates how to conditionally render content based on the current controller and action using `UseWhenView`, and based on the current Razor Page using `UseWhenPage`. The example uses a minimal `IHtmlHelper` implementation so it can run outside an MVC view. ```csharp +// Program.cs +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.Encodings.Web; +using System.Threading.Tasks; using Cuemon.Extensions.AspNetCore.Mvc.Rendering; +using Microsoft.AspNetCore.Html; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.AspNetCore.Mvc.ViewFeatures; +using Microsoft.AspNetCore.Routing; -namespace MyApp.Examples; +var routeData = new RouteData(); +routeData.Values["controller"] = "Home"; +routeData.Values["action"] = "Index"; +routeData.Values["page"] = "Contact"; -public class HtmlHelperExtensionsExample +var helper = new HtmlHelperStub { - public void Demonstrate(IHtmlHelper helper) + ViewContext = new ViewContext { - var showBanner = helper.UseWhenView("Index", "Home", () => "
Welcome to the Home Page
"); + HttpContext = new DefaultHttpContext(), + RouteData = routeData, + ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()), + Writer = TextWriter.Null + } +}; - var pageTitle = helper.UseWhenPage("Contact", () => "Contact Us"); +Console.WriteLine(helper.UseWhenView("Index", "Home", () => "
Welcome to the Home Page
")); +Console.WriteLine(helper.UseWhenPage("Contact", () => "Contact Us")); +public sealed class HtmlHelperStub : IHtmlHelper +{ + public ViewContext ViewContext { get; set; } = null!; + public ViewDataDictionary ViewData { get; } = new(new EmptyModelMetadataProvider(), new ModelStateDictionary()); + public Html5DateRenderingMode Html5DateRenderingMode { get; set; } + public string IdAttributeDotReplacement => "."; + public IModelMetadataProvider MetadataProvider { get; } = new EmptyModelMetadataProvider(); + public ITempDataDictionary TempData => throw new NotSupportedException(); + public UrlEncoder UrlEncoder { get; } = UrlEncoder.Default; + public object ViewBag => throw new NotSupportedException(); + public IHtmlContent ActionLink(string linkText, string actionName, string controllerName, string protocol, string hostname, string fragment, object routeValues, object htmlAttributes) => throw new NotSupportedException(); + public IHtmlContent AntiForgeryToken() => throw new NotSupportedException(); + public MvcForm BeginForm(string actionName, string controllerName, object routeValues, FormMethod method, bool? antiforgery, object htmlAttributes) => throw new NotSupportedException(); + public MvcForm BeginRouteForm(string routeName, object routeValues, FormMethod method, bool? antiforgery, object htmlAttributes) => throw new NotSupportedException(); + public IHtmlContent CheckBox(string expression, bool? isChecked, object htmlAttributes) => throw new NotSupportedException(); + public IHtmlContent Display(string expression, string templateName, string htmlFieldName, object additionalViewData) => throw new NotSupportedException(); + public string DisplayName(string expression) => throw new NotSupportedException(); + public string DisplayText(string expression) => throw new NotSupportedException(); + public IHtmlContent DropDownList(string expression, IEnumerable selectList, string optionLabel, object htmlAttributes) => throw new NotSupportedException(); + public IHtmlContent Editor(string expression, string templateName, string htmlFieldName, object additionalViewData) => throw new NotSupportedException(); + public string Encode(object value) => throw new NotSupportedException(); + public string Encode(string value) => throw new NotSupportedException(); + public void EndForm() => throw new NotSupportedException(); + public string FormatValue(object value, string format) => throw new NotSupportedException(); + public string GenerateIdFromName(string fullName) => throw new NotSupportedException(); + public IEnumerable GetEnumSelectList() => throw new NotSupportedException(); + public IEnumerable GetEnumSelectList() where TEnum : struct => throw new NotSupportedException(); + public IEnumerable GetEnumSelectList(Type enumType) => throw new NotSupportedException(); + public IHtmlContent Hidden(string expression, object value, object htmlAttributes) => throw new NotSupportedException(); + public string Id(string expression) => throw new NotSupportedException(); + public IHtmlContent Label(string expression, string labelText, object htmlAttributes) => throw new NotSupportedException(); + public IHtmlContent ListBox(string expression, IEnumerable selectList, object htmlAttributes) => throw new NotSupportedException(); + public string Name(string expression) => throw new NotSupportedException(); + public Task PartialAsync(string partialViewName, object model, ViewDataDictionary viewData) => throw new NotSupportedException(); + public IHtmlContent Password(string expression, object value, object htmlAttributes) => throw new NotSupportedException(); + public IHtmlContent RadioButton(string expression, object value, bool? isChecked, object htmlAttributes) => throw new NotSupportedException(); + public IHtmlContent Raw(string value) => throw new NotSupportedException(); + public IHtmlContent Raw(object value) => throw new NotSupportedException(); + public Task RenderPartialAsync(string partialViewName, object model, ViewDataDictionary viewData) => throw new NotSupportedException(); + public IHtmlContent RouteLink(string linkText, string routeName, string protocol, string hostName, string fragment, object routeValues, object htmlAttributes) => throw new NotSupportedException(); + public IHtmlContent TextArea(string expression, string value, int rows, int columns, object htmlAttributes) => throw new NotSupportedException(); + public IHtmlContent TextBox(string expression, object value, string format, object htmlAttributes) => throw new NotSupportedException(); + public IHtmlContent ValidationMessage(string expression, string message, object htmlAttributes, string tag) => throw new NotSupportedException(); + public IHtmlContent ValidationSummary(bool excludePropertyErrors, string message, object htmlAttributes, string tag) => throw new NotSupportedException(); + public string Value(string expression, string format) => throw new NotSupportedException(); } -} - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.ViewDataDictionaryExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.ViewDataDictionaryExtensions.md index 694ddbc93..3d8425ac9 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.ViewDataDictionaryExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Mvc.ViewDataDictionaryExtensions.md @@ -4,60 +4,98 @@ example: - *content --- -The following example follows the same pattern as the sample MVC app in the test project: controller actions populate breadcrumbs from the current model, and a shared Razor partial reads them back from . Three `RegionController` actions call `AddBreadcrumbs` with a `RegionPageModel` that holds hierarchical labels. A `BreadcrumbPartial` class then retrieves the breadcrumbs via `GetBreadcrumbs` and projects each into a readable string, demonstrating hierarchical navigation-data propagation in ASP.NET Core MVC. +The following example follows the same pattern as the sample MVC app in the test project: controller actions populate breadcrumbs from the current model, and a shared Razor partial reads them back from . Three `RegionController` actions call `AddBreadcrumbs` with a `RegionPageModel` that holds hierarchical labels. An `ExampleRazorPage` then retrieves the breadcrumbs via `GetBreadcrumbs`, and the sample prints each breadcrumb, demonstrating hierarchical navigation-data propagation in ASP.NET Core MVC. ```csharp +// Program.cs +using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; +using Cuemon.AspNetCore.Mvc; using Cuemon.Extensions.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.Razor; +using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; +using Microsoft.AspNetCore.Routing; +using Cuemon.Extensions.AspNetCore.Mvc.DocExamples; -namespace Cuemon.Extensions.AspNetCore.Mvc.DocExamples; +ViewDataDictionaryExtensionsExample.Demonstrate(); -public sealed class RegionController : Controller +namespace Cuemon.Extensions.AspNetCore.Mvc.DocExamples { - public IActionResult Index() + public class RegionController : Controller { - var model = new RegionPageModel("Regions", "Northern Europe", "Danish"); - ViewData.AddBreadcrumbs(this, model, page => page.Labels); - return View(model); - } + public IActionResult Index() + { + var model = new RegionPageModel("Regions", "Northern Europe", "Danish"); + ViewData.AddBreadcrumbs(this, model, page => page.Labels); + return new EmptyResult(); + } - public IActionResult Region(string regionName, string regionDisplayName) - { - var model = new RegionPageModel("Regions", regionDisplayName, "Danish"); - ViewData.AddBreadcrumbs(this, model, page => page.Labels); - return View("CultureCollection", model); - } + public IActionResult Region(string regionName, string regionDisplayName) + { + var model = new RegionPageModel("Regions", regionDisplayName, "Danish"); + ViewData.AddBreadcrumbs(this, model, page => page.Labels); + return new EmptyResult(); + } - public IActionResult Culture(string regionName, string regionDisplayName, string cultureName) - { - var model = new RegionPageModel("Regions", regionDisplayName, cultureName); - ViewData.AddBreadcrumbs(this, model, page => page.Labels); - return View("Culture", model); + public IActionResult Culture(string regionName, string regionDisplayName, string cultureName) + { + var model = new RegionPageModel("Regions", regionDisplayName, cultureName); + ViewData.AddBreadcrumbs(this, model, page => page.Labels); + return new EmptyResult(); + } } -} - -public sealed class BreadcrumbPartial -{ - public IReadOnlyList Render(ViewDataDictionary viewData, IRazorPage currentPage) + public static class ViewDataDictionaryExtensionsExample { - return viewData - .GetBreadcrumbs(currentPage) - .Select(link => $"{link.Label} ({link.ControllerName}/{link.ActionName})") - .ToList(); - } -} + public static void Demonstrate() + { + var controller = new RegionController + { + ControllerContext = new ControllerContext + { + RouteData = new RouteData() + } + }; + controller.ControllerContext.RouteData.Values["controller"] = "Region"; + controller.ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()); -public sealed class RegionPageModel -{ - public RegionPageModel(params string[] labels) + var model = new RegionPageModel("Regions", "Northern Europe", "Danish"); + controller.ViewData.AddBreadcrumbs(controller, model, page => page.Labels); + + var razorPage = new ExampleRazorPage + { + ViewContext = new ViewContext + { + RouteData = controller.ControllerContext.RouteData + } + }; + var breadcrumbs = controller.ViewData.GetBreadcrumbs(razorPage).ToList(); + foreach (var breadcrumb in breadcrumbs) + { + Console.WriteLine($"{breadcrumb.Label} ({breadcrumb.ControllerName}/{breadcrumb.ActionName})"); + } + } + } + public sealed class ExampleRazorPage : RazorPage { - Labels = labels; + public override Task ExecuteAsync() => Task.CompletedTask; } + public sealed class RegionPageModel + { + public RegionPageModel(params string[] labels) + { + Labels = labels; + } - public IReadOnlyList Labels { get; } + public IReadOnlyList Labels { get; } + } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.Converters.JsonConverterCollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.Converters.JsonConverterCollectionExtensions.md index de001e7d2..79d5b5f01 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.Converters.JsonConverterCollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.Converters.JsonConverterCollectionExtensions.md @@ -7,57 +7,56 @@ example: The following example demonstrates how to register ASP.NET Core-specific JSON converters using the class. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; +using System.Text.Json.Serialization.Metadata; using Cuemon.Extensions.AspNetCore.Text.Json.Converters; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; -namespace MyApp.Examples; +var converters = new List(); -public class JsonConverterCollectionExtensionsExample -{ - public void Demonstrate() - { - var converters = new List(); - - // Add converter for IHeaderDictionary - converters.AddHeaderDictionaryConverter(); - - // Add converter for ProblemDetails - converters.AddProblemDetailsConverter(); - - // Add converter for HttpExceptionDescriptor - converters.AddHttpExceptionDescriptorConverter(); - - // Add converter for StringValues - converters.AddStringValuesConverter(); +// Add converter for IHeaderDictionary +converters.AddHeaderDictionaryConverter(); - var options = new JsonSerializerOptions(); - foreach (var converter in converters) - { - options.Converters.Add(converter); +// Add converter for ProblemDetails +converters.AddProblemDetailsConverter(); - // Example: serialize a HeaderDictionary - var headers = new HeaderDictionary - { - { "X-Custom", "value1" }, - { "X-Another", "value2" } - }; +// Add converter for HttpExceptionDescriptor +converters.AddHttpExceptionDescriptorConverter(); - string json = JsonSerializer.Serialize(headers, options); - Console.WriteLine(json); - // Output: {"X-Custom":"value1","X-Another":"value2"} +// Add converter for StringValues +converters.AddStringValuesConverter(); - // Example: serialize StringValues - var values = new StringValues(new[] { "a", "b", "c" }); - string svJson = JsonSerializer.Serialize(values, options); - Console.WriteLine(svJson); - // Output: ["a","b","c"] - -}} +var options = new JsonSerializerOptions +{ + TypeInfoResolver = new DefaultJsonTypeInfoResolver() +}; +foreach (var converter in converters) +{ + options.Converters.Add(converter); } +// Example: serialize a HeaderDictionary +var headers = new HeaderDictionary +{ + { "X-Custom", "value1" }, + { "X-Another", "value2" } +}; + +string json = JsonSerializer.Serialize(headers, options); +Console.WriteLine(json); +// Output: {"X-Custom":"value1","X-Another":"value2"} + +// Example: serialize StringValues +var values = new StringValues(new[] { "a", "b", "c" }); +string svJson = JsonSerializer.Serialize(values, options); +Console.WriteLine(svJson); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.Formatters.ServiceCollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.Formatters.ServiceCollectionExtensions.md index f6c60d615..5fe0067aa 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.Formatters.ServiceCollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.Formatters.ServiceCollectionExtensions.md @@ -7,23 +7,32 @@ example: The following example demonstrates how to register JSON formatter options and a JSON-based exception response formatter in the ASP.NET Core service collection. ```csharp +// Program.cs +using System; +using System.Collections.Generic; +using System.Linq; +using Cuemon.AspNetCore.Diagnostics; +using Cuemon.Diagnostics; using Cuemon.Extensions.AspNetCore.Text.Json.Formatters; +using Cuemon.Extensions.Text.Json.Formatters; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; -namespace MyApp.Examples; - -public class JsonFormattersServiceCollectionExtensionsExample +var services = new ServiceCollection(); +services.AddJsonFormatterOptions(options => { - public void ConfigureServices(IServiceCollection services) - { - services.AddJsonFormatterOptions(options => - { - options.SensitivityDetails = Cuemon.Diagnostics.FaultSensitivityDetails.All; - }); - - services.AddJsonExceptionResponseFormatter(); + options.SensitivityDetails = FaultSensitivityDetails.All; +}); +services.AddJsonExceptionResponseFormatter(); -} -} +using var provider = services.BuildServiceProvider(); +var options = provider.GetRequiredService>().Value; +var formatters = provider.GetServices().ToList(); +Console.WriteLine(options.SensitivityDetails); +Console.WriteLine(formatters.Count); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.MinimalJsonOptions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.MinimalJsonOptions.md index 99796d42a..dfef67d9a 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.MinimalJsonOptions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.MinimalJsonOptions.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to register in an ASP.NET Core application to propagate custom into the minimal API JSON serialization pipeline. ```csharp +// Program.cs using System; using System.Text.Json; using Cuemon.Extensions.AspNetCore.Text.Json; @@ -15,32 +16,26 @@ using Microsoft.AspNetCore.Http.Json; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -namespace MyApp.Examples; +var services = new ServiceCollection(); -public class MinimalJsonOptionsExample +// Configure JsonFormatterOptions with custom settings +services.Configure(o => { - public void Demonstrate() - { - var services = new ServiceCollection(); + o.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; + o.Settings.WriteIndented = false; +}); - // Configure JsonFormatterOptions with custom settings - services.Configure(o => - { - o.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; - o.Settings.WriteIndented = false; - }); +// Register MinimalJsonOptions so that JsonOptions (minimal API) +// receives the same settings and converters +services.AddTransient, MinimalJsonOptions>(); - // Register MinimalJsonOptions so that JsonOptions (minimal API) - // receives the same settings and converters - services.AddTransient, MinimalJsonOptions>(); - - var provider = services.BuildServiceProvider(); - var jsonOptions = provider.GetRequiredService>(); - - Console.WriteLine($"Property naming policy: {jsonOptions.Value.SerializerOptions.PropertyNamingPolicy}"); // CamelCase - Console.WriteLine($"Write indented: {jsonOptions.Value.SerializerOptions.WriteIndented}"); // False - -} -} +var provider = services.BuildServiceProvider(); +var jsonOptions = provider.GetRequiredService>(); +Console.WriteLine($"Property naming policy: {jsonOptions.Value.SerializerOptions.PropertyNamingPolicy}"); // CamelCase +Console.WriteLine($"Write indented: {jsonOptions.Value.SerializerOptions.WriteIndented}"); // False ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.ServiceCollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.ServiceCollectionExtensions.md index a872fdb41..6c4f91dd8 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.ServiceCollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Text.Json.ServiceCollectionExtensions.md @@ -7,21 +7,29 @@ example: The following example demonstrates how to register minimal JSON formatter options using `AddMinimalJsonOptions` in the ASP.NET Core service collection. ```csharp +// Program.cs +using System; +using Cuemon.Diagnostics; using Cuemon.Extensions.AspNetCore.Text.Json; +using Cuemon.Extensions.Text.Json.Formatters; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; -namespace MyApp.Examples; - -public class TextJsonServiceCollectionExtensionsExample +var services = new ServiceCollection(); +services.Configure(options => { - public void ConfigureServices(IServiceCollection services) - { - services.AddMinimalJsonOptions(options => - { - options.SensitivityDetails = Cuemon.Diagnostics.FaultSensitivityDetails.All; - }); - -} -} + options.SensitivityDetails = FaultSensitivityDetails.All; +}); +services.AddMinimalJsonOptions(options => +{ + options.SensitivityDetails = FaultSensitivityDetails.All; +}); +using var provider = services.BuildServiceProvider(); +var options = provider.GetRequiredService>().Value; +Console.WriteLine(options.SensitivityDetails); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Xml.Converters.XmlConverterExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Xml.Converters.XmlConverterExtensions.md index 1e632e27a..16f924908 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Xml.Converters.XmlConverterExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Xml.Converters.XmlConverterExtensions.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to register ASP.NET Core-friendly XML converters on an instance. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon.Diagnostics; @@ -14,33 +15,28 @@ using Cuemon.Extensions.AspNetCore.Xml.Converters; using Cuemon.Xml.Serialization.Converters; using Cuemon.Xml.Serialization; -namespace MyApp.Examples +var converters = new List(); +converters.AddProblemDetailsConverter(); +converters.AddHttpExceptionDescriptorConverter(options => { -public static class XmlConverterExtensionsExample -{ - public static void Demonstrate() - { - var converters = new List(); - converters.AddProblemDetailsConverter(); - converters.AddHttpExceptionDescriptorConverter(options => - { - options.SensitivityDetails = FaultSensitivityDetails.All; - }); - converters.AddStringValuesConverter(); - converters.AddHeaderDictionaryConverter(); - converters.AddQueryCollectionConverter(); - converters.AddFormCollectionConverter(); - converters.AddCookieCollectionConverter(); - - var serializerOptions = new XmlSerializerOptions(); - foreach (var converter in converters) - { - serializerOptions.Converters.Add(converter); - } + options.SensitivityDetails = FaultSensitivityDetails.All; +}); +converters.AddStringValuesConverter(); +converters.AddHeaderDictionaryConverter(); +converters.AddQueryCollectionConverter(); +converters.AddFormCollectionConverter(); +converters.AddCookieCollectionConverter(); - Console.WriteLine(serializerOptions.Converters.Count); - Console.WriteLine(serializerOptions.Converters[0].CanConvert(typeof(object))); - } -} +var serializerOptions = new XmlSerializerOptions(); +foreach (var converter in converters) +{ + serializerOptions.Converters.Add(converter); } + +Console.WriteLine(serializerOptions.Converters.Count); +Console.WriteLine(serializerOptions.Converters[0].CanConvert(typeof(object))); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Xml.Formatters.ServiceCollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Xml.Formatters.ServiceCollectionExtensions.md index e85218e34..f6451dca8 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Xml.Formatters.ServiceCollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Xml.Formatters.ServiceCollectionExtensions.md @@ -7,23 +7,30 @@ example: The following example demonstrates how to register XML formatter options and an XML-based exception response formatter in the ASP.NET Core service collection. ```csharp +// Program.cs +using System; +using System.Linq; +using Cuemon.AspNetCore.Diagnostics; using Cuemon.Extensions.AspNetCore.Xml.Formatters; +using Cuemon.Xml.Serialization.Formatters; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; -namespace MyApp.Examples; - -public class XmlFormattersServiceCollectionExtensionsExample +var services = new ServiceCollection(); +services.AddXmlFormatterOptions(options => { - public void ConfigureServices(IServiceCollection services) - { - services.AddXmlFormatterOptions(options => - { - options.SynchronizeWithXmlConvert = true; - }); - - services.AddXmlExceptionResponseFormatter(); + options.SynchronizeWithXmlConvert = true; +}); +services.AddXmlExceptionResponseFormatter(); -} -} +using var provider = services.BuildServiceProvider(); +var options = provider.GetRequiredService>().Value; +var formatters = provider.GetServices().ToList(); +Console.WriteLine(options.SynchronizeWithXmlConvert); +Console.WriteLine(formatters.Count); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Xml.ServiceCollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Xml.ServiceCollectionExtensions.md index b7da6cff0..300e00e39 100644 --- a/.docfx/api/types/Cuemon.Extensions.AspNetCore.Xml.ServiceCollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.AspNetCore.Xml.ServiceCollectionExtensions.md @@ -7,21 +7,28 @@ example: The following example demonstrates how to register minimal XML formatter options using `AddMinimalXmlOptions` in the ASP.NET Core service collection. ```csharp +// Program.cs +using System; using Cuemon.Extensions.AspNetCore.Xml; +using Cuemon.Xml.Serialization.Formatters; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; -namespace MyApp.Examples; - -public class XmlServiceCollectionExtensionsExample +var services = new ServiceCollection(); +services.Configure(options => { - public void ConfigureServices(IServiceCollection services) - { - services.AddMinimalXmlOptions(options => - { - options.SynchronizeWithXmlConvert = true; - }); - -} -} + options.SynchronizeWithXmlConvert = true; +}); +services.AddMinimalXmlOptions(options => +{ + options.SynchronizeWithXmlConvert = true; +}); +using var provider = services.BuildServiceProvider(); +var options = provider.GetRequiredService>().Value; +Console.WriteLine(options.SynchronizeWithXmlConvert); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.ByteExtensions.md b/.docfx/api/types/Cuemon.Extensions.ByteExtensions.md index 9e0028f72..fe774cd67 100644 --- a/.docfx/api/types/Cuemon.Extensions.ByteExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.ByteExtensions.md @@ -7,32 +7,28 @@ example: The following example demonstrates how to use the extension methods to convert byte arrays to various string representations and detect Unicode encoding. ```csharp +// Program.cs using System; using System.Text; using Cuemon.Extensions; -namespace MyApp.Examples; +byte[] data = { 0xEF, 0xBB, 0xBF, 0x48, 0x65, 0x6C, 0x6C, 0x6F }; +string text = data.ToEncodedString(); +string hex = data.ToHexadecimalString(); +string binary = data.ToBinaryString(); +string base64 = data.ToBase64String(); +string urlBase64 = data.ToUrlEncodedBase64String(); -public static class ByteExtensionsExample -{ - public static void Demonstrate() - { - byte[] data = { 0xEF, 0xBB, 0xBF, 0x48, 0x65, 0x6C, 0x6C, 0x6F }; - string text = data.ToEncodedString(); - string hex = data.ToHexadecimalString(); - string binary = data.ToBinaryString(); - string base64 = data.ToBase64String(); - string urlBase64 = data.ToUrlEncodedBase64String(); - - data.TryDetectUnicodeEncoding(out Encoding detectedEncoding); - - Console.WriteLine(text); - Console.WriteLine(hex); - Console.WriteLine(binary); - Console.WriteLine(base64); - Console.WriteLine(urlBase64); - Console.WriteLine(detectedEncoding?.WebName ?? "unknown"); - } -} +data.TryDetectUnicodeEncoding(out Encoding detectedEncoding); +Console.WriteLine(text); +Console.WriteLine(hex); +Console.WriteLine(binary); +Console.WriteLine(base64); +Console.WriteLine(urlBase64); +Console.WriteLine(detectedEncoding?.WebName ?? "unknown"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.CharExtensions.md b/.docfx/api/types/Cuemon.Extensions.CharExtensions.md index 22011386e..45e297d61 100644 --- a/.docfx/api/types/Cuemon.Extensions.CharExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.CharExtensions.md @@ -7,26 +7,22 @@ example: The following example demonstrates converting sequences of values to strings and string sequences using the [ToEnumerable](https://docs.cuemon.net/api/extensions/dotnet/Cuemon.Extensions.CharExtensions.html#Cuemon_Extensions_CharExtensions_ToEnumerable_System_Collections_Generic_IEnumerable_System_Char__) and [FromChars](https://docs.cuemon.net/api/extensions/dotnet/Cuemon.Extensions.CharExtensions.html#Cuemon_Extensions_CharExtensions_FromChars_System_Collections_Generic_IEnumerable_System_Char__) extension methods. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; using Cuemon.Extensions; -namespace MyApp.Examples; - -public static class CharExtensionsExample -{ - public static void Demonstrate() - { - char[] chars = "Hello World".ToCharArray(); - string text = chars.FromChars(); - IEnumerable strings = chars.ToEnumerable(); - string alphabet = Enumerable.Range('A', 26).Select(c => (char)c).FromChars(); - - Console.WriteLine(text); - Console.WriteLine(strings.Count()); - Console.WriteLine(alphabet); - } -} +char[] chars = "Hello World".ToCharArray(); +string text = chars.FromChars(); +IEnumerable strings = chars.ToEnumerable(); +string alphabet = Enumerable.Range('A', 26).Select(c => (char)c).FromChars(); +Console.WriteLine(text); +Console.WriteLine(strings.Count()); +Console.WriteLine(alphabet); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Collections.Generic.CollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.Collections.Generic.CollectionExtensions.md index dda0843c7..dffc1a3f4 100644 --- a/.docfx/api/types/Cuemon.Extensions.Collections.Generic.CollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Collections.Generic.CollectionExtensions.md @@ -7,24 +7,21 @@ example: `CollectionExtensions` provides extension methods for `ICollection` including `AddRange` for bulk insertion and `ToPartitioner` for batched iteration. This example creates an empty `List`, calls `AddRange(1, 2, 3, 4)` to insert four integers at once, then creates a partitioner with `ToPartitioner(2)` to split elements into batches of two. Console output confirms the element count (`4`) and the partition count (`2`), demonstrating batch processing of collection contents. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; using Cuemon.Extensions.Collections.Generic; -namespace MyApp.Examples; +ICollection values = new List(); +values.AddRange(1, 2, 3, 4); -public static class CollectionExtensionsExample -{ - public static void Demonstrate() - { - ICollection values = new List(); - values.AddRange(1, 2, 3, 4); +var partitioner = values.ToPartitioner(2); - var partitioner = values.ToPartitioner(2); - - Console.WriteLine(values.Count); - Console.WriteLine(partitioner.Count()); - } -} +Console.WriteLine(values.Count); +Console.WriteLine(partitioner.Count()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Collections.Generic.DictionaryExtensions.md b/.docfx/api/types/Cuemon.Extensions.Collections.Generic.DictionaryExtensions.md index 73747d359..08dbe0fef 100644 --- a/.docfx/api/types/Cuemon.Extensions.Collections.Generic.DictionaryExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Collections.Generic.DictionaryExtensions.md @@ -7,39 +7,35 @@ example: `DictionaryExtensions` provides extension methods for `IDictionary` including `CopyTo`, `TryAdd` with a predicate, `AddOrUpdate`, `GetValueOrDefault` with a factory fallback, and `TryGetValueOrFallback`. This example creates a source dictionary with `"alpha": 1` and `"beta": 2`, copies entries to a new dictionary via `CopyTo`, conditionally adds `"gamma": 3` only if the key does not exist, updates `"beta"` to `20`, retrieves `"delta"` with a fallback factory returning `42`, and resolves a missing key using `TryGetValueOrFallback`. Console output confirms the destination count, fallback values, and the formatted key-value pairs. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; using Cuemon.Extensions.Collections.Generic; -namespace MyApp.Examples +IDictionary source = new Dictionary { - public static class DictionaryExtensionsExample - { - public static void Demonstrate() - { - IDictionary source = new Dictionary - { - ["alpha"] = 1, - ["beta"] = 2 - }; - - var destination = new Dictionary(); - source.CopyTo(destination); - - source.TryAdd("gamma", 3, dictionary => !dictionary.ContainsKey("gamma")); - source.AddOrUpdate("beta", 20); - - var configuredFallback = source.GetValueOrDefault("delta", () => 42); - var foundFallback = source.TryGetValueOrFallback("missing", keys => keys.OrderBy(key => key).First(), out var fallbackValue); - var rows = source.ToEnumerable().Select(pair => $"{pair.Key}:{pair.Value}"); - - Console.WriteLine(destination.Count); - Console.WriteLine(configuredFallback); - Console.WriteLine(foundFallback); - Console.WriteLine(fallbackValue); - Console.WriteLine(string.Join(", ", rows)); - } - } -} + ["alpha"] = 1, + ["beta"] = 2 +}; + +var destination = new Dictionary(); +source.CopyTo(destination); + +source.TryAdd("gamma", 3, dictionary => !dictionary.ContainsKey("gamma")); +source.AddOrUpdate("beta", 20); + +var configuredFallback = source.GetValueOrDefault("delta", () => 42); +var foundFallback = source.TryGetValueOrFallback("missing", keys => keys.OrderBy(key => key).First(), out var fallbackValue); +var rows = source.ToEnumerable().Select(pair => $"{pair.Key}:{pair.Value}"); + +Console.WriteLine(destination.Count); +Console.WriteLine(configuredFallback); +Console.WriteLine(foundFallback); +Console.WriteLine(fallbackValue); +Console.WriteLine(string.Join(", ", rows)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Collections.Generic.EnumerableExtensions.md b/.docfx/api/types/Cuemon.Extensions.Collections.Generic.EnumerableExtensions.md index 27b9eef7d..ac9a616e0 100644 --- a/.docfx/api/types/Cuemon.Extensions.Collections.Generic.EnumerableExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Collections.Generic.EnumerableExtensions.md @@ -7,48 +7,44 @@ example: `EnumerableExtensions` provides extension methods for `IEnumerable` including chunking, shuffling, ordering, pagination, and materialization. This example starts with an `int[] { 4, 1, 3, 2 }` and applies `Chunk(2)` to split into batches, `Shuffle` with both random and deterministic seeds, `OrderAscending` and `OrderDescending` for sorted output, `RandomOrDefault` for element selection, and `Yield` to wrap a single value. It also demonstrates `ToDictionary` from `KeyValuePair` sequences, `ToPartitioner` for partitioned iteration, and `ToPagination`/`ToPaginationList` for page-based access. Console output confirms each operation's results, such as chunk count (`2`), sorted order (`1, 2, 3, 4`), and dictionary value for key `"beta"`. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; using Cuemon.Extensions.Collections.Generic; using CuemonEnumerableExtensions = Cuemon.Extensions.Collections.Generic.EnumerableExtensions; -namespace MyApp.Examples +var values = new[] { 4, 1, 3, 2 }; +var chunked = CuemonEnumerableExtensions.Chunk(values, 2).ToList(); +var shuffled = CuemonEnumerableExtensions.Shuffle(values).ToArray(); +var deterministicShuffle = CuemonEnumerableExtensions.Shuffle(values, (min, max) => min).ToArray(); +var ascending = values.OrderAscending().ToArray(); +var ascendingWithComparer = values.OrderAscending(Comparer.Default).ToArray(); +var descending = CuemonEnumerableExtensions.OrderDescending(values).ToArray(); +var random = values.RandomOrDefault(); +var yielded = 5.Yield().Single(); +var dictionary = CuemonEnumerableExtensions.ToDictionary(new[] { - public static class EnumerableExtensionsExample - { - public static void Demonstrate() - { - var values = new[] { 4, 1, 3, 2 }; - var chunked = CuemonEnumerableExtensions.Chunk(values, 2).ToList(); - var shuffled = CuemonEnumerableExtensions.Shuffle(values).ToArray(); - var deterministicShuffle = CuemonEnumerableExtensions.Shuffle(values, (min, max) => min).ToArray(); - var ascending = values.OrderAscending().ToArray(); - var ascendingWithComparer = values.OrderAscending(Comparer.Default).ToArray(); - var descending = CuemonEnumerableExtensions.OrderDescending(values).ToArray(); - var random = values.RandomOrDefault(); - var yielded = 5.Yield().Single(); - var dictionary = CuemonEnumerableExtensions.ToDictionary(new[] - { - new KeyValuePair("alpha", 1), - new KeyValuePair("beta", 2) - }); - var partitioner = values.ToPartitioner(2).ToList(); - var pagination = values.ToPagination(() => values.Length).ToList(); - var paginationList = values.ToPaginationList(() => values.Length); + new KeyValuePair("alpha", 1), + new KeyValuePair("beta", 2) +}); +var partitioner = values.ToPartitioner(2).ToList(); +var pagination = values.ToPagination(() => values.Length).ToList(); +var paginationList = values.ToPaginationList(() => values.Length); - Console.WriteLine(chunked.Count); - Console.WriteLine(shuffled.Length + deterministicShuffle.Length); - Console.WriteLine(string.Join(", ", ascending)); - Console.WriteLine(string.Join(", ", ascendingWithComparer)); - Console.WriteLine(string.Join(", ", descending)); - Console.WriteLine(random); - Console.WriteLine(yielded); - Console.WriteLine(dictionary["beta"]); - Console.WriteLine(partitioner.Count); - Console.WriteLine(pagination.Count); - Console.WriteLine(paginationList.Count); - } - } -} +Console.WriteLine(chunked.Count); +Console.WriteLine(shuffled.Length + deterministicShuffle.Length); +Console.WriteLine(string.Join(", ", ascending)); +Console.WriteLine(string.Join(", ", ascendingWithComparer)); +Console.WriteLine(string.Join(", ", descending)); +Console.WriteLine(random); +Console.WriteLine(yielded); +Console.WriteLine(dictionary["beta"]); +Console.WriteLine(partitioner.Count); +Console.WriteLine(pagination.Count); +Console.WriteLine(paginationList.Count); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Collections.Generic.ListExtensions.md b/.docfx/api/types/Cuemon.Extensions.Collections.Generic.ListExtensions.md index 6f44d4437..182ae5637 100644 --- a/.docfx/api/types/Cuemon.Extensions.Collections.Generic.ListExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Collections.Generic.ListExtensions.md @@ -53,3 +53,7 @@ namespace DocExamples } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Collections.Generic.QueueExtensions.md b/.docfx/api/types/Cuemon.Extensions.Collections.Generic.QueueExtensions.md index 194c63626..b4e1bf482 100644 --- a/.docfx/api/types/Cuemon.Extensions.Collections.Generic.QueueExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Collections.Generic.QueueExtensions.md @@ -7,27 +7,24 @@ example: The following example shows how to use `TryPeek` to safely inspect the front of a `Queue` without removing the item. It demonstrates that successive calls return the same element. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon.Extensions.Collections.Generic; -namespace Cuemon.Extensions.Collections.Generic; +var queue = new Queue(); +queue.Enqueue("first"); +queue.Enqueue("second"); -public class QueueExtensionsExample +if (queue.TryPeek(out string result)) { - public void Demonstrate() - { - var queue = new Queue(); - queue.Enqueue("first"); - queue.Enqueue("second"); - - if (queue.TryPeek(out string result)) - { - Console.WriteLine($"Peeked: {result}"); - } - - queue.TryPeek(out string same); - Console.WriteLine(same); - } + Console.WriteLine($"Peeked: {result}"); } + +queue.TryPeek(out string same); +Console.WriteLine(same); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Collections.Generic.StackExtensions.md b/.docfx/api/types/Cuemon.Extensions.Collections.Generic.StackExtensions.md index 7bfa83403..cdd8df8e0 100644 --- a/.docfx/api/types/Cuemon.Extensions.Collections.Generic.StackExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Collections.Generic.StackExtensions.md @@ -7,30 +7,27 @@ example: The following example shows how to use `TryPop` to safely remove items from a `Stack`. It demonstrates popping until the stack is empty, after which `TryPop` returns `false` and sets the result to `null`. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon.Extensions.Collections.Generic; -namespace Cuemon.Extensions.Collections.Generic; +var stack = new Stack(); +stack.Push("bottom"); +stack.Push("top"); -public class StackExtensionsExample +if (stack.TryPop(out string item)) { - public void Demonstrate() - { - var stack = new Stack(); - stack.Push("bottom"); - stack.Push("top"); - - if (stack.TryPop(out string item)) - { - Console.WriteLine($"Popped: {item}"); - } + Console.WriteLine($"Popped: {item}"); +} - stack.TryPop(out string next); - Console.WriteLine(next); +stack.TryPop(out string next); +Console.WriteLine(next); - stack.TryPop(out string empty); - Console.WriteLine(empty == null); - } -} +stack.TryPop(out string empty); +Console.WriteLine(empty == null); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Collections.Specialized.DictionaryExtensions.md b/.docfx/api/types/Cuemon.Extensions.Collections.Specialized.DictionaryExtensions.md index 76704548c..6466c8d9a 100644 --- a/.docfx/api/types/Cuemon.Extensions.Collections.Specialized.DictionaryExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Collections.Specialized.DictionaryExtensions.md @@ -7,41 +7,36 @@ example: `DictionaryExtensions` in the `Specialized` namespace converts `Dictionary` into `NameValueCollection` instances, joining multi-valued keys with a configurable delimiter. This example creates a dictionary with `"colors": ["red", "green", "blue"]` and `"sizes": ["small", "large"]`, calls `ToNameValueCollection()` to produce a collection using the default comma delimiter, then calls `ToNameValueCollection` with a custom `";"` delimiter via an options delegate. Console output confirms that `"colors"` becomes `"red,green,blue"` with the default delimiter and `"red;green;blue"` with the custom semicolon delimiter. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Collections.Specialized; using Cuemon; using Cuemon.Extensions.Collections.Specialized; -namespace MyApp.Extensions.Collections.Specialized +// Create a dictionary with string array values +var source = new Dictionary { - public class DictionaryExtensionsExample - { - public void Demonstrate() - { - // Create a dictionary with string array values - var source = new Dictionary - { - ["colors"] = new[] { "red", "green", "blue" }, - ["sizes"] = new[] { "small", "large" } - }; - - // Convert to a NameValueCollection (default delimiter is comma) - NameValueCollection nvc = source.ToNameValueCollection(); - - Console.WriteLine(nvc["colors"]); // "red,green,blue" - Console.WriteLine(nvc["sizes"]); // "small,large" - - // Convert with a custom delimiter - NameValueCollection nvcSemicolon = source.ToNameValueCollection(o => - { - o.Delimiter = ";"; - }); - - Console.WriteLine(nvcSemicolon["colors"]); // "red;green;blue" - Console.WriteLine(nvcSemicolon["sizes"]); // "small;large" - -}} -} + ["colors"] = new[] { "red", "green", "blue" }, + ["sizes"] = new[] { "small", "large" } +}; +// Convert to a NameValueCollection (default delimiter is comma) +NameValueCollection nvc = source.ToNameValueCollection(); + +Console.WriteLine(nvc["colors"]); // "red,green,blue" +Console.WriteLine(nvc["sizes"]); // "small,large" + +// Convert with a custom delimiter +NameValueCollection nvcSemicolon = source.ToNameValueCollection(o => +{ + o.Delimiter = ";"; +}); + +Console.WriteLine(nvcSemicolon["colors"]); // "red;green;blue" +Console.WriteLine(nvcSemicolon["sizes"]); // "small;large" ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Collections.Specialized.NameValueCollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.Collections.Specialized.NameValueCollectionExtensions.md index f242f2daa..4dea25cb0 100644 --- a/.docfx/api/types/Cuemon.Extensions.Collections.Specialized.NameValueCollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Collections.Specialized.NameValueCollectionExtensions.md @@ -7,54 +7,49 @@ example: `NameValueCollectionExtensions` provides extension methods for `NameValueCollection` including case-insensitive key lookup and conversion to `IDictionary`. This example creates a collection with `"name": "John Doe"` and `"tag": ["dotnet", "csharp"]` (duplicate key), then calls `ContainsKey("NAME")` to verify case-insensitive matching and `ToDictionary()` to materialize entries as a dictionary with string array values. It also demonstrates `ToDictionary` with a custom `";"` delimiter for splitting multi-valued entries. Console output confirms boolean key-lookup results, the individual array elements `"dotnet"` and `"csharp"`, and the array length when using the custom delimiter. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Collections.Specialized; using Cuemon; using Cuemon.Extensions.Collections.Specialized; -namespace MyApp.Extensions.Collections.Specialized +// Create a NameValueCollection with some query parameters +var nvc = new NameValueCollection { - public class NameValueCollectionExtensionsExample - { - public void Demonstrate() - { - // Create a NameValueCollection with some query parameters - var nvc = new NameValueCollection - { - { "name", "John Doe" }, - { "tag", "dotnet" }, - { "tag", "csharp" } - }; - - // Check if a key exists (case-insensitive) - bool hasName = nvc.ContainsKey("NAME"); - Console.WriteLine(hasName); // True - - bool hasMissing = nvc.ContainsKey("missing"); - Console.WriteLine(hasMissing); // False - - // Convert to a dictionary with string[] values - IDictionary dict = nvc.ToDictionary(); - - Console.WriteLine(dict["name"][0]); // "John Doe" - Console.WriteLine(dict["tag"][0]); // "dotnet" - Console.WriteLine(dict["tag"][1]); // "csharp" - - // Use a custom delimiter for splitting values - var nvcSemicolon = new NameValueCollection - { - { "items", "a;b;c" } - }; - - IDictionary dictSemicolon = nvcSemicolon.ToDictionary(o => - { - o.Delimiter = ";"; - }); - - Console.WriteLine(dictSemicolon["items"].Length); // 3 - -}} -} + { "name", "John Doe" }, + { "tag", "dotnet" }, + { "tag", "csharp" } +}; +// Check if a key exists (case-insensitive) +bool hasName = nvc.ContainsKey("NAME"); +Console.WriteLine(hasName); // True + +bool hasMissing = nvc.ContainsKey("missing"); +Console.WriteLine(hasMissing); // False + +// Convert to a dictionary with string[] values +IDictionary dict = nvc.ToDictionary(); + +Console.WriteLine(dict["name"][0]); // "John Doe" +Console.WriteLine(dict["tag"][0]); // "dotnet" +Console.WriteLine(dict["tag"][1]); // "csharp" + +// Use a custom delimiter for splitting values +var nvcSemicolon = new NameValueCollection +{ + { "items", "a;b;c" } +}; + +IDictionary dictSemicolon = nvcSemicolon.ToDictionary(o => +{ + o.Delimiter = ";"; +}); + +Console.WriteLine(dictSemicolon["items"].Length); // 3 ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Data.DataReaderExtensions.md b/.docfx/api/types/Cuemon.Extensions.Data.DataReaderExtensions.md index 91a69a653..62c9017d4 100644 --- a/.docfx/api/types/Cuemon.Extensions.Data.DataReaderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Data.DataReaderExtensions.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to turn a delimiter-separated reader into row and column transfer objects. ```csharp +// Program.cs using System; using System.IO; using System.Linq; @@ -14,24 +15,20 @@ using System.Text; using Cuemon.Data; using Cuemon.Extensions.Data; -namespace MyApp.Examples; +var csv = "Id,Name\n1,Alice\n2,Bob"; +using var reader = new DsvDataReader(new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(csv)))); -public static class DataReaderExtensionsExample -{ - public static void Demonstrate() - { - var csv = "Id,Name\n1,Alice\n2,Bob"; - using var reader = new DsvDataReader(new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(csv)))); +var rows = reader.ToRows(); +Console.WriteLine(rows.Count); +Console.WriteLine(rows.ColumnNames.Contains("Name")); - var rows = reader.ToRows(); - Console.WriteLine(rows.Count); - Console.WriteLine(rows.ColumnNames.Contains("Name")); +using var columnReader = new DsvDataReader(new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(csv)))); +columnReader.Read(); +var columns = columnReader.ToColumns(); - using var columnReader = new DsvDataReader(new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(csv)))); - columnReader.Read(); - var columns = columnReader.ToColumns(); - - Console.WriteLine(columns.Count); - } -} +Console.WriteLine(columns.Count); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Data.DbTypeExtensions.md b/.docfx/api/types/Cuemon.Extensions.Data.DbTypeExtensions.md index 028277c77..5cd34a93c 100644 --- a/.docfx/api/types/Cuemon.Extensions.Data.DbTypeExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Data.DbTypeExtensions.md @@ -34,3 +34,7 @@ public class DbTypeExtensionsExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Data.Integrity.AssemblyExtensions.md b/.docfx/api/types/Cuemon.Extensions.Data.Integrity.AssemblyExtensions.md index b79b5e4a7..1e7ad98b4 100644 --- a/.docfx/api/types/Cuemon.Extensions.Data.Integrity.AssemblyExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Data.Integrity.AssemblyExtensions.md @@ -37,3 +37,7 @@ public class AssemblyExtensionsExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Data.Integrity.ChecksumBuilderExtensions.md b/.docfx/api/types/Cuemon.Extensions.Data.Integrity.ChecksumBuilderExtensions.md index 4427f35b8..d92d09fc4 100644 --- a/.docfx/api/types/Cuemon.Extensions.Data.Integrity.ChecksumBuilderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Data.Integrity.ChecksumBuilderExtensions.md @@ -7,43 +7,40 @@ example: The following example demonstrates how to use `ChecksumBuilderExtensions` to fluently combine typed values directly on a `ChecksumBuilder` instance. ```csharp +// Program.cs using System; using Cuemon.Data.Integrity; using Cuemon.Extensions.Data.Integrity; using Cuemon.Security; -namespace MyApp.Examples; +// Create a ChecksumBuilder and use extension methods directly +var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); -public class Example -{ - public void Run() - { - // Create a ChecksumBuilder and use extension methods directly - var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128()); +// Extension methods allow combining typed values without a Decorator wrapper +builder.CombineWith(42); // int overload +builder.CombineWith(3.14); // double overload +builder.CombineWith("data"); // string overload - // Extension methods allow combining typed values without a Decorator wrapper - builder.CombineWith(42); // int overload - builder.CombineWith(3.14); // double overload - builder.CombineWith("data"); // string overload +Console.WriteLine($"Combined checksum: {builder}"); - Console.WriteLine($"Combined checksum: {builder}"); +// Works with all numeric types +var checksum = new ChecksumBuilder(() => HashFactory.CreateFnv32()) + .CombineWith((short)1) + .CombineWith(2u) + .CombineWith(3L) + .CombineWith(4.0f) + .CombineWith(5ul); - // Works with all numeric types - var checksum = new ChecksumBuilder(() => HashFactory.CreateFnv32()) - .CombineWith((short)1) - .CombineWith(2u) - .CombineWith(3L) - .CombineWith(4.0f) - .CombineWith(5ul); +Console.WriteLine($"All types: {checksum}"); - Console.WriteLine($"All types: {checksum}"); +// Combine with byte arrays +var withBytes = new ChecksumBuilder(() => HashFactory.CreateFnv32()) + .CombineWith(new byte[] { 0x01, 0x02, 0x03 }); - // Combine with byte arrays - var withBytes = new ChecksumBuilder(() => HashFactory.CreateFnv32()) - .CombineWith(new byte[] { 0x01, 0x02, 0x03 }); - - Console.WriteLine($"With bytes: {withBytes}"); - } -} +Console.WriteLine($"With bytes: {withBytes}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Data.Integrity.DateTimeExtensions.md b/.docfx/api/types/Cuemon.Extensions.Data.Integrity.DateTimeExtensions.md index 106153c79..a383813f3 100644 --- a/.docfx/api/types/Cuemon.Extensions.Data.Integrity.DateTimeExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Data.Integrity.DateTimeExtensions.md @@ -50,3 +50,7 @@ public class DateTimeExtensionsExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Data.Integrity.FileInfoExtensions.md b/.docfx/api/types/Cuemon.Extensions.Data.Integrity.FileInfoExtensions.md index 5dfb838b9..0d71c3d02 100644 --- a/.docfx/api/types/Cuemon.Extensions.Data.Integrity.FileInfoExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Data.Integrity.FileInfoExtensions.md @@ -47,3 +47,7 @@ public class FileInfoExtensionsExample } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Data.QueryFormatExtensions.md b/.docfx/api/types/Cuemon.Extensions.Data.QueryFormatExtensions.md index 8377d0edb..a5948f4dc 100644 --- a/.docfx/api/types/Cuemon.Extensions.Data.QueryFormatExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Data.QueryFormatExtensions.md @@ -21,23 +21,27 @@ public class QueryFormatExtensionsExample // Embed string values in a delimited format: value, value, value var productIds = new[] { "ALFKI", "BONAP", "FRANS" }; string delimited = QueryFormat.Delimited.Embed(productIds); - Console.WriteLine(delimited); // Output: "ALFKI", "BONAP", "FRANS" + Console.WriteLine(delimited); // Output: ALFKI,BONAP,FRANS // Embed string values with single quotes: 'value', 'value', 'value' string delimitedString = QueryFormat.DelimitedString.Embed(productIds); - Console.WriteLine(delimitedString); // Output: 'ALFKI', 'BONAP', 'FRANS' + Console.WriteLine(delimitedString); // Output: 'ALFKI','BONAP','FRANS' // Embed integer values var ids = new[] { 1, 2, 3, 4, 5 }; string intEmbedded = QueryFormat.Delimited.Embed(ids); - Console.WriteLine(intEmbedded); // Output: 1, 2, 3, 4, 5 + Console.WriteLine(intEmbedded); // Output: 1,2,3,4,5 // Embed with distinct filtering to remove duplicates var withDuplicates = new[] { "apple", "banana", "apple", "cherry" }; string distinctFragment = QueryFormat.DelimitedString.Embed(withDuplicates, distinct: true); - Console.WriteLine(distinctFragment); // Output: 'apple', 'banana', 'cherry' + Console.WriteLine(distinctFragment); // Output: 'apple','banana','cherry' } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.DateTimeExtensions.md b/.docfx/api/types/Cuemon.Extensions.DateTimeExtensions.md index d05d97789..11826e769 100644 --- a/.docfx/api/types/Cuemon.Extensions.DateTimeExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.DateTimeExtensions.md @@ -7,47 +7,43 @@ example: `DateTimeExtensions` provides extension methods for `DateTime` including rounding, range checking, time-of-day classification, kind conversion, and Unix epoch round-tripping. This example creates UTC and local `DateTime` values and applies `Floor` to snap to the nearest hour, `Ceiling` to round up to the next hour, `IsWithinRange` for containment checks, and classification methods like `IsTimeOfDayMorning` and `IsTimeOfDayEvening`. It also converts between `DateTimeKind` values using `ToUtcKind`, `ToLocalKind`, and `ToDefaultKind`, and round-trips through Unix epoch seconds via `ToUnixEpochTime` and `FromUnixEpochTime`. Console output confirms each result, including the snapped timestamp, boolean range check, time-of-day flags, updated `Kind` values, and the restored timestamp. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Extensions; -namespace MyApp.Examples; - -public static class DateTimeExtensionsExample -{ - public static void Demonstrate() - { - var utc = new DateTime(2025, 6, 16, 14, 33, 22, DateTimeKind.Utc); - var local = new DateTime(2025, 6, 16, 14, 33, 22, DateTimeKind.Local); - - var floorHour = utc.Floor(TimeSpan.FromHours(1)); - var ceilingHour = utc.Ceiling(TimeSpan.FromHours(1)); - var floorFifteenMinutes = utc.Floor(15, TimeUnit.Minutes); - var roundedUp = utc.Round(TimeSpan.FromMinutes(30), VerticalDirection.Up); - var isWithinRange = utc.IsWithinRange(new DateTimeRange(utc.AddHours(-1), utc.AddHours(1))); - - var isNight = new DateTime(2025, 6, 16, 22, 15, 0, DateTimeKind.Utc).IsTimeOfDayNight(); - var isMorning = new DateTime(2025, 6, 16, 6, 15, 0, DateTimeKind.Utc).IsTimeOfDayMorning(); - var isForenoon = new DateTime(2025, 6, 16, 10, 15, 0, DateTimeKind.Utc).IsTimeOfDayForenoon(); - var isAfternoon = utc.IsTimeOfDayAfternoon(); - var isEvening = new DateTime(2025, 6, 16, 19, 15, 0, DateTimeKind.Utc).IsTimeOfDayEvening(); - - var utcKind = local.ToUtcKind(); - var localKind = utc.ToLocalKind(); - var unspecifiedKind = utc.ToDefaultKind(); - - var unixTime = utc.ToUnixEpochTime(); - var restored = unixTime.FromUnixEpochTime(); - - Console.WriteLine(floorHour.ToString("O")); - Console.WriteLine(ceilingHour.ToString("O")); - Console.WriteLine(floorFifteenMinutes.ToString("O")); - Console.WriteLine(roundedUp.ToString("O")); - Console.WriteLine(isWithinRange); - Console.WriteLine($"{isNight}, {isMorning}, {isForenoon}, {isAfternoon}, {isEvening}"); - Console.WriteLine($"{utcKind.Kind}, {localKind.Kind}, {unspecifiedKind.Kind}"); - Console.WriteLine(restored.ToString("O")); - } -} - +var utc = new DateTime(2025, 6, 16, 14, 33, 22, DateTimeKind.Utc); +var local = new DateTime(2025, 6, 16, 14, 33, 22, DateTimeKind.Local); + +var floorHour = utc.Floor(TimeSpan.FromHours(1)); +var ceilingHour = utc.Ceiling(TimeSpan.FromHours(1)); +var floorFifteenMinutes = utc.Floor(15, TimeUnit.Minutes); +var roundedUp = utc.Round(TimeSpan.FromMinutes(30), VerticalDirection.Up); +var isWithinRange = utc.IsWithinRange(new DateTimeRange(utc.AddHours(-1), utc.AddHours(1))); + +var isNight = new DateTime(2025, 6, 16, 22, 15, 0, DateTimeKind.Utc).IsTimeOfDayNight(); +var isMorning = new DateTime(2025, 6, 16, 6, 15, 0, DateTimeKind.Utc).IsTimeOfDayMorning(); +var isForenoon = new DateTime(2025, 6, 16, 10, 15, 0, DateTimeKind.Utc).IsTimeOfDayForenoon(); +var isAfternoon = utc.IsTimeOfDayAfternoon(); +var isEvening = new DateTime(2025, 6, 16, 19, 15, 0, DateTimeKind.Utc).IsTimeOfDayEvening(); + +var utcKind = local.ToUtcKind(); +var localKind = utc.ToLocalKind(); +var unspecifiedKind = utc.ToDefaultKind(); + +var unixTime = utc.ToUnixEpochTime(); +var restored = unixTime.FromUnixEpochTime(); + +Console.WriteLine(floorHour.ToString("O")); +Console.WriteLine(ceilingHour.ToString("O")); +Console.WriteLine(floorFifteenMinutes.ToString("O")); +Console.WriteLine(roundedUp.ToString("O")); +Console.WriteLine(isWithinRange); +Console.WriteLine($"{isNight}, {isMorning}, {isForenoon}, {isAfternoon}, {isEvening}"); +Console.WriteLine($"{utcKind.Kind}, {localKind.Kind}, {unspecifiedKind.Kind}"); +Console.WriteLine(restored.ToString("O")); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.DependencyInjection.ServiceCollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.DependencyInjection.ServiceCollectionExtensions.md index 7e803a7d9..69a78ac28 100644 --- a/.docfx/api/types/Cuemon.Extensions.DependencyInjection.ServiceCollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.DependencyInjection.ServiceCollectionExtensions.md @@ -7,10 +7,14 @@ example: `ServiceCollectionExtensions` provides registration methods for `IServiceCollection` that support multi-contract resolution, typed options, and bulk post-configuration. This example defines an `OrdersMessageHandler` implementing both `IMessageHandler` and `IDependencyInjectionMarker`, then registers it with various lifecycle options using `Add`, `TryAdd`, and `TryConfigure` overloads including scoped and singleton lifetimes. It also demonstrates `PostConfigureAllOf` for bulk configuration of options instances. After building the service provider and creating a scope, the concrete handler, typed contract, and marker are resolved and compared by reference. Console output confirms that all three resolve to the same instance and that `HandlerOptions.Label` is correctly set to `"post-configured"`. ```csharp +// Program.cs using System; using Cuemon.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; +using Cuemon.Docs.Samples.DependencyInjection; + +ServiceCollectionExtensionsExample.Demonstrate(); namespace Cuemon.Docs.Samples.DependencyInjection { @@ -95,6 +99,10 @@ namespace Cuemon.Docs.Samples.DependencyInjection } ``` + + + + Configure delivery retries with `AddConfiguredOptions` to let Microsoft Options construct the Parameter Object, calculate its retry budget during post-configuration, and validate the final settings. This example adds an ordinary Microsoft configurator that raises the attempt limit to four, then resolves the cached default options directly and through `IOptions`. The output shows a 15-second retry budget and a shared default instance. The injectable `Action` is the exact primary delegate and sets three attempts on a fresh object; invoking it directly does not calculate the budget or validate the object. Further `AddConfiguredOptions` calls would be ignored, while ordinary `Configure` calls still compose. Cuemon's conventions participate for all options names in registration order, and recoverable validation failures surface as `OptionsValidationException` when Microsoft materializes options. ```csharp @@ -156,3 +164,7 @@ public sealed class DeliveryOptions : IPostConfigurableParameterObject, IValidat } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.DependencyInjection.ServiceOptions.md b/.docfx/api/types/Cuemon.Extensions.DependencyInjection.ServiceOptions.md index 14160c0ea..27698aa4f 100644 --- a/.docfx/api/types/Cuemon.Extensions.DependencyInjection.ServiceOptions.md +++ b/.docfx/api/types/Cuemon.Extensions.DependencyInjection.ServiceOptions.md @@ -7,9 +7,13 @@ example: The following example uses `ServiceOptions` to choose the lifetime that is applied when the Cuemon registration helpers add a service to `IServiceCollection`. ```csharp +// Program.cs using System; using Cuemon.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection; +using Cuemon.Docs.Samples.DependencyInjection; + +ServiceOptionsExample.Demonstrate(); namespace Cuemon.Docs.Samples.DependencyInjection { @@ -51,3 +55,7 @@ namespace Cuemon.Docs.Samples.DependencyInjection } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.DependencyInjection.ServiceProviderExtensions.md b/.docfx/api/types/Cuemon.Extensions.DependencyInjection.ServiceProviderExtensions.md index 8ee4c231e..493c411ca 100644 --- a/.docfx/api/types/Cuemon.Extensions.DependencyInjection.ServiceProviderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.DependencyInjection.ServiceProviderExtensions.md @@ -7,10 +7,14 @@ example: The following example wraps the built service provider and then uses `GetServiceDescriptors()` to inspect the registrations that were added to the container. It registers singleton and scoped services in a `ServiceCollection`, builds the provider, and wraps it in a `DelegatingServiceProvider`. The wrapped provider's descriptors are queried for the registered types, and the results are written to the console, showing how to introspect service registrations at runtime. ```csharp +// Program.cs using System; using System.Linq; using Cuemon.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection; +using Cuemon.Docs.Samples.DependencyInjection; + +ServiceProviderExtensionsExample.Demonstrate(); namespace Cuemon.Docs.Samples.DependencyInjection { @@ -64,3 +68,7 @@ namespace Cuemon.Docs.Samples.DependencyInjection } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.DependencyInjection.TypeExtensions.md b/.docfx/api/types/Cuemon.Extensions.DependencyInjection.TypeExtensions.md index 942983e5b..4eadacfed 100644 --- a/.docfx/api/types/Cuemon.Extensions.DependencyInjection.TypeExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.DependencyInjection.TypeExtensions.md @@ -7,8 +7,12 @@ example: The following example asks `TryGetDependencyInjectionMarker` whether a generic service type carries an `IDependencyInjectionMarker` contract and then reads the discovered marker type. It tests a `DefaultService` that implements the marker interface, and a plain `string` type that does not. The boolean results and the resolved marker type are written to the console, demonstrating how to detect marker-interface contracts for DI service wiring at runtime. ```csharp +// Program.cs using System; using Cuemon.Extensions.DependencyInjection; +using Cuemon.Docs.Samples.DependencyInjection; + +TypeExtensionsExample.Demonstrate(); namespace Cuemon.Docs.Samples.DependencyInjection { @@ -42,3 +46,7 @@ namespace Cuemon.Docs.Samples.DependencyInjection } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.DependencyInjection.TypeForwardServiceOptions.md b/.docfx/api/types/Cuemon.Extensions.DependencyInjection.TypeForwardServiceOptions.md index f9cc5eff3..0924ede5c 100644 --- a/.docfx/api/types/Cuemon.Extensions.DependencyInjection.TypeForwardServiceOptions.md +++ b/.docfx/api/types/Cuemon.Extensions.DependencyInjection.TypeForwardServiceOptions.md @@ -7,9 +7,13 @@ example: The following example customizes `TypeForwardServiceOptions` so only one nested contract is forwarded when a concrete implementation is added to the dependency-injection container. ```csharp +// Program.cs using System; using Cuemon.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection; +using Cuemon.Docs.Samples.DependencyInjection; + +TypeForwardServiceOptionsExample.Demonstrate(); namespace Cuemon.Docs.Samples.DependencyInjection { @@ -71,3 +75,7 @@ namespace Cuemon.Docs.Samples.DependencyInjection } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Diagnostics.FileVersionInfoExtensions.md b/.docfx/api/types/Cuemon.Extensions.Diagnostics.FileVersionInfoExtensions.md index cb8dd9b03..807d72cea 100644 --- a/.docfx/api/types/Cuemon.Extensions.Diagnostics.FileVersionInfoExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Diagnostics.FileVersionInfoExtensions.md @@ -7,43 +7,38 @@ example: `FileVersionInfoExtensions` provides extension methods for `FileVersionInfo` to extract structured version information as `VersionResult` objects from an assembly's metadata. This example obtains the `FileVersionInfo` for the current assembly, then calls `ToProductVersion` to retrieve the NuGet/semantic version string and `ToFileVersion` to retrieve the file version string. Key steps include checking `IsSemanticVersion()` and `HasAlphanumericVersion` on the product version, and converting the file version to a `System.Version` via `ToVersion()`. Console output displays the assembly full name, original version strings, structured version results, and boolean flags for version characteristics. ```csharp +// Program.cs using System; using System.Diagnostics; using System.Reflection; using Cuemon.Extensions.Diagnostics; using Cuemon.Reflection; -namespace MyApp.Diagnostics -{ - public static class FileVersionInfoExtensionsExamples - { - public static void Demonstrate() - { - // Get the FileVersionInfo for the current assembly. - Assembly assembly = typeof(FileVersionInfoExtensionsExamples).Assembly; - FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); +// Get the FileVersionInfo for the current assembly. +Assembly assembly = typeof(FileVersionInfoExtensions).Assembly; +FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); - Console.WriteLine("Assembly: {0}", assembly.FullName); - Console.WriteLine("Original ProductVersion: {0}", fvi.ProductVersion); - Console.WriteLine("Original FileVersion: {0}", fvi.FileVersion); +Console.WriteLine("Assembly: {0}", assembly.FullName); +Console.WriteLine("Original ProductVersion: {0}", fvi.ProductVersion); +Console.WriteLine("Original FileVersion: {0}", fvi.FileVersion); - // Convert to a structured VersionResult using the extension methods. +// Convert to a structured VersionResult using the extension methods. - // ToProductVersion returns the NuGet/semantic version string (e.g., "1.2.3-beta"). - VersionResult productVersion = fvi.ToProductVersion(); - Console.WriteLine("Product VersionResult: {0}", productVersion.Value); - Console.WriteLine("Is semantic version? {0}", productVersion.IsSemanticVersion()); - Console.WriteLine("Has alphanumeric part? {0}", productVersion.HasAlphanumericVersion); +// ToProductVersion returns the NuGet/semantic version string (e.g., "1.2.3-beta"). +VersionResult productVersion = fvi.ToProductVersion(); +Console.WriteLine("Product VersionResult: {0}", productVersion.Value); +Console.WriteLine("Is semantic version? {0}", productVersion.IsSemanticVersion()); +Console.WriteLine("Has alphanumeric part? {0}", productVersion.HasAlphanumericVersion); - // ToFileVersion returns the file version string (e.g., "1.2.3.0"). - VersionResult fileVersion = fvi.ToFileVersion(); - Console.WriteLine("File VersionResult: {0}", fileVersion.Value); - - // Both VersionResult objects can be converted to System.Version. - Version numericVersion = fileVersion.ToVersion(); - Console.WriteLine("Parsed as System.Version: {0}", numericVersion); - -}} -} +// ToFileVersion returns the file version string (e.g., "1.2.3.0"). +VersionResult fileVersion = fvi.ToFileVersion(); +Console.WriteLine("File VersionResult: {0}", fileVersion.Value); +// Both VersionResult objects can be converted to System.Version. +Version numericVersion = fileVersion.ToVersion(); +Console.WriteLine("Parsed as System.Version: {0}", numericVersion); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.DoubleExtensions.md b/.docfx/api/types/Cuemon.Extensions.DoubleExtensions.md index 2a6a48f51..94e415b17 100644 --- a/.docfx/api/types/Cuemon.Extensions.DoubleExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.DoubleExtensions.md @@ -7,32 +7,28 @@ example: `DoubleExtensions` provides extension methods for `Double` covering Unix epoch conversion, time span creation, factorial computation, and precision rounding. This example starts with a Unix timestamp of `1617738277` and converts it to a local `DateTime` via `FromUnixEpochTime`, creates a `TimeSpan` from `3661` seconds using `ToTimeSpan`, computes `5!` using `Factorial`, and rounds `123456789.987654321` to the nearest thousand and million using `RoundOff`. Console output shows the resulting date (`O` format), the duration (`01:01:01`), the factorial value (`120`), and the rounded figures (`123457000` and `123000000`). ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Extensions; -namespace MyApp.Numerics; +double unixTimestamp = 1617738277d; +DateTime fromUnix = unixTimestamp.FromUnixEpochTime().ToLocalTime(); -public static class DoubleExtensionsExample -{ - public static void Demonstrate() - { - double unixTimestamp = 1617738277d; - DateTime fromUnix = unixTimestamp.FromUnixEpochTime().ToLocalTime(); +TimeSpan fromSeconds = 3661d.ToTimeSpan(TimeUnit.Seconds); +double factorial = 5d.Factorial(); - TimeSpan fromSeconds = 3661d.ToTimeSpan(TimeUnit.Seconds); - double factorial = 5d.Factorial(); - - double value = 123456789.987654321d; - double nearestThousand = value.RoundOff(RoundOffAccuracy.NearestThousandth); - double nearestMillion = value.RoundOff(RoundOffAccuracy.NearestMillion); - - Console.WriteLine(fromUnix.ToString("O")); - Console.WriteLine(fromSeconds); - Console.WriteLine(factorial); - Console.WriteLine(nearestThousand); - Console.WriteLine(nearestMillion); - } -} +double value = 123456789.987654321d; +double nearestThousand = value.RoundOff(RoundOffAccuracy.NearestThousandth); +double nearestMillion = value.RoundOff(RoundOffAccuracy.NearestMillion); +Console.WriteLine(fromUnix.ToString("O")); +Console.WriteLine(fromSeconds); +Console.WriteLine(factorial); +Console.WriteLine(nearestThousand); +Console.WriteLine(nearestMillion); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.ExceptionExtensions.md b/.docfx/api/types/Cuemon.Extensions.ExceptionExtensions.md index 686bebc73..4415369bc 100644 --- a/.docfx/api/types/Cuemon.Extensions.ExceptionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.ExceptionExtensions.md @@ -7,34 +7,30 @@ example: `ExceptionExtensions.Flatten` unwinds deeply nested exception hierarchies into a flat `IEnumerable` while preserving insertion order. This example constructs a four-level exception chain starting with an `InvalidOperationException("First")` containing `AmbiguousMatchException`, `OutOfMemoryException`, and an inner `AggregateException` with an `AccessViolationException`. Key setup includes building the nested exception tree and calling `Flatten()` to produce a flat sequence. Console output shows the count of `4` and each caller-facing exception message in order. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Cuemon.Extensions; -namespace MyApp.Examples; +var exception = new InvalidOperationException( + "First", + new AmbiguousMatchException( + "Second", + new OutOfMemoryException( + "Third", + new AggregateException(new AccessViolationException("Fourth"))))); -public static class ExceptionExtensionsExample -{ - public static void Demonstrate() - { - var exception = new InvalidOperationException( - "First", - new AmbiguousMatchException( - "Second", - new OutOfMemoryException( - "Third", - new AggregateException(new AccessViolationException("Fourth"))))); - - IEnumerable flattened = exception.Flatten(); +IEnumerable flattened = exception.Flatten(); - Console.WriteLine(flattened.Count()); - foreach (var ex in flattened) - { - Console.WriteLine(ex.Message); - } - } +Console.WriteLine(flattened.Count()); +foreach (var ex in flattened) +{ + Console.WriteLine(ex.Message); } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.FileProviders.PortablePhysicalFileProvider.md b/.docfx/api/types/Cuemon.Extensions.FileProviders.PortablePhysicalFileProvider.md index 924a5a0d2..da85e294e 100644 --- a/.docfx/api/types/Cuemon.Extensions.FileProviders.PortablePhysicalFileProvider.md +++ b/.docfx/api/types/Cuemon.Extensions.FileProviders.PortablePhysicalFileProvider.md @@ -10,33 +10,33 @@ Successful logical paths are cached for the lifetime of the provider by using ca Misses and collisions are deliberately re-evaluated on every call. If callers can supply arbitrary paths, add the surrounding controls that fit the application boundary, such as request validation, response caching, or rate limiting. -[!INCLUDE [availability-default](../../includes/availability-default.md)] - ```csharp +// Program.cs using System; +using System.IO; using Cuemon.Extensions.FileProviders; -namespace MyApp.Examples; +var contentRoot = Path.Combine(Path.GetTempPath(), "cuemon-docs", "wwwroot"); +var imageDirectory = Path.Combine(contentRoot, "assets", "images"); +Directory.CreateDirectory(imageDirectory); +File.WriteAllText(Path.Combine(imageDirectory, "logo.svg"), ""); + +using var files = new PortablePhysicalFileProvider(contentRoot); -public static class PortablePhysicalFileProviderExample +var logo = files.GetFileInfo("assets/images/logo.svg"); +if (logo.Exists) { - public static void Demonstrate() - { - var contentRoot = @"C:\app\wwwroot"; - using var files = new PortablePhysicalFileProvider(contentRoot); - - var logo = files.GetFileInfo("assets/images/logo.svg"); - if (logo.Exists) - { - Console.WriteLine($"Resolved file: {logo.Name}"); - Console.WriteLine($"Physical path: {logo.PhysicalPath}"); - } - - var images = files.GetDirectoryContents("ASSETS/IMAGES"); - Console.WriteLine($"Image directory found: {images.Exists}"); - - var changeToken = files.Watch("assets/images/logo.svg"); - Console.WriteLine($"Change callbacks active: {changeToken.ActiveChangeCallbacks}"); - } + Console.WriteLine($"Resolved file: {logo.Name}"); + Console.WriteLine($"Physical path: {logo.PhysicalPath}"); } + +var images = files.GetDirectoryContents("ASSETS/IMAGES"); +Console.WriteLine($"Image directory found: {images.Exists}"); + +var changeToken = files.Watch("assets/images/logo.svg"); +Console.WriteLine($"Change callbacks active: {changeToken.ActiveChangeCallbacks}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.FuncFactory.md b/.docfx/api/types/Cuemon.Extensions.FuncFactory.md index a818563f3..bcbcae245 100644 --- a/.docfx/api/types/Cuemon.Extensions.FuncFactory.md +++ b/.docfx/api/types/Cuemon.Extensions.FuncFactory.md @@ -7,25 +7,22 @@ example: The following example demonstrates how to create a `FuncFactory` from a delegate and execute it to produce a result. It shows both creating a factory with `Create` and invoking directly with `Invoke` using a mutable tuple. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Extensions; -namespace Cuemon.Extensions; +Func formatter = (x, y) => $"{x} + {y} = {x + y}"; -public class FuncFactoryExample -{ - public void Demonstrate() - { - Func formatter = (x, y) => $"{x} + {y} = {x + y}"; +var factory = FuncFactory.Create(formatter, 3, 4); +string result = factory.ExecuteMethod(); - var factory = FuncFactory.Create(formatter, 3, 4); - string result = factory.ExecuteMethod(); +Console.WriteLine(result); - Console.WriteLine(result); - - int sum = FuncFactory.Invoke, int>(tuple => tuple.Arg1 + tuple.Arg2, MutableTupleFactory.CreateTwo(10, 20)); - Console.WriteLine(sum); - } -} +int sum = FuncFactory.Invoke, int>(tuple => tuple.Arg1 + tuple.Arg2, MutableTupleFactory.CreateTwo(10, 20)); +Console.WriteLine(sum); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Globalization.RegionInfoExtensions.md b/.docfx/api/types/Cuemon.Extensions.Globalization.RegionInfoExtensions.md index 3f41519a3..9f7e2c36f 100644 --- a/.docfx/api/types/Cuemon.Extensions.Globalization.RegionInfoExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Globalization.RegionInfoExtensions.md @@ -7,36 +7,32 @@ example: `RegionInfoExtensions` provides extension methods for `RegionInfo` to enumerate all cultures associated with a geographic region via the `GetCultures` method. This example creates `RegionInfo` instances for `"US"` and `"JP"`, then calls `GetCultures()` on each to retrieve their associated culture collections. Key steps include iterating the culture results and printing the culture name and English name for each. Console output lists cultures such as `en-US` for the US and `ja-JP` for Japan, along with their English names. ```csharp +// Program.cs using System; using System.Globalization; using System.Linq; using Cuemon.Extensions.Globalization; -namespace MyApp.Globalization -{ - public class RegionInfoExtensionsExample - { - public void Demonstrate() - { - // Get cultures associated with a specific region - var region = new RegionInfo("US"); +// Get cultures associated with a specific region +var region = new RegionInfo("US"); - var cultures = region.GetCultures().ToList(); - Console.WriteLine($"Cultures for {region.EnglishName} ({region.TwoLetterISORegionName}):"); - foreach (var culture in cultures) - { - Console.WriteLine($" {culture.Name} - {culture.EnglishName}"); - } +var cultures = region.GetCultures().ToList(); +Console.WriteLine($"Cultures for {region.EnglishName} ({region.TwoLetterISORegionName}):"); +foreach (var culture in cultures) +{ + Console.WriteLine($" {culture.Name} - {culture.EnglishName}"); +} - // Try another region - var japan = new RegionInfo("JP"); - var jpCultures = japan.GetCultures().ToList(); - Console.WriteLine($"\nCultures for {japan.EnglishName}:"); - foreach (var culture in jpCultures) - { - Console.WriteLine($" {culture.Name} - {culture.EnglishName}"); - } - } - } +// Try another region +var japan = new RegionInfo("JP"); +var jpCultures = japan.GetCultures().ToList(); +Console.WriteLine($"\nCultures for {japan.EnglishName}:"); +foreach (var culture in jpCultures) +{ + Console.WriteLine($" {culture.Name} - {culture.EnglishName}"); } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Globalization.StatisticalRegionExtensions.md b/.docfx/api/types/Cuemon.Extensions.Globalization.StatisticalRegionExtensions.md index dd5ce612e..8ad0e544b 100644 --- a/.docfx/api/types/Cuemon.Extensions.Globalization.StatisticalRegionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Globalization.StatisticalRegionExtensions.md @@ -7,66 +7,62 @@ example: `StatisticalRegionExtensions` provides extension methods for classifying geographic regions using the UN M.49 standard via the `World` class. This example retrieves `StatisticalRegion` instances for the world (`"001"`), Europe (`"150"`), Western Europe (`"155"`), Denmark (`"208"`), and the United States (`"840"`), then calls classification methods like `IsWorld`, `IsRegion`, `IsSubregion`, `IsCountryOrTerritory`, `IsArea`, and `HasIsoCodes`. It also traverses Denmark's hierarchy using `GetAncestors()` to show parent regions, finds the US by `RegionInfo`, and counts all countries via `world.Countries.Count()`. Console output confirms each classification, such as `True` for `denmark.IsCountryOrTerritory()` and the ancestor chain `Northern Europe → Europe → World`. ```csharp +// Program.cs using System; using System.Globalization; using System.Linq; using Cuemon.Extensions.Globalization; using Cuemon.Globalization; -namespace MyApp.Examples; +// Access regions via the World class +var world = World.GetStatisticalRegion("001"); +var europe = World.GetStatisticalRegion("150"); +var westernEurope = World.GetStatisticalRegion("155"); +var denmark = World.GetCountry("208"); // Denmark M.49 code +var usa = World.GetCountry("840"); // United States M.49 code -public class Example -{ - public void Run() - { - - // Access regions via the World class - var world = World.GetStatisticalRegion("001"); - var europe = World.GetStatisticalRegion("150"); - var westernEurope = World.GetStatisticalRegion("155"); - var denmark = World.GetCountry("208"); // Denmark M.49 code - var usa = World.GetCountry("840"); // United States M.49 code - - // Classify by kind using the extension methods - bool isWorld = world.IsWorld(); // true - bool isRegion = europe.IsRegion(); // true (continent) - bool isSubregion = westernEurope.IsSubregion(); // true - bool isCountry = denmark.IsCountryOrTerritory(); // true - bool isArea = europe.IsArea(); // true (not a country) - bool isCountryArea = denmark.IsArea(); // false (is a country) +// Classify by kind using the extension methods +bool isWorld = world.IsWorld(); // true +bool isRegion = europe.IsRegion(); // true (continent) +bool isSubregion = westernEurope.IsSubregion(); // true +bool isCountry = denmark.IsCountryOrTerritory(); // true +bool isArea = europe.IsArea(); // true (not a country) +bool isCountryArea = denmark.IsArea(); // false (is a country) - // Check intermediate regions (sub-Saharan Africa, Latin America) - var subSaharanAfrica = World.GetStatisticalRegion("202"); - bool isIntermediate = subSaharanAfrica.IsIntermediateRegion(); // true +// Check intermediate regions (sub-Saharan Africa, Latin America) +var subSaharanAfrica = World.GetStatisticalRegion("202"); +bool isIntermediate = subSaharanAfrica.IsIntermediateRegion(); // true - // Verify hierarchy - bool denmarkIsInEurope = denmark.Parent.IsSubregion(); // true (Northern Europe, M.49: 154) +// Verify hierarchy +bool denmarkIsInEurope = denmark.Parent.IsSubregion(); // true (Northern Europe, M.49: 154) - // Check if a country has associated .NET RegionInfo - bool hasRegionInfo = usa.HasRegionInfo(); // true (US has RegionInfo) - bool noRegionInfo = world.HasRegionInfo(); // false (World is not a country) +// Check if a country has associated .NET RegionInfo +bool hasRegionInfo = usa.HasRegionInfo(); // true (US has RegionInfo) +bool noRegionInfo = world.HasRegionInfo(); // false (World is not a country) - // Check if a region has ISO codes - bool hasIso = denmark.HasIsoCodes(); // true +// Check if a region has ISO codes +bool hasIso = denmark.HasIsoCodes(); // true - // Iterate all countries - int countryCount = world.Countries.Count(); - Console.WriteLine($"Total countries/territories: {countryCount}"); +// Iterate all countries +int countryCount = world.Countries.Count(); +Console.WriteLine($"Total countries/territories: {countryCount}"); - // Find a country by RegionInfo - var regionInfo = new RegionInfo("US"); - var usaByRegion = World.GetCountry(regionInfo); - Console.WriteLine(usaByRegion.IsCountryOrTerritory()); // True +// Find a country by RegionInfo +var regionInfo = new RegionInfo("US"); +var usaByRegion = World.GetCountry(regionInfo); +Console.WriteLine(usaByRegion.IsCountryOrTerritory()); // True - // Traverse the hierarchy - foreach (var ancestor in denmark.GetAncestors()) - { - Console.WriteLine($"{ancestor.Name} ({ancestor.Kind})"); - // "Northern Europe (Subregion)" - // "Europe (Region)" - // "World (World)" +// Traverse the hierarchy +foreach (var ancestor in denmark.GetAncestors()) +{ + Console.WriteLine($"{ancestor.Name} ({ancestor.Kind})"); +// "Northern Europe (Subregion)" +// "Europe (Region)" +// "World (World)" -}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Hosting.Environments.md b/.docfx/api/types/Cuemon.Extensions.Hosting.Environments.md index 910c5ef1a..3232d1e85 100644 --- a/.docfx/api/types/Cuemon.Extensions.Hosting.Environments.md +++ b/.docfx/api/types/Cuemon.Extensions.Hosting.Environments.md @@ -7,20 +7,19 @@ example: The following example shows how to configure a .NET generic host to use the `Environments.LocalDevelopment` environment. The host is built and run with this environment setting. ```csharp +// Program.cs +using System; using Cuemon.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -namespace Cuemon.Extensions.Hosting; +using var host = Host.CreateDefaultBuilder() + .UseEnvironment(Cuemon.Extensions.Hosting.Environments.LocalDevelopment) + .Build(); -public class EnvironmentsExample -{ - public void Demonstrate() - { - var builder = Host.CreateDefaultBuilder() - .UseEnvironment(Environments.LocalDevelopment); - - using var host = builder.Build(); - host.Run(); - } -} +Console.WriteLine(host.Services.GetRequiredService().EnvironmentName); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Hosting.HostBuilderExtensions.md b/.docfx/api/types/Cuemon.Extensions.Hosting.HostBuilderExtensions.md index e6704bcc0..b8de4d006 100644 --- a/.docfx/api/types/Cuemon.Extensions.Hosting.HostBuilderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Hosting.HostBuilderExtensions.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to add and remove configuration sources through . ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon.Extensions.Hosting; @@ -14,30 +15,26 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration.Memory; using Microsoft.Extensions.Hosting; -namespace MyApp.Examples; - -public static class HostBuilderExtensionsExample -{ - public static void Demonstrate() +var hostBuilder = Host.CreateDefaultBuilder() + .ConfigureConfigurationSources((environment, sources) => { - var hostBuilder = Host.CreateDefaultBuilder() - .ConfigureConfigurationSources((environment, sources) => + sources.Add(new MemoryConfigurationSource + { + InitialData = new Dictionary { - sources.Add(new MemoryConfigurationSource - { - InitialData = new Dictionary - { - ["App:Environment"] = environment.EnvironmentName - } - }); - }) - .RemoveConfigurationSource((environment, source) => - environment.IsProduction() && source is MemoryConfigurationSource); + ["App:Environment"] = environment.EnvironmentName + } + }); + }) + .RemoveConfigurationSource((environment, source) => + environment.IsProduction() && source is MemoryConfigurationSource); - using var host = hostBuilder.Build(); - var configuration = (IConfiguration)host.Services.GetService(typeof(IConfiguration)); +using var host = hostBuilder.Build(); +var configuration = (IConfiguration)host.Services.GetService(typeof(IConfiguration)); - Console.WriteLine(configuration["App:Environment"] == null); - } -} +Console.WriteLine(configuration["App:Environment"] == null); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Hosting.HostEnvironmentExtensions.md b/.docfx/api/types/Cuemon.Extensions.Hosting.HostEnvironmentExtensions.md index d652e4c6e..eada0c75e 100644 --- a/.docfx/api/types/Cuemon.Extensions.Hosting.HostEnvironmentExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Hosting.HostEnvironmentExtensions.md @@ -7,25 +7,21 @@ example: `HostEnvironmentExtensions` provides extension methods for `IHostEnvironment` to check whether the current environment is a local development or non-production environment. This example takes an `IHostEnvironment` parameter and calls `IsLocalDevelopment()` to detect a developer machine and `IsNonProduction()` to check for any non-production environment. Key setup includes using these methods in conditional startup logic. Console output prints `"Running on a developer machine."` or `"Environment is not Production."` based on the check results. ```csharp +// Program.cs using System; using Cuemon.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -namespace MyApp.Startup; - -public class EnvironmentReporter -{ - public void Report(IHostEnvironment env) - { - if (env.IsLocalDevelopment()) - { - Console.WriteLine("Running on a developer machine."); - - if (env.IsNonProduction()) - { - Console.WriteLine("Environment is not Production."); - -}}} -} +using var host = Host.CreateDefaultBuilder() + .UseEnvironment(Cuemon.Extensions.Hosting.Environments.LocalDevelopment) + .Build(); +var environment = host.Services.GetRequiredService(); +Console.WriteLine(environment.IsLocalDevelopment()); +Console.WriteLine(environment.IsNonProduction()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.IO.ByteArrayExtensions.md b/.docfx/api/types/Cuemon.Extensions.IO.ByteArrayExtensions.md index 308aa92ed..a50239b0c 100644 --- a/.docfx/api/types/Cuemon.Extensions.IO.ByteArrayExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.IO.ByteArrayExtensions.md @@ -7,6 +7,7 @@ example: `ByteArrayExtensions` provides extension methods for converting `byte[]` into seekable `MemoryStream` instances, with both synchronous and asynchronous overloads. This example encodes `"Hello, World!"` into a UTF-8 byte array, then calls `ToStream()` and `ToStreamAsync()` to create streams, verifying that the synchronous stream has `Length = 13` and `CanSeek = True`. The content is read back with a `StreamReader` to confirm round-trip fidelity, and the asynchronous overload is demonstrated with a `CancellationToken`. Console output confirms the stream properties and that re-read content matches the original string. ```csharp +// Program.cs using System.Threading; using System; using System.IO; @@ -14,37 +15,31 @@ using System.Text; using System.Threading.Tasks; using Cuemon.Extensions.IO; -namespace MyApp.Extensions.IO -{ - public class ByteArrayExtensionsExample - { - public async Task DemonstrateAsync() - { - byte[] data = Encoding.UTF8.GetBytes("Hello, World!"); +byte[] data = Encoding.UTF8.GetBytes("Hello, World!"); - // Convert a byte array to a seekable Stream (synchronous) - using Stream stream = data.ToStream(); - Console.WriteLine(stream.Length); // 13 - Console.WriteLine(stream.CanSeek); // True +// Convert a byte array to a seekable Stream (synchronous) +using Stream stream = data.ToStream(); +Console.WriteLine(stream.Length); // 13 +Console.WriteLine(stream.CanSeek); // True - // Read the content back - using var reader = new StreamReader(stream); - string content = reader.ReadToEnd(); - Console.WriteLine(content); // "Hello, World!" +// Read the content back +using var reader = new StreamReader(stream); +string content = reader.ReadToEnd(); +Console.WriteLine(content); // "Hello, World!" - // Convert a byte array to a Stream (asynchronous) - using Stream asyncStream = await data.ToStreamAsync(); +// Convert a byte array to a Stream (asynchronous) +using Stream asyncStream = await data.ToStreamAsync(); - // Verify the async stream content - using var asyncReader = new StreamReader(asyncStream); - string asyncContent = asyncReader.ReadToEnd(); - Console.WriteLine(asyncContent); // "Hello, World!" - - // Use cancellation with the async overload - using var cts = new System.Threading.CancellationTokenSource(); - using Stream cancelStream = await data.ToStreamAsync(cts.Token); - -}} -} +// Verify the async stream content +using var asyncReader = new StreamReader(asyncStream); +string asyncContent = asyncReader.ReadToEnd(); +Console.WriteLine(asyncContent); // "Hello, World!" +// Use cancellation with the async overload +using var cts = new System.Threading.CancellationTokenSource(); +using Stream cancelStream = await data.ToStreamAsync(cts.Token); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.IO.StreamExtensions.md b/.docfx/api/types/Cuemon.Extensions.IO.StreamExtensions.md index e33dd9b01..d9a55d77c 100644 --- a/.docfx/api/types/Cuemon.Extensions.IO.StreamExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.IO.StreamExtensions.md @@ -7,11 +7,15 @@ example: `StreamExtensions` provides extension methods for `Stream` covering concatenation, encoding conversion, compression (GZip, Deflate, Brotli), and encoding detection. This example creates memory streams from `"Cue"` and `"mon"` and concatenates them with `Concat`, then converts the result to byte arrays, character arrays, and encoded strings both synchronously and asynchronously. It demonstrates compression round-trips for GZip, Deflate, and Brotli — each compressing a source stream, decompressing back, and reading the result — and also includes `TryDetectUnicodeEncoding` on a BOM-prefixed stream and `WriteAllAsync` for asynchronous writes. Console output confirms that all compressed round-trips preserve the original payload (`"gzip payload"`, `"deflate payload"`, `"brotli payload"`), that detected encoding is UTF-8, and that byte counts and string values agree across sync and async paths. ```csharp +// Program.cs using System; using System.IO; using System.Text; using System.Threading.Tasks; using Cuemon.Extensions.IO; +using MyApp.Examples; + +await StreamExtensionsExample.DemonstrateAsync(); namespace MyApp.Examples { @@ -22,77 +26,68 @@ namespace MyApp.Examples using var first = CreateStream("Cue"); using var second = CreateStream("mon"); using var combined = first.Concat(second, options => options.LeaveOpen = true); + Console.WriteLine(combined.ToEncodedString(options => options.LeaveOpen = true)); - var bytes = combined.ToByteArray(); - combined.Position = 0; - var bytesAsync = await combined.ToByteArrayAsync(); - combined.Position = 0; - var chars = combined.ToCharArray(); - combined.Position = 0; - var text = combined.ToEncodedString(); - combined.Position = 0; - var asyncText = await combined.ToEncodedStringAsync(); + var bytes = CreateStream("Cuemon").ToByteArray(); + var bytesAsync = await CreateStream("Cuemon").ToByteArrayAsync(); + var chars = CreateStream("Cuemon").ToCharArray(); + var text = CreateStream("Cuemon").ToEncodedString(); + var asyncText = await CreateStream("Cuemon").ToEncodedStringAsync(); + + Console.WriteLine(bytes.Length == bytesAsync.Length); + Console.WriteLine(chars.Length); + Console.WriteLine(text == asyncText); using var bomStream = CreateStream("Hello with BOM", includePreamble: true); bomStream.TryDetectUnicodeEncoding(out var detectedEncoding); + Console.WriteLine(detectedEncoding?.WebName); using var writable = new MemoryStream(); await writable.WriteAllAsync(Encoding.UTF8.GetBytes("written asynchronously")); writable.Position = 0; + Console.WriteLine(writable.ToEncodedString()); using var gzipSource = CreateStream("gzip payload"); using var gzipCompressed = gzipSource.CompressGZip(); gzipCompressed.Position = 0; using var gzipDecompressed = gzipCompressed.DecompressGZip(); gzipDecompressed.Position = 0; - var gzipRoundTrip = gzipDecompressed.ToEncodedString(); + Console.WriteLine(gzipDecompressed.ToEncodedString()); using var gzipAsyncSource = CreateStream("gzip async payload"); using var gzipCompressedAsync = await gzipAsyncSource.CompressGZipAsync(); gzipCompressedAsync.Position = 0; using var gzipDecompressedAsync = await gzipCompressedAsync.DecompressGZipAsync(); gzipDecompressedAsync.Position = 0; - var gzipAsyncRoundTrip = await gzipDecompressedAsync.ToEncodedStringAsync(); + Console.WriteLine(await gzipDecompressedAsync.ToEncodedStringAsync()); using var deflateSource = CreateStream("deflate payload"); using var deflateCompressed = deflateSource.CompressDeflate(); deflateCompressed.Position = 0; using var deflateDecompressed = deflateCompressed.DecompressDeflate(); deflateDecompressed.Position = 0; - var deflateRoundTrip = deflateDecompressed.ToEncodedString(); + Console.WriteLine(deflateDecompressed.ToEncodedString()); using var deflateAsyncSource = CreateStream("deflate async payload"); using var deflateCompressedAsync = await deflateAsyncSource.CompressDeflateAsync(); deflateCompressedAsync.Position = 0; using var deflateDecompressedAsync = await deflateCompressedAsync.DecompressDeflateAsync(); deflateDecompressedAsync.Position = 0; - var deflateAsyncRoundTrip = await deflateDecompressedAsync.ToEncodedStringAsync(); + Console.WriteLine(await deflateDecompressedAsync.ToEncodedStringAsync()); using var brotliSource = CreateStream("brotli payload"); using var brotliCompressed = brotliSource.CompressBrotli(); brotliCompressed.Position = 0; using var brotliDecompressed = brotliCompressed.DecompressBrotli(); brotliDecompressed.Position = 0; - var brotliRoundTrip = brotliDecompressed.ToEncodedString(); + Console.WriteLine(brotliDecompressed.ToEncodedString()); using var brotliAsyncSource = CreateStream("brotli async payload"); using var brotliCompressedAsync = await brotliAsyncSource.CompressBrotliAsync(); brotliCompressedAsync.Position = 0; using var brotliDecompressedAsync = await brotliCompressedAsync.DecompressBrotliAsync(); brotliDecompressedAsync.Position = 0; - var brotliAsyncRoundTrip = await brotliDecompressedAsync.ToEncodedStringAsync(); - - Console.WriteLine(bytes.Length == bytesAsync.Length); - Console.WriteLine(chars.Length); - Console.WriteLine(text == asyncText); - Console.WriteLine(detectedEncoding?.WebName); - Console.WriteLine(writable.ToEncodedString()); - Console.WriteLine(gzipRoundTrip); - Console.WriteLine(gzipAsyncRoundTrip); - Console.WriteLine(deflateRoundTrip); - Console.WriteLine(deflateAsyncRoundTrip); - Console.WriteLine(brotliRoundTrip); - Console.WriteLine(brotliAsyncRoundTrip); + Console.WriteLine(await brotliDecompressedAsync.ToEncodedStringAsync()); } private static MemoryStream CreateStream(string value, bool includePreamble = false) @@ -112,3 +107,7 @@ namespace MyApp.Examples } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.IO.StringExtensions.md b/.docfx/api/types/Cuemon.Extensions.IO.StringExtensions.md index 1f6b25d14..90c17f437 100644 --- a/.docfx/api/types/Cuemon.Extensions.IO.StringExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.IO.StringExtensions.md @@ -7,32 +7,28 @@ example: `StringExtensions` in the `IO` namespace converts strings into `Stream` and `TextReader` instances for stream-based processing. This example starts with a JSON string `{"key":"value"}`, calls `ToStream` with a UTF-8 encoding configuration, `ToStreamAsync` for the asynchronous variant, and `ToTextReader` for direct text reader access. Key steps include verifying the stream has positive length, reading back the async stream's content with `ToEncodedStringAsync`, and reading the text reader content with `ReadToEnd`. Console output confirms the stream length is greater than zero, the async round-trip matches the original JSON, and the text reader reads the expected content. ```csharp +// Program.cs using System; using System.IO; using System.Text; using System.Threading.Tasks; using Cuemon.Extensions.IO; -namespace MyApp.Examples -{ - public static class StringExtensionsExample - { - public static async Task DemonstrateAsync() - { - const string json = "{\"key\":\"value\"}"; +const string json = "{\"key\":\"value\"}"; - using Stream stream = json.ToStream(options => - { - options.Encoding = Encoding.UTF8; - }); +using Stream stream = json.ToStream(options => +{ + options.Encoding = Encoding.UTF8; +}); - using Stream asyncStream = await json.ToStreamAsync(); - using TextReader reader = json.ToTextReader(); +using Stream asyncStream = await json.ToStreamAsync(); +using TextReader reader = json.ToTextReader(); - Console.WriteLine(stream.Length > 0); - Console.WriteLine((await asyncStream.ToEncodedStringAsync()) == json); - Console.WriteLine(reader.ReadToEnd()); - } - } -} +Console.WriteLine(stream.Length > 0); +Console.WriteLine((await asyncStream.ToEncodedStringAsync()) == json); +Console.WriteLine(reader.ReadToEnd()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.IO.TextReaderExtensions.md b/.docfx/api/types/Cuemon.Extensions.IO.TextReaderExtensions.md index f02e220ea..fedcd9db5 100644 --- a/.docfx/api/types/Cuemon.Extensions.IO.TextReaderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.IO.TextReaderExtensions.md @@ -7,34 +7,30 @@ example: `TextReaderExtensions` provides extension methods for `TextReader` including `ReadAllLines`, `ReadAllLinesAsync`, and `CopyToAsync` for reading and copying text content. This example creates a multi-line string `"line one\nline two\nline three"`, converts it to a `TextReader` via `ToTextReader`, then calls `ReadAllLines` synchronously and `ReadAllLinesAsync` asynchronously to collect each line. It also uses `CopyToAsync` to write the reader content into a `StringWriter`. Console output confirms all three approaches produce the correct line count of `3` and that the copied content contains `"line two"`. ```csharp +// Program.cs using System; using System.IO; using System.Linq; using System.Threading.Tasks; using Cuemon.Extensions.IO; -namespace MyApp.Examples -{ - public static class TextReaderExtensionsExample - { - public static async Task DemonstrateAsync() - { - const string input = "line one\nline two\nline three"; - - using var linesReader = input.ToTextReader(); - var lines = linesReader.ReadAllLines().ToList(); - - using var asyncLinesReader = input.ToTextReader(); - using var writer = new StringWriter(); - var asyncLines = await asyncLinesReader.ReadAllLinesAsync(); - - using var copyReader = input.ToTextReader(); - await copyReader.CopyToAsync(writer); - - Console.WriteLine(lines.Count); - Console.WriteLine(asyncLines.Count); - Console.WriteLine(writer.ToString().Contains("line two")); - } - } -} +const string input = "line one\nline two\nline three"; + +using var linesReader = input.ToTextReader(); +var lines = linesReader.ReadAllLines().ToList(); + +using var asyncLinesReader = input.ToTextReader(); +using var writer = new StringWriter(); +var asyncLines = await asyncLinesReader.ReadAllLinesAsync(); + +using var copyReader = input.ToTextReader(); +await copyReader.CopyToAsync(writer); + +Console.WriteLine(lines.Count); +Console.WriteLine(asyncLines.Count); +Console.WriteLine(writer.ToString().Contains("line two")); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.IntegerExtensions.md b/.docfx/api/types/Cuemon.Extensions.IntegerExtensions.md index 19aca8a68..9b08971a9 100644 --- a/.docfx/api/types/Cuemon.Extensions.IntegerExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.IntegerExtensions.md @@ -7,29 +7,25 @@ example: The following example demonstrates how to use the extension methods to check whether a given integer is prime, even, or odd, and to find the smallest or largest of two values. ```csharp +// Program.cs using System; using Cuemon.Extensions; -namespace MyApp.Examples; - -public static class IntegerExtensionsExample -{ - public static void Demonstrate() - { - var number = 17; - bool isPrime = number.IsPrime(); - bool isEven = number.IsEven(); - bool isOdd = number.IsOdd(); - - Console.WriteLine(isPrime); - Console.WriteLine(isEven); - Console.WriteLine(isOdd); - Console.WriteLine(5.Max(10)); - Console.WriteLine(15.Min(10)); - Console.WriteLine(500L.Min(1000L)); - Console.WriteLine(((short)3).Max((short)7)); - Console.WriteLine(new[] { 1, 3, 5, 7 }.IsCountableSequence()); - } -} +var number = 17; +bool isPrime = number.IsPrime(); +bool isEven = number.IsEven(); +bool isOdd = number.IsOdd(); +Console.WriteLine(isPrime); +Console.WriteLine(isEven); +Console.WriteLine(isOdd); +Console.WriteLine(5.Max(10)); +Console.WriteLine(15.Min(10)); +Console.WriteLine(500L.Min(1000L)); +Console.WriteLine(((short)3).Max((short)7)); +Console.WriteLine(new[] { 1, 3, 5, 7 }.IsCountableSequence()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.MethodDescriptorExtensions.md b/.docfx/api/types/Cuemon.Extensions.MethodDescriptorExtensions.md index 95af46854..0c4ccbad6 100644 --- a/.docfx/api/types/Cuemon.Extensions.MethodDescriptorExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.MethodDescriptorExtensions.md @@ -7,28 +7,24 @@ example: `MethodDescriptorExtensions` provides extension methods for `MethodDescriptor` to inspect parameter information and method metadata. This example retrieves `MethodInfo` for `Console.WriteLine(string)` (which has a parameter) and `Guid.NewGuid()` (which has none), creates `MethodDescriptor` instances via `MethodDescriptor.Create`, then calls `HasParameters()` to check each for parameters. Key steps include resolving the method info via reflection and calling `HasParameters` on each descriptor. Console output confirms `True` for `WriteLine`, `False` for `NewGuid`, and displays the method name and caller name. ```csharp +// Program.cs using System; using System.Reflection; using Cuemon.Extensions; using Cuemon.Reflection; -namespace MyApp.Reflection; +MethodInfo writeLine = typeof(Console).GetMethod(nameof(Console.WriteLine), new[] { typeof(string) }); +MethodInfo newGuid = typeof(Guid).GetMethod(nameof(Guid.NewGuid), BindingFlags.Public | BindingFlags.Static); -public static class MethodDescriptorExtensionsExample -{ - public static void Demonstrate() - { - MethodInfo writeLine = typeof(Console).GetMethod(nameof(Console.WriteLine), new[] { typeof(string) }); - MethodInfo newGuid = typeof(Guid).GetMethod(nameof(Guid.NewGuid), BindingFlags.Public | BindingFlags.Static); - - MethodDescriptor withParameters = MethodDescriptor.Create(writeLine); - MethodDescriptor withoutParameters = MethodDescriptor.Create(newGuid); - - Console.WriteLine(withParameters.HasParameters()); - Console.WriteLine(withoutParameters.HasParameters()); - Console.WriteLine(withParameters.Method.Name); - Console.WriteLine(withParameters.Caller?.Name); - } -} +MethodDescriptor withParameters = MethodDescriptor.Create(writeLine); +MethodDescriptor withoutParameters = MethodDescriptor.Create(newGuid); +Console.WriteLine(withParameters.HasParameters()); +Console.WriteLine(withoutParameters.HasParameters()); +Console.WriteLine(withParameters.Method.Name); +Console.WriteLine(withParameters.Caller?.Name); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.MutableTupleFactory.md b/.docfx/api/types/Cuemon.Extensions.MutableTupleFactory.md index 7c6194d3c..9e3802a87 100644 --- a/.docfx/api/types/Cuemon.Extensions.MutableTupleFactory.md +++ b/.docfx/api/types/Cuemon.Extensions.MutableTupleFactory.md @@ -7,27 +7,24 @@ example: The following example demonstrates how to create mutable tuples with zero to five arguments using `MutableTupleFactory`. It shows accessing tuple values and constructing tuples of various sizes. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Extensions; -namespace Cuemon.Extensions; +var zero = MutableTupleFactory.CreateZero(); -public class MutableTupleFactoryExample -{ - public void Demonstrate() - { - var zero = MutableTupleFactory.CreateZero(); +var one = MutableTupleFactory.CreateOne(42); +Console.WriteLine(one.Arg1); - var one = MutableTupleFactory.CreateOne(42); - Console.WriteLine(one.Arg1); +var two = MutableTupleFactory.CreateTwo("Alice", 30); +Console.WriteLine($"{two.Arg1} is {two.Arg2} years old"); - var two = MutableTupleFactory.CreateTwo("Alice", 30); - Console.WriteLine($"{two.Arg1} is {two.Arg2} years old"); +var three = MutableTupleFactory.CreateThree(1, 2, 3); - var three = MutableTupleFactory.CreateThree(1, 2, 3); - - var five = MutableTupleFactory.CreateFive('a', 'b', 'c', 'd', 'e'); - } -} +var five = MutableTupleFactory.CreateFive('a', 'b', 'c', 'd', 'e'); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Net.ByteArrayExtensions.md b/.docfx/api/types/Cuemon.Extensions.Net.ByteArrayExtensions.md index bc15af263..97821008e 100644 --- a/.docfx/api/types/Cuemon.Extensions.Net.ByteArrayExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Net.ByteArrayExtensions.md @@ -7,38 +7,32 @@ example: `ByteArrayExtensions` in the `Net` namespace URL-encodes byte arrays for safe HTTP transmission with support for partial encoding and custom character encodings. This example converts `"hello world"` to a UTF-8 byte array and calls `UrlEncode` to produce `hello%20world`, then demonstrates partial encoding of only the first five bytes (producing `hello`) and encoding with UTF-32 where each character is encoded as 4 bytes. Console output displays each encoded result, confirming that full encoding, partial ranges, and non-default encodings all produce correct percent-encoded output. ```csharp +// Program.cs using System; using System.Text; using Cuemon.Extensions.Net; using Cuemon.Text; -namespace MyApp.Net -{ - public class ByteArrayExtensionsExample - { - public void Demonstrate() - { - // Encode a byte array for safe URL transmission - byte[] data = Encoding.UTF8.GetBytes("hello world"); +// Encode a byte array for safe URL transmission +byte[] data = Encoding.UTF8.GetBytes("hello world"); - // URL-encode the entire byte array - byte[] encoded = data.UrlEncode(); - Console.WriteLine(Encoding.UTF8.GetString(encoded)); - // Output: hello%20world +// URL-encode the entire byte array +byte[] encoded = data.UrlEncode(0, data.Length); +Console.WriteLine(Encoding.UTF8.GetString(encoded)); +// Output: hello%20world - // Encode only a portion starting at position 0 for 5 bytes - byte[] partial = data.UrlEncode(position: 0, bytesToRead: 5); - Console.WriteLine(Encoding.UTF8.GetString(partial)); - // Output: hello - - // Use a custom encoding (e.g., UTF-32) - byte[] utf32Data = Encoding.UTF32.GetBytes("test data"); - byte[] utf32Encoded = utf32Data.UrlEncode(setup: o => o.Encoding = Encoding.UTF32); - string result = Encoding.UTF32.GetString(utf32Encoded); - Console.WriteLine(result); - // Output: test%00%00%00%20%00%00%00data - -}} -} +// Encode only a portion starting at position 0 for 5 bytes +byte[] partial = data.UrlEncode(position: 0, bytesToRead: 5); +Console.WriteLine(Encoding.UTF8.GetString(partial)); +// Output: hello +// Use a custom encoding (e.g., UTF-32) +byte[] utf32Data = Encoding.UTF32.GetBytes("test data"); +byte[] utf32Encoded = utf32Data.UrlEncode(0, utf32Data.Length, setup: o => o.Encoding = Encoding.UTF32); +string result = Encoding.UTF32.GetString(utf32Encoded); +Console.WriteLine(result); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Net.DictionaryExtensions.md b/.docfx/api/types/Cuemon.Extensions.Net.DictionaryExtensions.md index cb6c587cd..3f1becb29 100644 --- a/.docfx/api/types/Cuemon.Extensions.Net.DictionaryExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Net.DictionaryExtensions.md @@ -7,40 +7,35 @@ example: `DictionaryExtensions` in the `Net` namespace converts `Dictionary` into URL query strings with optional percent-encoding. This example creates a dictionary with parameters `"search": ["dotnet"]`, `"page": ["1"]`, and `"tags": ["aspnet", "core"]`, then calls `ToQueryString()` to produce `search=dotnet&page=1&tags=aspnet&tags=core` and `ToQueryString(urlEncode: true)` for URL-encoded output. It also handles an empty dictionary that returns an empty string. Console output shows the raw query string, the encoded variant, and the empty-collection result `"Empty: ''"`. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon.Extensions.Net; -namespace MyApp.Net +// Build a query string from a dictionary +var parameters = new Dictionary { - public class DictionaryExtensionsExample - { - public void Demonstrate() - { - // Build a query string from a dictionary - var parameters = new Dictionary - { - { "search", new[] { "dotnet" } }, - { "page", new[] { "1" } }, - { "tags", new[] { "aspnet", "core" } } - }; - - // Convert to a query string (not URL-encoded) - string queryString = parameters.ToQueryString(); - Console.WriteLine(queryString); - // Output: search=dotnet&page=1&tags=aspnet&tags=core - - // URL-encode the values - string encoded = parameters.ToQueryString(urlEncode: true); - Console.WriteLine(encoded); - // Output: search=dotnet&page=1&tags=aspnet&tags=core - - // Useful for building API request URLs - var empty = new Dictionary(); - string emptyQs = empty.ToQueryString(); - Console.WriteLine($"Empty: '{emptyQs}'"); // Empty: '' - -}} -} - + { "search", new[] { "dotnet" } }, + { "page", new[] { "1" } }, + { "tags", new[] { "aspnet", "core" } } +}; + +// Convert to a query string (not URL-encoded) +string queryString = parameters.ToQueryString(); +Console.WriteLine(queryString); +// Output: search=dotnet&page=1&tags=aspnet&tags=core + +// URL-encode the values +string encoded = parameters.ToQueryString(urlEncode: true); +Console.WriteLine(encoded); +// Output: search=dotnet&page=1&tags=aspnet&tags=core + +// Useful for building API request URLs +var empty = new Dictionary(); +string emptyQs = empty.ToQueryString(); +Console.WriteLine($"Empty: '{emptyQs}'"); // Empty: '' ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Net.Http.HttpManagerFactory.md b/.docfx/api/types/Cuemon.Extensions.Net.Http.HttpManagerFactory.md index 73147ad55..814c82286 100644 --- a/.docfx/api/types/Cuemon.Extensions.Net.Http.HttpManagerFactory.md +++ b/.docfx/api/types/Cuemon.Extensions.Net.Http.HttpManagerFactory.md @@ -7,32 +7,40 @@ example: The following example shows how to create an HTTP manager using `HttpManagerFactory` with a custom `IHttpClientFactory`. It performs a GET request and prints the response content. ```csharp +// Program.cs using System; using System.Net.Http; using System.Threading.Tasks; using Cuemon.Extensions.Net.Http; -namespace Cuemon.Extensions.Net.Http; +await new HttpManagerFactoryExample().DemonstrateAsync(); -public class HttpManagerFactoryExample +namespace Cuemon.Extensions.Net.Http { - public async Task DemonstrateAsync() + public class HttpManagerFactoryExample { - var clientFactory = new HttpClientFactoryStub(); + public async Task DemonstrateAsync() + { + var clientFactory = new HttpClientFactoryStub(); - var manager = HttpManagerFactory.CreateManager(clientFactory, "github"); - var response = await manager.HttpGetAsync(new Uri("https://api.github.com")); - Console.WriteLine(await response.Content.ReadAsStringAsync()); - } + var manager = HttpManagerFactory.CreateManager(clientFactory, "github"); + var response = await manager.HttpGetAsync(new Uri("https://api.github.com")); + Console.WriteLine(await response.Content.ReadAsStringAsync()); + } - private class HttpClientFactoryStub : IHttpClientFactory - { - public HttpClient CreateClient(string name) + private class HttpClientFactoryStub : IHttpClientFactory { - var client = new HttpClient(); - client.DefaultRequestHeaders.UserAgent.ParseAdd("HttpManagerFactoryExample"); - return client; + public HttpClient CreateClient(string name) + { + var client = new HttpClient(); + client.DefaultRequestHeaders.UserAgent.ParseAdd("HttpManagerFactoryExample"); + return client; + } } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Net.Http.HttpMethodExtensions.md b/.docfx/api/types/Cuemon.Extensions.Net.Http.HttpMethodExtensions.md index 2362f90a1..f1252f979 100644 --- a/.docfx/api/types/Cuemon.Extensions.Net.Http.HttpMethodExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Net.Http.HttpMethodExtensions.md @@ -7,17 +7,12 @@ example: The following example demonstrates how to convert between System.Net.Http.HttpMethod and the Cuemon HttpMethods enum using HttpMethodExtensions. ```csharp +// Program.cs using System; using System.Net.Http; using Cuemon.Extensions.Net.Http; using Cuemon.Net.Http; -namespace MyApp.Net -{ - public class HttpMethodExtensionsExample - { - public void Demonstrate() - { // Convert System.Net.Http.HttpMethod to the Cuemon HttpMethods enum HttpMethod getMethod = HttpMethod.Get; HttpMethods method = getMethod.ToHttpMethod(); @@ -37,7 +32,9 @@ namespace MyApp.Net { Console.WriteLine("This is a GET request."); -}}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Net.Http.SlimHttpClientFactory.md b/.docfx/api/types/Cuemon.Extensions.Net.Http.SlimHttpClientFactory.md index 23ba42531..b5010e91f 100644 --- a/.docfx/api/types/Cuemon.Extensions.Net.Http.SlimHttpClientFactory.md +++ b/.docfx/api/types/Cuemon.Extensions.Net.Http.SlimHttpClientFactory.md @@ -7,38 +7,30 @@ example: The following example demonstrates how to use to create named instances with a shared handler pool and configurable lifetime. ```csharp +// Program.cs using System; using System.Net.Http; using Cuemon.Extensions.Net.Http; -namespace MyApp.Examples; - -public class SlimHttpClientFactoryExample -{ - public void Demonstrate() +// Create a factory that reuses HttpClientHandler instances per name +var factory = new SlimHttpClientFactory( + () => new HttpClientHandler { - // Create a factory that reuses HttpClientHandler instances per name - var factory = new SlimHttpClientFactory( - () => new HttpClientHandler - { - AllowAutoRedirect = false, - MaxAutomaticRedirections = 5 - }); - - // Create two named clients - they share the same handler pool - using var clientA = factory.CreateClient("ServiceA"); - using var clientB = factory.CreateClient("ServiceB"); - - clientA.BaseAddress = new Uri("https://service-a.example.com"); - clientB.BaseAddress = new Uri("https://service-b.example.com"); + AllowAutoRedirect = false, + MaxAutomaticRedirections = 5 + }); - Console.WriteLine($"ClientA base: {clientA.BaseAddress}"); - Console.WriteLine($"ClientB base: {clientB.BaseAddress}"); +// Create two named clients - they share the same handler pool +using var clientA = factory.CreateClient("ServiceA"); +using var clientB = factory.CreateClient("ServiceB"); - // The handler for "ServiceA" is reused across calls to CreateClient("ServiceA") - // until the configured handler lifetime expires. - -} -} +clientA.BaseAddress = new Uri("https://service-a.example.com"); +clientB.BaseAddress = new Uri("https://service-b.example.com"); +Console.WriteLine($"ClientA base: {clientA.BaseAddress}"); +Console.WriteLine($"ClientB base: {clientB.BaseAddress}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Net.Http.SlimHttpClientFactoryOptions.md b/.docfx/api/types/Cuemon.Extensions.Net.Http.SlimHttpClientFactoryOptions.md index 366701c5c..6eccf5f77 100644 --- a/.docfx/api/types/Cuemon.Extensions.Net.Http.SlimHttpClientFactoryOptions.md +++ b/.docfx/api/types/Cuemon.Extensions.Net.Http.SlimHttpClientFactoryOptions.md @@ -7,36 +7,31 @@ example: The following example demonstrates how to configure with a custom handler lifetime and use it alongside to create named instances. ```csharp +// Program.cs using System; using System.Net.Http; using Cuemon.Extensions.Net.Http; -namespace MyApp.Examples; - -public class SlimHttpClientFactoryOptionsExample +// Direct instantiation of SlimHttpClientFactoryOptions +var factoryOptions = new SlimHttpClientFactoryOptions { - public void Demonstrate() - { - // Direct instantiation of SlimHttpClientFactoryOptions - var factoryOptions = new SlimHttpClientFactoryOptions - { - HandlerLifetime = TimeSpan.FromSeconds(30) - }; - - var factory = new SlimHttpClientFactory( - () => new HttpClientHandler(), - o => - { - o.HandlerLifetime = TimeSpan.FromSeconds(30); - }); + HandlerLifetime = TimeSpan.FromSeconds(30) +}; - // Create a named client - using var client = factory.CreateClient("MyApi"); - client.BaseAddress = new Uri("https://api.example.com"); - - Console.WriteLine($"Client ready: {client.BaseAddress}"); +var factory = new SlimHttpClientFactory( + () => new HttpClientHandler(), + o => + { + o.HandlerLifetime = TimeSpan.FromSeconds(30); + }); -} -} +// Create a named client +using var client = factory.CreateClient("MyApi"); +client.BaseAddress = new Uri("https://api.example.com"); +Console.WriteLine($"Client ready: {client.BaseAddress}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Net.Http.UriExtensions.md b/.docfx/api/types/Cuemon.Extensions.Net.Http.UriExtensions.md index 205da2796..ebac0e2e1 100644 --- a/.docfx/api/types/Cuemon.Extensions.Net.Http.UriExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Net.Http.UriExtensions.md @@ -7,6 +7,7 @@ example: `UriExtensions` provides HTTP extension methods directly on `Uri` covering GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH, and TRACE with support for custom headers, content types, and cancellation. This example assigns a stub `IHttpClientFactory` that returns a fixed `200 OK` response, then calls each HTTP method variant including `HttpGetAsync`, `HttpDeleteAsync`, `HttpPostAsync` with JSON content, `HttpPutAsync` with a stream body, `HttpPatchAsync`, `HttpTraceAsync`, and the generic `HttpAsync` overload for full `HttpRequestOptions` control with custom headers. It also demonstrates passing a `CancellationToken` with a timeout that triggers a `TaskCanceledException`. Console output confirms that each request returns `200 OK` and that cancellation is handled gracefully. ```csharp +// Program.cs using System.Text; using System; using System.IO; @@ -16,6 +17,9 @@ using System.Net.Http.Headers; using System.Threading; using System.Threading.Tasks; using Cuemon.Extensions.Net.Http; +using MyApp.Http; + +await new UriExtensionsExample().DemonstrateAsync(); namespace MyApp.Http { @@ -175,5 +179,8 @@ namespace MyApp.Http } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Net.HttpStatusCodeExtensions.md b/.docfx/api/types/Cuemon.Extensions.Net.HttpStatusCodeExtensions.md index 2105600a0..2f0a88676 100644 --- a/.docfx/api/types/Cuemon.Extensions.Net.HttpStatusCodeExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Net.HttpStatusCodeExtensions.md @@ -44,3 +44,7 @@ namespace DocExamples } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Net.NameValueCollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.Net.NameValueCollectionExtensions.md index 737f09a70..661bdde86 100644 --- a/.docfx/api/types/Cuemon.Extensions.Net.NameValueCollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Net.NameValueCollectionExtensions.md @@ -7,40 +7,35 @@ example: `NameValueCollectionExtensions` in the `Net` namespace converts `NameValueCollection` instances into URL query strings with optional percent-encoding. This example populates a collection with `"name": "John Doe"`, `"city": "Copenhagen"`, and duplicate key `"hobbies": ["reading", "coding"]`, then calls `ToQueryString()` to produce `name=John Doe&city=Copenhagen&hobbies=reading&hobbies=coding` and `ToQueryString(urlEncode: true)` where spaces become `+`. It also handles an empty collection that returns an empty string. Console output shows both query string variants and the empty result. ```csharp +// Program.cs using System; using System.Collections.Specialized; using Cuemon.Extensions.Net; -namespace MyApp.Net +var nvc = new NameValueCollection { - public class NameValueCollectionExtensionsExample - { - public void Demonstrate() - { - var nvc = new NameValueCollection - { - { "name", "John Doe" }, - { "city", "Copenhagen" }, - { "hobbies", "reading" }, - { "hobbies", "coding" } - }; - - // Convert NameValueCollection to a query string (not URL-encoded) - string queryString = nvc.ToQueryString(); - Console.WriteLine(queryString); - // Output: name=John Doe&city=Copenhagen&hobbies=reading&hobbies=coding - - // URL-encode the values for safe HTTP transmission - string encoded = nvc.ToQueryString(urlEncode: true); - Console.WriteLine(encoded); - // Output: name=John+Doe&city=Copenhagen&hobbies=reading&hobbies=coding - - // Empty collection - var empty = new NameValueCollection(); - string emptyResult = empty.ToQueryString(); - Console.WriteLine($"Empty: '{emptyResult}'"); // Empty: '' - -}} -} - + { "name", "John Doe" }, + { "city", "Copenhagen" }, + { "hobbies", "reading" }, + { "hobbies", "coding" } +}; + +// Convert NameValueCollection to a query string (not URL-encoded) +string queryString = nvc.ToQueryString(); +Console.WriteLine(queryString); +// Output: name=John Doe&city=Copenhagen&hobbies=reading&hobbies=coding + +// URL-encode the values for safe HTTP transmission +string encoded = nvc.ToQueryString(urlEncode: true); +Console.WriteLine(encoded); +// Output: name=John+Doe&city=Copenhagen&hobbies=reading&hobbies=coding + +// Empty collection +var empty = new NameValueCollection(); +string emptyResult = empty.ToQueryString(); +Console.WriteLine($"Empty: '{emptyResult}'"); // Empty: '' ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Net.Security.SignedUriOptions.md b/.docfx/api/types/Cuemon.Extensions.Net.Security.SignedUriOptions.md index 1e9eafad8..b20a36b4d 100644 --- a/.docfx/api/types/Cuemon.Extensions.Net.Security.SignedUriOptions.md +++ b/.docfx/api/types/Cuemon.Extensions.Net.Security.SignedUriOptions.md @@ -7,25 +7,25 @@ example: The following example demonstrates how to configure `SignedUriOptions` for generating time-limited signed URIs with HMAC-SHA256. ```csharp +// Program.cs +using System; using Cuemon.Extensions.Net.Security; using Cuemon.Security.Cryptography; -namespace MyApp.Examples; - -public class SignedUriOptionsExample +var options = new SignedUriOptions { - public void Demonstrate() - { - var options = new SignedUriOptions - { - Algorithm = KeyedCryptoAlgorithm.HmacSha256, - SignatureFieldName = "sig", - StartFieldName = "st", - ExpiryFieldName = "se", - UrlEncode = true - }; - -} -} + Algorithm = KeyedCryptoAlgorithm.HmacSha256, + SignatureFieldName = "sig", + StartFieldName = "st", + ExpiryFieldName = "se", + UrlEncode = true +}; +Console.WriteLine(options.Algorithm); +Console.WriteLine(options.SignatureFieldName); +Console.WriteLine(options.UrlEncode); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Net.Security.StringExtensions.md b/.docfx/api/types/Cuemon.Extensions.Net.Security.StringExtensions.md index 2d9a072fb..4f6c60e4f 100644 --- a/.docfx/api/types/Cuemon.Extensions.Net.Security.StringExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Net.Security.StringExtensions.md @@ -7,36 +7,32 @@ example: The following example demonstrates how to sign a URI string and validate the signature later. ```csharp +// Program.cs using System; using System.Security; using System.Text; using Cuemon.Extensions.Net.Security; -namespace MyApp.Examples -{ - public static class SignedStringExtensionsExample - { - public static void Demonstrate() - { - var secret = Encoding.UTF8.GetBytes("1234"); - var uriString = "https://example.com/search?q=cuemon"; - var signedUri = uriString.ToSignedUri(secret, DateTime.UtcNow.AddMinutes(-1), DateTime.UtcNow.AddMinutes(1)); +var secret = Encoding.UTF8.GetBytes("1234"); +var uriString = "https://example.com/search?q=cuemon"; +var signedUri = uriString.ToSignedUri(secret, DateTime.UtcNow.AddMinutes(-1), DateTime.UtcNow.AddMinutes(1)); - signedUri.OriginalString.ValidateSignedUri(secret); +signedUri.OriginalString.ValidateSignedUri(secret); - Console.WriteLine(signedUri); +Console.WriteLine(signedUri); - try - { - var tampered = new UriBuilder(signedUri); - tampered.Query = tampered.Query.TrimStart('?') + "&tampered=1"; - tampered.Uri.OriginalString.ValidateSignedUri(secret); - } - catch (SecurityException ex) - { - Console.WriteLine(ex.Message); - } - } - } +try +{ + var tampered = new UriBuilder(signedUri); + tampered.Query = tampered.Query.TrimStart('?') + "&tampered=1"; + tampered.Uri.OriginalString.ValidateSignedUri(secret); +} +catch (SecurityException ex) +{ + Console.WriteLine(ex.Message); } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Net.Security.UriExtensions.md b/.docfx/api/types/Cuemon.Extensions.Net.Security.UriExtensions.md index 475f10992..329ecd271 100644 --- a/.docfx/api/types/Cuemon.Extensions.Net.Security.UriExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Net.Security.UriExtensions.md @@ -7,25 +7,21 @@ example: The following example demonstrates how to sign and validate a with . ```csharp +// Program.cs using System; using System.Text; using Cuemon.Extensions.Net.Security; -namespace MyApp.Examples -{ - public static class SignedUriExtensionsExample - { - public static void Demonstrate() - { - var secret = Encoding.UTF8.GetBytes("1234"); - var location = new Uri("https://example.com/search?q=cuemon"); - var signed = location.ToSignedUri(secret, DateTime.UtcNow.AddMinutes(-1), DateTime.UtcNow.AddMinutes(1)); +var secret = Encoding.UTF8.GetBytes("1234"); +var location = new Uri("https://example.com/search?q=cuemon"); +var signed = location.ToSignedUri(secret, DateTime.UtcNow.AddMinutes(-1), DateTime.UtcNow.AddMinutes(1)); - signed.ValidateSignedUri(secret); +signed.ValidateSignedUri(secret); - Console.WriteLine(signed != location); - Console.WriteLine(signed.AbsoluteUri); - } - } -} +Console.WriteLine(signed != location); +Console.WriteLine(signed.AbsoluteUri); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Net.StringExtensions.md b/.docfx/api/types/Cuemon.Extensions.Net.StringExtensions.md index 151450378..306cfd158 100644 --- a/.docfx/api/types/Cuemon.Extensions.Net.StringExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Net.StringExtensions.md @@ -7,45 +7,40 @@ example: `StringExtensions` in the `Net` namespace provides URL-encoding and URL-decoding extension methods on `string` with custom encoding support and null-safe handling. This example encodes `"hello world"` to `"hello+world"`, decodes it back, encodes with UTF-32 where each character produces 4 bytes, and handles query-string special characters in `"name=Jane Doe&city=Copenhagen"` producing `"name%3dJane+Doe%26city%3dCopenhagen"`. It also demonstrates null input safety where `((string)null).UrlEncode()` returns `null`. Console output confirms each round-trip operation and the null-safe result. ```csharp +// Program.cs using System.Text; using System; using Cuemon.Extensions.Net; using Cuemon.Text; - using Cuemon; -namespace MyApp.Extensions.Net + +// URL-encode a string directly (no Decorator needed) +string encoded = "hello world".UrlEncode(); +Console.WriteLine(encoded); // "hello+world" + +// URL-decode a previously encoded string +string decoded = "hello+world".UrlDecode(); +Console.WriteLine(decoded); // "hello world" + +// Encode with a custom encoding +string encodedUtf32 = "a & b".UrlEncode(o => { - public class StringExtensionsExample - { - public void Demonstrate() - { - // URL-encode a string directly (no Decorator needed) - string encoded = "hello world".UrlEncode(); - Console.WriteLine(encoded); // "hello+world" - - // URL-decode a previously encoded string - string decoded = "hello+world".UrlDecode(); - Console.WriteLine(decoded); // "hello world" - - // Encode with a custom encoding - string encodedUtf32 = "a & b".UrlEncode(o => - { - o.Encoding = Encoding.UTF32; - }); - - // Encode query-string special characters - string queryEncoded = "name=Jane Doe&city=Copenhagen".UrlEncode(); - Console.WriteLine(queryEncoded); // "name%3dJane+Doe%26city%3dCopenhagen" - - // Decode back - string queryDecoded = queryEncoded.UrlDecode(); - Console.WriteLine(queryDecoded); // "name=Jane Doe&city=Copenhagen" - - // Handle null input safely - string nullResult = ((string)null).UrlEncode(); - Console.WriteLine(nullResult == null); // True - -}} -} + o.Encoding = Encoding.UTF32; +}); +// Encode query-string special characters +string queryEncoded = "name=Jane Doe&city=Copenhagen".UrlEncode(); +Console.WriteLine(queryEncoded); // "name%3dJane+Doe%26city%3dCopenhagen" + +// Decode back +string queryDecoded = queryEncoded.UrlDecode(); +Console.WriteLine(queryDecoded); // "name=Jane Doe&city=Copenhagen" + +// Handle null input safely +string nullResult = ((string)null).UrlEncode(); +Console.WriteLine(nullResult == null); // True ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.ObjectExtensions.md b/.docfx/api/types/Cuemon.Extensions.ObjectExtensions.md index 93f30c05e..868f80bf7 100644 --- a/.docfx/api/types/Cuemon.Extensions.ObjectExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.ObjectExtensions.md @@ -7,56 +7,64 @@ example: `ObjectExtensions` provides extension methods for type conversion with fallback (`As`), wrapper creation (`UseWrapper`), collection manipulation (`Adjust`, `Alter`), and delimited-string formatting. This example converts `"42"` to an `int`, handles `"not-a-number"` with a fallback of `99`, wraps a string with `UseWrapper` to attach metadata, adjusts a `List` by appending elements, and alters it in-place. Key steps include using the `As` method for safe casts, `UseWrapper` for attaching diagnostic data, and `Adjust`/`Alter` for immutable/mutable collection operations. Console output confirms each conversion result, the wrapper data value `"example"`, hash codes, and the delimited string `"1;2;3;4"`. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon.Extensions; +using MyApp.Examples; -namespace MyApp.Examples; +ObjectExtensionsExample.Demonstrate(); -public static class ObjectExtensionsExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class ObjectExtensionsExample { - object raw = "42"; - int number = raw.As(0); - int fallback = "not-a-number".As(99); - object nullValue = null; - int safe = nullValue.As(0); - string upper = "hello".As(value => value.ToUpperInvariant()); - object converted = raw.As(typeof(int)); - - var wrapped = "docs".UseWrapper(extender => + public static void Demonstrate() { - extender["source"] = "example"; - }); + object raw = "42"; + int number = raw.As(0); + int fallback = "not-a-number".As(99); + object nullValue = null; + int safe = nullValue.As(0); + string upper = "hello".As(value => value.ToUpperInvariant()); + object converted = raw.As(typeof(int)); - var memberWrapped = 42.UseWrapper(typeof(int).GetMethod("ToString"), data => - { - data["category"] = "number"; - }); + var wrapped = "docs".UseWrapper(extender => + { + extender["source"] = "example"; + }); - var numbers = new List { 1, 2, 3 }; - var adjusted = numbers.Adjust(list => - { - var copy = new List(list); - copy.Add(4); - return copy; - }); - var altered = numbers.Alter(list => list.Add(4)); - string delimited = adjusted.ToDelimitedString(options => options.Delimiter = ";"); - - Console.WriteLine(number); - Console.WriteLine(fallback); - Console.WriteLine(safe); - Console.WriteLine(upper); - Console.WriteLine(converted); - Console.WriteLine(wrapped.Data["source"]); - Console.WriteLine(memberWrapped.MemberReference?.Name); - Console.WriteLine(adjusted.GetHashCode32()); - Console.WriteLine(altered.GetHashCode64()); - Console.WriteLine(delimited); - Console.WriteLine(default(int?).IsNullable()); + var memberWrapped = 42.UseWrapper(typeof(int).GetMethod(nameof(ToString), Type.EmptyTypes), data => + { + data["category"] = "number"; + }); + + var numbers = new List { 1, 2, 3 }; + var adjusted = numbers.Adjust(list => + { + var copy = new List(list); + copy.Add(4); + return copy; + }); + var altered = numbers.Alter(list => list.Add(4)); + string delimited = adjusted.ToDelimitedString(options => options.Delimiter = ";"); + + Console.WriteLine(number); + Console.WriteLine(fallback); + Console.WriteLine(safe); + Console.WriteLine(upper); + Console.WriteLine(converted); + Console.WriteLine(wrapped.Data["source"]); + Console.WriteLine(memberWrapped.MemberReference?.Name); + Console.WriteLine(adjusted.GetHashCode32()); + Console.WriteLine(altered.GetHashCode64()); + Console.WriteLine(delimited); + Console.WriteLine(default(int?).IsNullable()); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Reflection.AssemblyExtensions.md b/.docfx/api/types/Cuemon.Extensions.Reflection.AssemblyExtensions.md index 577df48fa..16af8c930 100644 --- a/.docfx/api/types/Cuemon.Extensions.Reflection.AssemblyExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Reflection.AssemblyExtensions.md @@ -7,39 +7,34 @@ example: `AssemblyExtensions` provides extension methods for `Assembly` to retrieve version information and debug-build status. This example obtains the entry assembly and calls `GetAssemblyVersion`, `GetFileVersion`, and `GetProductVersion` to read version attributes, then checks `HasAlphanumericVersion` and `IsSemanticVersion()` on the returned `SourceVersion` objects. It also calls `IsDebugBuild()` to determine whether the assembly was compiled in Debug configuration. Console output displays each version string (e.g., `1.0.0.0`), whether it has alphanumeric or semantic version characteristics, and the debug-build flag. ```csharp +// Program.cs using System; -using System.Reflection; +using Assembly = System.Reflection.Assembly; using Cuemon.Extensions.Reflection; -namespace MyApp.Reflection -{ - public class AssemblyExtensionsExample - { - public void Demonstrate() - { - var assembly = typeof(AssemblyExtensionsExample).Assembly; - - // Get the assembly version (from AssemblyVersionAttribute) - var assemblyVersion = assembly.GetAssemblyVersion(); - Console.WriteLine($"Assembly version: {assemblyVersion}"); // e.g., "1.0.0.0" - Console.WriteLine($"Has alphanumeric version: {assemblyVersion.HasAlphanumericVersion}"); // False - Console.WriteLine($"Is semantic version: {assemblyVersion.IsSemanticVersion()}"); // False - - // Get the file version (from AssemblyFileVersionAttribute) - var fileVersion = assembly.GetFileVersion(); - Console.WriteLine($"File version: {fileVersion}"); // e.g., "1.0.0.0" - - // Get the product version (from AssemblyInformationalVersionAttribute) - var productVersion = assembly.GetProductVersion(); - Console.WriteLine($"Product version: {productVersion}"); // e.g., "1.0.0" - Console.WriteLine($"Has alphanumeric version: {productVersion.HasAlphanumericVersion}"); // True (usually) - Console.WriteLine($"Is semantic version: {productVersion.IsSemanticVersion()}"); // True - - // Check if the assembly is a debug build - var isDebug = assembly.IsDebugBuild(); - Console.WriteLine($"Is debug build: {isDebug}"); // True in Debug, False in Release - -}} -} +var assembly = typeof(AssemblyExtensions).Assembly; +// Get the assembly version (from AssemblyVersionAttribute) +var assemblyVersion = assembly.GetAssemblyVersion(); +Console.WriteLine($"Assembly version: {assemblyVersion}"); // e.g., "1.0.0.0" +Console.WriteLine($"Has alphanumeric version: {assemblyVersion.HasAlphanumericVersion}"); // False +Console.WriteLine($"Is semantic version: {assemblyVersion.IsSemanticVersion()}"); // False + +// Get the file version (from AssemblyFileVersionAttribute) +var fileVersion = assembly.GetFileVersion(); +Console.WriteLine($"File version: {fileVersion}"); // e.g., "1.0.0.0" + +// Get the product version (from AssemblyInformationalVersionAttribute) +var productVersion = assembly.GetProductVersion(); +Console.WriteLine($"Product version: {productVersion}"); // e.g., "1.0.0" +Console.WriteLine($"Has alphanumeric version: {productVersion.HasAlphanumericVersion}"); // True (usually) +Console.WriteLine($"Is semantic version: {productVersion.IsSemanticVersion()}"); // True + +// Check if the assembly is a debug build +var isDebug = assembly.IsDebugBuild(); +Console.WriteLine($"Is debug build: {isDebug}"); // True in Debug, False in Release ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Reflection.MemberInfoExtensions.md b/.docfx/api/types/Cuemon.Extensions.Reflection.MemberInfoExtensions.md index 3f79f382b..6b91419db 100644 --- a/.docfx/api/types/Cuemon.Extensions.Reflection.MemberInfoExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Reflection.MemberInfoExtensions.md @@ -38,3 +38,7 @@ public class MemberInfoExtensionsExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Reflection.PropertyInfoExtensions.md b/.docfx/api/types/Cuemon.Extensions.Reflection.PropertyInfoExtensions.md index b8514589f..079234560 100644 --- a/.docfx/api/types/Cuemon.Extensions.Reflection.PropertyInfoExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Reflection.PropertyInfoExtensions.md @@ -7,34 +7,43 @@ example: `PropertyInfoExtensions` provides extension methods for `PropertyInfo` to detect auto-implemented properties via `IsAutoProperty`. This example defines a `Sample` class with an auto-property (`AutoProperty`) and a manually implemented property (`ManualProperty`) that uses a backing field with a null-guard in its setter, then retrieves both `PropertyInfo` instances via reflection and calls `IsAutoProperty` on each. Console output displays `True` for the auto-property and `False` for the manual one, confirming the extension correctly distinguishes compiler-generated get/set accessors from custom implementations. ```csharp +// Program.cs using System; using System.Reflection; using Cuemon.Extensions.Reflection; +using MyApp.Examples; -namespace MyApp.Examples; +PropertyInfoExtensionsExample.Demonstrate(); -public static class PropertyInfoExtensionsExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class PropertyInfoExtensionsExample { - var autoProperty = typeof(Sample).GetProperty(nameof(Sample.AutoProperty), BindingFlags.Instance | BindingFlags.Public); - var manualProperty = typeof(Sample).GetProperty(nameof(Sample.ManualProperty), BindingFlags.Instance | BindingFlags.Public); + public static void Demonstrate() + { + var autoProperty = typeof(Sample).GetProperty(nameof(Sample.AutoProperty), BindingFlags.Instance | BindingFlags.Public); + var manualProperty = typeof(Sample).GetProperty(nameof(Sample.ManualProperty), BindingFlags.Instance | BindingFlags.Public); - Console.WriteLine(autoProperty.IsAutoProperty()); - Console.WriteLine(manualProperty.IsAutoProperty()); - } + Console.WriteLine(autoProperty.IsAutoProperty()); + Console.WriteLine(manualProperty.IsAutoProperty()); + } - private sealed class Sample - { - private string _manual; + private sealed class Sample + { + private string _manual; - public string AutoProperty { get; set; } + public string AutoProperty { get; set; } - public string ManualProperty - { - get => _manual; - set => _manual = value ?? throw new ArgumentNullException(nameof(value)); + public string ManualProperty + { + get => _manual; + set => _manual = value ?? throw new ArgumentNullException(nameof(value)); + } } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Reflection.TypeExtensions.md b/.docfx/api/types/Cuemon.Extensions.Reflection.TypeExtensions.md index c87b65310..24fde1804 100644 --- a/.docfx/api/types/Cuemon.Extensions.Reflection.TypeExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Reflection.TypeExtensions.md @@ -7,60 +7,69 @@ example: `TypeExtensions` in the `Reflection` namespace provides methods for inspecting type hierarchies and enumerating members across the inheritance tree. This example uses `typeof(Stream)` to retrieve derived, inherited, and hierarchy types via `GetDerivedTypes`, `GetInheritedTypes`, and `GetHierarchyTypes`, then uses `TypeCatalog` (extending `BaseCatalog`) with `GetAllProperties`, `GetAllEvents`, `GetAllFields`, and `GetAllMethods` to enumerate members. It also demonstrates `GetRuntimePropertiesExceptOf` to exclude inherited properties, `GetEmbeddedResources` for assembly resource lookup, and `ToFullNameIncludingAssemblyName` for a fully qualified type name. Console output confirms member names, hierarchy inclusion (e.g., `Stream` in `GetHierarchyTypes`), and assembly-qualified type identity. ```csharp +// Program.cs using System; using System.IO; using System.Linq; using Cuemon; using Cuemon.Extensions.Reflection; using Cuemon.Reflection; +using MyApp.Examples; -namespace MyApp.Examples; +TypeExtensionsExample.Demonstrate(); -public static class TypeExtensionsExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class TypeExtensionsExample { - var streamType = typeof(Stream); - var derivedTypes = streamType.GetDerivedTypes().Where(type => type.IsPublic).Select(type => type.Name).Take(3).ToArray(); - var inheritedTypes = streamType.GetInheritedTypes().Select(type => type.Name).ToArray(); - var properties = typeof(TypeArgumentOutOfRangeException).GetAllProperties().Select(property => property.Name).ToArray(); - var events = typeof(TypeCatalog).GetAllEvents().Select(@event => @event.Name).ToArray(); - var fields = typeof(TypeCatalog).GetAllFields().Select(field => field.Name).ToArray(); - var methods = typeof(TypeCatalog).GetAllMethods().Select(method => method.Name).ToArray(); - var hierarchy = typeof(Stream).GetHierarchyTypes().Select(type => type.Name).ToArray(); - var resources = typeof(TypeExtensionsExample).GetEmbeddedResources("missing", ManifestResourceMatch.ContainsName); - var ownProperties = typeof(TypeCatalog).GetRuntimePropertiesExceptOf().Select(property => property.Name).ToArray(); - var fullName = typeof(TypeCatalog).ToFullNameIncludingAssemblyName(); + public static void Demonstrate() + { + var streamType = typeof(Stream); + var derivedTypes = streamType.GetDerivedTypes().Where(type => type.IsPublic).Select(type => type.Name).Take(3).ToArray(); + var inheritedTypes = streamType.GetInheritedTypes().Select(type => type.Name).ToArray(); + var properties = typeof(TypeArgumentOutOfRangeException).GetAllProperties().Select(property => property.Name).ToArray(); + var events = typeof(TypeCatalog).GetAllEvents().Select(@event => @event.Name).ToArray(); + var fields = typeof(TypeCatalog).GetAllFields().Select(field => field.Name).ToArray(); + var methods = typeof(TypeCatalog).GetAllMethods().Select(method => method.Name).ToArray(); + var hierarchy = typeof(Stream).GetHierarchyTypes().Select(type => type.Name).ToArray(); + var resources = typeof(TypeExtensionsExample).GetEmbeddedResources("missing", ManifestResourceMatch.ContainsName); + var ownProperties = typeof(TypeCatalog).GetRuntimePropertiesExceptOf().Select(property => property.Name).ToArray(); + var fullName = typeof(TypeCatalog).ToFullNameIncludingAssemblyName(); - Console.WriteLine(string.Join(", ", derivedTypes)); - Console.WriteLine(string.Join(", ", inheritedTypes)); - Console.WriteLine(properties.Contains(nameof(TypeArgumentOutOfRangeException.ActualValue))); - Console.WriteLine(events.Contains(nameof(TypeCatalog.Changed))); - Console.WriteLine(fields.Contains(nameof(TypeCatalog._state))); - Console.WriteLine(methods.Contains(nameof(TypeCatalog.MarkChanged))); - Console.WriteLine(hierarchy.Contains(nameof(Stream))); - Console.WriteLine(resources.Count); - Console.WriteLine(ownProperties.Contains(nameof(TypeCatalog.Name))); - Console.WriteLine(fullName.Contains(nameof(TypeCatalog))); - } + Console.WriteLine(string.Join(", ", derivedTypes)); + Console.WriteLine(string.Join(", ", inheritedTypes)); + Console.WriteLine(properties.Contains(nameof(TypeArgumentOutOfRangeException.ActualValue))); + Console.WriteLine(events.Contains(nameof(TypeCatalog.Changed))); + Console.WriteLine(fields.Contains(nameof(TypeCatalog._state))); + Console.WriteLine(methods.Contains(nameof(TypeCatalog.MarkChanged))); + Console.WriteLine(hierarchy.Contains(nameof(Stream))); + Console.WriteLine(resources.Count); + Console.WriteLine(ownProperties.Contains(nameof(TypeCatalog.Name))); + Console.WriteLine(fullName.Contains(nameof(TypeCatalog))); + } - private abstract class BaseCatalog - { - public int Id { get; set; } - } + private abstract class BaseCatalog + { + public int Id { get; set; } + } - private sealed class TypeCatalog : BaseCatalog - { - internal string _state = "draft"; + private sealed class TypeCatalog : BaseCatalog + { + internal string _state = "draft"; - public string Name { get; set; } = "Extensions"; + public string Name { get; set; } = "Extensions"; - public event EventHandler Changed; + public event EventHandler Changed; - public void MarkChanged() - { - Changed?.Invoke(this, EventArgs.Empty); + public void MarkChanged() + { + Changed?.Invoke(this, EventArgs.Empty); + } } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.RoundOffAccuracy.md b/.docfx/api/types/Cuemon.Extensions.RoundOffAccuracy.md index 4b66a9099..9ed6470b3 100644 --- a/.docfx/api/types/Cuemon.Extensions.RoundOffAccuracy.md +++ b/.docfx/api/types/Cuemon.Extensions.RoundOffAccuracy.md @@ -7,22 +7,18 @@ example: The following example demonstrates how to use the enum with the extension method to round double values to the nearest specified accuracy. ```csharp +// Program.cs using System; using Cuemon.Extensions; -namespace MyApp.Examples; - -public static class RoundOffAccuracyExample -{ - public static void Demonstrate() - { - double value = 123456789.987654321d; - - Console.WriteLine(value.RoundOff(RoundOffAccuracy.NearestTenth)); - Console.WriteLine(value.RoundOff(RoundOffAccuracy.NearestHundredth)); - Console.WriteLine(value.RoundOff(RoundOffAccuracy.NearestThousandth)); - Console.WriteLine(value.RoundOff(RoundOffAccuracy.NearestMillion)); - } -} +double value = 123456789.987654321d; +Console.WriteLine(value.RoundOff(RoundOffAccuracy.NearestTenth)); +Console.WriteLine(value.RoundOff(RoundOffAccuracy.NearestHundredth)); +Console.WriteLine(value.RoundOff(RoundOffAccuracy.NearestThousandth)); +Console.WriteLine(value.RoundOff(RoundOffAccuracy.NearestMillion)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Runtime.Caching.CacheEnumerableExtensions.md b/.docfx/api/types/Cuemon.Extensions.Runtime.Caching.CacheEnumerableExtensions.md index ab4eea86f..a4d4d85b9 100644 --- a/.docfx/api/types/Cuemon.Extensions.Runtime.Caching.CacheEnumerableExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Runtime.Caching.CacheEnumerableExtensions.md @@ -7,25 +7,22 @@ example: The following example demonstrates how to cache a generated value and memoize a delegate with . ```csharp +// Program.cs using System; using Cuemon.Extensions.Runtime.Caching; using Cuemon.Runtime.Caching; -namespace MyApp.Examples; +ICacheEnumerable cache = new SlimMemoryCache(); -public static class CacheEnumerableExtensionsExample -{ - public static void Demonstrate() - { - ICacheEnumerable cache = new SlimMemoryCache(); +var timestamp = cache.GetOrAdd("current-time", TimeSpan.FromSeconds(30), () => DateTime.UtcNow.ToString("O")); +var cachedAgain = cache.GetOrAdd("current-time", TimeSpan.FromSeconds(30), () => "should-not-be-used"); - var timestamp = cache.GetOrAdd("current-time", TimeSpan.FromSeconds(30), () => DateTime.UtcNow.ToString("O")); - var cachedAgain = cache.GetOrAdd("current-time", TimeSpan.FromSeconds(30), () => "should-not-be-used"); +var memoized = cache.Memoize(TimeSpan.FromSeconds(30), () => 42); - var memoized = cache.Memoize(TimeSpan.FromSeconds(30), () => 42); - - Console.WriteLine(timestamp == cachedAgain); - Console.WriteLine(memoized()); - } -} +Console.WriteLine(timestamp == cachedAgain); +Console.WriteLine(memoized()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Runtime.Hierarchy.md b/.docfx/api/types/Cuemon.Extensions.Runtime.Hierarchy.md index 0ddecae90..2a1ec6e24 100644 --- a/.docfx/api/types/Cuemon.Extensions.Runtime.Hierarchy.md +++ b/.docfx/api/types/Cuemon.Extensions.Runtime.Hierarchy.md @@ -7,34 +7,31 @@ example: The following example demonstrates how to build and traverse a hierarchical tree structure using `Hierarchy`. It shows adding nodes, printing paths, searching for nodes with `Find`, and generating an object hierarchy from an anonymous type. ```csharp +// Program.cs using System; using System.Linq; using Cuemon.Extensions.Runtime; -namespace Cuemon.Extensions.Runtime; +var root = new Hierarchy(); +root.Add("root"); -public class HierarchyExample -{ - public void Demonstrate() - { - var root = new Hierarchy(); - root.Add("root"); +var child1 = root.Add("department"); +var child2 = root.Add("team"); - var child1 = root.Add("department"); - var child2 = root.Add("team"); +child1.Add("employee1"); +child1.Add("employee2"); - child1.Add("employee1"); - child1.Add("employee2"); +Console.WriteLine(root.GetPath()); +Console.WriteLine(child1.GetPath(n => n.Instance.ToString().ToUpper())); - Console.WriteLine(root.GetPath()); - Console.WriteLine(child1.GetPath(n => n.Instance.ToString().ToUpper())); +var matches = Hierarchy.Find(root, n => n.Instance.ToString().StartsWith("employee")); +Console.WriteLine($"Found {matches.Count()} node(s)"); - var matches = Hierarchy.Find(root, n => n.Instance.ToString().StartsWith("employee")); - Console.WriteLine($"Found {matches.Count()} node(s)"); - - var obj = new { Name = "Root", Items = new[] { new { Id = 1 }, new { Id = 2 } } }; - IHierarchy tree = Hierarchy.GetObjectHierarchy(obj); - Console.WriteLine(tree.GetPath(n => n.InstanceType.Name)); - } -} +var obj = new { Name = "Root", Items = new[] { new { Id = 1 }, new { Id = 2 } } }; +IHierarchy tree = Hierarchy.GetObjectHierarchy(obj); +Console.WriteLine(tree.GetPath(n => n.InstanceType.Name)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Runtime.HierarchyDecoratorExtensions.md b/.docfx/api/types/Cuemon.Extensions.Runtime.HierarchyDecoratorExtensions.md index 82a9aaab9..6d50fe70a 100644 --- a/.docfx/api/types/Cuemon.Extensions.Runtime.HierarchyDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Runtime.HierarchyDecoratorExtensions.md @@ -7,146 +7,154 @@ example: `HierarchyDecoratorExtensions` provides extension methods on `Decorator.Enclose` for navigating, replacing, and materializing hierarchy trees built from `Hierarchy` nodes. This example builds a three-level string hierarchy (`root` → `child-one` → `grandchild`) and demonstrates root navigation, ancestor/descendant/sibling traversal, node replacement, and `DataPair` value extraction using typed formatters like `UseConvertibleFormatter`, `UseDateTimeFormatter`, and `UseGuidFormatter`. Key steps include using `Decorator.Enclose` to call methods such as `Root()`, `AncestorsAndSelf()`, `Replace()`, and `UseCollection()`. Console output confirms the root node name (`"root"`), ancestor chain (`"root > child-one"`), and typed values extracted from `DataPair` nodes. ```csharp +// Program.cs using System; using System.Collections; using System.Collections.Generic; using System.Linq; using Cuemon; using Cuemon.Extensions.Runtime; +using MyApp.Examples; -namespace MyApp.Examples; +HierarchyDecoratorExtensionsExample.Demonstrate(); -public static class HierarchyDecoratorExtensionsExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class HierarchyDecoratorExtensionsExample { - var root = BuildStringHierarchy(out var childOne, out var grandchild, out _); - - var rootNode = Decorator.Enclose(grandchild).Root(); - var ancestors = Decorator.Enclose(grandchild).AncestorsAndSelf().Select(node => node.Instance).ToArray(); - var descendants = Decorator.Enclose(root).DescendantsAndSelf().Select(node => node.Instance).ToArray(); - var siblings = Decorator.Enclose(childOne).SiblingsAndSelf().Select(node => node.Instance).ToArray(); - var nodesAtDepth = Decorator.Enclose(grandchild).SiblingsAndSelfAt(1).Select(node => node.Instance).ToArray(); - var flattened = Decorator.Enclose(childOne).FlattenAll().Select(node => node.Instance).ToArray(); - var firstChildName = Decorator.Enclose(root).FindFirstInstance(node => node.Instance.StartsWith("child", StringComparison.Ordinal)); - var grandchildName = Decorator.Enclose(root).FindSingleInstance(node => node.Instance == "grandchild"); - var firstChildNode = Decorator.Enclose(root).FindFirst(node => node.Depth == 1); - var grandchildNode = Decorator.Enclose(root).FindSingle(node => node.Instance == "grandchild"); - var childNames = Decorator.Enclose(root).FindInstance(node => node.Depth == 1).OrderBy(name => name).ToArray(); - var childNodes = Decorator.Enclose(root).Find(node => node.Depth == 1).ToArray(); - var indexedNode = Decorator.Enclose(root).NodeAt(2); - - Decorator.Enclose(grandchild).Replace((node, value) => node.Replace(value.ToUpperInvariant())); - Decorator.Enclose(Decorator.Enclose(root).Find(node => node.Depth == 1)).ReplaceAll((node, value) => node.Replace(value.ToUpperInvariant())); - - var integerNode = BuildDataPairHierarchy(new DataPair(typeof(int).Name, "42", typeof(string))); - var timestamp = new DateTime(2024, 1, 2, 3, 4, 5, DateTimeKind.Utc); - var dateTimeNode = BuildDataPairHierarchy(new DataPair("When", timestamp, typeof(DateTime))); - var guid = Guid.Parse("11111111-2222-3333-4444-555555555555"); - var guidNode = BuildDataPairHierarchy(new DataPair("Value", guid.ToString("D"), typeof(string))); - var stringNode = BuildDataPairHierarchy(new DataPair("Text", "hello", typeof(string))); - var decimalNode = BuildDataPairHierarchy(new DataPair("Amount", "42.5", typeof(string))); - var uri = new Uri("https://example.com/path?value=42", UriKind.Absolute); - var uriNode = BuildDataPairHierarchy(new DataPair("OriginalString", uri.OriginalString, typeof(string))); - - var typedValues = new object[] + public static void Demonstrate() { - Decorator.Enclose(integerNode).UseConvertibleFormatter(), - Decorator.Enclose(dateTimeNode).UseDateTimeFormatter(), - Decorator.Enclose(guidNode).UseGuidFormatter(), - Decorator.Enclose(stringNode).UseStringFormatter(), - Decorator.Enclose(decimalNode).UseDecimalFormatter(), - Decorator.Enclose(uriNode).UseUriFormatter() - }; - - ICollection prices = Decorator.Enclose(BuildCollectionHierarchy(typeof(decimal), "42.5", "84.0")).UseCollection(typeof(decimal)); - IDictionary milestones = Decorator.Enclose(BuildDictionaryHierarchy( - typeof(DateTime), - new KeyValuePair("created", timestamp), - new KeyValuePair("updated", timestamp.AddHours(2)))) - .UseDictionary(new[] { typeof(string), typeof(DateTime) }); - - Console.WriteLine(rootNode.Instance); - Console.WriteLine(string.Join(" > ", ancestors)); - Console.WriteLine(string.Join(", ", descendants)); - Console.WriteLine(string.Join(", ", siblings)); - Console.WriteLine(string.Join(", ", nodesAtDepth)); - Console.WriteLine(string.Join(", ", flattened)); - Console.WriteLine(firstChildName); - Console.WriteLine(grandchildName); - Console.WriteLine(firstChildNode.Instance); - Console.WriteLine(grandchildNode.Instance); - Console.WriteLine(string.Join(", ", childNames)); - Console.WriteLine(childNodes.Length); - Console.WriteLine(indexedNode.Instance); - Console.WriteLine(grandchild.Instance); - Console.WriteLine(string.Join(", ", root.GetChildren().Select(node => node.Instance))); - Console.WriteLine(string.Join(", ", typedValues)); - Console.WriteLine(string.Join(", ", prices.Cast())); - Console.WriteLine(string.Join(", ", milestones.Keys.Cast())); - } - - private static Hierarchy BuildStringHierarchy(out IHierarchy childOne, out IHierarchy grandchild, out IHierarchy childTwo) - { - var root = new Hierarchy(); - root.Add("root"); - childOne = root.Add("child-one"); - grandchild = childOne.Add("grandchild"); - childTwo = root.Add("child-two"); - return root; - } - - private static IHierarchy BuildDataPairHierarchy(DataPair pair) - { - var hierarchy = new Hierarchy(); - hierarchy.Add(pair); - return hierarchy; - } + var root = BuildStringHierarchy(out var childOne, out var grandchild, out _); + + var rootNode = Decorator.Enclose(grandchild).Root(); + var ancestors = Decorator.Enclose(grandchild).AncestorsAndSelf().Select(node => node.Instance).ToArray(); + var descendants = Decorator.Enclose(root).DescendantsAndSelf().Select(node => node.Instance).ToArray(); + var siblings = Decorator.Enclose(childOne).SiblingsAndSelf().Select(node => node.Instance).ToArray(); + var nodesAtDepth = Decorator.Enclose(grandchild).SiblingsAndSelfAt(1).Select(node => node.Instance).ToArray(); + var flattened = Decorator.Enclose(childOne).FlattenAll().Select(node => node.Instance).ToArray(); + var firstChildName = Decorator.Enclose(root).FindFirstInstance(node => node.Instance.StartsWith("child", StringComparison.Ordinal)); + var grandchildName = Decorator.Enclose(root).FindSingleInstance(node => node.Instance == "grandchild"); + var firstChildNode = Decorator.Enclose(root).FindFirst(node => node.Depth == 1); + var grandchildNode = Decorator.Enclose(root).FindSingle(node => node.Instance == "grandchild"); + var childNames = Decorator.Enclose(root).FindInstance(node => node.Depth == 1).OrderBy(name => name).ToArray(); + var childNodes = Decorator.Enclose(root).Find(node => node.Depth == 1).ToArray(); + var indexedNode = Decorator.Enclose(root).NodeAt(2); + + Decorator.Enclose(grandchild).Replace((node, value) => node.Replace(value.ToUpperInvariant())); + Decorator.Enclose(Decorator.Enclose(root).Find(node => node.Depth == 1)).ReplaceAll((node, value) => node.Replace(value.ToUpperInvariant())); + + var integerNode = BuildDataPairHierarchy(new DataPair(typeof(int).Name, "42", typeof(string))); + var timestamp = new DateTime(2024, 1, 2, 3, 4, 5, DateTimeKind.Utc); + var dateTimeNode = BuildDataPairHierarchy(new DataPair("When", timestamp, typeof(DateTime))); + var guid = Guid.Parse("11111111-2222-3333-4444-555555555555"); + var guidNode = BuildDataPairHierarchy(new DataPair("Value", guid.ToString("D"), typeof(string))); + var stringNode = BuildDataPairHierarchy(new DataPair("Text", "hello", typeof(string))); + var decimalNode = BuildDataPairHierarchy(new DataPair("Amount", "42.5", typeof(string))); + var uri = new Uri("https://example.com/path?value=42", UriKind.Absolute); + var uriNode = BuildDataPairHierarchy(new DataPair("OriginalString", uri.OriginalString, typeof(string))); + + var typedValues = new object[] + { + Decorator.Enclose(integerNode).UseConvertibleFormatter(), + Decorator.Enclose(dateTimeNode).UseDateTimeFormatter(), + Decorator.Enclose(guidNode).UseGuidFormatter(), + Decorator.Enclose(stringNode).UseStringFormatter(), + Decorator.Enclose(decimalNode).UseDecimalFormatter(), + Decorator.Enclose(uriNode).UseUriFormatter() + }; + + ICollection prices = Decorator.Enclose(BuildCollectionHierarchy(typeof(decimal), "42.5", "84.0")).UseCollection(typeof(decimal)); + IDictionary milestones = Decorator.Enclose(BuildDictionaryHierarchy( + typeof(DateTime), + new KeyValuePair("created", timestamp), + new KeyValuePair("updated", timestamp.AddHours(2)))) + .UseDictionary(new[] { typeof(string), typeof(DateTime) }); + + Console.WriteLine(rootNode.Instance); + Console.WriteLine(string.Join(" > ", ancestors)); + Console.WriteLine(string.Join(", ", descendants)); + Console.WriteLine(string.Join(", ", siblings)); + Console.WriteLine(string.Join(", ", nodesAtDepth)); + Console.WriteLine(string.Join(", ", flattened)); + Console.WriteLine(firstChildName); + Console.WriteLine(grandchildName); + Console.WriteLine(firstChildNode.Instance); + Console.WriteLine(grandchildNode.Instance); + Console.WriteLine(string.Join(", ", childNames)); + Console.WriteLine(childNodes.Length); + Console.WriteLine(indexedNode.Instance); + Console.WriteLine(grandchild.Instance); + Console.WriteLine(string.Join(", ", root.GetChildren().Select(node => node.Instance))); + Console.WriteLine(string.Join(", ", typedValues)); + Console.WriteLine(string.Join(", ", prices.Cast())); + Console.WriteLine(string.Join(", ", milestones.Keys.Cast())); + } - private static IHierarchy BuildCollectionHierarchy(Type valueType, params object[] values) - { - var hierarchy = new Hierarchy(); - hierarchy.Add(new DataPair("Items", null, typeof(List))); - foreach (var value in values) + private static Hierarchy BuildStringHierarchy(out IHierarchy childOne, out IHierarchy grandchild, out IHierarchy childTwo) { - hierarchy.Add(CreateValuePair(valueType, value)); + var root = new Hierarchy(); + root.Add("root"); + childOne = root.Add("child-one"); + grandchild = childOne.Add("grandchild"); + childTwo = root.Add("child-two"); + return root; } - return hierarchy; - } - - private static IHierarchy BuildDictionaryHierarchy(Type valueType, params KeyValuePair[] values) - { - var hierarchy = new Hierarchy(); - hierarchy.Add(new DataPair("Entries", null, typeof(Dictionary))); - foreach (var value in values) + private static IHierarchy BuildDataPairHierarchy(DataPair pair) { - var keyNode = hierarchy.Add(new DataPair("Key", value.Key, typeof(string))); - keyNode.Add(CreateValuePair(valueType, value.Value)); + var hierarchy = new Hierarchy(); + hierarchy.Add(pair); + return hierarchy; } - return hierarchy; - } - - private static DataPair CreateValuePair(Type valueType, object value) - { - if (valueType.IsPrimitive) + private static IHierarchy BuildCollectionHierarchy(Type valueType, params object[] values) { - return new DataPair(valueType.Name, value, value.GetType()); + var hierarchy = new Hierarchy(); + hierarchy.Add(new DataPair("Items", null, typeof(List))); + foreach (var value in values) + { + hierarchy.Add(CreateValuePair(valueType, value)); + } + + return hierarchy; } - if (valueType == typeof(Uri)) + private static IHierarchy BuildDictionaryHierarchy(Type valueType, params KeyValuePair[] values) { - return new DataPair("OriginalString", value, typeof(string)); + var hierarchy = new Hierarchy(); + hierarchy.Add(new DataPair("Entries", null, typeof(Dictionary))); + foreach (var value in values) + { + var keyNode = hierarchy.Add(new DataPair("Key", value.Key, typeof(string))); + keyNode.Add(CreateValuePair(valueType, value.Value)); + } + + return hierarchy; } - if (valueType == typeof(DateTime)) + private static DataPair CreateValuePair(Type valueType, object value) { - return new DataPair("When", value, typeof(DateTime)); + if (valueType.IsPrimitive) + { + return new DataPair(valueType.Name, value, value.GetType()); + } + + if (valueType == typeof(Uri)) + { + return new DataPair("OriginalString", value, typeof(string)); + } + + if (valueType == typeof(DateTime)) + { + return new DataPair("When", value, typeof(DateTime)); + } + + return new DataPair("Value", value, value?.GetType() ?? typeof(object)); } - - return new DataPair("Value", value, value?.GetType() ?? typeof(object)); } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Runtime.HierarchyOptions.md b/.docfx/api/types/Cuemon.Extensions.Runtime.HierarchyOptions.md index 21cd86820..60e6a4856 100644 --- a/.docfx/api/types/Cuemon.Extensions.Runtime.HierarchyOptions.md +++ b/.docfx/api/types/Cuemon.Extensions.Runtime.HierarchyOptions.md @@ -7,48 +7,45 @@ example: The following example demonstrates how to configure to control the depth of object hierarchy traversal and skip specific property types. ```csharp +// Program.cs using System; using System.Linq; using Cuemon.Extensions.Runtime; -namespace MyApp.Examples; +// Direct instantiation of HierarchyOptions +var hierarchyOptions = new HierarchyOptions +{ + MaxDepth = 2, + SkipPropertyType = t => t == typeof(string) || t.IsValueType +}; -public class HierarchyOptionsExample +var source = new { - public void Demonstrate() + Name = "Root", + Value = 42, + Nested = new { - // Direct instantiation of HierarchyOptions - var hierarchyOptions = new HierarchyOptions + Deep = new { - MaxDepth = 2, - SkipPropertyType = t => t == typeof(string) || t.IsValueType - }; + Deeper = "found" + } + } +}; - var source = new - { - Name = "Root", - Value = 42, - Nested = new - { - Deep = new - { - Deeper = "found" - } - } - }; - - // Limit depth to 2 and skip string types - var hierarchy = Hierarchy.GetObjectHierarchy(source, o => - { - o.MaxDepth = 2; - o.SkipPropertyType = t => t == typeof(string) || t.IsValueType; - }); +// Limit depth to 2 and skip string types +var hierarchy = Hierarchy.GetObjectHierarchy(source, o => +{ + o.MaxDepth = 2; + o.SkipPropertyType = t => t == typeof(string) || t.IsValueType; +}); - var root = hierarchy; - Console.WriteLine($"Root type: {root.InstanceType.Name}"); // Anonymous type +var root = hierarchy; +Console.WriteLine($"Root type: {root.InstanceType.Name}"); // Anonymous type - var children = root.GetChildren().ToList(); - Console.WriteLine($"Children count: {children.Count}"); // 0 (all primitive types skipped) - } -} +var children = root.GetChildren().ToList(); +Console.WriteLine($"Children count: {children.Count}"); // 0 (all primitive types skipped) ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Runtime.Hierarchy`1.md b/.docfx/api/types/Cuemon.Extensions.Runtime.Hierarchy`1.md index 2c08b5310..be52b7ac5 100644 --- a/.docfx/api/types/Cuemon.Extensions.Runtime.Hierarchy`1.md +++ b/.docfx/api/types/Cuemon.Extensions.Runtime.Hierarchy`1.md @@ -7,40 +7,37 @@ example: The following example demonstrates how to build a tree structure using and navigate nodes through parent-child relationships, depth, index, and path. ```csharp +// Program.cs using System; using System.Linq; using Cuemon.Extensions.Runtime; -namespace MyApp.Examples; - -public class HierarchyOfTExample +var root = new Hierarchy(); +var rootNode = root.Add("Root"); +var child = root.Add("Child"); +var grandchild = child.Add("Grandchild"); +var sibling = root.Add("Sibling"); + +Console.WriteLine($"Root depth: {root.Depth}, index: {root.Index}"); // 0, 0 +Console.WriteLine($"Child depth: {child.Depth}, index: {child.Index}"); // 1, 1 +Console.WriteLine($"Grandchild depth: {grandchild.Depth}"); // 2 +Console.WriteLine($"Path: {grandchild.GetPath()}"); // Root.Child.Grandchild +Console.WriteLine($"HasChildren: {root.HasChildren}"); // True +Console.WriteLine($"HasParent: {child.HasParent}"); // True + +// Retrieve via indexer +Console.WriteLine(root[0].Instance); // Root +Console.WriteLine(root[2].Instance); // Grandchild + +// Enumerate children +foreach (var node in root.GetChildren()) { - public void Demonstrate() - { - var root = new Hierarchy(); - var rootNode = root.Add("Root"); - var child = root.Add("Child"); - var grandchild = child.Add("Grandchild"); - var sibling = root.Add("Sibling"); - - Console.WriteLine($"Root depth: {root.Depth}, index: {root.Index}"); // 0, 0 - Console.WriteLine($"Child depth: {child.Depth}, index: {child.Index}"); // 1, 1 - Console.WriteLine($"Grandchild depth: {grandchild.Depth}"); // 2 - Console.WriteLine($"Path: {grandchild.GetPath()}"); // Root.Child.Grandchild - Console.WriteLine($"HasChildren: {root.HasChildren}"); // True - Console.WriteLine($"HasParent: {child.HasParent}"); // True - - // Retrieve via indexer - Console.WriteLine(root[0].Instance); // Root - Console.WriteLine(root[2].Instance); // Grandchild - - // Enumerate children - foreach (var node in root.GetChildren()) - { - Console.WriteLine(node.Instance); - // Output: Child, Sibling - -}} -} + Console.WriteLine(node.Instance); +// Output: Child, Sibling +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Runtime.Serialization.HierarchySerializer.md b/.docfx/api/types/Cuemon.Extensions.Runtime.Serialization.HierarchySerializer.md index 93395a53f..77d3a6f4e 100644 --- a/.docfx/api/types/Cuemon.Extensions.Runtime.Serialization.HierarchySerializer.md +++ b/.docfx/api/types/Cuemon.Extensions.Runtime.Serialization.HierarchySerializer.md @@ -7,37 +7,45 @@ example: `HierarchySerializer` converts any object graph into a hierarchical node structure (`IHierarchy`) for inspection and path-based representation. This example creates a `ReportRoot` with a `Name` of `"alpha"` and a `ReportChild` with `Count = 7`, passes it to the `HierarchySerializer` constructor, and accesses the root node's instance type name, checks whether it has children, and prints the tree path representation via `ToString()`. Key steps include constructing a serializer from a plain object and reading the resulting node properties. Console output displays the `ReportRoot` type name, `True` for `HasChildren`, and a path-based tree showing `ReportRoot > ReportChild`. ```csharp +// Program.cs using System; using Cuemon.Extensions.Runtime.Serialization; +using MyApp.Examples; -namespace MyApp.Examples; +HierarchySerializerExample.Demonstrate(); -public static class HierarchySerializerExample +namespace MyApp.Examples { - private sealed class ReportRoot + public static class HierarchySerializerExample { - public string Name { get; set; } = string.Empty; - - public ReportChild Child { get; set; } = new ReportChild(); - } + private sealed class ReportRoot + { + public string Name { get; set; } = string.Empty; - private sealed class ReportChild - { - public int Count { get; set; } - } + public ReportChild Child { get; set; } = new ReportChild(); + } - public static void Demonstrate() - { - var serializer = new HierarchySerializer(new ReportRoot + private sealed class ReportChild { - Name = "alpha", - Child = new ReportChild { Count = 7 } - }); + public int Count { get; set; } + } - Console.WriteLine(serializer.Nodes.InstanceType.Name); - Console.WriteLine(serializer.Nodes.HasChildren); - Console.WriteLine(serializer.ToString()); + public static void Demonstrate() + { + var serializer = new HierarchySerializer(new ReportRoot + { + Name = "alpha", + Child = new ReportChild { Count = 7 } + }); + + Console.WriteLine(serializer.Nodes.InstanceType.Name); + Console.WriteLine(serializer.Nodes.HasChildren); + Console.WriteLine(serializer.ToString()); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.StringExtensions.md b/.docfx/api/types/Cuemon.Extensions.StringExtensions.md index 6351b5ab4..9d5746ee6 100644 --- a/.docfx/api/types/Cuemon.Extensions.StringExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.StringExtensions.md @@ -7,6 +7,7 @@ example: `StringExtensions` provides a comprehensive set of extension methods for `string` covering trimming, casing, content inspection, encoding, parsing, and utility operations. This example applies `TrimAll` to remove whitespace, `ToCasing` with `LowerCase`, `UpperCase`, and `TitleCase` modes, and content checks like `IsEmailAddress`, `IsGuid`, `IsHex`, `IsNumeric`, and `IsBase64`. It also demonstrates encoding conversions (`ToByteArray`, `ToHexadecimal`, `FromBase64`, `FromUrlEncodedBase64`), enum parsing (`"Monday".ToEnum()`), delimited-string splitting (`SplitDelimited` with quoted fields), and utility operations such as `Count`, `Difference`, `JsEscape`, `Chunk`, `PrefixWith`, `SuffixWith`, and `ToGuid`. Console output confirms transformations like `" Hello, World! "` trimmed to `"Hello,World!"`, `"hello".SuffixWith(" world")` producing `"hello world"`, and `"Monday".ToEnum()` returning `DayOfWeek.Monday`. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Globalization; @@ -15,104 +16,99 @@ using Cuemon; using Cuemon.Extensions; using Cuemon.Text; -namespace MyApp.Examples; - -public class Example -{ - public void Run() - { - var value = " Hello, World! "; - var answer = "yes"; - var chunkSource = "abcdefgh"; - var plainText = "Hello"; - var encodedText = "SGVsbG8="; - var binarySource = "1101"; - var dayName = "Monday"; - var timeSource = "42"; - var counted = "hello"; - var quoted = "hello's"; - var guidSource = "550e8400-e29b-41d4-a716-446655440000"; - var uriSource = "https://example.com"; - var sequence = new[] { "1", "2", "3" }; - var emptySource = string.Empty; - - // Trim all whitespace characters - var trimmed = value.TrimAll(); // "Hello,World!" - - // Convert to different casing styles - var lower = value.ToCasing(CasingMethod.LowerCase); // " hello, world! " - var upper = value.ToCasing(CasingMethod.UpperCase); // " HELLO, WORLD! " - var title = value.ToCasing(CasingMethod.TitleCase, new CultureInfo("en-US")); // " Hello, World! " - - // Check string characteristics - bool isEmail = value.IsEmailAddress(); // false - bool isGuid = value.IsGuid(); // false - bool isHex = value.IsHex(); // false - bool isNumeric = value.IsNumeric(); // false - bool isBase64 = value.IsBase64(); // false - - // Substring operations - var before = value.SubstringBefore(","); // " Hello" - var after = value.SuffixWithForwardingSlash(); // " Hello, World! /" - var prefixed = value.PrefixWith(">>"); // ">> Hello, World! " - - // Remove and replace - var removed = value.RemoveAll(" ", "!"); // "Hello,World" - var replaced = value.ReplaceAll("world", "Earth"); // " Hello, Earth! " - - // Contains checks - bool hasHello = value.ContainsAny("Hello", "World"); // true - bool hasAll = value.ContainsAll("Hello", "World"); // true - bool hasChar = value.ContainsAny('o', 'x'); // true - - // Equality checks - bool equalsAny = answer.EqualsAny("yes", "no"); // true - bool equalsAnyIgnoreCase = answer.EqualsAny(StringComparison.OrdinalIgnoreCase, "YES", "NO"); // true - - // StartsWith - bool starts = value.StartsWith(" Hello"); // true - - // Chunk - IEnumerable chunks = chunkSource.Chunk(3); // ["abc", "def", "gh"] - var chunksDefault = chunkSource.Chunk(); // ["abc", "def", "gh"] - - // Encoding conversions - byte[] bytes = plainText.ToByteArray(o => o.Encoding = Encoding.UTF8); - string hex = plainText.ToHexadecimal(); - string fromHex = hex.FromHexadecimal(); - - // Base64 - byte[] base64Bytes = encodedText.FromBase64(); - var urlB64 = encodedText.FromUrlEncodedBase64(); // "Hello" - - // Enum parsing - var day = dayName.ToEnum(); // DayOfWeek.Monday - - // TimeSpan from string - var ts = timeSource.ToTimeSpan(TimeUnit.Minutes); // 00:42:00 - - // Delimited string splitting - string csv = "apple,\"orange, citrus\",banana"; - string[] parts = csv.SplitDelimited(); // ["apple", "orange, citrus", "banana"] - - // Validate a sequence of strings against a target type - bool isIntegerSequence = sequence.IsSequenceOf(); // true - - // Additional string utilities - int charCount = counted.Count('l'); // 2 - string diff = counted.Difference("world"); // "world" - var biDigits = binarySource.FromBinaryDigits(); // new byte[] { 13 } - bool emptyCheck = emptySource.IsNullOrEmpty(); // true - bool emptySequenceCheck = sequence.IsNullOrEmpty(); // false - var whitespaceSource = " "; - bool whiteSpaceCheck = whitespaceSource.IsNullOrWhiteSpace(); // true - string jsEsc = quoted.JsEscape(); // "hello\\u0027s" - string jsUnesc = quoted.JsUnescape(); // "hello's" - string suffixed = counted.SuffixWith(" world"); // "hello world" - Guid asGuid = guidSource.ToGuid(); - Uri asUri = uriSource.ToUri(); - Console.WriteLine(isIntegerSequence); - } -} - +var value = " Hello, World! "; +var answer = "yes"; +var chunkSource = "abcdefgh"; +var plainText = "Hello"; +var encodedText = "SGVsbG8="; +var binarySource = "00001101"; +var dayName = "Monday"; +var timeSource = "42"; +var counted = "hello"; +var quoted = "hello's"; +var guidSource = "550e8400-e29b-41d4-a716-446655440000"; +var uriSource = "https://example.com"; +var sequence = new[] { "1", "2", "3" }; +var emptySource = string.Empty; + +// Trim all whitespace characters +var trimmed = value.TrimAll(); // "Hello,World!" + +// Convert to different casing styles +var lower = value.ToCasing(CasingMethod.LowerCase); // " hello, world! " +var upper = value.ToCasing(CasingMethod.UpperCase); // " HELLO, WORLD! " +var title = value.ToCasing(CasingMethod.TitleCase, new CultureInfo("en-US")); // " Hello, World! " + +// Check string characteristics +bool isEmail = value.IsEmailAddress(); // false +bool isGuid = value.IsGuid(); // false +bool isHex = value.IsHex(); // false +bool isNumeric = value.IsNumeric(); // false +bool isBase64 = value.IsBase64(); // false + +// Substring operations +var before = value.SubstringBefore(","); // " Hello" +var after = value.SuffixWithForwardingSlash(); // " Hello, World! /" +var prefixed = value.PrefixWith(">>"); // ">> Hello, World! " + +// Remove and replace +var removed = value.RemoveAll(" ", "!"); // "Hello,World" +var replaced = value.ReplaceAll("world", "Earth"); // " Hello, Earth! " + +// Contains checks +bool hasHello = value.ContainsAny("Hello", "World"); // true +bool hasAll = value.ContainsAll("Hello", "World"); // true +bool hasChar = value.ContainsAny('o', 'x'); // true + +// Equality checks +bool equalsAny = answer.EqualsAny("yes", "no"); // true +bool equalsAnyIgnoreCase = answer.EqualsAny(StringComparison.OrdinalIgnoreCase, "YES", "NO"); // true + +// StartsWith +bool starts = value.StartsWith(" Hello"); // true + +// Chunk +IEnumerable chunks = chunkSource.Chunk(3); // ["abc", "def", "gh"] +var chunksDefault = chunkSource.Chunk(); // ["abc", "def", "gh"] + +// Encoding conversions +byte[] bytes = plainText.ToByteArray(o => o.Encoding = Encoding.UTF8); +string hex = plainText.ToHexadecimal(); +string fromHex = hex.FromHexadecimal(); + +// Base64 +byte[] base64Bytes = encodedText.FromBase64(); +var urlB64 = encodedText.FromUrlEncodedBase64(); // "Hello" + +// Enum parsing +var day = dayName.ToEnum(); // DayOfWeek.Monday + +// TimeSpan from string +var ts = timeSource.ToTimeSpan(TimeUnit.Minutes); // 00:42:00 + +// Delimited string splitting +string csv = "apple,\"orange, citrus\",banana"; +string[] parts = csv.SplitDelimited(); // ["apple", "orange, citrus", "banana"] + +// Validate a sequence of strings against a target type +bool isIntegerSequence = sequence.IsSequenceOf(); // true + +// Additional string utilities +int charCount = counted.Count('l'); // 2 +string diff = counted.Difference("world"); // "world" +var biDigits = binarySource.FromBinaryDigits(); // new byte[] { 13 } +bool emptyCheck = emptySource.IsNullOrEmpty(); // true +bool emptySequenceCheck = sequence.IsNullOrEmpty(); // false +var whitespaceSource = " "; +bool whiteSpaceCheck = whitespaceSource.IsNullOrWhiteSpace(); // true +string jsEsc = quoted.JsEscape(); // "hello\\u0027s" +string jsUnesc = quoted.JsUnescape(); // "hello's" +string suffixed = counted.SuffixWith(" world"); // "hello world" +Guid asGuid = guidSource.ToGuid(); +Uri asUri = uriSource.ToUri(); +Console.WriteLine(isIntegerSequence); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.TesterFuncFactory.md b/.docfx/api/types/Cuemon.Extensions.TesterFuncFactory.md index f448270c1..8ab0452a9 100644 --- a/.docfx/api/types/Cuemon.Extensions.TesterFuncFactory.md +++ b/.docfx/api/types/Cuemon.Extensions.TesterFuncFactory.md @@ -7,25 +7,22 @@ example: The following example demonstrates how to create a `TesterFuncFactory` from a TryParse-style delegate. It shows both a successful parse and a failure case, printing the parsed value or fallback accordingly. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Extensions; -namespace Cuemon.Extensions; +TesterFunc tryParse = (string input, out int result) => int.TryParse(input, out result); -public class TesterFuncFactoryExample -{ - public void Demonstrate() - { - TesterFunc tryParse = (string input, out int result) => int.TryParse(input, out result); +var factory = TesterFuncFactory.Create(tryParse, "42"); +bool success = factory.ExecuteMethod(out int value); +Console.WriteLine($"Parsed: {value}, Success: {success}"); - var factory = TesterFuncFactory.Create(tryParse, "42"); - bool success = factory.ExecuteMethod(out int value); - Console.WriteLine($"Parsed: {value}, Success: {success}"); - - var failFactory = TesterFuncFactory.Create(tryParse, "not-a-number"); - bool failed = failFactory.ExecuteMethod(out int fallback); - Console.WriteLine($"Fallback: {fallback}, Success: {failed}"); - } -} +var failFactory = TesterFuncFactory.Create(tryParse, "not-a-number"); +bool failed = failFactory.ExecuteMethod(out int fallback); +Console.WriteLine($"Fallback: {fallback}, Success: {failed}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.EncodingOptionsExtensions.md b/.docfx/api/types/Cuemon.Extensions.Text.EncodingOptionsExtensions.md index e90b0f5a5..b51ed9ee5 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.EncodingOptionsExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.EncodingOptionsExtensions.md @@ -47,3 +47,7 @@ public class EncodingOptionsExtensionsExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.DateTimeConverter.md b/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.DateTimeConverter.md index f81ce304e..4ac004b0c 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.DateTimeConverter.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.DateTimeConverter.md @@ -7,31 +7,30 @@ example: `DateTimeConverter` enables custom format and culture-aware serialization of `DateTime` values in `System.Text.Json`. This example registers the converter in `JsonSerializerOptions` with the French date format `"dd/MM/yyyy"` and `fr-FR` culture, then serializes a UTC `DateTime` (`2026-06-16`). The JSON output contains the date as `"16/06/2026"`. Deserializing the same JSON back to a `DateTime` and formatting it again with `"dd/MM/yyyy"` produces `"16/06/2026"`, confirming round-trip fidelity with culture-aware formatting. ```csharp +// Program.cs using System; using System.Globalization; using System.Text.Json; +using System.Text.Json.Serialization.Metadata; using Cuemon.Extensions.Text.Json.Converters; -namespace MyApp.Examples; - -public class DateTimeConverterExample +var options = new JsonSerializerOptions { - public void Demonstrate() - { - var options = new JsonSerializerOptions(); - - // Register a converter that writes dates in the French "dd/MM/yyyy" format - options.Converters.Add(new DateTimeConverter("dd/MM/yyyy", new CultureInfo("fr-FR"))); + TypeInfoResolver = new DefaultJsonTypeInfoResolver() +}; - var original = new DateTime(2026, 6, 16, 14, 30, 0, DateTimeKind.Utc); +// Register a converter that writes dates in the French "dd/MM/yyyy" format +options.Converters.Add(new DateTimeConverter("dd/MM/yyyy", new CultureInfo("fr-FR"))); - string json = JsonSerializer.Serialize(original, options); - Console.WriteLine(json); // "16/06/2026" +var original = new DateTime(2026, 6, 16, 14, 30, 0, DateTimeKind.Utc); - var restored = JsonSerializer.Deserialize(json, options); - Console.WriteLine(restored.ToString("dd/MM/yyyy")); // 16/06/2026 - -} -} +string json = JsonSerializer.Serialize(original, options); +Console.WriteLine(json); // "16/06/2026" +var restored = JsonSerializer.Deserialize(json, options); +Console.WriteLine(restored.ToString("dd/MM/yyyy")); // 16/06/2026 ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.ExceptionConverter.md b/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.ExceptionConverter.md index ae7731a01..9eb1c00e1 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.ExceptionConverter.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.ExceptionConverter.md @@ -7,43 +7,29 @@ example: `ExceptionConverter` serializes `Exception` instances to JSON, including optional stack trace and `Data` dictionary content. This example configures `JsonSerializerOptions` with `WriteIndented = true` and adds the converter with `includeStackTrace: true` and `includeData: true`, then creates a nested `InvalidOperationException("Outer operation failed.")` with an inner `InvalidOperationException("Inner operation failed.")` and a `CorrelationId` data entry. The resulting JSON includes top-level fields (`Type`, `Source`, `Message`, `Stack`, `Data`) and a nested `Inner` section for the inner exception with its own `Type` and `Message`. Console output displays the complete JSON structure. ```csharp +// Program.cs using System; using System.Text.Json; +using System.Text.Json.Serialization.Metadata; using Cuemon.Extensions.Text.Json.Converters; -namespace MyApp.Examples; - -public class ExceptionConverterExample +var options = new JsonSerializerOptions { - public void Demonstrate() - { - var options = new JsonSerializerOptions - { - WriteIndented = true - }; - - // Include both stack trace and exception data - options.Converters.Add(new ExceptionConverter(includeStackTrace: true, includeData: true)); + TypeInfoResolver = new DefaultJsonTypeInfoResolver(), + WriteIndented = true +}; - var inner = new InvalidOperationException("Inner operation failed."); - var ex = new InvalidOperationException("Outer operation failed.", inner); - ex.Data["CorrelationId"] = "abc-123"; +// Include both stack trace and exception data +options.Converters.Add(new ExceptionConverter(includeStackTrace: true, includeData: true)); - string json = JsonSerializer.Serialize(ex, options); - Console.WriteLine(json); - // { - // "Type": "System.InvalidOperationException", - // "Source": "...", - // "Message": "Outer operation failed.", - // "Stack": [ " at ..." ], - // "Data": { "CorrelationId": "abc-123" }, - // "Inner": { - // "Type": "System.InvalidOperationException", - // "Message": "Inner operation failed." - // } - // } - -} -} +var inner = new InvalidOperationException("Inner operation failed."); +var ex = new InvalidOperationException("Outer operation failed.", inner); +ex.Data["CorrelationId"] = "abc-123"; +string json = JsonSerializer.Serialize(ex, options); +Console.WriteLine(json); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.JsonConverterCollectionExtensions.md b/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.JsonConverterCollectionExtensions.md index 69a8f23ed..928b16a52 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.JsonConverterCollectionExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.JsonConverterCollectionExtensions.md @@ -7,58 +7,57 @@ example: `JsonConverterCollectionExtensions` provides fluent extension methods for building a `List` with specialized converters and applying them to a `JsonFormatter`. This example calls `AddDateTimeConverter`, `AddStringEnumConverter`, `AddStringFlagsEnumConverter`, `AddExceptionConverter`, `AddFailureConverter`, `AddTransientFaultExceptionConverter`, and `AddDataPairConverter` to register each converter, then demonstrates `RemoveAllOf()` and `RemoveAllOf(typeof(TimeSpan))` to remove converters by type. The converter list is applied to a `JsonFormatter` with `CamelCase` naming policy to serialize an anonymous person object. Console output displays the resulting JSON with the configured formatting. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Globalization; using System.Text.Json; using System.Text.Json.Serialization; +using System.Text.Json.Serialization.Metadata; using Cuemon; using Cuemon.Diagnostics; using Cuemon.Extensions.Text.Json.Converters; using Cuemon.Extensions.Text.Json.Formatters; -namespace MyApp.Examples; +var converters = new List(); +converters.AddDateTimeConverter("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); +converters.AddStringEnumConverter(); +converters.AddStringFlagsEnumConverter(); +converters.AddExceptionConverter(true, false); +converters.AddFailureConverter(); +converters.AddTransientFaultExceptionConverter(); +converters.AddExceptionDescriptorConverterOf( + o => o.SensitivityDetails = FaultSensitivityDetails.All); +converters.AddDataPairConverter(); +converters.RemoveAllOf(); +converters.RemoveAllOf(typeof(TimeSpan)); -public class Example +var formatter = new JsonFormatter(o => { - public void Run() + o.Settings.TypeInfoResolver = new DefaultJsonTypeInfoResolver(); + o.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; + foreach (var converter in converters) { - var converters = new List(); - converters.AddDateTimeConverter("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); - converters.AddStringEnumConverter(); - converters.AddStringFlagsEnumConverter(); - converters.AddExceptionConverter(true, false); - converters.AddFailureConverter(); - converters.AddTransientFaultExceptionConverter(); - converters.AddExceptionDescriptorConverterOf( - o => o.SensitivityDetails = FaultSensitivityDetails.All); - converters.AddDataPairConverter(); - converters.RemoveAllOf(); - converters.RemoveAllOf(typeof(TimeSpan)); - - var formatter = new JsonFormatter(o => - { - o.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; - foreach (var converter in converters) - { - o.Settings.Converters.Add(converter); - } - }); - - var person = new { FullName = "Alice Johnson", BirthDate = new DateTime(1990, 6, 15) }; - using var jsonStream = JsonFormatter.SerializeObject(person, options => - { - options.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; - foreach (var converter in converters) - { - options.Settings.Converters.Add(converter); - } - }); - jsonStream.Position = 0; - using var reader = new System.IO.StreamReader(jsonStream); - string json = reader.ReadToEnd(); - Console.WriteLine(json); + o.Settings.Converters.Add(converter); } -} +}); +var person = new { FullName = "Alice Johnson", BirthDate = new DateTime(1990, 6, 15) }; +using var jsonStream = JsonFormatter.SerializeObject(person, options => +{ + options.Settings.TypeInfoResolver = new DefaultJsonTypeInfoResolver(); + options.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; + foreach (var converter in converters) + { + options.Settings.Converters.Add(converter); + } +}); +jsonStream.Position = 0; +using var reader = new System.IO.StreamReader(jsonStream); +string json = reader.ReadToEnd(); +Console.WriteLine(json); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.StringEnumConverter.md b/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.StringEnumConverter.md index c25f320f1..83c178fbc 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.StringEnumConverter.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.StringEnumConverter.md @@ -7,36 +7,47 @@ example: `StringEnumConverter` serializes and deserializes non-flags enum values as their string names rather than underlying integer values in `System.Text.Json`. This example creates `JsonSerializerOptions` with `CamelCase` naming policy and adds the converter, then serializes an anonymous object with `DayOfWeek.Friday` and `UriKind.Relative`. The JSON output shows `"friday"` and `"relative"` instead of numeric values like `5` or `2`. Deserializing the JSON back into a typed `Payload` object confirms that the string values round-trip correctly to the original enum members, with `restored.Day` output as `Friday`. ```csharp +// Program.cs using System; using System.Text.Json; +using System.Text.Json.Serialization.Metadata; using Cuemon.Extensions.Text.Json.Converters; +using MyApp.Examples; -namespace MyApp.Examples; +new StringEnumConverterExample().Demonstrate(); -public class StringEnumConverterExample +namespace MyApp.Examples { - public void Demonstrate() + public class StringEnumConverterExample { - var options = new JsonSerializerOptions + public void Demonstrate() { - PropertyNamingPolicy = JsonNamingPolicy.CamelCase - }; - options.Converters.Add(new StringEnumConverter()); + var options = new JsonSerializerOptions + { + TypeInfoResolver = new DefaultJsonTypeInfoResolver(), + PropertyNamingPolicy = JsonNamingPolicy.CamelCase + }; + options.Converters.Add(new StringEnumConverter()); - var payload = new { Day = DayOfWeek.Friday, Status = UriKind.Relative }; + var payload = new { Day = DayOfWeek.Friday, Status = UriKind.Relative }; - string json = JsonSerializer.Serialize(payload, options); - Console.WriteLine(json); - // { "day": "Friday", "status": "Relative" } + string json = JsonSerializer.Serialize(payload, options); + Console.WriteLine(json); + // { "day": "Friday", "status": "Relative" } - var restored = JsonSerializer.Deserialize(json, options); - Console.WriteLine(restored.Day); // Friday - } + var restored = JsonSerializer.Deserialize(json, options); + Console.WriteLine(restored.Day); // Friday + } - public class Payload - { - public DayOfWeek Day { get; set; } - public UriKind Status { get; set; } + public class Payload + { + public DayOfWeek Day { get; set; } + public UriKind Status { get; set; } + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.StringFlagsEnumConverter.md b/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.StringFlagsEnumConverter.md index b508e9489..969eeaf0d 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.StringFlagsEnumConverter.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.StringFlagsEnumConverter.md @@ -7,33 +7,30 @@ example: `StringFlagsEnumConverter` serializes and deserializes `[Flags]` enum values as an array of active flag string names instead of a single integer. This example registers the converter in `JsonSerializerOptions`, then serializes `FileShare.Read | FileShare.Write` which produces the JSON array `["Read", "Write"]`. Deserializing the array back to a `FileShare` value restores the combined flags, and the output displays `Read, Write`, confirming round-trip correctness for flags enum values. ```csharp +// Program.cs using System; using System.IO; using System.Text.Json; +using System.Text.Json.Serialization.Metadata; using Cuemon.Extensions.Text.Json.Converters; -namespace MyApp.Examples; - -public class StringFlagsEnumConverterExample +var options = new JsonSerializerOptions { - public void Demonstrate() - { - var options = new JsonSerializerOptions - { - PropertyNamingPolicy = JsonNamingPolicy.CamelCase - }; - options.Converters.Add(new StringFlagsEnumConverter()); - - var value = FileShare.Read | FileShare.Write; + TypeInfoResolver = new DefaultJsonTypeInfoResolver(), + PropertyNamingPolicy = JsonNamingPolicy.CamelCase +}; +options.Converters.Add(new StringFlagsEnumConverter()); - string json = JsonSerializer.Serialize(value, options); - Console.WriteLine(json); - // ["Read", "Write"] +var value = FileShare.Read | FileShare.Write; - var restored = JsonSerializer.Deserialize(json, options); - Console.WriteLine(restored); // Read, Write - -} -} +string json = JsonSerializer.Serialize(value, options); +Console.WriteLine(json); +// ["Read", "Write"] +var restored = JsonSerializer.Deserialize(json, options); +Console.WriteLine(restored); // Read, Write ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.TransientFaultExceptionConverter.md b/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.TransientFaultExceptionConverter.md index 4c57d0d20..12886e013 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.TransientFaultExceptionConverter.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.Json.Converters.TransientFaultExceptionConverter.md @@ -7,89 +7,101 @@ example: `TransientFaultExceptionConverter` serializes and deserializes `TransientFaultException` instances including their `TransientFaultEvidence` with attempt count, recovery wait times, latency, and method signature. This example creates a `TransientFaultException` with evidence (`Attempts = 3`, `RecoveryWaitTime = 2s`, etc.) and a method descriptor, then configures a `JsonFormatter` with the converter and serializes it to JSON. The deserialization part reads the JSON back through the same formatter, reconstructing the exception with its `Evidence` properties intact. Console output displays the round-tripped message (`"Failed to connect after 3 retries."`) and evidence attempt count (`3`). ```csharp +// Program.cs using System; using System.IO; using System.Text; +using System.Text.Json.Serialization.Metadata; using Cuemon.Extensions.Text.Json.Converters; using Cuemon.Extensions.Text.Json; using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Reflection; using Cuemon.Resilience; +using MyApp.Examples; -namespace MyApp.Examples; +new TransientFaultExceptionConverterExample().SerializeTransientFaultException(); -public class TransientFaultExceptionConverterExample +namespace MyApp.Examples { - public void SerializeTransientFaultException() + public class TransientFaultExceptionConverterExample { - // Create a transient fault exception with evidence - var evidence = new TransientFaultEvidence( - attempts: 3, - recoveryWaitTime: TimeSpan.FromSeconds(2), - totalRecoveryWaitTime: TimeSpan.FromSeconds(6), - latency: TimeSpan.FromMilliseconds(500), - descriptor: new MethodSignature( - "MyService", - "ConnectAsync", - new[] { "connectionString" }, - new object[] { "server=db;timeout=30" })); + public void SerializeTransientFaultException() + { + // Create a transient fault exception with evidence + var evidence = new TransientFaultEvidence( + attempts: 3, + recoveryWaitTime: TimeSpan.FromSeconds(2), + totalRecoveryWaitTime: TimeSpan.FromSeconds(6), + latency: TimeSpan.FromMilliseconds(500), + descriptor: new MethodSignature( + "MyService", + "ConnectAsync", + new[] { "connectionString" }, + new object[] { "server=db;timeout=30" })); - var exception = new TransientFaultException( - "Failed to connect after 3 retries.", - new TimeoutException("Connection timed out."), - evidence); + var exception = new TransientFaultException( + "Failed to connect after 3 retries.", + new TimeoutException("Connection timed out."), + evidence); - // Configure JSON formatter with the converter - var options = new JsonFormatterOptions(); - options.Settings.Converters.Add(new TransientFaultExceptionConverter()); + // Configure JSON formatter with the converter + var options = new JsonFormatterOptions(); + options.Settings.TypeInfoResolver = new DefaultJsonTypeInfoResolver(); + options.Settings.Converters.Add(new TransientFaultExceptionConverter()); - // Serialize to JSON - var formatter = new JsonFormatter(options); - using (var stream = formatter.Serialize(exception)) - using (var reader = new StreamReader(stream)) - { - string json = reader.ReadToEnd(); - Console.WriteLine(json); - // The output includes exception details, inner exception, and evidence: - // { - // "type": "Cuemon.Resilience.TransientFaultException", - // "message": "Failed to connect after 3 retries.", - // "evidence": { - // "attempts": 3, - // ... - // } - // } + // Serialize to JSON + var formatter = new JsonFormatter(options); + using (var stream = formatter.Serialize(exception)) + using (var reader = new StreamReader(stream)) + { + string json = reader.ReadToEnd(); + Console.WriteLine(json); + // The output includes exception details, inner exception, and evidence: + // { + // "type": "Cuemon.Resilience.TransientFaultException", + // "message": "Failed to connect after 3 retries.", + // "evidence": { + // "attempts": 3, + // ... + // } + // } + } } - } - public void DeserializeTransientFaultException() - { - string json = @"{ - ""type"": ""Cuemon.Resilience.TransientFaultException"", - ""message"": ""Failed to connect after 3 retries."", - ""evidence"": { - ""attempts"": 3, - ""recoveryWaitTime"": ""00:00:02"", - ""totalRecoveryWaitTime"": ""00:00:06"", - ""latency"": ""00:00:00.500"", - ""descriptor"": { - ""caller"": ""MyService"", - ""methodName"": ""ConnectAsync"", - ""parameters"": [""connectionString""], - ""arguments"": [""server=db;timeout=30""] -}"; + public void DeserializeTransientFaultException() + { + string json = @"{ + ""type"": ""Cuemon.Resilience.TransientFaultException"", + ""message"": ""Failed to connect after 3 retries."", + ""evidence"": { + ""attempts"": 3, + ""recoveryWaitTime"": ""00:00:02"", + ""totalRecoveryWaitTime"": ""00:00:06"", + ""latency"": ""00:00:00.500"", + ""descriptor"": { + ""caller"": ""MyService"", + ""methodName"": ""ConnectAsync"", + ""parameters"": [""connectionString""], + ""arguments"": [""server=db;timeout=30""] + }"; - var options = new JsonFormatterOptions(); - options.Settings.Converters.Add(new TransientFaultExceptionConverter()); + var options = new JsonFormatterOptions(); + options.Settings.TypeInfoResolver = new DefaultJsonTypeInfoResolver(); + options.Settings.Converters.Add(new TransientFaultExceptionConverter()); - using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(json))) - { - var formatter = new JsonFormatter(options); - var exception = formatter.Deserialize(stream); + using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(json))) + { + var formatter = new JsonFormatter(options); + var exception = formatter.Deserialize(stream); - Console.WriteLine(exception.Message); - Console.WriteLine($"Evidence - Attempts: {exception.Evidence.Attempts}"); + Console.WriteLine(exception.Message); + Console.WriteLine($"Evidence - Attempts: {exception.Evidence.Attempts}"); + } } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.Json.DynamicJsonConverter.md b/.docfx/api/types/Cuemon.Extensions.Text.Json.DynamicJsonConverter.md index cebad9a3e..233644bcd 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.Json.DynamicJsonConverter.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.Json.DynamicJsonConverter.md @@ -7,28 +7,29 @@ example: The following example shows how to register a custom JSON converter for the `Version` type using `DynamicJsonConverter`. It serializes a version to JSON and deserializes it back, printing each result. ```csharp +// Program.cs using System; using System.Text.Json; +using System.Text.Json.Serialization.Metadata; using Cuemon.Extensions.Text.Json; -namespace Cuemon.Extensions.Text.Json; - -public class DynamicJsonConverterExample +var options = new JsonSerializerOptions { - public void Demonstrate() - { - var options = new JsonSerializerOptions(); - options.Converters.Add(DynamicJsonConverter.Create( - writer: (utf8Writer, value, _) => utf8Writer.WriteStringValue(value.ToString()), - reader: (ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions jsonOptions) => Version.Parse(reader.GetString()) - )); + TypeInfoResolver = new DefaultJsonTypeInfoResolver() +}; +options.Converters.Add(DynamicJsonConverter.Create( + writer: (utf8Writer, value, _) => utf8Writer.WriteStringValue(value.ToString()), + reader: (ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions jsonOptions) => Version.Parse(reader.GetString()) +)); - var version = new Version("5.0.0"); - string json = JsonSerializer.Serialize(version, options); - Console.WriteLine(json); +var version = new Version("5.0.0"); +string json = JsonSerializer.Serialize(version, options); +Console.WriteLine(json); - var deserialized = JsonSerializer.Deserialize("\"6.0.0\"", options); - Console.WriteLine(deserialized); - } -} +var deserialized = JsonSerializer.Deserialize("\"6.0.0\"", options); +Console.WriteLine(deserialized); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.Json.Formatters.JsonFormatter.md b/.docfx/api/types/Cuemon.Extensions.Text.Json.Formatters.JsonFormatter.md index 543ef3fcc..500510d2f 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.Json.Formatters.JsonFormatter.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.Json.Formatters.JsonFormatter.md @@ -4,45 +4,53 @@ example: - *content --- -The following example demonstrates how to use `JsonFormatter` to serialize and deserialize objects to and from JSON. +This example creates a `JsonFormatter` with a `DefaultJsonTypeInfoResolver`, serializes a `Product` record to a stream, and reads the encoded JSON back. It then resets the stream position, deserializes the payload into a `Product`, and prints the round-tripped values plus the result of a static serialization round trip. ```csharp +// Program.cs using System; using System.IO; +using System.Text.Json.Serialization.Metadata; using Cuemon; using Cuemon.IO; using Cuemon.Extensions.Text.Json.Formatters; +using MyApp.Examples; -namespace MyApp.Examples; +new Example().Run(); -public record Product(int Id, string Name, decimal Price); - -public class Example +namespace MyApp.Examples { - public void Run() + public record Product(int Id, string Name, decimal Price); + public class Example { - // Create a JsonFormatter with default settings - var formatter = new JsonFormatter(); - - // Serialize an object to a stream - var product = new Product(1, "Wireless Mouse", 29.99m); - using var jsonStream = formatter.Serialize(product, typeof(Product)); - - // Read the JSON string (leave the stream open for reuse) - Console.WriteLine("Serialized JSON:"); - Console.WriteLine(Decorator.Enclose(jsonStream).ToEncodedString(o => o.LeaveOpen = true)); - - // Reset position and deserialize from the same stream - jsonStream.Position = 0; - var deserialized = (Product)formatter.Deserialize(jsonStream, typeof(Product)); - Console.WriteLine($"Deserialized: Id={deserialized.Id}, Name={deserialized.Name}, Price={deserialized.Price}"); - - // Use static convenience methods - using var json = JsonFormatter.SerializeObject(product); - json.Position = 0; - Console.WriteLine($"Static round-trip: {JsonFormatter.DeserializeObject(json).Name}"); - + public void Run() + { + // Create a JsonFormatter with default settings + var formatter = new JsonFormatter(o => o.Settings.TypeInfoResolver = new DefaultJsonTypeInfoResolver()); + + // Serialize an object to a stream + var product = new Product(1, "Wireless Mouse", 29.99m); + using var jsonStream = formatter.Serialize(product, typeof(Product)); + + // Read the JSON string (leave the stream open for reuse) + Console.WriteLine("Serialized JSON:"); + Console.WriteLine(Decorator.Enclose(jsonStream).ToEncodedString(o => o.LeaveOpen = true)); + + // Reset position and deserialize from the same stream + jsonStream.Position = 0; + var deserialized = (Product)formatter.Deserialize(jsonStream, typeof(Product)); + Console.WriteLine($"Deserialized: Id={deserialized.Id}, Name={deserialized.Name}, Price={deserialized.Price}"); + + // Use static convenience methods + using var json = JsonFormatter.SerializeObject(product, o => o.Settings.TypeInfoResolver = new DefaultJsonTypeInfoResolver()); + json.Position = 0; + Console.WriteLine($"Static round-trip: {JsonFormatter.DeserializeObject(json, o => o.Settings.TypeInfoResolver = new DefaultJsonTypeInfoResolver()).Name}"); + + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.Json.Formatters.JsonFormatterOptions.md b/.docfx/api/types/Cuemon.Extensions.Text.Json.Formatters.JsonFormatterOptions.md index c715b9268..a516c5817 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.Json.Formatters.JsonFormatterOptions.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.Json.Formatters.JsonFormatterOptions.md @@ -7,67 +7,78 @@ example: The following example demonstrates how to configure and use it with the JSON formatter to serialize objects. ```csharp +// Program.cs using System; using System.IO; using System.Text.Json; using System.Text.Json.Serialization; +using System.Text.Json.Serialization.Metadata; using Cuemon.Diagnostics; using Cuemon.Extensions.Text.Json.Formatters; +using MyApp.Examples; -namespace MyApp.Examples; +new JsonFormatterOptionsExample().SerializeWithCustomOptions(); -public class JsonFormatterOptionsExample +namespace MyApp.Examples { - public void SerializeWithCustomOptions() + public class JsonFormatterOptionsExample { - // Create options with custom JSON serializer settings - var options = new JsonFormatterOptions + public void SerializeWithCustomOptions() { - Settings = new JsonSerializerOptions + // Create options with custom JSON serializer settings + var options = new JsonFormatterOptions { - PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - WriteIndented = true, - DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, - PropertyNameCaseInsensitive = true - }, - SensitivityDetails = FaultSensitivityDetails.None - }; + Settings = new JsonSerializerOptions + { + TypeInfoResolver = new DefaultJsonTypeInfoResolver(), + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + WriteIndented = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + PropertyNameCaseInsensitive = true + }, + SensitivityDetails = FaultSensitivityDetails.None + }; - // Add custom converters - options.Settings.Converters.Add(new JsonStringEnumConverter()); + // Add custom converters + options.Settings.Converters.Add(new JsonStringEnumConverter()); - var formatter = new JsonFormatter(options); - var payload = new { UserName = "johndoe", Email = "john@example.com", Age = 30 }; + var formatter = new JsonFormatter(options); + var payload = new { UserName = "johndoe", Email = "john@example.com", Age = 30 }; - using (var stream = formatter.Serialize(payload)) - using (var reader = new StreamReader(stream)) - { - string json = reader.ReadToEnd(); - Console.WriteLine(json); - // Output: - // { - // "userName": "johndoe", - // "email": "john@example.com", - // "age": 30 - // } + using (var stream = formatter.Serialize(payload)) + using (var reader = new StreamReader(stream)) + { + string json = reader.ReadToEnd(); + Console.WriteLine(json); + // Output: + // { + // "userName": "johndoe", + // "email": "john@example.com", + // "age": 30 + // } + } } - } - public void ConfigureDefaultMediaType() - { - // Access the default media type for JSON - Console.WriteLine(JsonFormatterOptions.DefaultMediaType); // "application/json" + public void ConfigureDefaultMediaType() + { + // Access the default media type for JSON + Console.WriteLine(JsonFormatterOptions.DefaultMediaType); // "application/json" - // DefaultConverters are applied automatically at static initialization - Console.WriteLine($"Default converters configured: {JsonFormatterOptions.DefaultConverters != null}"); // true - } + // DefaultConverters are applied automatically at static initialization + Console.WriteLine($"Default converters configured: {JsonFormatterOptions.DefaultConverters != null}"); // true + } - public void ValidateOptions() - { - var options = new JsonFormatterOptions(); - // ValidateOptions throws InvalidOperationException if Settings is null - options.ValidateOptions(); - Console.WriteLine("Options are valid."); + public void ValidateOptions() + { + var options = new JsonFormatterOptions(); + // ValidateOptions throws InvalidOperationException if Settings is null + options.ValidateOptions(); + Console.WriteLine("Options are valid."); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.Json.JsonNamingPolicyExtensions.md b/.docfx/api/types/Cuemon.Extensions.Text.Json.JsonNamingPolicyExtensions.md index 253662b6f..0338837b2 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.Json.JsonNamingPolicyExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.Json.JsonNamingPolicyExtensions.md @@ -39,3 +39,7 @@ public class JsonNamingPolicyExtensionsExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.Json.JsonSerializerOptionsExtensions.md b/.docfx/api/types/Cuemon.Extensions.Text.Json.JsonSerializerOptionsExtensions.md index eebc781b6..2326f8849 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.Json.JsonSerializerOptionsExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.Json.JsonSerializerOptionsExtensions.md @@ -45,3 +45,7 @@ public class JsonSerializerOptionsExtensionsExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.Json.Utf8JsonReaderFunc`1.md b/.docfx/api/types/Cuemon.Extensions.Text.Json.Utf8JsonReaderFunc`1.md index 07461cdc1..84e610f96 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.Json.Utf8JsonReaderFunc`1.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.Json.Utf8JsonReaderFunc`1.md @@ -7,26 +7,25 @@ example: The following example demonstrates how a can deserialize a value inside a dynamic JSON converter. ```csharp +// Program.cs using System; using System.Text.Json; +using System.Text.Json.Serialization.Metadata; using Cuemon.Extensions.Text.Json; -namespace MyApp.Examples; +Utf8JsonReaderFunc reader = (ref Utf8JsonReader jsonReader, Type _, JsonSerializerOptions __) => + Guid.Parse(jsonReader.GetString()); -public static class Utf8JsonReaderFuncExample +var converter = DynamicJsonConverter.Create(reader: reader); +var result = JsonSerializer.Deserialize("\"11111111-2222-3333-4444-555555555555\"", new JsonSerializerOptions { - public static void Demonstrate() - { - Utf8JsonReaderFunc reader = (ref Utf8JsonReader jsonReader, Type _, JsonSerializerOptions __) => - Guid.Parse(jsonReader.GetString()); + TypeInfoResolver = new DefaultJsonTypeInfoResolver(), + Converters = { converter } +}); - var converter = DynamicJsonConverter.Create(reader: reader); - var result = JsonSerializer.Deserialize("\"11111111-2222-3333-4444-555555555555\"", new JsonSerializerOptions - { - Converters = { converter } - }); - - Console.WriteLine(result); - } -} +Console.WriteLine(result); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.Json.Utf8JsonWriterAction`1.md b/.docfx/api/types/Cuemon.Extensions.Text.Json.Utf8JsonWriterAction`1.md index dc5472f2c..f0343671d 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.Json.Utf8JsonWriterAction`1.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.Json.Utf8JsonWriterAction`1.md @@ -7,26 +7,25 @@ example: The following example demonstrates how a can serialize a value inside a dynamic JSON converter. ```csharp +// Program.cs using System; using System.Text.Json; +using System.Text.Json.Serialization.Metadata; using Cuemon.Extensions.Text.Json; -namespace MyApp.Examples; +Utf8JsonWriterAction writer = (jsonWriter, value, _) => + jsonWriter.WriteStringValue(value.ToString("D")); -public static class Utf8JsonWriterActionExample +var converter = DynamicJsonConverter.Create(writer: writer); +var json = JsonSerializer.Serialize(Guid.Parse("11111111-2222-3333-4444-555555555555"), new JsonSerializerOptions { - public static void Demonstrate() - { - Utf8JsonWriterAction writer = (jsonWriter, value, _) => - jsonWriter.WriteStringValue(value.ToString("D")); + TypeInfoResolver = new DefaultJsonTypeInfoResolver(), + Converters = { converter } +}); - var converter = DynamicJsonConverter.Create(writer: writer); - var json = JsonSerializer.Serialize(Guid.Parse("11111111-2222-3333-4444-555555555555"), new JsonSerializerOptions - { - Converters = { converter } - }); - - Console.WriteLine(json); - } -} +Console.WriteLine(json); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.Json.Utf8JsonWriterExtensions.md b/.docfx/api/types/Cuemon.Extensions.Text.Json.Utf8JsonWriterExtensions.md index d784faed8..891e9454b 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.Json.Utf8JsonWriterExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.Json.Utf8JsonWriterExtensions.md @@ -11,6 +11,7 @@ using System; using System.IO; using System.Text; using System.Text.Json; +using System.Text.Json.Serialization.Metadata; using Cuemon.Extensions.Text.Json; namespace MyApp.Examples; @@ -35,7 +36,8 @@ public class Utf8JsonWriterExtensionsExample var options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - WriteIndented = true + WriteIndented = true, + TypeInfoResolver = new DefaultJsonTypeInfoResolver() }; using var stream = new MemoryStream(); @@ -58,3 +60,7 @@ public class Utf8JsonWriterExtensionsExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Text.StringExtensions.md b/.docfx/api/types/Cuemon.Extensions.Text.StringExtensions.md index 0dcbaa946..694d4c662 100644 --- a/.docfx/api/types/Cuemon.Extensions.Text.StringExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Text.StringExtensions.md @@ -7,62 +7,57 @@ example: `StringExtensions` in the `Text` namespace provides encoding conversion between character encodings with custom fallback handling and ASCII sanitization. This example takes `"Café au lait: 2,50 €"` and converts it to UTF-8 (preserves all characters), ASCII with `EncoderReplacementFallback("?")` (replaces `é` and `€` with `?`), and Windows-1252 (preserves Western European characters). It also demonstrates `ToAsciiEncodedString` for quick ASCII sanitization that removes unsupported characters by default. Console output shows each encoded result, such as `"Caf? au lait: 2,50 ?"` for the ASCII replacement case and `"Cafe au lait: 2,50 "` for the quick ASCII sanitization. ```csharp +// Program.cs using System; using System.Text; using Cuemon.Extensions.Text; using Cuemon.Text; -namespace MyApp.Text -{ - public class StringExtensionsExample - { - public void Demonstrate() - { - // ToEncodedString - encodes a string to a different encoding with fallback handling - var withSpecialChars = "Café au lait: 2,50 €"; - - // Default: uses ExceptionFallback, will throw for unrepresentable chars - var encoded = withSpecialChars.ToEncodedString(o => - { - o.TargetEncoding = Encoding.UTF8; - }); - Console.WriteLine(encoded); // "Café au lait: 2,50 €" - - // Convert to ASCII with replacement fallback - var asciiResult = withSpecialChars.ToEncodedString(o => - { - o.TargetEncoding = Encoding.ASCII; - o.EncoderFallback = new EncoderReplacementFallback("?"); - }); - Console.WriteLine(asciiResult); // "Caf? au lait: 2,50 ?" - - // Convert to Windows-1252 (Western European) - var win1252 = withSpecialChars.ToEncodedString(o => - { - o.TargetEncoding = Encoding.GetEncoding(1252); - o.EncoderFallback = new EncoderReplacementFallback("?"); - }); - Console.WriteLine(win1252); // preserves most of the special chars - - // ToAsciiEncodedString - quick ASCII conversion - var asciiQuick = withSpecialChars.ToAsciiEncodedString(); - Console.WriteLine(asciiQuick); // "Cafe au lait: 2,50 " - // Uses EncoderReplacementFallback("") by default, so unsupported chars are removed silently - - // ToAsciiEncodedString with custom encoding options - var asciiCustom = withSpecialChars.ToAsciiEncodedString(o => - { - o.Preamble = PreambleSequence.Remove; - o.Encoding = Encoding.UTF8; - }); - Console.WriteLine(asciiCustom); // same result, no BOM +// ToEncodedString - encodes a string to a different encoding with fallback handling +var withSpecialChars = "Café au lait: 2,50 €"; - // Practical example: sanitize user input to safe ASCII - var userInput = "Hello World — 2025 ©"; - var sanitized = userInput.ToAsciiEncodedString(); - Console.WriteLine(sanitized); // "Hello World 2025 " (em dash and copyright removed) +// Default: uses ExceptionFallback, will throw for unrepresentable chars +var encoded = withSpecialChars.ToEncodedString(o => +{ + o.TargetEncoding = Encoding.UTF8; +}); +Console.WriteLine(encoded); // "Café au lait: 2,50 €" -}} -} +// Convert to ASCII with replacement fallback +var asciiResult = withSpecialChars.ToEncodedString(o => +{ + o.TargetEncoding = Encoding.ASCII; + o.EncoderFallback = new EncoderReplacementFallback("?"); +}); +Console.WriteLine(asciiResult); // "Caf? au lait: 2,50 ?" +// Convert to UTF-16 (Unicode) +var unicode = withSpecialChars.ToEncodedString(o => +{ + o.TargetEncoding = Encoding.Unicode; + o.EncoderFallback = new EncoderReplacementFallback("?"); +}); +Console.WriteLine(unicode); + +// ToAsciiEncodedString - quick ASCII conversion +var asciiQuick = withSpecialChars.ToAsciiEncodedString(); +Console.WriteLine(asciiQuick); // "Cafe au lait: 2,50 " +// Uses EncoderReplacementFallback("") by default, so unsupported chars are removed silently + +// ToAsciiEncodedString with custom encoding options +var asciiCustom = withSpecialChars.ToAsciiEncodedString(o => +{ + o.Preamble = PreambleSequence.Remove; + o.Encoding = Encoding.UTF8; +}); +Console.WriteLine(asciiCustom); // same result, no BOM + +// Practical example: sanitize user input to safe ASCII +var userInput = "Hello World — 2025 ©"; +var sanitized = userInput.ToAsciiEncodedString(); +Console.WriteLine(sanitized); // "Hello World 2025 " (em dash and copyright removed) ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Threading.Tasks.TaskExtensions.md b/.docfx/api/types/Cuemon.Extensions.Threading.Tasks.TaskExtensions.md index a759985d0..759345b26 100644 --- a/.docfx/api/types/Cuemon.Extensions.Threading.Tasks.TaskExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Threading.Tasks.TaskExtensions.md @@ -7,25 +7,21 @@ example: The following example demonstrates how to await a task with or without flowing the captured synchronization context. ```csharp +// Program.cs using System; using System.Threading.Tasks; using Cuemon.Extensions.Threading.Tasks; -namespace MyApp.Examples -{ - public static class TaskExtensionsExample - { - public static async Task DemonstrateAsync() - { - await Task.Delay(10).ContinueWithCapturedContext(); - await Task.Delay(10).ContinueWithSuppressedContext(); +await Task.Delay(10).ContinueWithCapturedContext(); +await Task.Delay(10).ContinueWithSuppressedContext(); - var captured = await Task.FromResult(42).ContinueWithCapturedContext(); - var suppressed = await Task.FromResult(42).ContinueWithSuppressedContext(); +var captured = await Task.FromResult(42).ContinueWithCapturedContext(); +var suppressed = await Task.FromResult(42).ContinueWithSuppressedContext(); - Console.WriteLine(captured); - Console.WriteLine(suppressed); - } - } -} +Console.WriteLine(captured); +Console.WriteLine(suppressed); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.TimeSpanExtensions.md b/.docfx/api/types/Cuemon.Extensions.TimeSpanExtensions.md index c8136791e..245a93f09 100644 --- a/.docfx/api/types/Cuemon.Extensions.TimeSpanExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.TimeSpanExtensions.md @@ -7,27 +7,23 @@ example: `TimeSpanExtensions` provides extension methods for `TimeSpan` including high-resolution unit queries (`GetTotalNanoseconds`, `GetTotalMicroseconds`) and interval snapping (`Floor`, `Ceiling`, `Round`). This example creates `TimeSpan.FromHours(1)` and `TimeSpan.FromMinutes(280)`, then calls `GetTotalNanoseconds` and `GetTotalMicroseconds` on the hour, `Floor(1, TimeUnit.Hours)` and `Ceiling(1, TimeUnit.Hours)` on 280 minutes, and `Round` on 45 minutes with both up and down directions. Console output shows the nanosecond and microsecond values, the floored/ceiling hours, and the rounded minutes. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Extensions; -namespace MyApp.Examples; - -public static class TimeSpanExtensionsExample -{ - public static void Demonstrate() - { - var hour = TimeSpan.FromHours(1); - var duration = TimeSpan.FromMinutes(280); - var shortDuration = TimeSpan.FromMinutes(45); - - Console.WriteLine(hour.GetTotalNanoseconds()); - Console.WriteLine(hour.GetTotalMicroseconds()); - Console.WriteLine(duration.Floor(1, TimeUnit.Hours)); - Console.WriteLine(duration.Ceiling(1, TimeUnit.Hours)); - Console.WriteLine(shortDuration.Round(TimeSpan.FromHours(1), VerticalDirection.Up)); - Console.WriteLine(shortDuration.Round(30, TimeUnit.Minutes, VerticalDirection.Down)); - } -} +var hour = TimeSpan.FromHours(1); +var duration = TimeSpan.FromMinutes(280); +var shortDuration = TimeSpan.FromMinutes(45); +Console.WriteLine(hour.GetTotalNanoseconds()); +Console.WriteLine(hour.GetTotalMicroseconds()); +Console.WriteLine(duration.Floor(1, TimeUnit.Hours)); +Console.WriteLine(duration.Ceiling(1, TimeUnit.Hours)); +Console.WriteLine(shortDuration.Round(TimeSpan.FromHours(1), VerticalDirection.Up)); +Console.WriteLine(shortDuration.Round(30, TimeUnit.Minutes, VerticalDirection.Down)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.TypeExtensions.md b/.docfx/api/types/Cuemon.Extensions.TypeExtensions.md index 797fa1f2f..82376f122 100644 --- a/.docfx/api/types/Cuemon.Extensions.TypeExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.TypeExtensions.md @@ -7,41 +7,37 @@ example: `TypeExtensions` provides extension methods for `Type` that simplify classification and metadata retrieval via methods like `ToFriendlyName`, `ToTypeCode`, and various `Has*`/`Is*` predicates. This example inspects `IList`, `ConcurrentDictionary`, `StringComparer`, `int?`, and anonymous types, calling `HasEnumerableImplementation`, `HasDictionaryImplementation`, `IsNullable`, `IsComplex`, `GetDefaultValue`, and `ToFriendlyName`. It also demonstrates `HasAnonymousCharacteristics` on an anonymous object, `HasTypes` for hierarchy checks, `HasInterfaces` for generic interface matching, and `HasAttributes` for attribute presence. Console output prints friendly type names like `IList`, boolean capability flags, and the default value `0` for `typeof(int)`. ```csharp +// Program.cs using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using Cuemon.Extensions; -namespace MyApp.Examples; - -public static class TypeExtensionsExample -{ - public static void Demonstrate() - { - Type listType = typeof(IList); - Type dictionaryType = typeof(ConcurrentDictionary); - Type comparerType = typeof(StringComparer); - Type nullableInt = typeof(int?); - - Console.WriteLine(listType.ToFriendlyName()); - Console.WriteLine(listType.ToFriendlyName(options => options.FullName = true)); - Console.WriteLine(typeof(string).ToTypeCode()); - Console.WriteLine(listType.HasEnumerableImplementation()); - Console.WriteLine(typeof(string).HasComparableImplementation()); - Console.WriteLine(dictionaryType.HasDictionaryImplementation()); - Console.WriteLine(comparerType.HasEqualityComparerImplementation()); - Console.WriteLine(comparerType.HasComparerImplementation()); - Console.WriteLine(typeof(KeyValuePair).HasKeyValuePairImplementation()); - Console.WriteLine(nullableInt.IsNullable()); - Console.WriteLine(typeof(Stream).IsComplex()); - Console.WriteLine(typeof(int).IsSimple()); - Console.WriteLine(typeof(int).GetDefaultValue()); - Console.WriteLine(typeof(FileStream).HasTypes(typeof(Stream))); - Console.WriteLine(typeof(List<>).HasInterfaces(typeof(IEnumerable<>))); - Console.WriteLine(typeof(string).HasAttributes(typeof(SerializableAttribute))); - Console.WriteLine(new { Name = "sample", Value = 42 }.GetType().HasAnonymousCharacteristics()); - } -} +Type listType = typeof(IList); +Type dictionaryType = typeof(ConcurrentDictionary); +Type comparerType = typeof(StringComparer); +Type nullableInt = typeof(int?); +Console.WriteLine(listType.ToFriendlyName()); +Console.WriteLine(listType.ToFriendlyName(options => options.FullName = true)); +Console.WriteLine(typeof(string).ToTypeCode()); +Console.WriteLine(listType.HasEnumerableImplementation()); +Console.WriteLine(typeof(string).HasComparableImplementation()); +Console.WriteLine(dictionaryType.HasDictionaryImplementation()); +Console.WriteLine(comparerType.HasEqualityComparerImplementation()); +Console.WriteLine(comparerType.HasComparerImplementation()); +Console.WriteLine(typeof(KeyValuePair).HasKeyValuePairImplementation()); +Console.WriteLine(nullableInt.IsNullable()); +Console.WriteLine(typeof(Stream).IsComplex()); +Console.WriteLine(typeof(int).IsSimple()); +Console.WriteLine(typeof(int).GetDefaultValue()); +Console.WriteLine(typeof(FileStream).HasTypes(typeof(Stream))); +Console.WriteLine(typeof(List<>).HasInterfaces(typeof(IEnumerable<>))); +Console.WriteLine(typeof(string).HasAttributes(typeof(SerializableAttribute))); +Console.WriteLine(new { Name = "sample", Value = 42 }.GetType().HasAnonymousCharacteristics()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.VerticalDirection.md b/.docfx/api/types/Cuemon.Extensions.VerticalDirection.md index 291b062c8..acd0308f3 100644 --- a/.docfx/api/types/Cuemon.Extensions.VerticalDirection.md +++ b/.docfx/api/types/Cuemon.Extensions.VerticalDirection.md @@ -7,22 +7,18 @@ example: The following example demonstrates how to use the enum to indicate vertical positioning. ```csharp +// Program.cs using System; using Cuemon.Extensions; -namespace MyApp.Examples; - -public static class VerticalDirectionExample -{ - public static void Demonstrate() - { - var upward = VerticalDirection.Up; - var downward = (VerticalDirection)Enum.Parse(typeof(VerticalDirection), "Down"); - - Console.WriteLine($"{upward} = {(int)upward}"); - Console.WriteLine($"{downward} = {(int)downward}"); - Console.WriteLine(default(VerticalDirection)); - } -} +var upward = VerticalDirection.Up; +var downward = (VerticalDirection)Enum.Parse(typeof(VerticalDirection), "Down"); +Console.WriteLine($"{upward} = {(int)upward}"); +Console.WriteLine($"{downward} = {(int)downward}"); +Console.WriteLine(default(VerticalDirection)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Wrapper.md b/.docfx/api/types/Cuemon.Extensions.Wrapper.md index d3c9fe93c..b6da30600 100644 --- a/.docfx/api/types/Cuemon.Extensions.Wrapper.md +++ b/.docfx/api/types/Cuemon.Extensions.Wrapper.md @@ -7,28 +7,25 @@ example: The following example demonstrates how to wrap values using `Wrapper` to access the inner instance, its type, and a parsed string representation. It shows wrapping both an integer and a string value. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Extensions; -namespace Cuemon.Extensions; +var wrapped = new Wrapper(42); +Console.WriteLine(wrapped.Instance); +Console.WriteLine(wrapped.InstanceType); -public class WrapperExample -{ - public void Demonstrate() - { - var wrapped = new Wrapper(42); - Console.WriteLine(wrapped.Instance); - Console.WriteLine(wrapped.InstanceType); +string parsed = Wrapper.ParseInstance(wrapped); +Console.WriteLine(parsed); - string parsed = Wrapper.ParseInstance(wrapped); - Console.WriteLine(parsed); +int asInt = wrapped.InstanceAs(); +Console.WriteLine(asInt); - int asInt = wrapped.InstanceAs(); - Console.WriteLine(asInt); - - var wrappedString = new Wrapper("Hello, World!"); - Console.WriteLine(Wrapper.ParseInstance(wrappedString)); - } -} +var wrappedString = new Wrapper("Hello, World!"); +Console.WriteLine(Wrapper.ParseInstance(wrappedString)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Wrapper`1.md b/.docfx/api/types/Cuemon.Extensions.Wrapper`1.md index bc89ed9ee..1399f53bc 100644 --- a/.docfx/api/types/Cuemon.Extensions.Wrapper`1.md +++ b/.docfx/api/types/Cuemon.Extensions.Wrapper`1.md @@ -7,39 +7,47 @@ example: The following example demonstrates how to use to wrap an object with optional member reference metadata. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Globalization; using System.Reflection; using Cuemon.Extensions; +using MyApp.Examples; -namespace MyApp.Examples; +WrapperExample.Demonstrate(); -public static class WrapperExample +namespace MyApp.Examples { - private sealed class WrapperExampleModel + public static class WrapperExample { - public string Name { get; set; } = string.Empty; - } - - public static void Demonstrate() - { - PropertyInfo nameProperty = typeof(WrapperExampleModel).GetProperty(nameof(WrapperExampleModel.Name), BindingFlags.Public | BindingFlags.Instance); - var answer = new Wrapper(42, nameProperty); - answer.Data["category"] = "number"; - - var fromText = new Wrapper("42"); - var bytes = new Wrapper(new byte[] { 1, 2, 3, 4 }); - var type = new Wrapper(typeof(Dictionary)); - - Console.WriteLine(answer.Instance); - Console.WriteLine(answer.MemberReference?.Name); - Console.WriteLine(answer.InstanceAs(CultureInfo.InvariantCulture)); - Console.WriteLine(fromText.InstanceAs()); - Console.WriteLine(answer.Data["category"]); - Console.WriteLine(Wrapper.ParseInstance(bytes)); - Console.WriteLine(type.ToString()); + private sealed class WrapperExampleModel + { + public string Name { get; set; } = string.Empty; + } + + public static void Demonstrate() + { + PropertyInfo nameProperty = typeof(WrapperExampleModel).GetProperty(nameof(WrapperExampleModel.Name), BindingFlags.Public | BindingFlags.Instance); + var answer = new Wrapper(42, nameProperty); + answer.Data["category"] = "number"; + + var fromText = new Wrapper("42"); + var bytes = new Wrapper(new byte[] { 1, 2, 3, 4 }); + var type = new Wrapper(typeof(Dictionary)); + + Console.WriteLine(answer.Instance); + Console.WriteLine(answer.MemberReference?.Name); + Console.WriteLine(answer.InstanceAs(CultureInfo.InvariantCulture)); + Console.WriteLine(fromText.InstanceAs()); + Console.WriteLine(answer.Data["category"]); + Console.WriteLine(Wrapper.ParseInstance(bytes)); + Console.WriteLine(type.ToString()); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Xml.ByteArrayExtensions.md b/.docfx/api/types/Cuemon.Extensions.Xml.ByteArrayExtensions.md index 108aff436..eadec4e74 100644 --- a/.docfx/api/types/Cuemon.Extensions.Xml.ByteArrayExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Xml.ByteArrayExtensions.md @@ -7,29 +7,26 @@ example: The following example demonstrates how to convert a byte array to an [XmlReader](https://learn.microsoft.com/dotnet/api/system.xml.xmlreader) using the class. ```csharp +// Program.cs using System; using System.Text; using System.Xml; using Cuemon.Extensions.Xml; -namespace MyApp.Examples; +byte[] xmlData = Encoding.UTF8.GetBytes("Value"); -public class ByteArrayExtensionsExample +// Convert the byte array to an XmlReader +using (XmlReader reader = xmlData.ToXmlReader()) { - public void Demonstrate() + while (reader.Read()) { - byte[] xmlData = Encoding.UTF8.GetBytes("Value"); - - // Convert the byte array to an XmlReader - using (XmlReader reader = xmlData.ToXmlReader()) + if (reader.NodeType == XmlNodeType.Element) { - while (reader.Read()) - { - if (reader.NodeType == XmlNodeType.Element) - { - Console.WriteLine(reader.Name); - -}}}} -} + Console.WriteLine(reader.Name); +}}} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Xml.DateTimeExtensions.md b/.docfx/api/types/Cuemon.Extensions.Xml.DateTimeExtensions.md index d91cd2aad..9ad06370b 100644 --- a/.docfx/api/types/Cuemon.Extensions.Xml.DateTimeExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Xml.DateTimeExtensions.md @@ -7,40 +7,34 @@ example: `DateTimeExtensions` in the `Xml` namespace formats `DateTime` values as XML strings using `XmlDateTimeSerializationMode` enum values. This example creates `DateTime.UtcNow` and `DateTime.Now`, then calls `ToString` with `XmlDateTimeSerializationMode.Utc` (appends `Z`), `Local` (includes timezone offset like `+02:00`), `RoundtripKind` (preserves `Kind` information), and `Unspecified` (omits timezone info). Console output for each mode shows how time zone information is represented or omitted, such as `2026-06-16T12:34:56.789Z` for UTC and `2026-06-16T14:34:56.789+02:00` for local. ```csharp +// Program.cs using System; using System.Xml; using Cuemon.Extensions.Xml; -namespace MyApp.Xml -{ - public class DateTimeExtensionsExample - { - public void Demonstrate() - { - DateTime utcNow = DateTime.UtcNow; - - // Format as XML UTC string (appends "Z" for UTC) - string xmlUtc = utcNow.ToString(XmlDateTimeSerializationMode.Utc); - Console.WriteLine(xmlUtc); - // Output: 2026-06-16T12:34:56.789Z - - // Convert local time to XML local string (includes offset) - DateTime localNow = DateTime.Now; - string xmlLocal = localNow.ToString(XmlDateTimeSerializationMode.Local); - Console.WriteLine(xmlLocal); - // Output: 2026-06-16T14:34:56.789+02:00 - - // Round-trip format preserves the Kind information - string xmlRoundtrip = utcNow.ToString(XmlDateTimeSerializationMode.RoundtripKind); - Console.WriteLine(xmlRoundtrip); - // Output: 2026-06-16T12:34:56.789Z - - // Unspecified mode drops any time zone info - string xmlUnspecified = utcNow.ToString(XmlDateTimeSerializationMode.Unspecified); - Console.WriteLine(xmlUnspecified); - // Output: 2026-06-16T12:34:56.789 - -}} -} +DateTime utcNow = DateTime.UtcNow; +// Format as XML UTC string (appends "Z" for UTC) +string xmlUtc = utcNow.ToString(XmlDateTimeSerializationMode.Utc); +Console.WriteLine(xmlUtc); +// Output: 2026-06-16T12:34:56.789Z + +// Convert local time to XML local string (includes offset) +DateTime localNow = DateTime.Now; +string xmlLocal = localNow.ToString(XmlDateTimeSerializationMode.Local); +Console.WriteLine(xmlLocal); +// Output: 2026-06-16T14:34:56.789+02:00 + +// Round-trip format preserves the Kind information +string xmlRoundtrip = utcNow.ToString(XmlDateTimeSerializationMode.RoundtripKind); +Console.WriteLine(xmlRoundtrip); +// Output: 2026-06-16T12:34:56.789Z + +// Unspecified mode drops any time zone info +string xmlUnspecified = utcNow.ToString(XmlDateTimeSerializationMode.Unspecified); +Console.WriteLine(xmlUnspecified); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Xml.HierarchyExtensions.md b/.docfx/api/types/Cuemon.Extensions.Xml.HierarchyExtensions.md index 382253ae1..a27c4b8d6 100644 --- a/.docfx/api/types/Cuemon.Extensions.Xml.HierarchyExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Xml.HierarchyExtensions.md @@ -7,6 +7,7 @@ example: `HierarchyExtensions` provides extension methods for inspecting XML serialization metadata on hierarchy nodes, including qualified entity names, enumerable detection, and XML ignore and ordering attributes. This example creates `HierarchySerializer` instances for `CatalogDocument` (with `[XmlAttribute]` on `Id` and a `List Tags` property) and `IgnoredDocument` (with `[XmlIgnore]` on `Hidden`), then calls `GetXmlQualifiedEntity`, `IsNodeEnumerable`, `HasXmlIgnoreAttribute`, and `OrderByXmlAttributes` on individual nodes. Console output shows the qualified entity local name, whether the node is enumerable, whether it has `[XmlIgnore]`, and the reordered element order. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; @@ -14,44 +15,52 @@ using System.Xml.Serialization; using Cuemon.Extensions.Runtime.Serialization; using Cuemon.Extensions.Xml; using Cuemon.Xml.Serialization; +using DocExamples; -namespace DocExamples; +HierarchyExtensionsExample.Demonstrate(); -public static class HierarchyExtensionsExample +namespace DocExamples { - public static void Demonstrate() + public static class HierarchyExtensionsExample { - var documentNodes = new HierarchySerializer(new CatalogDocument()).Nodes.GetChildren().ToList(); - var idNode = documentNodes.Single(node => node.MemberReference?.Name == nameof(CatalogDocument.Id)); - var tagsNode = documentNodes.Single(node => node.MemberReference?.Name == nameof(CatalogDocument.Tags)); + public static void Demonstrate() + { + var documentNodes = new HierarchySerializer(new CatalogDocument()).Nodes.GetChildren().ToList(); + var idNode = documentNodes.Single(node => node.MemberReference?.Name == nameof(CatalogDocument.Id)); + var tagsNode = documentNodes.Single(node => node.MemberReference?.Name == nameof(CatalogDocument.Tags)); - var ignoredNodes = new HierarchySerializer(new IgnoredDocument()).Nodes.GetChildren().ToList(); - var hiddenNode = ignoredNodes.Single(node => node.MemberReference?.Name == nameof(IgnoredDocument.Hidden)); - var overrideEntity = new XmlQualifiedEntity("Override"); + var ignoredNodes = new HierarchySerializer(new IgnoredDocument()).Nodes.GetChildren().ToList(); + var hiddenNode = ignoredNodes.Single(node => node.MemberReference?.Name == nameof(IgnoredDocument.Hidden)); + var overrideEntity = new XmlQualifiedEntity("Override"); - Console.WriteLine(idNode.GetXmlQualifiedEntity().LocalName); - Console.WriteLine(idNode.GetXmlQualifiedEntity(overrideEntity).LocalName); - Console.WriteLine(tagsNode.IsNodeEnumerable()); - Console.WriteLine(hiddenNode.HasXmlIgnoreAttribute()); + Console.WriteLine(idNode.GetXmlQualifiedEntity().LocalName); + Console.WriteLine(idNode.GetXmlQualifiedEntity(overrideEntity).LocalName); + Console.WriteLine(tagsNode.IsNodeEnumerable()); + Console.WriteLine(hiddenNode.HasXmlIgnoreAttribute()); - var reordered = new[] { tagsNode, idNode }.OrderByXmlAttributes().ToList(); - Console.WriteLine(reordered[0].MemberReference?.Name); - } + var reordered = new[] { tagsNode, idNode }.OrderByXmlAttributes().ToList(); + Console.WriteLine(reordered[0].MemberReference?.Name); + } - private sealed class CatalogDocument - { - [XmlAttribute] - public Guid Id { get; } = Guid.Empty; + private sealed class CatalogDocument + { + [XmlAttribute] + public Guid Id { get; } = Guid.Empty; - public List Tags { get; } = new() { "xml", "docfx" }; - } + public List Tags { get; } = new() { "xml", "docfx" }; + } - private sealed class IgnoredDocument - { - [XmlIgnore] - public string Hidden => "internal"; + private sealed class IgnoredDocument + { + [XmlIgnore] + public string Hidden => "internal"; - public string Visible => "public"; + public string Visible => "public"; + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Xml.Linq.StringExtensions.md b/.docfx/api/types/Cuemon.Extensions.Xml.Linq.StringExtensions.md index f384eccf6..738d851d4 100644 --- a/.docfx/api/types/Cuemon.Extensions.Xml.Linq.StringExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Xml.Linq.StringExtensions.md @@ -7,34 +7,31 @@ example: The following example demonstrates how to parse XML strings into [XElement](https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement) using the class. ```csharp +// Program.cs using System; using System.Xml.Linq; using Cuemon.Extensions.Xml.Linq; -namespace MyApp.Examples; +string xml = "Value"; -public class StringExtensionsExample +// Try to parse the XML string into an XElement +if (xml.TryParseXElement(out XElement element)) { - public void Demonstrate() - { - string xml = "Value"; - - // Try to parse the XML string into an XElement - if (xml.TryParseXElement(out XElement element)) - { - Console.WriteLine(element.Name); // root - Console.WriteLine(element.Element("item")?.Value); // Value - - // Check if a string is valid XML - bool isValid = xml.IsXmlString(); - Console.WriteLine(isValid); // True - - // Invalid XML returns false - string invalid = ""; - bool isInvalid = invalid.IsXmlString(); - Console.WriteLine(isInvalid); // False - -}} -} + Console.WriteLine(element.Name); // root + Console.WriteLine(element.Element("item")?.Value); // Value + +// Check if a string is valid XML +bool isValid = xml.IsXmlString(); +Console.WriteLine(isValid); // True + +// Invalid XML returns false +string invalid = ""; +bool isInvalid = invalid.IsXmlString(); +Console.WriteLine(isInvalid); // False +} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Xml.Serialization.Converters.XmlConverterExtensions.md b/.docfx/api/types/Cuemon.Extensions.Xml.Serialization.Converters.XmlConverterExtensions.md index a667a3a7b..247ceaa51 100644 --- a/.docfx/api/types/Cuemon.Extensions.Xml.Serialization.Converters.XmlConverterExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Xml.Serialization.Converters.XmlConverterExtensions.md @@ -7,6 +7,7 @@ example: `XmlConverterExtensions` provides extension methods for building a list of `XmlConverter` instances with both built-in and custom converters that can be reused through `XmlSerializer`. This example creates an `IList` and calls `InsertXmlConverter` to register a custom string converter at position 0, `AddXmlConverter` for an integer converter, and fluent methods like `AddEnumerableConverter`, `AddExceptionDescriptorConverter`, `AddUriConverter`, `AddDateTimeConverter`, `AddTimeSpanConverter`, `AddStringConverter`, `AddExceptionConverter`, and `AddFailureConverter`. It then uses `FirstOrDefaultWriterConverter` and `FirstOrDefaultReaderConverter` to query converters, applies them to `XmlSerializerOptions`, and serializes a `Uri` to XML. Console output confirms converter lookup results and displays the serialized XML. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.IO; @@ -16,52 +17,48 @@ using Cuemon.Extensions.Xml.Serialization.Converters; using Cuemon.Xml.Serialization; using Cuemon.Xml.Serialization.Converters; -namespace DocExamples; +IList converters = new List(); -public static class XmlConverterExtensionsExample -{ - public static void Demonstrate() - { - IList converters = new List(); - - converters.InsertXmlConverter( - 0, - (writer, value, entity) => writer.WriteElementString(entity?.LocalName ?? "Value", value), - (reader, objectType) => reader.ReadElementContentAsString(), - objectType => objectType == typeof(string), - new XmlQualifiedEntity("String")); +converters.InsertXmlConverter( + 0, + (writer, value, entity) => writer.WriteElementString(entity?.LocalName ?? "Value", value), + (reader, objectType) => reader.ReadElementContentAsString(), + objectType => objectType == typeof(string), + new XmlQualifiedEntity("String")); - converters.AddXmlConverter( - (writer, value, entity) => writer.WriteElementString(entity?.LocalName ?? "Value", value.ToString()), - (reader, objectType) => reader.ReadElementContentAsInt(), - objectType => objectType == typeof(int), - new XmlQualifiedEntity("Int32")); +converters.AddXmlConverter( + (writer, value, entity) => writer.WriteElementString(entity?.LocalName ?? "Value", value.ToString()), + (reader, objectType) => reader.ReadElementContentAsInt(), + objectType => objectType == typeof(int), + new XmlQualifiedEntity("Int32")); - converters.AddEnumerableConverter(); - converters.AddExceptionDescriptorConverter(options => options.SensitivityDetails = FaultSensitivityDetails.All); - converters.AddUriConverter(); - converters.AddDateTimeConverter(); - converters.AddTimeSpanConverter(); - converters.AddStringConverter(); - converters.AddExceptionConverter(includeStackTrace: true, includeData: true); - converters.AddFailureConverter(); +converters.AddEnumerableConverter(); +converters.AddExceptionDescriptorConverter(options => options.SensitivityDetails = FaultSensitivityDetails.All); +converters.AddUriConverter(); +converters.AddDateTimeConverter(); +converters.AddTimeSpanConverter(); +converters.AddStringConverter(); +converters.AddExceptionConverter(includeStackTrace: true, includeData: true); +converters.AddFailureConverter(); - var writerConverter = converters.FirstOrDefaultWriterConverter(typeof(Uri)); - var readerConverter = converters.FirstOrDefaultReaderConverter(typeof(string)); +var writerConverter = converters.FirstOrDefaultWriterConverter(typeof(Uri)); +var readerConverter = converters.FirstOrDefaultReaderConverter(typeof(string)); - var serializerOptions = new XmlSerializerOptions(); - serializerOptions.Converters.Clear(); - foreach (var converter in converters) - { - serializerOptions.Converters.Add(converter); - } +var serializerOptions = new XmlSerializerOptions(); +serializerOptions.Converters.Clear(); +foreach (var converter in converters) +{ + serializerOptions.Converters.Add(converter); +} - var serializer = XmlSerializer.Create(serializerOptions); - using var stream = serializer.Serialize(new Uri("https://example.com/feed.xml"), typeof(Uri)); - using var xml = new StreamReader(stream); +var serializer = XmlSerializer.Create(serializerOptions); +using var stream = serializer.Serialize(new Uri("https://example.com/feed.xml"), typeof(Uri)); +using var xml = new StreamReader(stream); - Console.WriteLine(writerConverter is not null && readerConverter is not null); - Console.WriteLine(xml.ReadToEnd()); - } -} +Console.WriteLine(writerConverter is not null && readerConverter is not null); +Console.WriteLine(xml.ReadToEnd()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Xml.Serialization.XmlSerializerOptionsExtensions.md b/.docfx/api/types/Cuemon.Extensions.Xml.Serialization.XmlSerializerOptionsExtensions.md index c2584a76f..85907723b 100644 --- a/.docfx/api/types/Cuemon.Extensions.Xml.Serialization.XmlSerializerOptionsExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Xml.Serialization.XmlSerializerOptionsExtensions.md @@ -7,31 +7,28 @@ example: The following example demonstrates how to apply custom to the default settings using the class. ```csharp +// Program.cs using System; using System.Text; using System.Xml; using Cuemon.Extensions.Xml.Serialization; using Cuemon.Xml.Serialization; -namespace MyApp.Examples; - -public class XmlSerializerOptionsExtensionsExample +// Configure XmlSerializerOptions +var options = new XmlSerializerOptions { - public void Demonstrate() - { - // Configure XmlSerializerOptions - var options = new XmlSerializerOptions - { - Reader = new XmlReaderSettings { IgnoreWhitespace = true }, - Writer = new XmlWriterSettings { Indent = true, Encoding = Encoding.UTF8 } - }; - - // Apply to default XmlConvert settings - options.ApplyToDefaultSettings(); + Reader = new XmlReaderSettings { IgnoreWhitespace = true }, + Writer = new XmlWriterSettings { Indent = true, Encoding = Encoding.UTF8 } +}; - // After this call, XmlConvert.DefaultSettings will reflect the options - -} -} +// Apply to default XmlConvert settings +options.ApplyToDefaultSettings(); +// After this call, XmlConvert.DefaultSettings will reflect the options +Console.WriteLine(options.Writer.Indent); +Console.WriteLine(options.Reader.IgnoreWhitespace); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Xml.StreamExtensions.md b/.docfx/api/types/Cuemon.Extensions.Xml.StreamExtensions.md index cacdb6607..cc3826f91 100644 --- a/.docfx/api/types/Cuemon.Extensions.Xml.StreamExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Xml.StreamExtensions.md @@ -7,11 +7,15 @@ example: `StreamExtensions` in the `Xml` namespace provides stream-based XML operations including `XmlReader` creation, indented copying, encoding detection, and namespace removal. This example loads an XML string into a `MemoryStream` and demonstrates four operations: `ToXmlReader` to parse element names, `CopyXmlStream` with `Indent = true` for pretty-printed XML output, `TryDetectXmlEncoding` to identify `UTF-8` encoding, and `RemoveXmlNamespaceDeclarations` to strip namespace prefixes from elements. Each operation repositions the stream to `Position = 0` before proceeding. Console output shows element names (`root`, `item`), the indented XML, the detected encoding name (`Unicode (UTF-8)`), and the namespace-cleaned content. ```csharp +// Program.cs using System; using System.IO; using System.Text; using System.Xml; using Cuemon.Extensions.Xml; +using MyApp.Xml; + +new StreamExtensionsExample().Demonstrate(); namespace MyApp.Xml { @@ -19,45 +23,48 @@ namespace MyApp.Xml { public void Demonstrate() { - var xml = "Value"; - var stream = new MemoryStream(Encoding.UTF8.GetBytes(xml)); + const string xml = "Value"; - // Convert an XML stream to an XmlReader - using (var reader = stream.ToXmlReader()) + using (var reader = CreateStream(xml).ToXmlReader()) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { Console.WriteLine(reader.Name); + } + } + } - // Reset stream position for next demonstration - stream.Position = 0; - - // Copy an XML stream with specified writer settings (e.g., indented output) - using (var copy = stream.CopyXmlStream(o => o.Indent = true)) + using (var copy = CreateStream(xml).CopyXmlStream(o => o.Indent = true)) + using (var streamReader = new StreamReader(copy)) { - var indentedXml = new StreamReader(copy).ReadToEnd(); - Console.WriteLine(indentedXml); // Indented XML - - stream.Position = 0; + Console.WriteLine(streamReader.ReadToEnd()); + } - // Detect XML encoding from the stream - if (stream.TryDetectXmlEncoding(out var encoding)) + using (var encodingStream = CreateStream(xml)) { - Console.WriteLine(encoding.EncodingName); // "Unicode (UTF-8)" - - stream.Position = 0; + if (encodingStream.TryDetectXmlEncoding(out var encoding)) + { + Console.WriteLine(encoding.EncodingName); + } + } - // Remove XML namespace declarations from the stream - using (var noNs = stream.RemoveXmlNamespaceDeclarations()) + using (var noNamespace = CreateStream(xml).RemoveXmlNamespaceDeclarations()) + using (var streamReader = new StreamReader(noNamespace)) { - var cleaned = new StreamReader(noNs).ReadToEnd(); - Console.WriteLine(cleaned); // Elements without namespace prefixes + Console.WriteLine(streamReader.ReadToEnd()); + } + } - stream.Dispose(); - -}}}}}}}} + private static MemoryStream CreateStream(string xml) + { + return new MemoryStream(Encoding.UTF8.GetBytes(xml)); + } + } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Xml.StringExtensions.md b/.docfx/api/types/Cuemon.Extensions.Xml.StringExtensions.md index 330ad107d..cb86dead7 100644 --- a/.docfx/api/types/Cuemon.Extensions.Xml.StringExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Xml.StringExtensions.md @@ -7,40 +7,35 @@ example: `StringExtensions` in the `Xml` namespace provides XML escaping, unescaping, element name sanitization, and control-character removal for text content. This example starts with `"Use & < > \" ' in XML"` and calls `EscapeXml` to produce `"Use & < > " ' in XML"`, then round-trips back with `UnescapeXml`. It also demonstrates `SanitizeXmlElementName` on `"1st Element Name!"` to replace leading digits and punctuation with underscores, and `SanitizeXmlElementText` to remove control characters except `\t`, `\n`, `\r`, with optional CDATA section protection that removes `"]]>"` sequences. Console output displays each transformation result. ```csharp +// Program.cs using System; using Cuemon.Extensions.Xml; -namespace MyApp.Xml -{ - public class StringExtensionsExample - { - public void Demonstrate() - { - // Escape XML special characters - var unsafeText = "Use & < > \" ' in XML"; - var escaped = unsafeText.EscapeXml(); - Console.WriteLine(escaped); // "Use & < > " ' in XML" - - // Unescape XML back to original text - var unescaped = escaped.UnescapeXml(); - Console.WriteLine(unescaped); // "Use & < > \" ' in XML" - - // Sanitize a string for use as an XML element name - var invalidName = "1st Element Name!"; - var sanitizedName = invalidName.SanitizeXmlElementName(); - Console.WriteLine(sanitizedName); // "_st_Element_Name_" - - // Sanitize XML element text (remove control characters except \t, \n, \r) - var invalidText = "Valid text \x00 with \x01 control chars"; - var sanitizedText = invalidText.SanitizeXmlElementText(); - Console.WriteLine(sanitizedText); // "Valid text with control chars" - - // Sanitize XML element text with CDATA section rules (discourages "]]>" sequence) - var cdataText = "text with ]]> inside"; - var sanitizedCdata = cdataText.SanitizeXmlElementText(cdataSection: true); - Console.WriteLine(sanitizedCdata); // "text with ]] inside" - -}} -} - +// Escape XML special characters +var unsafeText = "Use & < > \" ' in XML"; +var escaped = unsafeText.EscapeXml(); +Console.WriteLine(escaped); // "Use & < > " ' in XML" + +// Unescape XML back to original text +var unescaped = escaped.UnescapeXml(); +Console.WriteLine(unescaped); // "Use & < > \" ' in XML" + +// Sanitize a string for use as an XML element name +var invalidName = "1st Element Name!"; +var sanitizedName = invalidName.SanitizeXmlElementName(); +Console.WriteLine(sanitizedName); // "_st_Element_Name_" + +// Sanitize XML element text (remove control characters except \t, \n, \r) +var invalidText = "Valid text \x00 with \x01 control chars"; +var sanitizedText = invalidText.SanitizeXmlElementText(); +Console.WriteLine(sanitizedText); // "Valid text with control chars" + +// Sanitize XML element text with CDATA section rules (discourages "]]>" sequence) +var cdataText = "text with ]]> inside"; +var sanitizedCdata = cdataText.SanitizeXmlElementText(cdataSection: true); +Console.WriteLine(sanitizedCdata); // "text with ]] inside" ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Xml.UriExtensions.md b/.docfx/api/types/Cuemon.Extensions.Xml.UriExtensions.md index 8e96e2b61..e7df99534 100644 --- a/.docfx/api/types/Cuemon.Extensions.Xml.UriExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Xml.UriExtensions.md @@ -7,42 +7,39 @@ example: `UriExtensions` in the `Xml` namespace creates `XmlReader` instances from file URIs with configurable reader settings. This example writes a simple XML snippet to a temporary file, constructs a `Uri` pointing to it, and calls `ToXmlReader` with settings that ignore XML comments and disable DTD processing. After positioning the reader with `MoveToFirstElement`, the local element name is output as `"root"`. A `finally` block ensures the temporary file is deleted after the demonstration. ```csharp +// Program.cs using System; using System.IO; using System.Text; using System.Xml; using Cuemon.Extensions.Xml; -namespace DocExamples; +var xml = "42"; +var filePath = Path.Combine(AppContext.BaseDirectory, "settings.xml"); +File.WriteAllText(filePath, xml, Encoding.UTF8); -public static class UriExtensionsExample +try { - public static void Demonstrate() + using var reader = new Uri(filePath).ToXmlReader(settings => { - var xml = "42"; - var filePath = Path.Combine(AppContext.BaseDirectory, "settings.xml"); - File.WriteAllText(filePath, xml, Encoding.UTF8); + settings.IgnoreComments = true; + settings.DtdProcessing = DtdProcessing.Ignore; + }); - try - { - using var reader = new Uri(filePath).ToXmlReader(settings => - { - settings.IgnoreComments = true; - settings.DtdProcessing = DtdProcessing.Ignore; - }); - - if (reader.MoveToFirstElement()) - { - Console.WriteLine(reader.LocalName); - } - } - finally - { - if (File.Exists(filePath)) - { - File.Delete(filePath); - } - } + if (reader.MoveToFirstElement()) + { + Console.WriteLine(reader.LocalName); + } +} +finally +{ + if (File.Exists(filePath)) + { + File.Delete(filePath); } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Xml.XmlCopyOptions.md b/.docfx/api/types/Cuemon.Extensions.Xml.XmlCopyOptions.md index 366367033..15d57a803 100644 --- a/.docfx/api/types/Cuemon.Extensions.Xml.XmlCopyOptions.md +++ b/.docfx/api/types/Cuemon.Extensions.Xml.XmlCopyOptions.md @@ -7,57 +7,65 @@ example: The following example demonstrates how to use to configure settings when copying XML content. ```csharp +// Program.cs using System; using System.IO; using System.Xml; using Cuemon.Extensions.Xml; +using MyApp.Examples; -namespace MyApp.Examples; +new XmlCopyOptionsExample().CopyXmlWithCustomSettings(); -public class XmlCopyOptionsExample +namespace MyApp.Examples { - public void CopyXmlWithCustomSettings() + public class XmlCopyOptionsExample { - // Configure writer settings for indentation and encoding - var copyOptions = new XmlCopyOptions + public void CopyXmlWithCustomSettings() { - WriterSettings = settings => + // Configure writer settings for indentation and encoding + var copyOptions = new XmlCopyOptions { - settings.Indent = true; - settings.IndentChars = " "; - settings.OmitXmlDeclaration = false; - settings.NewLineOnAttributes = false; - } - }; + WriterSettings = settings => + { + settings.Indent = true; + settings.IndentChars = " "; + settings.OmitXmlDeclaration = false; + settings.NewLineOnAttributes = false; + } + }; - // Use the options to configure an XmlWriter during a copy operation - string input = @"text"; + // Use the options to configure an XmlWriter during a copy operation + string input = @"text"; - using (var reader = XmlReader.Create(new StringReader(input))) - using (var writer = XmlWriter.Create(Console.Out, ConfigureWriter(copyOptions))) - { - writer.WriteNode(reader, false); + using (var reader = XmlReader.Create(new StringReader(input))) + using (var writer = XmlWriter.Create(Console.Out, ConfigureWriter(copyOptions))) + { + writer.WriteNode(reader, false); + } + // Output: + // + // + // text + // } - // Output: - // - // - // text - // - } - private static XmlWriterSettings ConfigureWriter(XmlCopyOptions options) - { - var settings = new XmlWriterSettings(); - options.WriterSettings?.Invoke(settings); - return settings; - } + private static XmlWriterSettings ConfigureWriter(XmlCopyOptions options) + { + var settings = new XmlWriterSettings(); + options.WriterSettings?.Invoke(settings); + return settings; + } - public void UseDefaults() - { - // Default options have null WriterSettings (no custom configuration) - var options = new XmlCopyOptions(); - Console.WriteLine($"WriterSettings: {(options.WriterSettings == null ? "null (no customization)" : "configured")}"); + public void UseDefaults() + { + // Default options have null WriterSettings (no custom configuration) + var options = new XmlCopyOptions(); + Console.WriteLine($"WriterSettings: {(options.WriterSettings == null ? "null (no customization)" : "configured")}"); + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Xml.XmlReaderExtensions.md b/.docfx/api/types/Cuemon.Extensions.Xml.XmlReaderExtensions.md index f94d5a405..59047e6ce 100644 --- a/.docfx/api/types/Cuemon.Extensions.Xml.XmlReaderExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Xml.XmlReaderExtensions.md @@ -4,59 +4,68 @@ example: - *content --- -`XmlReaderExtensions` provides extension methods for `XmlReader` including navigation, hierarchy building, chunked reading, and stream conversion. This example starts with an XML string containing `` and two `` elements, then demonstrates `MoveToFirstElement` to position at the first element, `ToHierarchy` to build a tree of element nodes with child names, `Chunk(1)` to stream only the first element as a new indented `XmlReader`, and `ToStream` to convert the entire reader content into a readable stream. Console output shows the root element name (`"root"`), a hierarchy description with child names, the outer XML of the first chunk (`First`), and the full XML content. +`XmlReaderExtensions` provides extension methods for `XmlReader` including navigation, hierarchy building, chunked reading, and stream conversion. This example starts with an XML string containing `` and two `` elements, then demonstrates `MoveToFirstElement` to position at the first element, `ToHierarchy` to build a tree of element nodes with child names, `Chunk(1)` to stream only the first element as a new indented `XmlReader`, and `ToStream` to convert the entire reader content into a readable stream. Console output shows the root element name (`"root"`), a hierarchy description with child names, the outer XML of the first chunk (`First`), and the full XML content. ```csharp +// Program.cs using System; using System.IO; using System.Linq; using System.Xml; using Cuemon.Extensions.Xml; +using DocExamples; -namespace DocExamples; +XmlReaderExtensionsExample.Demonstrate(); -public static class XmlReaderExtensionsExample +namespace DocExamples { - private const string XmlDocument = "FirstSecond"; - - public static void Demonstrate() + public static class XmlReaderExtensionsExample { - Console.WriteLine(GetRootName()); - Console.WriteLine(DescribeHierarchy()); - Console.WriteLine(ReadFirstChunk()); - Console.WriteLine(CopyXml()); - } + private const string XmlDocument = "FirstSecond"; - private static string GetRootName() - { - using var xmlReader = XmlReader.Create(new StringReader(XmlDocument)); - return xmlReader.MoveToFirstElement() ? xmlReader.LocalName : string.Empty; - } + public static void Demonstrate() + { + Console.WriteLine(GetRootName()); + Console.WriteLine(DescribeHierarchy()); + Console.WriteLine(ReadFirstChunk()); + Console.WriteLine(CopyXml()); + } - private static string DescribeHierarchy() - { - using var xmlReader = XmlReader.Create(new StringReader(XmlDocument)); - var hierarchy = xmlReader.ToHierarchy(); - var childNames = string.Join(", ", hierarchy.GetChildren().Select(child => child.Instance.Name)); - return $"{hierarchy.Instance.Name}: {childNames}"; - } + private static string GetRootName() + { + using var xmlReader = XmlReader.Create(new StringReader(XmlDocument)); + return xmlReader.MoveToFirstElement() ? xmlReader.LocalName : string.Empty; + } - private static string ReadFirstChunk() - { - using var xmlReader = XmlReader.Create(new StringReader(XmlDocument)); - using var firstChunk = xmlReader.Chunk(1, settings => settings.Indent = true).First(); + private static string DescribeHierarchy() + { + using var xmlReader = XmlReader.Create(new StringReader(XmlDocument)); + var hierarchy = xmlReader.ToHierarchy(); + var childNames = string.Join(", ", hierarchy.GetChildren().Select(child => child.Instance.Name)); + return $"{hierarchy.Instance.Name}: {childNames}"; + } - firstChunk.MoveToFirstElement(); - return firstChunk.ReadOuterXml(); - } + private static string ReadFirstChunk() + { + using var xmlReader = XmlReader.Create(new StringReader(XmlDocument)); + using var firstChunk = xmlReader.Chunk(1, settings => settings.Indent = true).First(); - private static string CopyXml() - { - using var xmlReader = XmlReader.Create(new StringReader(XmlDocument)); - using var xmlStream = xmlReader.ToStream(); - using var streamReader = new StreamReader(xmlStream); + firstChunk.MoveToFirstElement(); + return firstChunk.ReadOuterXml(); + } - return streamReader.ReadToEnd(); + private static string CopyXml() + { + using var xmlReader = XmlReader.Create(new StringReader(XmlDocument)); + using var xmlStream = xmlReader.ToStream(); + using var streamReader = new StreamReader(xmlStream); + + return streamReader.ReadToEnd(); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Extensions.Xml.XmlWriterExtensions.md b/.docfx/api/types/Cuemon.Extensions.Xml.XmlWriterExtensions.md index 612969d5b..27009136c 100644 --- a/.docfx/api/types/Cuemon.Extensions.Xml.XmlWriterExtensions.md +++ b/.docfx/api/types/Cuemon.Extensions.Xml.XmlWriterExtensions.md @@ -7,65 +7,74 @@ example: `XmlWriterExtensions` provides extension methods for `XmlWriter` including object serialization, qualified element names, conditional wrapping, and root element generation. This example creates an `XmlWriter` targeting a `StringWriter` with indented, declaration-free settings, then calls `WriteObject` to serialize an `InvalidOperationException`, `WriteStartElement` with an `XmlQualifiedEntity("Cuemon")` for a standalone element, `WriteEncapsulatingElementWhenNotNull` to conditionally wrap an exception in a `"MyWrappedElement"`, and `WriteXmlRootElement` to produce a `Root` element with a `"cuemon"` namespace URI. Console output displays four separate XML results showing the serialized exception, the standalone element, the wrapped exception, and the namespace-qualified root element. ```csharp +// Program.cs using System; using System.IO; using System.Xml; using Cuemon.Extensions.Xml; using Cuemon.Xml.Serialization; +using DocExamples; -namespace DocExamples; +XmlWriterExtensionsExample.Demonstrate(); -public static class XmlWriterExtensionsExample +namespace DocExamples { - public static void Demonstrate() + public static class XmlWriterExtensionsExample { - Console.WriteLine(WriteException()); - Console.WriteLine(WriteStandaloneElement()); - Console.WriteLine(WriteWrappedException()); - Console.WriteLine(WriteRootElement()); - } + public static void Demonstrate() + { + Console.WriteLine(WriteException()); + Console.WriteLine(WriteStandaloneElement()); + Console.WriteLine(WriteWrappedException()); + Console.WriteLine(WriteRootElement()); + } - private static string WriteException() - { - var output = new StringWriter(); - using var writer = XmlWriter.Create(output, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true }); - writer.WriteObject(new InvalidOperationException()); - writer.Flush(); - return output.ToString(); - } + private static string WriteException() + { + var output = new StringWriter(); + using var writer = XmlWriter.Create(output, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true }); + writer.WriteObject(new InvalidOperationException()); + writer.Flush(); + return output.ToString(); + } - private static string WriteStandaloneElement() - { - var output = new StringWriter(); - using var writer = XmlWriter.Create(output, new XmlWriterSettings { OmitXmlDeclaration = true }); - writer.WriteStartElement(new XmlQualifiedEntity("Cuemon")); - writer.WriteEndElement(); - writer.Flush(); - return output.ToString(); - } + private static string WriteStandaloneElement() + { + var output = new StringWriter(); + using var writer = XmlWriter.Create(output, new XmlWriterSettings { OmitXmlDeclaration = true }); + writer.WriteStartElement(new XmlQualifiedEntity("Cuemon")); + writer.WriteEndElement(); + writer.Flush(); + return output.ToString(); + } - private static string WriteWrappedException() - { - var output = new StringWriter(); - using var writer = XmlWriter.Create(output, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true }); - writer.WriteEncapsulatingElementWhenNotNull(new InvalidOperationException(), new XmlQualifiedEntity("MyWrappedElement"), (nestedWriter, exception) => + private static string WriteWrappedException() { - nestedWriter.WriteObject(exception); - }); - writer.Flush(); - return output.ToString(); - } + var output = new StringWriter(); + using var writer = XmlWriter.Create(output, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true }); + writer.WriteEncapsulatingElementWhenNotNull(new InvalidOperationException(), new XmlQualifiedEntity("MyWrappedElement"), (nestedWriter, exception) => + { + nestedWriter.WriteObject(exception); + }); + writer.Flush(); + return output.ToString(); + } - private static string WriteRootElement() - { - var output = new StringWriter(); - using var writer = XmlWriter.Create(output, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true }); - writer.WriteXmlRootElement(new InvalidOperationException(), (nestedWriter, exception, rootEntity) => + private static string WriteRootElement() { - nestedWriter.WriteObject(exception); - }, new XmlQualifiedEntity("Root", "cuemon")); - writer.Flush(); - return output.ToString(); + var output = new StringWriter(); + using var writer = XmlWriter.Create(output, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true }); + writer.WriteXmlRootElement(new InvalidOperationException(), (nestedWriter, exception, rootEntity) => + { + nestedWriter.WriteObject(exception); + }, new XmlQualifiedEntity("Root", "cuemon")); + writer.Flush(); + return output.ToString(); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.FormattingOptions.md b/.docfx/api/types/Cuemon.FormattingOptions.md index 81da44275..3b2f7783f 100644 --- a/.docfx/api/types/Cuemon.FormattingOptions.md +++ b/.docfx/api/types/Cuemon.FormattingOptions.md @@ -7,27 +7,22 @@ example: The following example demonstrates how to configure a with a custom format provider to control numeric formatting. ```csharp +// Program.cs using System; using System.Globalization; using Cuemon; -namespace MyApp.Examples; - -public class FormattingOptionsExample +var options = new FormattingOptions { - public void Demonstrate() - { - var options = new FormattingOptions - { - FormatProvider = new CultureInfo("da-DK") - }; - - var value = 1234.56; - var formatted = value.ToString("N2", options.FormatProvider); + FormatProvider = new CultureInfo("da-DK") +}; - Console.WriteLine(formatted); // Output depends on the culture (e.g., "1.234,56" for da-DK) - -} -} +var value = 1234.56; +var formatted = value.ToString("N2", options.FormatProvider); +Console.WriteLine(formatted); // Output depends on the culture (e.g., "1.234,56" for da-DK) ``` + + + + diff --git a/.docfx/api/types/Cuemon.FuncFactory`2.md b/.docfx/api/types/Cuemon.FuncFactory`2.md index 10ef58cf7..dcc7e718a 100644 --- a/.docfx/api/types/Cuemon.FuncFactory`2.md +++ b/.docfx/api/types/Cuemon.FuncFactory`2.md @@ -7,24 +7,21 @@ example: The following example demonstrates how to use to encapsulate a function delegate and its arguments together for deferred execution. ```csharp +// Program.cs using System; using Cuemon; -namespace Contoso.Formatting; +var factory = new FuncFactory, string>( + tuple => $"{tuple.Arg1}-{tuple.Arg2:D3}", + new MutableTuple("Item", 7)); -public sealed class FuncFactoryExample -{ - public static void Run() - { - var factory = new FuncFactory, string>( - tuple => $"{tuple.Arg1}-{tuple.Arg2:D3}", - new MutableTuple("Item", 7)); +string result = factory.ExecuteMethod(); +var clone = (FuncFactory, string>)factory.Clone(); - string result = factory.ExecuteMethod(); - var clone = (FuncFactory, string>)factory.Clone(); - - Console.WriteLine(result); - Console.WriteLine(clone.ExecuteMethod()); - } -} +Console.WriteLine(result); +Console.WriteLine(clone.ExecuteMethod()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Generate.md b/.docfx/api/types/Cuemon.Generate.md index b2ef35e86..cdbdd587e 100644 --- a/.docfx/api/types/Cuemon.Generate.md +++ b/.docfx/api/types/Cuemon.Generate.md @@ -7,44 +7,42 @@ example: The following example demonstrates how to use `Generate` to produce numeric ranges, random numbers, random strings, hash codes, and structured object portrayals. ```csharp +// Program.cs using System; using System.Collections.Generic; +using Cuemon; -namespace Cuemon; - -public class GenerateExample -{ - public void Demonstrate() - { - // Generate a range of values using a generator function - IEnumerable numbers = Generate.RangeOf(5, i => i * 10); - Console.WriteLine(string.Join(", ", numbers)); // 0, 10, 20, 30, 40 - - // Generate a random integer in a specific range - int randomValue = Generate.RandomNumber(1, 101); - Console.WriteLine($"Random between 1 and 100: {randomValue}"); - - // Generate a random alphanumeric string - string randomStr = Generate.RandomString(12); - Console.WriteLine($"Random 12-char string: {randomStr}"); - - // Generate a random string from custom character buckets - string customRandom = Generate.RandomString(8, "ABCDEF", "123456"); - Console.WriteLine($"Custom random string: {customRandom}"); - - // Generate a fixed string of repeated characters - string separator = Generate.FixedString('-', 20); - Console.WriteLine(separator); // -------------------- - - // Compute hash codes from convertible values - int hash32 = Generate.HashCode32(42, "hello", true); - long hash64 = Generate.HashCode64(42, "hello", true); - Console.WriteLine($"32-bit hash: {hash32}, 64-bit hash: {hash64}"); - - // Generate a structured portrayal of an object - var person = new { Name = "Alice", Age = 30 }; - string portrayal = Generate.ObjectPortrayal(person); - Console.WriteLine(portrayal); // shows property names and values - } -} +// Generate a range of values using a generator function +IEnumerable numbers = Generate.RangeOf(5, i => i * 10); +Console.WriteLine(string.Join(", ", numbers)); // 0, 10, 20, 30, 40 + +// Generate a random integer in a specific range +int randomValue = Generate.RandomNumber(1, 101); +Console.WriteLine($"Random between 1 and 100: {randomValue}"); + +// Generate a random alphanumeric string +string randomStr = Generate.RandomString(12); +Console.WriteLine($"Random 12-char string: {randomStr}"); + +// Generate a random string from custom character buckets +string customRandom = Generate.RandomString(8, "ABCDEF", "123456"); +Console.WriteLine($"Custom random string: {customRandom}"); + +// Generate a fixed string of repeated characters +string separator = Generate.FixedString('-', 20); +Console.WriteLine(separator); // -------------------- + +// Compute hash codes from convertible values +int hash32 = Generate.HashCode32(42, "hello", true); +long hash64 = Generate.HashCode64(42, "hello", true); +Console.WriteLine($"32-bit hash: {hash32}, 64-bit hash: {hash64}"); + +// Generate a structured portrayal of an object +var person = new { Name = "Alice", Age = 30 }; +string portrayal = Generate.ObjectPortrayal(person); +Console.WriteLine(portrayal); // shows property names and values ``` + + + + diff --git a/.docfx/api/types/Cuemon.Globalization.StatisticalRegionInfo.md b/.docfx/api/types/Cuemon.Globalization.StatisticalRegionInfo.md index 022125fa2..feb82bce1 100644 --- a/.docfx/api/types/Cuemon.Globalization.StatisticalRegionInfo.md +++ b/.docfx/api/types/Cuemon.Globalization.StatisticalRegionInfo.md @@ -7,38 +7,35 @@ example: The following example demonstrates how to use via the class to retrieve UN M.49 region data. ```csharp +// Program.cs using System; using System.Linq; using Cuemon.Globalization; -namespace MyApp.Examples; +// Get United States by its UN M.49 code +StatisticalRegionInfo usa = World.GetCountry("840"); -public class StatisticalRegionInfoExample +if (usa != null) { - public void Demonstrate() + Console.WriteLine($"Name: {usa.Name}"); + Console.WriteLine($"Code: {usa.Code}"); + Console.WriteLine($"ISO Alpha-2: {usa.IsoAlpha2}"); + Console.WriteLine($"ISO Alpha-3: {usa.IsoAlpha3}"); + Console.WriteLine($"Kind: {usa.Kind}"); + Console.WriteLine($"Parent: {usa.Parent?.Name}"); + +// List all European countries +var europe = World.GetStatisticalRegion("150"); +if (europe != null) +{ + Console.WriteLine($"\nCountries in {europe.Name}:"); + foreach (var country in europe.Countries.Take(5)) { - // Get United States by its UN M.49 code - StatisticalRegionInfo usa = World.GetCountry("840"); - - if (usa != null) - { - Console.WriteLine($"Name: {usa.Name}"); - Console.WriteLine($"Code: {usa.Code}"); - Console.WriteLine($"ISO Alpha-2: {usa.IsoAlpha2}"); - Console.WriteLine($"ISO Alpha-3: {usa.IsoAlpha3}"); - Console.WriteLine($"Kind: {usa.Kind}"); - Console.WriteLine($"Parent: {usa.Parent?.Name}"); - - // List all European countries - var europe = World.GetStatisticalRegion("150"); - if (europe != null) - { - Console.WriteLine($"\nCountries in {europe.Name}:"); - foreach (var country in europe.Countries.Take(5)) - { - Console.WriteLine($" - {country.Name} ({country.IsoAlpha2})"); - -}}}} -} + Console.WriteLine($" - {country.Name} ({country.IsoAlpha2})"); +}}} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Globalization.StatisticalRegionKind.md b/.docfx/api/types/Cuemon.Globalization.StatisticalRegionKind.md index 6838b5836..46b398d2b 100644 --- a/.docfx/api/types/Cuemon.Globalization.StatisticalRegionKind.md +++ b/.docfx/api/types/Cuemon.Globalization.StatisticalRegionKind.md @@ -7,36 +7,33 @@ example: The following example demonstrates how to use to categorize geographic regions according to the UN M.49 standard. ```csharp +// Program.cs using System; using Cuemon.Globalization; -namespace MyApp.Examples; +var regionKind = StatisticalRegionKind.CountryOrTerritory; -public class StatisticalRegionKindExample +switch (regionKind) { - public void Demonstrate() - { - var regionKind = StatisticalRegionKind.CountryOrTerritory; + case StatisticalRegionKind.World: + Console.WriteLine("The entire world (code 001)."); + break; + case StatisticalRegionKind.Region: + Console.WriteLine("A major geographic region or continent."); + break; + case StatisticalRegionKind.Subregion: + Console.WriteLine("A subdivision of a region (e.g., Western Europe)."); + break; + case StatisticalRegionKind.IntermediateRegion: + Console.WriteLine("An intermediate grouping of subregions."); + break; + case StatisticalRegionKind.CountryOrTerritory: + Console.WriteLine("An individual country or territory (leaf node)."); + break; - switch (regionKind) - { - case StatisticalRegionKind.World: - Console.WriteLine("The entire world (code 001)."); - break; - case StatisticalRegionKind.Region: - Console.WriteLine("A major geographic region or continent."); - break; - case StatisticalRegionKind.Subregion: - Console.WriteLine("A subdivision of a region (e.g., Western Europe)."); - break; - case StatisticalRegionKind.IntermediateRegion: - Console.WriteLine("An intermediate grouping of subregions."); - break; - case StatisticalRegionKind.CountryOrTerritory: - Console.WriteLine("An individual country or territory (leaf node)."); - break; - -}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Globalization.World.md b/.docfx/api/types/Cuemon.Globalization.World.md index b1702b132..7b6a27a7d 100644 --- a/.docfx/api/types/Cuemon.Globalization.World.md +++ b/.docfx/api/types/Cuemon.Globalization.World.md @@ -7,31 +7,28 @@ example: The following example demonstrates how to query global regions, statistical regions, and cultures using the `World` class. It prints region counts, looks up the United States by M.49 code, and enumerates cultures for a specific region. ```csharp +// Program.cs using System; using System.Globalization; using System.Linq; using Cuemon.Globalization; -namespace Cuemon.Globalization; +var regions = World.Regions.ToList(); +Console.WriteLine($"Number of regions: {regions.Count}"); -public class WorldExample -{ - public void Demonstrate() - { - var regions = World.Regions.ToList(); - Console.WriteLine($"Number of regions: {regions.Count}"); - - var statisticalRegions = World.StatisticalRegions.ToList(); - Console.WriteLine($"Statistical regions: {statisticalRegions.Count}"); +var statisticalRegions = World.StatisticalRegions.ToList(); +Console.WriteLine($"Statistical regions: {statisticalRegions.Count}"); - var country = World.GetStatisticalRegion("840"); - Console.WriteLine($"United States M.49: {country?.Name}"); +var country = World.GetStatisticalRegion("840"); +Console.WriteLine($"United States M.49: {country?.Name}"); - var cultures = World.GetCultures(new RegionInfo("US")); - foreach (var culture in cultures) - { - Console.WriteLine($"Culture: {culture.DisplayName}"); - } - } +var cultures = World.GetCultures(new RegionInfo("US")); +foreach (var culture in cultures) +{ + Console.WriteLine($"Culture: {culture.DisplayName}"); } ``` + + + + diff --git a/.docfx/api/types/Cuemon.GuidFormats.md b/.docfx/api/types/Cuemon.GuidFormats.md index 74e8863d7..e6d399ff6 100644 --- a/.docfx/api/types/Cuemon.GuidFormats.md +++ b/.docfx/api/types/Cuemon.GuidFormats.md @@ -7,38 +7,33 @@ example: The following example demonstrates how to use the flags enum to control which GUID formats are accepted during parsing. ```csharp +// Program.cs using System; using Cuemon; // for GuidFormats using Cuemon.Text; // for ParserFactory, GuidStringOptions -namespace MyApp.Examples; +var parser = ParserFactory.FromGuid(); -public class GuidFormatsExample -{ - public void Demonstrate() - { - var parser = ParserFactory.FromGuid(); +// Accept only digit (D) and brace (B) formats +Guid g1 = parser.Parse("12345678-1234-1234-1234-123456789abc", + o => o.Formats = GuidFormats.D | GuidFormats.B); +Console.WriteLine(g1); // 12345678-1234-1234-1234-123456789abc - // Accept only digit (D) and brace (B) formats - Guid g1 = parser.Parse("12345678-1234-1234-1234-123456789abc", - o => o.Formats = GuidFormats.D | GuidFormats.B); - Console.WriteLine(g1); // 12345678-1234-1234-1234-123456789abc +Guid g2 = parser.Parse("{12345678-1234-1234-1234-123456789abc}", + o => o.Formats = GuidFormats.D | GuidFormats.B); +Console.WriteLine(g2); - Guid g2 = parser.Parse("{12345678-1234-1234-1234-123456789abc}", - o => o.Formats = GuidFormats.D | GuidFormats.B); - Console.WriteLine(g2); - - // TryParse with number format (N) - using Hyphens, so it would fail - bool ok = parser.TryParse("12345678123412341234123456789abc", out Guid g3, - o => o.Formats = GuidFormats.N); - Console.WriteLine(ok); // True - only N is selected and input has no hyphens - - // Fail: brace format but only D selected - ok = parser.TryParse("{12345678-1234-1234-1234-123456789abc}", out Guid g4, - o => o.Formats = GuidFormats.D); - Console.WriteLine(ok); // False - -} -} +// TryParse with number format (N) - using Hyphens, so it would fail +bool ok = parser.TryParse("12345678123412341234123456789abc", out Guid g3, + o => o.Formats = GuidFormats.N); +Console.WriteLine(ok); // True - only N is selected and input has no hyphens +// Fail: brace format but only D selected +ok = parser.TryParse("{12345678-1234-1234-1234-123456789abc}", out Guid g4, + o => o.Formats = GuidFormats.D); +Console.WriteLine(ok); // False ``` + + + + diff --git a/.docfx/api/types/Cuemon.IO.AsyncDisposableOptions.md b/.docfx/api/types/Cuemon.IO.AsyncDisposableOptions.md index ca32a77d6..e0f843f59 100644 --- a/.docfx/api/types/Cuemon.IO.AsyncDisposableOptions.md +++ b/.docfx/api/types/Cuemon.IO.AsyncDisposableOptions.md @@ -28,6 +28,7 @@ public class AsyncDisposableOptionsExample if (!options.LeaveOpen) { stream.Dispose(); + } Console.WriteLine("LeaveOpen: {0}", options.LeaveOpen); Console.WriteLine("Stream still open: {0}", stream.CanWrite); @@ -35,8 +36,11 @@ public class AsyncDisposableOptionsExample // Output: // LeaveOpen: True // Stream still open: True - -}} + } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.IO.AsyncStreamCompressionOptions.md b/.docfx/api/types/Cuemon.IO.AsyncStreamCompressionOptions.md index e36d048d5..815f1e51d 100644 --- a/.docfx/api/types/Cuemon.IO.AsyncStreamCompressionOptions.md +++ b/.docfx/api/types/Cuemon.IO.AsyncStreamCompressionOptions.md @@ -7,6 +7,7 @@ example: `AsyncStreamCompressionOptions` configures compression level and buffer size for asynchronous stream compression operations. This example creates default options with `CompressionLevel.Optimal` and an `81920` buffer size, fast options with `CompressionLevel.Fastest` and a `4096` buffer for CPU-sensitive scenarios, and no-compression options for testing or passthrough use. Key steps include compressing sample data using `DeflateStream` with the configured options and comparing original vs. compressed byte sizes. Console output shows the default level (`Optimal`), buffer size, and the compression ratio between original and compressed sizes. ```csharp +// Program.cs using System; using System.IO; using System.IO.Compression; @@ -14,12 +15,6 @@ using System.Text; using System.Threading.Tasks; using Cuemon.IO; -namespace MyApp.IO -{ - public class AsyncStreamCompressionOptionsExample - { - public async Task DemonstrateAsync() - { // Default compression: Optimal balance of speed and size var defaultOptions = new AsyncStreamCompressionOptions(); Console.WriteLine($"Default level: {defaultOptions.Level}"); // Optimal @@ -51,7 +46,9 @@ namespace MyApp.IO }; Console.WriteLine($"No compression level: {noCompressionOptions.Level}"); -}}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.IO.AsyncStreamCopyOptions.md b/.docfx/api/types/Cuemon.IO.AsyncStreamCopyOptions.md index 27329a2cd..d655cd9a1 100644 --- a/.docfx/api/types/Cuemon.IO.AsyncStreamCopyOptions.md +++ b/.docfx/api/types/Cuemon.IO.AsyncStreamCopyOptions.md @@ -7,6 +7,7 @@ example: `AsyncStreamCopyOptions` configures buffer size and stream lifetime for asynchronous stream copy operations. This example creates options with `BufferSize = 4096` and `LeaveOpen = true`, then copies UTF-8 string content from one `MemoryStream` to another using `Decorator.Enclose(source).CopyStreamAsync(destination, options.BufferSize, ...)`. The copied data is read back as a string and printed to confirm `"Copy me asynchronously."` was transferred intact, while the source stream remains open due to `LeaveOpen = true`. ```csharp +// Program.cs using System; using System.IO; using System.Text; @@ -15,30 +16,26 @@ using System.Threading.Tasks; using Cuemon; using Cuemon.IO; -namespace Contoso.FileTransfers; +var options = new AsyncStreamCopyOptions +{ + BufferSize = 4096, + LeaveOpen = true +}; + +using var source = new MemoryStream(Encoding.UTF8.GetBytes("Copy me asynchronously.")); +using var destination = new MemoryStream(); + +await Decorator.Enclose(source).CopyStreamAsync(destination, options.BufferSize, changePosition: true, ct: CancellationToken.None); -public sealed class AsyncStreamCopyOptionsExample +byte[] copied = await Decorator.Enclose(destination).ToByteArrayAsync(setup => { - public static async Task RunAsync() - { - var options = new AsyncStreamCopyOptions - { - BufferSize = 4096, - LeaveOpen = true - }; - - using var source = new MemoryStream(Encoding.UTF8.GetBytes("Copy me asynchronously.")); - using var destination = new MemoryStream(); - - await Decorator.Enclose(source).CopyStreamAsync(destination, options.BufferSize, changePosition: true, ct: CancellationToken.None); - - byte[] copied = await Decorator.Enclose(destination).ToByteArrayAsync(setup => - { - setup.BufferSize = options.BufferSize; - setup.LeaveOpen = options.LeaveOpen; - }); - - Console.WriteLine(Encoding.UTF8.GetString(copied)); - } -} + setup.BufferSize = options.BufferSize; + setup.LeaveOpen = options.LeaveOpen; +}); + +Console.WriteLine(Encoding.UTF8.GetString(copied)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.IO.AsyncStreamEncodingOptions.md b/.docfx/api/types/Cuemon.IO.AsyncStreamEncodingOptions.md index 0a12ec22b..253330f31 100644 --- a/.docfx/api/types/Cuemon.IO.AsyncStreamEncodingOptions.md +++ b/.docfx/api/types/Cuemon.IO.AsyncStreamEncodingOptions.md @@ -43,3 +43,7 @@ public class AsyncStreamEncodingOptionsExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.IO.AsyncStreamReaderOptions.md b/.docfx/api/types/Cuemon.IO.AsyncStreamReaderOptions.md index a87777b8a..8aa8c84ea 100644 --- a/.docfx/api/types/Cuemon.IO.AsyncStreamReaderOptions.md +++ b/.docfx/api/types/Cuemon.IO.AsyncStreamReaderOptions.md @@ -7,6 +7,7 @@ example: `AsyncStreamReaderOptions` configures encoding, preamble handling, and buffer size for asynchronous stream reading operations. This example creates a `MemoryStream` with UTF-8 preamble bytes followed by `"Hej Cuemon"` text, sets up options with `PreambleSequence.Remove` to strip the BOM, `Encoding = EncodingOptions.DefaultEncoding` for auto-detection, and `BufferSize = 4096`, then calls `ToEncodedStringAsync` via the decorator pattern. Console output shows the encoding web name (`utf-8`) and the decoded text with the preamble stripped, confirming correct preamble handling. ```csharp +// Program.cs using System; using System.IO; using System.Linq; @@ -16,35 +17,31 @@ using Cuemon; using Cuemon.IO; using Cuemon.Text; -namespace Contoso.Imports; +byte[] payload = Encoding.UTF8.GetPreamble() + .Concat(Encoding.UTF8.GetBytes("Hej Cuemon")) + .ToArray(); -public sealed class AsyncStreamReaderOptionsExample +using var stream = new MemoryStream(payload); + +var options = new AsyncStreamReaderOptions +{ + BufferSize = 4096, + Encoding = EncodingOptions.DefaultEncoding, + Preamble = PreambleSequence.Remove, + LeaveOpen = true +}; + +string text = await Decorator.Enclose(stream).ToEncodedStringAsync(setup => { - public static async Task RunAsync() - { - byte[] payload = Encoding.UTF8.GetPreamble() - .Concat(Encoding.UTF8.GetBytes("Hej Cuemon")) - .ToArray(); - - using var stream = new MemoryStream(payload); - - var options = new AsyncStreamReaderOptions - { - BufferSize = 4096, - Encoding = EncodingOptions.DefaultEncoding, - Preamble = PreambleSequence.Remove, - LeaveOpen = true - }; - - string text = await Decorator.Enclose(stream).ToEncodedStringAsync(setup => - { - setup.BufferSize = options.BufferSize; - setup.Encoding = options.Encoding; - setup.Preamble = options.Preamble; - setup.LeaveOpen = options.LeaveOpen; - }); - - Console.WriteLine($"{options.Encoding.WebName}:{text}"); - } -} + setup.BufferSize = options.BufferSize; + setup.Encoding = options.Encoding; + setup.Preamble = options.Preamble; + setup.LeaveOpen = options.LeaveOpen; +}); + +Console.WriteLine($"{options.Encoding.WebName}:{text}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.IO.BufferWriterOptions.md b/.docfx/api/types/Cuemon.IO.BufferWriterOptions.md index 348433c0a..44fc1aff9 100644 --- a/.docfx/api/types/Cuemon.IO.BufferWriterOptions.md +++ b/.docfx/api/types/Cuemon.IO.BufferWriterOptions.md @@ -40,3 +40,7 @@ public class BufferWriterOptionsExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.IO.FileInfoOptions.md b/.docfx/api/types/Cuemon.IO.FileInfoOptions.md index e6d6a443f..ac21a43a3 100644 --- a/.docfx/api/types/Cuemon.IO.FileInfoOptions.md +++ b/.docfx/api/types/Cuemon.IO.FileInfoOptions.md @@ -7,55 +7,51 @@ example: `FileInfoOptions` controls the maximum number of bytes read from a file, useful for reading headers or file signatures. This example demonstrates default options where `BytesToRead = 0` means no limit, a 100-byte limit for reading file headers, and a 16-byte limit for file signature detection. A temporary file with 1000 `'A'` characters is created, then read with the 100-byte limit and the actual bytes read is reported. Console output shows the default `BytesToRead` value, the requested vs. actual bytes read, and confirms that `BytesToRead = 0` means no limit. ```csharp +// Program.cs using System; using System.IO; using Cuemon.IO; -namespace MyApp.IO +// Default options: BytesToRead = 0 (read entire file) +var defaultOptions = new FileInfoOptions(); +Console.WriteLine($"Default bytes to read: {defaultOptions.BytesToRead}"); // 0 + +// Read only the first 100 bytes of a file +var headerOptions = new FileInfoOptions +{ + BytesToRead = 100 +}; + +// Read only the first 16 bytes (e.g., for file signature detection) +var signatureOptions = new FileInfoOptions { - public class FileInfoOptionsExample - { - public void Demonstrate() - { - // Default options: BytesToRead = 0 (read entire file) - var defaultOptions = new FileInfoOptions(); - Console.WriteLine($"Default bytes to read: {defaultOptions.BytesToRead}"); // 0 - - // Read only the first 100 bytes of a file - var headerOptions = new FileInfoOptions - { - BytesToRead = 100 - }; - - // Read only the first 16 bytes (e.g., for file signature detection) - var signatureOptions = new FileInfoOptions - { - BytesToRead = 16 - }; - - string tempFile = Path.GetTempFileName(); - try - { - File.WriteAllText(tempFile, new string('A', 1000)); - - // Demonstrate how BytesToRead limits the data read - using var fileStream = File.OpenRead(tempFile); - byte[] buffer = new byte[headerOptions.BytesToRead]; - int bytesRead = fileStream.Read(buffer, 0, headerOptions.BytesToRead); - Console.WriteLine($"Requested {headerOptions.BytesToRead} bytes, read {bytesRead} bytes"); - } - finally - { - File.Delete(tempFile); - } - - // BytesToRead of 0 means no limit - var noLimitOptions = new FileInfoOptions - { - BytesToRead = 0 - }; - Console.WriteLine($"BytesToRead = 0 means no limit: {noLimitOptions.BytesToRead}"); - } - } + BytesToRead = 16 +}; + +string tempFile = Path.GetTempFileName(); +try +{ + File.WriteAllText(tempFile, new string('A', 1000)); + + // Demonstrate how BytesToRead limits the data read + using var fileStream = File.OpenRead(tempFile); + byte[] buffer = new byte[headerOptions.BytesToRead]; + int bytesRead = fileStream.Read(buffer, 0, headerOptions.BytesToRead); + Console.WriteLine($"Requested {headerOptions.BytesToRead} bytes, read {bytesRead} bytes"); } +finally +{ + File.Delete(tempFile); +} + +// BytesToRead of 0 means no limit +var noLimitOptions = new FileInfoOptions +{ + BytesToRead = 0 +}; +Console.WriteLine($"BytesToRead = 0 means no limit: {noLimitOptions.BytesToRead}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.IO.StreamCompressionOptions.md b/.docfx/api/types/Cuemon.IO.StreamCompressionOptions.md index 120a8f5ed..4122dfa55 100644 --- a/.docfx/api/types/Cuemon.IO.StreamCompressionOptions.md +++ b/.docfx/api/types/Cuemon.IO.StreamCompressionOptions.md @@ -7,18 +7,13 @@ example: `StreamCompressionOptions` configures the compression level for synchronous stream compression operations. This example creates default options with `CompressionLevel.Optimal`, fast options with `CompressionLevel.Fastest`, and no-compression options for testing, then compresses sample data using `DeflateStream` with the fastest level. Console output shows the default compression level (`Optimal`), the original byte size of sample text, and the compressed byte size after deflate compression, demonstrating the compression ratio achieved. ```csharp +// Program.cs using System; using System.IO; using System.IO.Compression; using System.Text; using Cuemon.IO; -namespace MyApp.IO -{ - public class StreamCompressionOptionsExample - { - public void Demonstrate() - { // Default options: Optimal compression level var defaultOptions = new StreamCompressionOptions(); Console.WriteLine($"Default compression level: {defaultOptions.Level}"); // Optimal @@ -46,7 +41,9 @@ namespace MyApp.IO Console.WriteLine($"Original size: {originalData.Length} bytes"); Console.WriteLine($"Compressed size: {compressed.Length} bytes"); -}}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.IO.StreamCopyOptions.md b/.docfx/api/types/Cuemon.IO.StreamCopyOptions.md index 1b03a3e2b..68a154421 100644 --- a/.docfx/api/types/Cuemon.IO.StreamCopyOptions.md +++ b/.docfx/api/types/Cuemon.IO.StreamCopyOptions.md @@ -7,48 +7,43 @@ example: `StreamCopyOptions` configures buffer size and whether the source stream remains open after synchronous copy operations. This example creates custom options with `BufferSize = 4096` and `LeaveOpen = true`, converts a `MemoryStream` to a byte array via the decorator pattern with these options, then confirms the source stream is still readable (`CanRead = True`). It also demonstrates the default behavior where `LeaveOpen = false` disposes the source stream after copying, showing `CanRead = False`. Console output displays the byte count (`26`), the decoded string (`"Hello, StreamCopyOptions!"`), and the stream's open/disposed state. ```csharp +// Program.cs using System; using System.IO; using System.Text; using Cuemon; using Cuemon.IO; -namespace MyApp.IO; +// Create and use StreamCopyOptions directly +var customOptions = new StreamCopyOptions { BufferSize = 4096, LeaveOpen = true }; +Console.WriteLine($"Buffer size: {customOptions.BufferSize}, Leave open: {customOptions.LeaveOpen}"); -public class StreamCopyOptionsExample -{ - public void Demonstrate() - { - // Create and use StreamCopyOptions directly - var customOptions = new StreamCopyOptions { BufferSize = 4096, LeaveOpen = true }; - Console.WriteLine($"Buffer size: {customOptions.BufferSize}, Leave open: {customOptions.LeaveOpen}"); - - // Create a memory stream with some data - var source = new MemoryStream(Encoding.UTF8.GetBytes("Hello, StreamCopyOptions!")); - - // Convert the stream to a byte array using custom StreamCopyOptions - byte[] bytes = Decorator.Enclose(source).ToByteArray(setup => - { - setup.BufferSize = 4096; - setup.LeaveOpen = true; - }); - - Console.WriteLine($"Read {bytes.Length} bytes"); // 26 - Console.WriteLine(Encoding.UTF8.GetString(bytes)); // Hello, StreamCopyOptions! - Console.WriteLine($"Source stream is still open: {source.CanRead}"); // True - - // Without LeaveOpen, the source stream is automatically disposed after reading - var temp = new MemoryStream(Encoding.UTF8.GetBytes("Temporary data.")); - byte[] tempBytes = Decorator.Enclose(temp).ToByteArray(); // disposes 'temp' - Console.WriteLine(Encoding.UTF8.GetString(tempBytes)); // Temporary data. - Console.WriteLine($"Stream was disposed: {!temp.CanRead}"); // True - - // Using default options (BufferSize = 81920, LeaveOpen = false) - var data = new MemoryStream(Encoding.UTF8.GetBytes("Default options.")); - byte[] result = Decorator.Enclose(data).ToByteArray(); - Console.WriteLine(Encoding.UTF8.GetString(result)); // Default options. - -} -} +// Create a memory stream with some data +var source = new MemoryStream(Encoding.UTF8.GetBytes("Hello, StreamCopyOptions!")); +// Convert the stream to a byte array using custom StreamCopyOptions +byte[] bytes = Decorator.Enclose(source).ToByteArray(setup => +{ + setup.BufferSize = 4096; + setup.LeaveOpen = true; +}); + +Console.WriteLine($"Read {bytes.Length} bytes"); // 26 +Console.WriteLine(Encoding.UTF8.GetString(bytes)); // Hello, StreamCopyOptions! +Console.WriteLine($"Source stream is still open: {source.CanRead}"); // True + +// Without LeaveOpen, the source stream is automatically disposed after reading +var temp = new MemoryStream(Encoding.UTF8.GetBytes("Temporary data.")); +byte[] tempBytes = Decorator.Enclose(temp).ToByteArray(); // disposes 'temp' +Console.WriteLine(Encoding.UTF8.GetString(tempBytes)); // Temporary data. +Console.WriteLine($"Stream was disposed: {!temp.CanRead}"); // True + +// Using default options (BufferSize = 81920, LeaveOpen = false) +var data = new MemoryStream(Encoding.UTF8.GetBytes("Default options.")); +byte[] result = Decorator.Enclose(data).ToByteArray(); +Console.WriteLine(Encoding.UTF8.GetString(result)); // Default options. ``` + + + + diff --git a/.docfx/api/types/Cuemon.IO.StreamDecoratorExtensions.md b/.docfx/api/types/Cuemon.IO.StreamDecoratorExtensions.md index f7d29942e..5f964560a 100644 --- a/.docfx/api/types/Cuemon.IO.StreamDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.IO.StreamDecoratorExtensions.md @@ -7,6 +7,7 @@ example: `StreamDecoratorExtensions` provides extension methods on `Decorator.Enclose` for stream operations including byte array conversion, string encoding, compression (GZip, Deflate, Brotli), and copying. This example creates multiple `MemoryStream` instances with sample text and demonstrates `ToByteArray` and `ToByteArrayAsync`, `ToEncodedString` and `ToEncodedStringAsync`, `CopyStream` and `CopyStreamAsync`, `CompressGZip`/`DecompressGZip`, `CompressDeflate`/`DecompressDeflate`, `CompressBrotli`/`DecompressBrotli`, and `WriteAllAsync` — all via the decorator pattern. Console output confirms each operation's result, such as byte array lengths, decompressed strings matching the original content, and stream copy sizes. ```csharp +// Program.cs using System; using Cuemon; using System.IO; @@ -15,116 +16,110 @@ using System.Threading.Tasks; using Cuemon; using Cuemon.IO; -namespace MyApp.IO; +// ---- InvokeToByteArray: convert stream to byte array ---- +var source0 = new MemoryStream(Encoding.UTF8.GetBytes("Invoke test.")); +Decorator.Enclose(source0).InvokeToByteArray(); -public class StreamDecoratorExtensionsExample +// ---- ToByteArray: convert stream to byte array ---- +var source1 = new MemoryStream(Encoding.UTF8.GetBytes("Hello, World!")); +byte[] bytes = Decorator.Enclose(source1).ToByteArray(); +Console.WriteLine($"Byte array length: {bytes.Length}"); // 13 + +// ---- ToByteArrayAsync: async version ---- +var source2 = new MemoryStream(Encoding.UTF8.GetBytes("Async bytes.")); +byte[] asyncBytes = await Decorator.Enclose(source2).ToByteArrayAsync(); +Console.WriteLine($"Async bytes length: {asyncBytes.Length}"); // 11 + +// ---- ToEncodedString: stream to string ---- +var source3 = new MemoryStream(Encoding.UTF8.GetBytes("Read me as text.")); +string text = Decorator.Enclose(source3).ToEncodedString(setup => { - public async Task DemonstrateAsync() - { - // ---- InvokeToByteArray: convert stream to byte array ---- - var source0 = new MemoryStream(Encoding.UTF8.GetBytes("Invoke test.")); - Decorator.Enclose(source0).InvokeToByteArray(); - - // ---- ToByteArray: convert stream to byte array ---- - var source1 = new MemoryStream(Encoding.UTF8.GetBytes("Hello, World!")); - byte[] bytes = Decorator.Enclose(source1).ToByteArray(); - Console.WriteLine($"Byte array length: {bytes.Length}"); // 13 - - // ---- ToByteArrayAsync: async version ---- - var source2 = new MemoryStream(Encoding.UTF8.GetBytes("Async bytes.")); - byte[] asyncBytes = await Decorator.Enclose(source2).ToByteArrayAsync(); - Console.WriteLine($"Async bytes length: {asyncBytes.Length}"); // 11 - - // ---- ToEncodedString: stream to string ---- - var source3 = new MemoryStream(Encoding.UTF8.GetBytes("Read me as text.")); - string text = Decorator.Enclose(source3).ToEncodedString(setup => - { - setup.LeaveOpen = true; - }); - Console.WriteLine(text); // Read me as text. - - // ---- ToEncodedStringAsync: async stream to string ---- - source3.Position = 0; - string textAsync = await Decorator.Enclose(source3).ToEncodedStringAsync(setup => - { - setup.LeaveOpen = true; - }); - Console.WriteLine(textAsync); // Read me as text. - - // ---- CopyStreamAsync: async copy to destination stream ---- - var source4 = new MemoryStream(Encoding.UTF8.GetBytes("Copy me.")); - using var destination = new MemoryStream(); - await Decorator.Enclose(source4).CopyStreamAsync(destination, bufferSize: 8192, changePosition: true); - Console.WriteLine($"Destination length: {destination.Length}"); // 8 - - // ---- CopyStream: synchronous copy ---- - var source4b = new MemoryStream(Encoding.UTF8.GetBytes("Sync copy.")); - using var dest4b = new MemoryStream(); - Decorator.Enclose(source4b).CopyStream(dest4b); - Console.WriteLine($"Sync copy length: {dest4b.Length}"); // 9 - - // ---- CompressGZip / DecompressGZip ---- - var source5 = new MemoryStream(Encoding.UTF8.GetBytes("GZip compress this.")); - using var gzipCompressed = Decorator.Enclose(source5).CompressGZip(); - Console.WriteLine($"GZip compressed size: {gzipCompressed.Length}"); - gzipCompressed.Position = 0; - var gzipDecompressed = Decorator.Enclose(gzipCompressed).DecompressGZip(); - var gzipText = await Decorator.Enclose(gzipDecompressed).ToEncodedStringAsync(); - Console.WriteLine(gzipText); // GZip compress this. - - // ---- CompressGZipAsync / DecompressGZipAsync ---- - var source5b = new MemoryStream(Encoding.UTF8.GetBytes("Async GZip test.")); - var gzipCompressedAsync = await Decorator.Enclose(source5b).CompressGZipAsync(); - var gzipDecompressedAsync = await Decorator.Enclose(gzipCompressedAsync).DecompressGZipAsync(); - var gzipAsyncText = await Decorator.Enclose(gzipDecompressedAsync).ToEncodedStringAsync(); - Console.WriteLine(gzipAsyncText); // Async GZip test. - - // ---- CompressDeflate / DecompressDeflate (sync) ---- - var source6 = new MemoryStream(Encoding.UTF8.GetBytes("Deflate test.")); - using var deflated = Decorator.Enclose(source6).CompressDeflate(); - deflated.Position = 0; - var deflatedResult = Decorator.Enclose(deflated).DecompressDeflate(); - var deflateText = await Decorator.Enclose(deflatedResult).ToEncodedStringAsync(); - Console.WriteLine(deflateText); // Deflate test. - - // ---- CompressDeflateAsync / DecompressDeflateAsync ---- - var source6b = new MemoryStream(Encoding.UTF8.GetBytes("Async Deflate.")); - var deflatedAsync = await Decorator.Enclose(source6b).CompressDeflateAsync(); - var deflatedDecompAsync = await Decorator.Enclose(deflatedAsync).DecompressDeflateAsync(); - var deflateAsyncText = await Decorator.Enclose(deflatedDecompAsync).ToEncodedStringAsync(); - Console.WriteLine(deflateAsyncText); // Async Deflate. - - // ---- ToByteArrayAsync / ToEncodedStringAsync (async byte/string conversion) ---- - var sourceBytes = new MemoryStream(Encoding.UTF8.GetBytes("Async byte conversion.")); - var bytesAsync = await Decorator.Enclose(sourceBytes).ToByteArrayAsync(); - Console.WriteLine(bytesAsync.Length); // 22 - - sourceBytes.Position = 0; - var strAsync = await Decorator.Enclose(sourceBytes).ToEncodedStringAsync(); - Console.WriteLine(strAsync); // Async byte conversion. - - // ---- CompressBrotli / DecompressBrotli (sync, netstandard2.1+ or net9.0+) ---- - var source7 = new MemoryStream(Encoding.UTF8.GetBytes("Brotli test.")); - var brotliCompressed = Decorator.Enclose(source7).CompressBrotli(); - brotliCompressed.Position = 0; - var brotliDecompressed = Decorator.Enclose(brotliCompressed).DecompressBrotli(); - var brotliText = await Decorator.Enclose(brotliDecompressed).ToEncodedStringAsync(); - Console.WriteLine(brotliText); // Brotli test. - - // ---- CompressBrotliAsync / DecompressBrotliAsync ---- - var source7b = new MemoryStream(Encoding.UTF8.GetBytes("Async Brotli.")); - var brotliCompressedAsync = await Decorator.Enclose(source7b).CompressBrotliAsync(); - var brotliDecompressedAsync = await Decorator.Enclose(brotliCompressedAsync).DecompressBrotliAsync(); - var brotliAsyncText = await Decorator.Enclose(brotliDecompressedAsync).ToEncodedStringAsync(); - Console.WriteLine(brotliAsyncText); // Async Brotli. - - // ---- WriteAllAsync: write bytes to stream ---- - var target = new MemoryStream(); - byte[] data = Encoding.UTF8.GetBytes("Write this."); - await Decorator.Enclose(target).WriteAllAsync(data); - Console.WriteLine($"Written bytes: {target.Length}"); // 10 - - } -} + setup.LeaveOpen = true; +}); +Console.WriteLine(text); // Read me as text. +// ---- ToEncodedStringAsync: async stream to string ---- +source3.Position = 0; +string textAsync = await Decorator.Enclose(source3).ToEncodedStringAsync(setup => +{ + setup.LeaveOpen = true; +}); +Console.WriteLine(textAsync); // Read me as text. + +// ---- CopyStreamAsync: async copy to destination stream ---- +var source4 = new MemoryStream(Encoding.UTF8.GetBytes("Copy me.")); +using var destination = new MemoryStream(); +await Decorator.Enclose(source4).CopyStreamAsync(destination, bufferSize: 8192, changePosition: true); +Console.WriteLine($"Destination length: {destination.Length}"); // 8 + +// ---- CopyStream: synchronous copy ---- +var source4b = new MemoryStream(Encoding.UTF8.GetBytes("Sync copy.")); +using var dest4b = new MemoryStream(); +Decorator.Enclose(source4b).CopyStream(dest4b); +Console.WriteLine($"Sync copy length: {dest4b.Length}"); // 9 + +// ---- CompressGZip / DecompressGZip ---- +var source5 = new MemoryStream(Encoding.UTF8.GetBytes("GZip compress this.")); +using var gzipCompressed = Decorator.Enclose(source5).CompressGZip(); +Console.WriteLine($"GZip compressed size: {gzipCompressed.Length}"); +gzipCompressed.Position = 0; +var gzipDecompressed = Decorator.Enclose(gzipCompressed).DecompressGZip(); +var gzipText = await Decorator.Enclose(gzipDecompressed).ToEncodedStringAsync(); +Console.WriteLine(gzipText); // GZip compress this. + +// ---- CompressGZipAsync / DecompressGZipAsync ---- +var source5b = new MemoryStream(Encoding.UTF8.GetBytes("Async GZip test.")); +var gzipCompressedAsync = await Decorator.Enclose(source5b).CompressGZipAsync(); +var gzipDecompressedAsync = await Decorator.Enclose(gzipCompressedAsync).DecompressGZipAsync(); +var gzipAsyncText = await Decorator.Enclose(gzipDecompressedAsync).ToEncodedStringAsync(); +Console.WriteLine(gzipAsyncText); // Async GZip test. + +// ---- CompressDeflate / DecompressDeflate (sync) ---- +var source6 = new MemoryStream(Encoding.UTF8.GetBytes("Deflate test.")); +using var deflated = Decorator.Enclose(source6).CompressDeflate(); +deflated.Position = 0; +var deflatedResult = Decorator.Enclose(deflated).DecompressDeflate(); +var deflateText = await Decorator.Enclose(deflatedResult).ToEncodedStringAsync(); +Console.WriteLine(deflateText); // Deflate test. + +// ---- CompressDeflateAsync / DecompressDeflateAsync ---- +var source6b = new MemoryStream(Encoding.UTF8.GetBytes("Async Deflate.")); +var deflatedAsync = await Decorator.Enclose(source6b).CompressDeflateAsync(); +var deflatedDecompAsync = await Decorator.Enclose(deflatedAsync).DecompressDeflateAsync(); +var deflateAsyncText = await Decorator.Enclose(deflatedDecompAsync).ToEncodedStringAsync(); +Console.WriteLine(deflateAsyncText); // Async Deflate. + +// ---- ToByteArrayAsync / ToEncodedStringAsync (async byte/string conversion) ---- +var sourceBytes = new MemoryStream(Encoding.UTF8.GetBytes("Async byte conversion.")); +var bytesAsync = await Decorator.Enclose(sourceBytes).ToByteArrayAsync(o => o.LeaveOpen = true); +Console.WriteLine(bytesAsync.Length); // 22 + +sourceBytes.Position = 0; +var strAsync = await Decorator.Enclose(sourceBytes).ToEncodedStringAsync(o => o.LeaveOpen = true); +Console.WriteLine(strAsync); // Async byte conversion. + +// ---- CompressBrotli / DecompressBrotli (sync, netstandard2.1+ or net9.0+) ---- +var source7 = new MemoryStream(Encoding.UTF8.GetBytes("Brotli test.")); +var brotliCompressed = Decorator.Enclose(source7).CompressBrotli(); +brotliCompressed.Position = 0; +var brotliDecompressed = Decorator.Enclose(brotliCompressed).DecompressBrotli(); +var brotliText = await Decorator.Enclose(brotliDecompressed).ToEncodedStringAsync(); +Console.WriteLine(brotliText); // Brotli test. + +// ---- CompressBrotliAsync / DecompressBrotliAsync ---- +var source7b = new MemoryStream(Encoding.UTF8.GetBytes("Async Brotli.")); +var brotliCompressedAsync = await Decorator.Enclose(source7b).CompressBrotliAsync(); +var brotliDecompressedAsync = await Decorator.Enclose(brotliCompressedAsync).DecompressBrotliAsync(); +var brotliAsyncText = await Decorator.Enclose(brotliDecompressedAsync).ToEncodedStringAsync(); +Console.WriteLine(brotliAsyncText); // Async Brotli. + +// ---- WriteAllAsync: write bytes to stream ---- +var target = new MemoryStream(); +byte[] data = Encoding.UTF8.GetBytes("Write this."); +await Decorator.Enclose(target).WriteAllAsync(data); +Console.WriteLine($"Written bytes: {target.Length}"); // 10 ``` + + + + diff --git a/.docfx/api/types/Cuemon.IO.StreamEncodingOptions.md b/.docfx/api/types/Cuemon.IO.StreamEncodingOptions.md index 91151a770..f73c08d34 100644 --- a/.docfx/api/types/Cuemon.IO.StreamEncodingOptions.md +++ b/.docfx/api/types/Cuemon.IO.StreamEncodingOptions.md @@ -7,6 +7,7 @@ example: `StreamEncodingOptions` configures preamble handling and encoding detection when reading stream content as strings. This example creates a `MemoryStream` with UTF-32 encoded `"Hello with BOM!"` text including a BOM preamble, then reads it twice using the decorator pattern: first with `PreambleSequence.Remove` to strip the BOM (resulting text matches the original), then with `PreambleSequence.Keep` to preserve the BOM bytes in the output. Console output displays the decoded text (`"Hello with BOM!"`), the increased string length when BOM is kept, and confirms the stream is disposed after the second read. ```csharp +// Program.cs using System; using System.IO; using System.Text; @@ -14,50 +15,44 @@ using Cuemon; using Cuemon.IO; using Cuemon.Text; -namespace MyApp.IO; +// Directly instantiate and use StreamEncodingOptions +var defaultOptions = new StreamEncodingOptions(); +Console.WriteLine($"Default preamble handling: {defaultOptions.Preamble}"); -public class StreamEncodingOptionsExample +// Create a stream with UTF-32 encoded content including a BOM +var text = "Hello with BOM!"; +var preamble = Encoding.UTF32.GetPreamble(); +var encoded = Encoding.UTF32.GetBytes(text); + +var stream = new MemoryStream(preamble.Length + encoded.Length); +stream.Write(preamble, 0, preamble.Length); +stream.Write(encoded, 0, encoded.Length); +stream.Position = 0; + +// Read the stream as a string using StreamReaderOptions (which inherits StreamEncodingOptions) +// This auto-detects the encoding from the BOM and removes the preamble from the output +string result = Decorator.Enclose(stream).ToEncodedString(setup => +{ + setup.Encoding = EncodingOptions.DefaultEncoding; // auto-detect from BOM + setup.Preamble = PreambleSequence.Remove; // strip the BOM from output + setup.LeaveOpen = true; // keep stream open for reuse +}); + +Console.WriteLine($"Read: {result}"); // Hello with BOM! + +// Read again, this time keeping the BOM preamble +stream.Position = 0; +string withBom = Decorator.Enclose(stream).ToEncodedString(setup => { - public void Demonstrate() - { - // Directly instantiate and use StreamEncodingOptions - var defaultOptions = new StreamEncodingOptions(); - Console.WriteLine($"Default preamble handling: {defaultOptions.Preamble}"); - - // Create a stream with UTF-32 encoded content including a BOM - var text = "Hello with BOM!"; - var preamble = Encoding.UTF32.GetPreamble(); - var encoded = Encoding.UTF32.GetBytes(text); - - var stream = new MemoryStream(preamble.Length + encoded.Length); - stream.Write(preamble, 0, preamble.Length); - stream.Write(encoded, 0, encoded.Length); - stream.Position = 0; - - // Read the stream as a string using StreamReaderOptions (which inherits StreamEncodingOptions) - // This auto-detects the encoding from the BOM and removes the preamble from the output - string result = Decorator.Enclose(stream).ToEncodedString(setup => - { - setup.Encoding = EncodingOptions.DefaultEncoding; // auto-detect from BOM - setup.Preamble = PreambleSequence.Remove; // strip the BOM from output - setup.LeaveOpen = true; // keep stream open for reuse - }); - - Console.WriteLine($"Read: {result}"); // Hello with BOM! - - // Read again, this time keeping the BOM preamble - stream.Position = 0; - string withBom = Decorator.Enclose(stream).ToEncodedString(setup => - { - setup.Encoding = Encoding.UTF32; - setup.Preamble = PreambleSequence.Keep; - setup.LeaveOpen = false; // let the extension dispose the stream - }); - - Console.WriteLine($"With BOM length: {withBom.Length}"); // includes BOM bytes - Console.WriteLine($"Stream disposed: {!stream.CanRead}"); // True - -} -} + setup.Encoding = Encoding.UTF32; + setup.Preamble = PreambleSequence.Keep; + setup.LeaveOpen = false; // let the extension dispose the stream +}); +Console.WriteLine($"With BOM length: {withBom.Length}"); // includes BOM bytes +Console.WriteLine($"Stream disposed: {!stream.CanRead}"); // True ``` + + + + diff --git a/.docfx/api/types/Cuemon.IO.StreamFactory.md b/.docfx/api/types/Cuemon.IO.StreamFactory.md index a25f86492..d5c215019 100644 --- a/.docfx/api/types/Cuemon.IO.StreamFactory.md +++ b/.docfx/api/types/Cuemon.IO.StreamFactory.md @@ -7,43 +7,40 @@ example: The following example demonstrates how to create instances using . ```csharp +// Program.cs using System; using System.IO; using System.Text; using Cuemon.IO; using Cuemon.Text; -namespace MyApp.Examples; +// Create a stream by writing to a StreamWriter +Stream stream = StreamFactory.Create(writer => +{ + writer.Write("Hello, StreamFactory!"); +}); + +Console.WriteLine($"Stream length: {stream.Length}"); +Console.WriteLine($"Stream position: {stream.Position}"); + +using var reader = new StreamReader(stream); +string content = reader.ReadToEnd(); +Console.WriteLine(content); -public static class StreamFactoryExample +// Create a stream with encoding options +Stream utf32Stream = StreamFactory.Create(writer => { - public static void Demonstrate() - { - // Create a stream by writing to a StreamWriter - Stream stream = StreamFactory.Create(writer => - { - writer.Write("Hello, StreamFactory!"); - }); - - Console.WriteLine($"Stream length: {stream.Length}"); - Console.WriteLine($"Stream position: {stream.Position}"); - - using var reader = new StreamReader(stream); - string content = reader.ReadToEnd(); - Console.WriteLine(content); - - // Create a stream with encoding options - Stream utf32Stream = StreamFactory.Create(writer => - { - writer.Write("UTF-32 encoded content"); - }, options => - { - options.Encoding = Encoding.UTF32; - options.Preamble = PreambleSequence.Remove; - }); - - using var utf32Reader = new StreamReader(utf32Stream, Encoding.UTF32); - Console.WriteLine(utf32Reader.ReadToEnd()); - } -} + writer.Write("UTF-32 encoded content"); +}, options => +{ + options.Encoding = Encoding.UTF32; + options.Preamble = PreambleSequence.Remove; +}); + +using var utf32Reader = new StreamReader(utf32Stream, Encoding.UTF32); +Console.WriteLine(utf32Reader.ReadToEnd()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.IO.StreamReaderOptions.md b/.docfx/api/types/Cuemon.IO.StreamReaderOptions.md index 91aad888a..d26ec5f40 100644 --- a/.docfx/api/types/Cuemon.IO.StreamReaderOptions.md +++ b/.docfx/api/types/Cuemon.IO.StreamReaderOptions.md @@ -7,49 +7,44 @@ example: `StreamReaderOptions` configures encoding, preamble handling, and buffer size for reading from streams via `StreamReader`. This example shows default options (UTF-8, `PreambleSequence.Remove`, `BufferSize = 81920`) and custom options for UTF-32 with `PreambleSequence.Keep` and `BufferSize = 4096`. A `StreamReader` is created using the custom options to read `"Hello, World!"` UTF-32 data from a `MemoryStream`, and the default preamble and buffer size values are also printed. Console output displays the default encoding name (`UTF-8`), preamble mode, buffer size, and the read content. ```csharp +// Program.cs using System; using System.IO; using System.Text; using Cuemon.IO; using Cuemon.Text; -namespace MyApp.IO +// Default options: UTF-8 without BOM, 81920 buffer +var defaultOptions = new StreamReaderOptions(); +Console.WriteLine($"Default encoding: {defaultOptions.Encoding.EncodingName}"); // UTF-8 +Console.WriteLine($"Default preamble: {defaultOptions.Preamble}"); // Remove +Console.WriteLine($"Default buffer size: {defaultOptions.BufferSize}"); // 81920 + +// Read a UTF-32 file with a smaller buffer +var utf32Options = new StreamReaderOptions { - public class StreamReaderOptionsExample - { - public void Demonstrate() - { - // Default options: UTF-8 without BOM, 81920 buffer - var defaultOptions = new StreamReaderOptions(); - Console.WriteLine($"Default encoding: {defaultOptions.Encoding.EncodingName}"); // UTF-8 - Console.WriteLine($"Default preamble: {defaultOptions.Preamble}"); // Remove - Console.WriteLine($"Default buffer size: {defaultOptions.BufferSize}"); // 81920 - - // Read a UTF-32 file with a smaller buffer - var utf32Options = new StreamReaderOptions - { - Encoding = Encoding.UTF32, - Preamble = PreambleSequence.Keep, - BufferSize = 4096 - }; - - // Create a StreamReader using these options - byte[] data = Encoding.UTF32.GetBytes("Hello, World!"); - using var stream = new MemoryStream(data); - using var reader = new StreamReader(stream, utf32Options.Encoding, false, utf32Options.BufferSize); - - string content = reader.ReadToEnd(); - Console.WriteLine($"Read content: {content}"); - - // Options for reading with explicit BOM handling - var bomOptions = new StreamReaderOptions - { - Encoding = Encoding.UTF8, - Preamble = PreambleSequence.Keep - }; - Console.WriteLine($"BOM preamble: {bomOptions.Preamble}"); // Keep - -}} -} + Encoding = Encoding.UTF32, + Preamble = PreambleSequence.Keep, + BufferSize = 4096 +}; + +// Create a StreamReader using these options +byte[] data = Encoding.UTF32.GetBytes("Hello, World!"); +using var stream = new MemoryStream(data); +using var reader = new StreamReader(stream, utf32Options.Encoding, false, utf32Options.BufferSize); + +string content = reader.ReadToEnd(); +Console.WriteLine($"Read content: {content}"); +// Options for reading with explicit BOM handling +var bomOptions = new StreamReaderOptions +{ + Encoding = Encoding.UTF8, + Preamble = PreambleSequence.Keep +}; +Console.WriteLine($"BOM preamble: {bomOptions.Preamble}"); // Keep ``` + + + + diff --git a/.docfx/api/types/Cuemon.IO.StreamWriterOptions.md b/.docfx/api/types/Cuemon.IO.StreamWriterOptions.md index 3e99af9e5..bbea2b970 100644 --- a/.docfx/api/types/Cuemon.IO.StreamWriterOptions.md +++ b/.docfx/api/types/Cuemon.IO.StreamWriterOptions.md @@ -7,6 +7,7 @@ example: `StreamWriterOptions` configures encoding, preamble handling, buffer size, format provider, and newline style when writing to streams via `StreamWriter`. This example sets up options with `AutoFlush = true`, `BufferSize = 256`, `Encoding = EncodingOptions.DefaultEncoding`, `Preamble = PreambleSequence.Remove`, `FormatProvider = CultureInfo.InvariantCulture`, and `NewLine = "\n"`, then uses `StreamFactory.Create` with a writer delegate to format a string with `Math.PI` to two decimal places. The resulting stream is read back as a string via the decorator pattern. Console output displays the trimmed formatted output `"Value: 3.14"`. ```csharp +// Program.cs using System; using System.Globalization; using System.IO; @@ -14,44 +15,40 @@ using Cuemon; using Cuemon.IO; using Cuemon.Text; -namespace Contoso.Reporting; - -public sealed class StreamWriterOptionsExample +var options = new StreamWriterOptions { - public static void Run() - { - var options = new StreamWriterOptions - { - AutoFlush = true, - BufferSize = 256, - Encoding = EncodingOptions.DefaultEncoding, - Preamble = PreambleSequence.Remove, - FormatProvider = CultureInfo.InvariantCulture, - NewLine = "\n" - }; + AutoFlush = true, + BufferSize = 256, + Encoding = EncodingOptions.DefaultEncoding, + Preamble = PreambleSequence.Remove, + FormatProvider = CultureInfo.InvariantCulture, + NewLine = "\n" +}; - using Stream stream = StreamFactory.Create(writer => - { - string formatted = string.Format(options.FormatProvider, "Value: {0:F2}", Math.PI); - writer.WriteLine(formatted); - }, setup => - { - setup.AutoFlush = options.AutoFlush; - setup.BufferSize = options.BufferSize; - setup.Encoding = options.Encoding; - setup.Preamble = options.Preamble; - setup.FormatProvider = options.FormatProvider; - setup.NewLine = options.NewLine; - }); +using Stream stream = StreamFactory.Create(writer => +{ + string formatted = string.Format(options.FormatProvider, "Value: {0:F2}", Math.PI); + writer.WriteLine(formatted); +}, setup => +{ + setup.AutoFlush = options.AutoFlush; + setup.BufferSize = options.BufferSize; + setup.Encoding = options.Encoding; + setup.Preamble = options.Preamble; + setup.FormatProvider = options.FormatProvider; + setup.NewLine = options.NewLine; +}); - string output = Decorator.Enclose(stream).ToEncodedString(setup => - { - setup.Encoding = options.Encoding; - setup.Preamble = options.Preamble; - setup.LeaveOpen = true; - }); +string output = Decorator.Enclose(stream).ToEncodedString(setup => +{ + setup.Encoding = options.Encoding; + setup.Preamble = options.Preamble; + setup.LeaveOpen = true; +}); - Console.WriteLine(output.Trim()); - } -} +Console.WriteLine(output.Trim()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.IO.TextReaderDecoratorExtensions.md b/.docfx/api/types/Cuemon.IO.TextReaderDecoratorExtensions.md index b895920be..bc3e8693f 100644 --- a/.docfx/api/types/Cuemon.IO.TextReaderDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.IO.TextReaderDecoratorExtensions.md @@ -7,6 +7,7 @@ example: `TextReaderDecoratorExtensions` provides extension methods on `Decorator.Enclose` for copying `TextReader` content to `TextWriter` instances asynchronously with configurable buffer sizes. This example creates a `StringReader` with three lines of text, copies to a `StringWriter` via `CopyToAsync`, and outputs the result. It also demonstrates a custom buffer size of `1024` for the copy operation and copying between different reader/writer types (`StreamReader` to `StringWriter`). Console output confirms the copied content matches the source for all three scenarios. ```csharp +// Program.cs using System.Text; using System; using System.IO; @@ -14,41 +15,35 @@ using System.Threading.Tasks; using Cuemon; using Cuemon.IO; -namespace MyApp.IO -{ - public class TextReaderDecoratorExtensionsExample - { - public async Task DemonstrateAsync() - { - string source = "Line 1\nLine 2\nLine 3\n"; +string source = "Line 1\nLine 2\nLine 3\n"; - // Copy content from a TextReader to a TextWriter asynchronously - using var reader = new StringReader(source); - using var writer = new StringWriter(); +// Copy content from a TextReader to a TextWriter asynchronously +using var reader = new StringReader(source); +using var writer = new StringWriter(); - await Decorator.Enclose(reader).CopyToAsync(writer); +await Decorator.Enclose(reader).CopyToAsync(writer); - string result = writer.ToString(); - Console.WriteLine(result); // "Line 1\nLine 2\nLine 3\n" +string result = writer.ToString(); +Console.WriteLine(result); // "Line 1\nLine 2\nLine 3\n" - // Use a custom buffer size - using var readerSmallBuffer = new StringReader(source); - using var writerSmallBuffer = new StringWriter(); +// Use a custom buffer size +using var readerSmallBuffer = new StringReader(source); +using var writerSmallBuffer = new StringWriter(); - await Decorator.Enclose(readerSmallBuffer).CopyToAsync(writerSmallBuffer, bufferSize: 1024); +await Decorator.Enclose(readerSmallBuffer).CopyToAsync(writerSmallBuffer, bufferSize: 1024); - string resultSmallBuffer = writerSmallBuffer.ToString(); - Console.WriteLine(resultSmallBuffer); // "Line 1\nLine 2\nLine 3\n" +string resultSmallBuffer = writerSmallBuffer.ToString(); +Console.WriteLine(resultSmallBuffer); // "Line 1\nLine 2\nLine 3\n" - // Copy between different TextReader/TextWriter types - using var streamReader = new StreamReader(new MemoryStream( - Encoding.UTF8.GetBytes("Stream content"))); - using var stringWriter = new StringWriter(); - - await Decorator.Enclose(streamReader).CopyToAsync(stringWriter); - Console.WriteLine(stringWriter.ToString()); // "Stream content" - -}} -} +// Copy between different TextReader/TextWriter types +using var streamReader = new StreamReader(new MemoryStream( + Encoding.UTF8.GetBytes("Stream content"))); +using var stringWriter = new StringWriter(); +await Decorator.Enclose(streamReader).CopyToAsync(stringWriter); +Console.WriteLine(stringWriter.ToString()); // "Stream content" ``` + + + + diff --git a/.docfx/api/types/Cuemon.IntegerDecoratorExtensions.md b/.docfx/api/types/Cuemon.IntegerDecoratorExtensions.md index 590a0eb8c..265bf899a 100644 --- a/.docfx/api/types/Cuemon.IntegerDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.IntegerDecoratorExtensions.md @@ -7,33 +7,28 @@ example: `IntegerDecoratorExtensions` provides extension methods on `Decorator.Enclose` for clamping integer values to a minimum bound using the `Max` extension method. This example wraps `int` values of `42`, `500`, and `-10`, then calls `Max` with a minimum threshold of `100` or `0`. Key setup includes comparing the wrapped value against the minimum and returning the larger of the two. Console output shows `100` for `42.Max(100)`, `500` for `500.Max(100)` (pass-through), and `0` for `(-10).Max(0)`. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.Numeric -{ - public class IntegerDecoratorExtensionsExample - { - public void Demonstrate() - { - // Wrap an int with Decorator.Enclose to access the Max extension - int value = 42; - int minimum = 100; +// Wrap an int with Decorator.Enclose to access the Max extension +int value = 42; +int minimum = 100; - // Returns the larger of the wrapped value and the specified minimum - int result = Decorator.Enclose(value).Max(minimum); - Console.WriteLine(result); // Output: 100 +// Returns the larger of the wrapped value and the specified minimum +int result = Decorator.Enclose(value).Max(minimum); +Console.WriteLine(result); // Output: 100 - // When the wrapped value is larger than the minimum - value = 500; - result = Decorator.Enclose(value).Max(minimum); - Console.WriteLine(result); // Output: 500 - - // Works with any int expression - result = Decorator.Enclose(-10).Max(0); - Console.WriteLine(result); // Output: 0 - -}} -} +// When the wrapped value is larger than the minimum +value = 500; +result = Decorator.Enclose(value).Max(minimum); +Console.WriteLine(result); // Output: 500 +// Works with any int expression +result = Decorator.Enclose(-10).Max(0); +Console.WriteLine(result); // Output: 0 ``` + + + + diff --git a/.docfx/api/types/Cuemon.Messaging.CorrelationToken.md b/.docfx/api/types/Cuemon.Messaging.CorrelationToken.md index dce7a575e..80a907377 100644 --- a/.docfx/api/types/Cuemon.Messaging.CorrelationToken.md +++ b/.docfx/api/types/Cuemon.Messaging.CorrelationToken.md @@ -7,26 +7,35 @@ example: The following example shows how to create one correlation identifier and pass it through related work. ```csharp +// Program.cs using System; using Cuemon.Messaging; +using MyApp.Examples; -namespace MyApp.Examples; +CorrelationTokenExample.Demonstrate(); -public static class CorrelationTokenExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class CorrelationTokenExample { - var generated = new CorrelationToken(); - var provided = new CorrelationToken("order-2026-0001"); + public static void Demonstrate() + { + var generated = new CorrelationToken(); + var provided = new CorrelationToken("order-2026-0001"); - Console.WriteLine(generated.CorrelationId.Length == 32); - Console.WriteLine(provided.ToString()); - Console.WriteLine(AttachToMessage("InventoryReserved", provided)); - } + Console.WriteLine(generated.CorrelationId.Length == 32); + Console.WriteLine(provided.ToString()); + Console.WriteLine(AttachToMessage("InventoryReserved", provided)); + } - private static string AttachToMessage(string messageType, ICorrelationToken token) - { - return $"{messageType}:{token.CorrelationId}"; + private static string AttachToMessage(string messageType, ICorrelationToken token) + { + return $"{messageType}:{token.CorrelationId}"; + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Messaging.RequestToken.md b/.docfx/api/types/Cuemon.Messaging.RequestToken.md index 8adf952ab..c4bb58636 100644 --- a/.docfx/api/types/Cuemon.Messaging.RequestToken.md +++ b/.docfx/api/types/Cuemon.Messaging.RequestToken.md @@ -7,24 +7,19 @@ example: The following example demonstrates how to use to uniquely identify an individual request within a system. ```csharp +// Program.cs using System; using Cuemon.Messaging; -namespace MyApp.Examples; - -public class RequestTokenExample -{ - public void Demonstrate() - { - // Each request gets its own unique ID - var request1 = new RequestToken(); - var request2 = new RequestToken(); - - Console.WriteLine($"Request 1 ID: {request1}"); - Console.WriteLine($"Request 2 ID: {request2}"); - Console.WriteLine($"Are they different? {request1.RequestId != request2.RequestId}"); - -} -} +// Each request gets its own unique ID +var request1 = new RequestToken(); +var request2 = new RequestToken(); +Console.WriteLine($"Request 1 ID: {request1}"); +Console.WriteLine($"Request 2 ID: {request2}"); +Console.WriteLine($"Are they different? {request1.RequestId != request2.RequestId}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.MutableTuple.md b/.docfx/api/types/Cuemon.MutableTuple.md index 429729981..9af0a3e5b 100644 --- a/.docfx/api/types/Cuemon.MutableTuple.md +++ b/.docfx/api/types/Cuemon.MutableTuple.md @@ -7,26 +7,23 @@ example: The following example demonstrates how to create and use and its generic variants to store and pass multiple values without creating a custom class. ```csharp +// Program.cs using System; using Cuemon; -namespace Contoso.Workflow; +MutableTuple empty = new MutableTuple(); +var pair = new MutableTuple("Alice", 30); -public sealed class MutableTupleExample -{ - public static void Run() - { - MutableTuple empty = new MutableTuple(); - var pair = new MutableTuple("Alice", 30); +pair.Arg2 = 31; - pair.Arg2 = 31; +object[] values = pair.ToArray("verified"); +var clone = (MutableTuple)pair.Clone(); - object[] values = pair.ToArray("verified"); - var clone = (MutableTuple)pair.Clone(); - - Console.WriteLine($"Empty: {empty.IsEmpty}"); - Console.WriteLine($"{clone.Arg1}:{clone.Arg2}"); - Console.WriteLine($"Array length: {values.Length}"); - } -} +Console.WriteLine($"Empty: {empty.IsEmpty}"); +Console.WriteLine($"{clone.Arg1}:{clone.Arg2}"); +Console.WriteLine($"Array length: {values.Length}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.MutableTuple`1.md b/.docfx/api/types/Cuemon.MutableTuple`1.md index b741931d2..03e1e63a5 100644 --- a/.docfx/api/types/Cuemon.MutableTuple`1.md +++ b/.docfx/api/types/Cuemon.MutableTuple`1.md @@ -7,20 +7,17 @@ example: The following example shows how to create a single-argument `MutableTuple` and access its value. It demonstrates both reading and updating the `Arg1` property. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.Data; +var tuple = new MutableTuple("example"); +Console.WriteLine(tuple.Arg1); // "example" -public class MutableTupleExample -{ - public void Demonstrate() - { - var tuple = new MutableTuple("example"); - Console.WriteLine(tuple.Arg1); // "example" - - tuple.Arg1 = "updated"; - Console.WriteLine(tuple.Arg1); // "updated" - } -} +tuple.Arg1 = "updated"; +Console.WriteLine(tuple.Arg1); // "updated" ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.ByteArrayDecoratorExtensions.md b/.docfx/api/types/Cuemon.Net.ByteArrayDecoratorExtensions.md index a25fa4dbb..6eed4111f 100644 --- a/.docfx/api/types/Cuemon.Net.ByteArrayDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Net.ByteArrayDecoratorExtensions.md @@ -7,45 +7,40 @@ example: `ByteArrayDecoratorExtensions` in the `Net` namespace provides URL-encoding extension methods on `Decorator.Enclose` for byte arrays with partial encoding and custom encoding support. This example creates UTF-8 bytes from `"hello world & more "` and calls `UrlEncode` with default parameters producing `"hello+world+%26+more+%3cstuff%3e"`, then demonstrates partial encoding on the first 5 bytes of `"a & b & c"` producing `"a+%26+b"`. It also shows custom UTF-32 encoding and empty array handling where `Array.Empty()` returns an encoded array of length `0`. Console output displays each encoded result. ```csharp +// Program.cs using System; using System.Text; using Cuemon; using Cuemon.Net; using Cuemon.Text; -namespace MyApp.Net +// Create bytes containing characters that need URL encoding +byte[] data = Encoding.UTF8.GetBytes("hello world & more "); + +// URL-encode the bytes with default position (0) and length (all) +byte[] encoded = Decorator.Enclose(data).UrlEncode(0, data.Length); +string encodedString = Encoding.ASCII.GetString(encoded); +Console.WriteLine(encodedString); // "hello+world+%26+more+%3cstuff%3e" + +// Encode only a portion of the byte array +byte[] partial = Encoding.UTF8.GetBytes("a & b & c"); +byte[] encodedPartial = Decorator.Enclose(partial).UrlEncode(position: 0, bytesToRead: 5); +string partialString = Encoding.ASCII.GetString(encodedPartial); +Console.WriteLine(partialString); // "a+%26+b" (only first 5 bytes encoded) + +// Encode with custom encoding options +byte[] utf32Data = Encoding.UTF32.GetBytes("hello"); +byte[] utf32Encoded = Decorator.Enclose(utf32Data).UrlEncode(0, utf32Data.Length, o => { - public class ByteArrayDecoratorExtensionsExample - { - public void Demonstrate() - { - // Create bytes containing characters that need URL encoding - byte[] data = Encoding.UTF8.GetBytes("hello world & more "); - - // URL-encode the bytes with default position (0) and length (all) - byte[] encoded = Decorator.Enclose(data).UrlEncode(); - string encodedString = Encoding.ASCII.GetString(encoded); - Console.WriteLine(encodedString); // "hello+world+%26+more+%3cstuff%3e" - - // Encode only a portion of the byte array - byte[] partial = Encoding.UTF8.GetBytes("a & b & c"); - byte[] encodedPartial = Decorator.Enclose(partial).UrlEncode(position: 0, bytesToRead: 5); - string partialString = Encoding.ASCII.GetString(encodedPartial); - Console.WriteLine(partialString); // "a+%26+b" (only first 5 bytes encoded) - - // Encode with custom encoding options - byte[] utf32Data = Encoding.UTF32.GetBytes("hello"); - byte[] utf32Encoded = Decorator.Enclose(utf32Data).UrlEncode(0, utf32Data.Length, o => - { - o.Encoding = Encoding.UTF32; - }); - - // Handle empty byte arrays - byte[] empty = Array.Empty(); - byte[] emptyEncoded = Decorator.Enclose(empty).UrlEncode(); - Console.WriteLine(emptyEncoded.Length); // 0 - -}} -} + o.Encoding = Encoding.UTF32; +}); +// Handle empty byte arrays +byte[] empty = Array.Empty(); +byte[] emptyEncoded = Decorator.Enclose(empty).UrlEncode(0, 0); +Console.WriteLine(emptyEncoded.Length); // 0 ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.Collections.Specialized.NameValueCollectionDecoratorExtensions.md b/.docfx/api/types/Cuemon.Net.Collections.Specialized.NameValueCollectionDecoratorExtensions.md index 3fd9b4d18..30f45b6c2 100644 --- a/.docfx/api/types/Cuemon.Net.Collections.Specialized.NameValueCollectionDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Net.Collections.Specialized.NameValueCollectionDecoratorExtensions.md @@ -31,9 +31,13 @@ public class NameValueCollectionDecoratorExtensionsExample Console.WriteLine(queryString); // Output: - // ?name=John%20Doe&city=Copenhagen&country=Denmark + // ?name=John+Doe&city=Copenhagen&country=Denmark } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.FieldValueSeparator.md b/.docfx/api/types/Cuemon.Net.FieldValueSeparator.md index fb325f1b8..e92fb3cbf 100644 --- a/.docfx/api/types/Cuemon.Net.FieldValueSeparator.md +++ b/.docfx/api/types/Cuemon.Net.FieldValueSeparator.md @@ -7,27 +7,24 @@ example: The following example demonstrates how to use to specify the separator for query string key-value pairs. ```csharp +// Program.cs using System; using Cuemon.Net; -namespace MyApp.Examples; +var separator = FieldValueSeparator.Ampersand; -public class FieldValueSeparatorExample +switch (separator) { - public void Demonstrate() - { - var separator = FieldValueSeparator.Ampersand; + case FieldValueSeparator.Ampersand: + Console.WriteLine("Using & separator for query string parameters (default)."); + break; + case FieldValueSeparator.Semicolon: + Console.WriteLine("Using ; separator for query string parameters."); + break; - switch (separator) - { - case FieldValueSeparator.Ampersand: - Console.WriteLine("Using & separator for query string parameters (default)."); - break; - case FieldValueSeparator.Semicolon: - Console.WriteLine("Using ; separator for query string parameters."); - break; - -}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.Http.HttpAuthenticationSchemes.md b/.docfx/api/types/Cuemon.Net.Http.HttpAuthenticationSchemes.md index 739d8e9c9..d550f5289 100644 --- a/.docfx/api/types/Cuemon.Net.Http.HttpAuthenticationSchemes.md +++ b/.docfx/api/types/Cuemon.Net.Http.HttpAuthenticationSchemes.md @@ -7,31 +7,28 @@ example: The following example shows how to use the `HttpAuthenticationSchemes` constants to construct HTTP Authorization headers. It prints each scheme name and creates a Basic authentication header value. ```csharp +// Program.cs using System; using System.Net.Http.Headers; using System.Text; using Cuemon.Net.Http; -namespace MyApp.Examples; +// Use scheme constants to construct Authorization headers +string basic = HttpAuthenticationSchemes.Basic; +string bearer = HttpAuthenticationSchemes.Bearer; +string digest = HttpAuthenticationSchemes.Digest; -public static class HttpAuthenticationSchemesExample -{ - public static void Demonstrate() - { - // Use scheme constants to construct Authorization headers - string basic = HttpAuthenticationSchemes.Basic; - string bearer = HttpAuthenticationSchemes.Bearer; - string digest = HttpAuthenticationSchemes.Digest; +Console.WriteLine($"Basic: {basic}"); +Console.WriteLine($"Bearer: {bearer}"); +Console.WriteLine($"Digest: {digest}"); - Console.WriteLine($"Basic: {basic}"); - Console.WriteLine($"Bearer: {bearer}"); - Console.WriteLine($"Digest: {digest}"); - - // Example: create a Basic authentication header value - string credentials = Convert.ToBase64String( - Encoding.UTF8.GetBytes("user:password")); - string authHeader = $"{basic} {credentials}"; - Console.WriteLine($"Authorization: {authHeader}"); - } -} +// Example: create a Basic authentication header value +string credentials = Convert.ToBase64String( + Encoding.UTF8.GetBytes("user:password")); +string authHeader = $"{basic} {credentials}"; +Console.WriteLine($"Authorization: {authHeader}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.Http.HttpDependency.md b/.docfx/api/types/Cuemon.Net.Http.HttpDependency.md index fd75eed82..fc607c9d6 100644 --- a/.docfx/api/types/Cuemon.Net.Http.HttpDependency.md +++ b/.docfx/api/types/Cuemon.Net.Http.HttpDependency.md @@ -7,16 +7,20 @@ example: `HttpDependency` wraps an `HttpWatcher` to monitor an HTTP resource for changes, detecting modifications via ETag and Last-Modified headers. This example creates a `Lazy` that monitors `https://example.com/api/status` with HEAD requests at 30-second intervals, then constructs an `HttpDependency` from the factory and subscribes to the `DependencyChanged` event. Key steps include calling `StartAsync` to begin monitoring and handling the `DependencyChanged` event to react to changes. Console output prints the UTC timestamp when a resource change is detected. ```csharp +// Program.cs using System; using System.Net.Http; using System.Threading.Tasks; using Cuemon.Net.Http; +using MyApp.Net; + +new HttpDependencyExample().Demonstrate(); namespace MyApp.Net { public class HttpDependencyExample { - public async Task DemonstrateAsync() + public void Demonstrate() { // Create an HttpWatcher that monitors changes to a URI resource var watcherFactory = new Lazy(() => @@ -38,15 +42,14 @@ namespace MyApp.Net Console.WriteLine($"Resource changed at: {args.UtcLastModified}"); }; - // Start monitoring - await dependency.StartAsync(); - - // The watcher will poll the URI every 30 seconds - // and raise DependencyChanged when a change is detected - - Console.WriteLine("Monitoring started. Press any key to stop..."); - Console.ReadKey(); + // Call StartAsync when you are ready to begin polling the URI. + // The watcher will poll every 30 seconds and raise DependencyChanged when a change is detected. + Console.WriteLine("HttpDependency configured for https://example.com/api/status."); } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.Http.HttpHeaderNames.md b/.docfx/api/types/Cuemon.Net.Http.HttpHeaderNames.md index 450e54872..34d0d8c10 100644 --- a/.docfx/api/types/Cuemon.Net.Http.HttpHeaderNames.md +++ b/.docfx/api/types/Cuemon.Net.Http.HttpHeaderNames.md @@ -7,31 +7,28 @@ example: The following example demonstrates how to use constants when working with HTTP request and response headers. ```csharp +// Program.cs using System; using System.Net.Http; using System.Threading.Tasks; using Cuemon.Net.Http; -namespace MyApp.Examples; +using var client = new HttpClient(); +using var request = new HttpRequestMessage(HttpMethod.Get, "https://example.com"); -public static class HttpHeaderNamesExample -{ - public static async Task DemonstrateAsync() - { - using var client = new HttpClient(); - using var request = new HttpRequestMessage(HttpMethod.Get, "https://example.com"); - - // Set request headers using the constants - request.Headers.Add(HttpHeaderNames.Accept, "application/json"); - request.Headers.Add(HttpHeaderNames.Authorization, "Bearer token123"); - request.Headers.Add(HttpHeaderNames.UserAgent, "MyApp/1.0"); - request.Headers.Add(HttpHeaderNames.AcceptEncoding, "gzip"); +// Set request headers using the constants +request.Headers.Add(HttpHeaderNames.Accept, "application/json"); +request.Headers.Add(HttpHeaderNames.Authorization, "Bearer token123"); +request.Headers.Add(HttpHeaderNames.UserAgent, "MyApp/1.0"); +request.Headers.Add(HttpHeaderNames.AcceptEncoding, "gzip"); - Console.WriteLine("Request headers configured:"); - foreach (var header in request.Headers) - { - Console.WriteLine($" {header.Key}: {string.Join(", ", header.Value)}"); - } - } +Console.WriteLine("Request headers configured:"); +foreach (var header in request.Headers) +{ + Console.WriteLine($" {header.Key}: {string.Join(", ", header.Value)}"); } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.Http.HttpManager.md b/.docfx/api/types/Cuemon.Net.Http.HttpManager.md index 019c9ed65..748c407e4 100644 --- a/.docfx/api/types/Cuemon.Net.Http.HttpManager.md +++ b/.docfx/api/types/Cuemon.Net.Http.HttpManager.md @@ -7,36 +7,45 @@ example: `HttpManager` provides HTTP operation methods backed by a configurable `IHttpClientFactory`. This example creates an `HttpManager` with a custom `EchoHandler` that returns `200 OK` for all requests, then calls `HttpGetAsync` on a test URI. Key setup includes passing a factory delegate that returns `HttpClient` instances backed by the echo handler. Console output confirms the response status code (`OK`) and that `Timeout` is greater than `TimeSpan.Zero`. ```csharp +// Program.cs using System; using System.Net; using System.Net.Http; using System.Threading; using System.Threading.Tasks; using Cuemon.Net.Http; +using MyApp.Examples; -namespace MyApp.Examples; +await HttpManagerExample.DemonstrateAsync(); -public static class HttpManagerExample +namespace MyApp.Examples { - public static async Task DemonstrateAsync() + public static class HttpManagerExample { - using var manager = new HttpManager(() => new HttpClient(new EchoHandler(), false)); - using var response = await manager.HttpGetAsync(new Uri("https://example.com/health")); + public static async Task DemonstrateAsync() + { + using var manager = new HttpManager(() => new HttpClient(new EchoHandler(), false)); + using var response = await manager.HttpGetAsync(new Uri("https://example.com/health")); - Console.WriteLine(response.StatusCode); - Console.WriteLine(manager.Timeout > TimeSpan.Zero); - } + Console.WriteLine(response.StatusCode); + Console.WriteLine(manager.Timeout > TimeSpan.Zero); + } - private sealed class EchoHandler : HttpMessageHandler - { - protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + private sealed class EchoHandler : HttpMessageHandler { - return Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) + protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { - RequestMessage = request, - Content = new StringContent("OK") - }); + return Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) + { + RequestMessage = request, + Content = new StringContent("OK") + }); + } } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.Http.HttpManagerOptions.md b/.docfx/api/types/Cuemon.Net.Http.HttpManagerOptions.md index 2a0948481..afedfb83c 100644 --- a/.docfx/api/types/Cuemon.Net.Http.HttpManagerOptions.md +++ b/.docfx/api/types/Cuemon.Net.Http.HttpManagerOptions.md @@ -7,30 +7,27 @@ example: The following example demonstrates how to configure before passing them to . ```csharp +// Program.cs using System; using System.Net.Http; using Cuemon.Net.Http; -namespace MyApp.Examples; - -public static class HttpManagerOptionsExample +var options = new HttpManagerOptions { - public static void Demonstrate() + Timeout = TimeSpan.FromSeconds(10), + HandlerFactory = () => new HttpClientHandler(), + DefaultRequestHeaders = { - var options = new HttpManagerOptions - { - Timeout = TimeSpan.FromSeconds(10), - HandlerFactory = () => new HttpClientHandler(), - DefaultRequestHeaders = - { - ["X-Correlation-Id"] = "docs-123" - } - }; + ["X-Correlation-Id"] = "docs-123" + } +}; - options.ValidateOptions(); +options.ValidateOptions(); - Console.WriteLine(options.Timeout.TotalSeconds); - Console.WriteLine(options.DefaultRequestHeaders["X-Correlation-Id"]); - } -} +Console.WriteLine(options.Timeout.TotalSeconds); +Console.WriteLine(options.DefaultRequestHeaders["X-Correlation-Id"]); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.Http.HttpMethodConverter.md b/.docfx/api/types/Cuemon.Net.Http.HttpMethodConverter.md index d2cb8a133..3aaec0158 100644 --- a/.docfx/api/types/Cuemon.Net.Http.HttpMethodConverter.md +++ b/.docfx/api/types/Cuemon.Net.Http.HttpMethodConverter.md @@ -7,19 +7,16 @@ example: The following example demonstrates how to convert a `System.Net.Http.HttpMethod` to the corresponding `HttpMethods` enum value using `HttpMethodConverter`. It converts the GET method and prints the result. ```csharp +// Program.cs using System; using System.Net.Http; using Cuemon.Net.Http; -namespace MyApp.Examples; - -public static class HttpMethodConverterExample -{ - public static void Demonstrate() - { - HttpMethod get = HttpMethod.Get; - HttpMethods result = HttpMethodConverter.ToHttpMethod(get); - Console.WriteLine(result); // Get - } -} +HttpMethod get = HttpMethod.Get; +HttpMethods result = HttpMethodConverter.ToHttpMethod(get); +Console.WriteLine(result); // Get ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.Http.HttpMethods.md b/.docfx/api/types/Cuemon.Net.Http.HttpMethods.md index 9a512a0cd..de442aa58 100644 --- a/.docfx/api/types/Cuemon.Net.Http.HttpMethods.md +++ b/.docfx/api/types/Cuemon.Net.Http.HttpMethods.md @@ -7,20 +7,17 @@ example: The following example demonstrates how to combine and test flags. ```csharp +// Program.cs using System; using Cuemon.Net.Http; -namespace MyApp.Examples; +var allowedMethods = HttpMethods.Get | HttpMethods.Post | HttpMethods.Head; -public static class HttpMethodsExample -{ - public static void Demonstrate() - { - var allowedMethods = HttpMethods.Get | HttpMethods.Post | HttpMethods.Head; - - Console.WriteLine(allowedMethods.HasFlag(HttpMethods.Get)); - Console.WriteLine(allowedMethods.HasFlag(HttpMethods.Delete)); - Console.WriteLine(allowedMethods & ~HttpMethods.Head); - } -} +Console.WriteLine(allowedMethods.HasFlag(HttpMethods.Get)); +Console.WriteLine(allowedMethods.HasFlag(HttpMethods.Delete)); +Console.WriteLine(allowedMethods & ~HttpMethods.Head); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.Http.HttpRequestOptions.md b/.docfx/api/types/Cuemon.Net.Http.HttpRequestOptions.md index 1f4029dd7..8cf5998cd 100644 --- a/.docfx/api/types/Cuemon.Net.Http.HttpRequestOptions.md +++ b/.docfx/api/types/Cuemon.Net.Http.HttpRequestOptions.md @@ -7,31 +7,21 @@ example: The following example demonstrates how to configure and send an HTTP request using `HttpRequestOptions` with the `HttpManager`. ```csharp +// Program.cs using System; using System.Net.Http; using System.Threading.Tasks; using Cuemon.Net.Http; using HttpRequestOptions = Cuemon.Net.Http.HttpRequestOptions; -namespace Examples; - -public class HttpRequestExample -{ - public async Task SendRequestAsync() - { - // Direct instantiation of HttpRequestOptions - var requestOptions = new HttpRequestOptions(); - requestOptions.Request.Method = HttpMethod.Get; - - using var manager = new HttpManager(); - using var response = await manager.HttpAsync( - new Uri("https://api.example.com/data"), - o => - { - o.Request.Method = HttpMethod.Get; - o.Request.Headers.Add("Accept", "application/json"); - }); - } -} +// Direct instantiation of HttpRequestOptions +var requestOptions = new HttpRequestOptions(); +requestOptions.Request.Method = HttpMethod.Get; +requestOptions.Request.Headers.Add("Accept", "application/json"); +Console.WriteLine($"{requestOptions.Request.Method} {string.Join(", ", requestOptions.Request.Headers.Accept)}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.Http.HttpWatcher.md b/.docfx/api/types/Cuemon.Net.Http.HttpWatcher.md index 2917aba3a..80aac84c8 100644 --- a/.docfx/api/types/Cuemon.Net.Http.HttpWatcher.md +++ b/.docfx/api/types/Cuemon.Net.Http.HttpWatcher.md @@ -7,24 +7,21 @@ example: The following example demonstrates how to configure an for a remote URI and inspect its active monitoring settings. ```csharp +// Program.cs using System; using Cuemon.Net.Http; -namespace MyApp.Examples; - -public static class HttpWatcherExample +var watcher = new HttpWatcher(new Uri("https://example.com/feed"), options => { - public static void Demonstrate() - { - var watcher = new HttpWatcher(new Uri("https://example.com/feed"), options => - { - options.ReadResponseBody = true; - options.Period = TimeSpan.FromSeconds(10); - }); + options.ReadResponseBody = true; + options.Period = TimeSpan.FromSeconds(10); +}); - Console.WriteLine(watcher.Location); - Console.WriteLine(watcher.ReadResponseBody); - Console.WriteLine(watcher.HashFactory != null); - } -} +Console.WriteLine(watcher.Location); +Console.WriteLine(watcher.ReadResponseBody); +Console.WriteLine(watcher.HashFactory != null); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.Http.HttpWatcherOptions.md b/.docfx/api/types/Cuemon.Net.Http.HttpWatcherOptions.md index 8af37b0a3..0ef0fb579 100644 --- a/.docfx/api/types/Cuemon.Net.Http.HttpWatcherOptions.md +++ b/.docfx/api/types/Cuemon.Net.Http.HttpWatcherOptions.md @@ -7,30 +7,27 @@ example: The following example demonstrates how to configure before creating an . ```csharp +// Program.cs using System; using System.Net.Http; using Cuemon.Net.Http; using Cuemon.Security; -namespace MyApp.Examples; - -public static class HttpWatcherOptionsExample +var options = new HttpWatcherOptions { - public static void Demonstrate() - { - var options = new HttpWatcherOptions - { - ClientFactory = () => new HttpClient(new HttpClientHandler(), false), - HashFactory = () => new CyclicRedundancyCheck64(), - ReadResponseBody = true, - Period = TimeSpan.FromSeconds(5) - }; + ClientFactory = () => new HttpClient(new HttpClientHandler(), false), + HashFactory = () => new CyclicRedundancyCheck64(), + ReadResponseBody = true, + Period = TimeSpan.FromSeconds(5) +}; - options.ValidateOptions(); +options.ValidateOptions(); - Console.WriteLine(options.ReadResponseBody); - Console.WriteLine(options.Period.TotalSeconds); - Console.WriteLine($"HTTP client factory configured: {options.ClientFactory is not null}"); - } -} +Console.WriteLine(options.ReadResponseBody); +Console.WriteLine(options.Period.TotalSeconds); +Console.WriteLine($"HTTP client factory configured: {options.ClientFactory is not null}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.Mail.MailDistributor.md b/.docfx/api/types/Cuemon.Net.Mail.MailDistributor.md index 1f9fe2fe9..0dd692a78 100644 --- a/.docfx/api/types/Cuemon.Net.Mail.MailDistributor.md +++ b/.docfx/api/types/Cuemon.Net.Mail.MailDistributor.md @@ -7,27 +7,24 @@ example: The following example demonstrates how to construct a and skip delivery through a filter when you only want to validate a message batch. ```csharp +// Program.cs using System; using System.Net.Mail; using System.Threading.Tasks; using Cuemon.Net.Mail; -namespace MyApp.Examples; - -public static class MailDistributorExample +var distributor = new MailDistributor(() => new SmtpClient("smtp.example.com", 25), deliverySize: 10); +using var mail = new MailMessage("sender@example.com", "receiver@example.com") { - public static async Task DemonstrateAsync() - { - var distributor = new MailDistributor(() => new SmtpClient("smtp.example.com", 25), deliverySize: 10); - using var mail = new MailMessage("sender@example.com", "receiver@example.com") - { - Subject = "Docs sample", - Body = "This message is filtered out before delivery." - }; + Subject = "Docs sample", + Body = "This message is filtered out before delivery." +}; - await distributor.SendOneAsync(mail, _ => false); +await distributor.SendOneAsync(mail, _ => false); - Console.WriteLine("Delivery skipped by filter."); - } -} +Console.WriteLine("Delivery skipped by filter."); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.QueryStringCollection.md b/.docfx/api/types/Cuemon.Net.QueryStringCollection.md index 1dd39f2bb..8cea3e354 100644 --- a/.docfx/api/types/Cuemon.Net.QueryStringCollection.md +++ b/.docfx/api/types/Cuemon.Net.QueryStringCollection.md @@ -7,16 +7,11 @@ example: `QueryStringCollection` provides creation, parsing, and manipulation of URI query string parameters, extending `NameValueCollection` with URL decoding support. This example creates an empty collection and adds `"search"`, `"page"`, and `"sort"` parameters, parses an existing query string (`"?category=books&author=tolkien"`) with and without URL decoding, and iterates key-value pairs. It also demonstrates cloning the collection and modifying the clone independently to verify they are separate instances. Console output shows the query string representation, decoded values, keys, clone independence, and entry counts. ```csharp +// Program.cs using System; using System.Linq; using Cuemon.Net; -namespace MyApp.Net -{ - public static class QueryStringCollectionExamples - { - public static void Demonstrate() - { // Create an empty query string collection and add parameters. var qsc = new QueryStringCollection(); qsc.Add("search", "dotnet"); @@ -50,7 +45,9 @@ namespace MyApp.Net // Count entries. Console.WriteLine("Count: {0}", qsc.Count); -}}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Net.StringDecoratorExtensions.md b/.docfx/api/types/Cuemon.Net.StringDecoratorExtensions.md index 0b64e1f1f..168173dd3 100644 --- a/.docfx/api/types/Cuemon.Net.StringDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Net.StringDecoratorExtensions.md @@ -7,46 +7,40 @@ example: `StringDecoratorExtensions` in the `Net` namespace provides URL-encoding and URL-decoding extension methods on `Decorator.Enclose` for strings with custom encoding support. This example encodes `"hello world & some "` via `UrlEncode` producing `"hello+world+%26+some+%3cstuff%3e"`, decodes it back to the original via `UrlDecode`, and also demonstrates calling the static methods directly on `Cuemon.Net.StringDecoratorExtensions.UrlEncode`. Custom encoding with UTF-8 on `"a=b&c=d"` produces `"a%3db%26c%3dd"`. Console output confirms each encode and decode operation's round-trip behavior. ```csharp +// Program.cs using System; using Cuemon; using System.Text; using Cuemon.Net; using Cuemon.Text; -namespace MyApp.Net -{ - public class StringDecoratorExtensionsExample - { - public void Demonstrate() - { - // URL-encode a string with special characters - string raw = "hello world & some "; - - // Invoke UrlEncode extension method - string encoded = Decorator.Enclose(raw).UrlEncode(); - Console.WriteLine(encoded); // "hello+world+%26+some+%3cstuff%3e" - - // Also invoke as static method via the Cuemon.Net.StringDecoratorExtensions type - string encodedStatic = Cuemon.Net.StringDecoratorExtensions.UrlEncode(Decorator.Enclose(raw)); - Console.WriteLine(encodedStatic); // "hello+world+%26+some+%3cstuff%3e" - - // URL-decode the encoded string back - string decoded = Decorator.Enclose(encoded).UrlDecode(); - Console.WriteLine(decoded); // "hello world & some " - - // Invoke UrlDecode as static method via the Cuemon.Net.StringDecoratorExtensions type - string decodedStatic = Cuemon.Net.StringDecoratorExtensions.UrlDecode(Decorator.Enclose(encoded)); - Console.WriteLine(decodedStatic); // "hello world & some " - - // Encode with a specific encoding - string encodedUtf8 = Decorator.Enclose("a=b&c=d").UrlEncode(o => - { - o.Encoding = Encoding.UTF8; - }); - Console.WriteLine(encodedUtf8); // "a%3db%26c%3dd" - - } - } -} +// URL-encode a string with special characters +string raw = "hello world & some "; + +// Invoke UrlEncode extension method +string encoded = Decorator.Enclose(raw).UrlEncode(); +Console.WriteLine(encoded); // "hello+world+%26+some+%3cstuff%3e" + +// Also invoke as static method via the Cuemon.Net.StringDecoratorExtensions type +string encodedStatic = Cuemon.Net.StringDecoratorExtensions.UrlEncode(Decorator.Enclose(raw)); +Console.WriteLine(encodedStatic); // "hello+world+%26+some+%3cstuff%3e" + +// URL-decode the encoded string back +string decoded = Decorator.Enclose(encoded).UrlDecode(); +Console.WriteLine(decoded); // "hello world & some " +// Invoke UrlDecode as static method via the Cuemon.Net.StringDecoratorExtensions type +string decodedStatic = Cuemon.Net.StringDecoratorExtensions.UrlDecode(Decorator.Enclose(encoded)); +Console.WriteLine(decodedStatic); // "hello world & some " + +// Encode with a specific encoding +string encodedUtf8 = Decorator.Enclose("a=b&c=d").UrlEncode(o => +{ + o.Encoding = Encoding.UTF8; +}); +Console.WriteLine(encodedUtf8); // "a%3db%26c%3dd" ``` + + + + diff --git a/.docfx/api/types/Cuemon.ObjectDecoratorExtensions.md b/.docfx/api/types/Cuemon.ObjectDecoratorExtensions.md index 58f3138cc..581170e72 100644 --- a/.docfx/api/types/Cuemon.ObjectDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.ObjectDecoratorExtensions.md @@ -63,3 +63,7 @@ namespace DocExamples } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.ObjectFormattingOptions.md b/.docfx/api/types/Cuemon.ObjectFormattingOptions.md index 4038470f0..135e5c53f 100644 --- a/.docfx/api/types/Cuemon.ObjectFormattingOptions.md +++ b/.docfx/api/types/Cuemon.ObjectFormattingOptions.md @@ -7,34 +7,29 @@ example: The following example demonstrates how to use to customize the conversion of an object to a different type via . ```csharp +// Program.cs using System; using System.Globalization; using Cuemon; -namespace MyApp.Examples; - -public class ObjectFormattingOptionsExample +// Direct instantiation of ObjectFormattingOptions +var options = new ObjectFormattingOptions { - public void Demonstrate() - { - // Direct instantiation of ObjectFormattingOptions - var options = new ObjectFormattingOptions - { - FormatProvider = new CultureInfo("da-DK") - }; - - var value = "1234.56"; + FormatProvider = new CultureInfo("da-DK") +}; - // Convert the string to a double using Danish formatting - var result = Decorator.Enclose((object)value) - .ChangeType(o => - { - o.FormatProvider = new CultureInfo("da-DK"); - }); +var value = "1234.56"; - Console.WriteLine(result); // Output: 1234.56 - -} -} +// Convert the string to a double using Danish formatting +var result = Decorator.Enclose((object)value) + .ChangeType(o => + { + o.FormatProvider = new CultureInfo("da-DK"); + }); +Console.WriteLine(result); // Output: 1234.56 ``` + + + + diff --git a/.docfx/api/types/Cuemon.ObjectPortrayalOptions.md b/.docfx/api/types/Cuemon.ObjectPortrayalOptions.md index a095638b1..5cca75f4f 100644 --- a/.docfx/api/types/Cuemon.ObjectPortrayalOptions.md +++ b/.docfx/api/types/Cuemon.ObjectPortrayalOptions.md @@ -7,39 +7,48 @@ example: The following example demonstrates how to use with to produce a human-readable property dump of an object. ```csharp +// Program.cs using System; using Cuemon; +using Contoso.Diagnostics; -namespace Contoso.Diagnostics; +ObjectPortrayalOptionsExample.Run(); -public sealed class ObjectPortrayalOptionsExample +namespace Contoso.Diagnostics { - public static void Run() + public sealed class ObjectPortrayalOptionsExample { - var options = new ObjectPortrayalOptions + public static void Run() { - BypassOverrideCheck = true, - Delimiter = "; ", - NullValue = "(none)" - }; - - var profile = new SampleProfile { Name = "Alice", Nickname = null }; - - string portrayal = Generate.ObjectPortrayal(profile, setup => + var options = new ObjectPortrayalOptions + { + BypassOverrideCheck = true, + Delimiter = "; ", + NullValue = "(none)" + }; + + var profile = new SampleProfile { Name = "Alice", Nickname = null }; + + string portrayal = Generate.ObjectPortrayal(profile, setup => + { + setup.BypassOverrideCheck = options.BypassOverrideCheck; + setup.Delimiter = options.Delimiter; + setup.NullValue = options.NullValue; + }); + + Console.WriteLine(portrayal); + } + + private sealed class SampleProfile { - setup.BypassOverrideCheck = options.BypassOverrideCheck; - setup.Delimiter = options.Delimiter; - setup.NullValue = options.NullValue; - }); + public string Name { get; set; } - Console.WriteLine(portrayal); - } - - private sealed class SampleProfile - { - public string Name { get; set; } - - public string Nickname { get; set; } + public string Nickname { get; set; } + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Patterns.md b/.docfx/api/types/Cuemon.Patterns.md index a3a553999..9c00c8f0e 100644 --- a/.docfx/api/types/Cuemon.Patterns.md +++ b/.docfx/api/types/Cuemon.Patterns.md @@ -7,40 +7,49 @@ example: The following example demonstrates how to use the class to safely invoke delegates, configure options via the Options pattern, and guard against fatal exceptions. ```csharp +// Program.cs using System; using System.Threading; using Cuemon; using Cuemon.Threading; +using Contoso.Infrastructure; -namespace Contoso.Infrastructure; +PatternsExample.Run(); -public sealed class PatternsExample +namespace Contoso.Infrastructure { - public static void Run() + public sealed class PatternsExample { - var options = Patterns.Configure(setup => + public static void Run() { - setup.CancellationToken = CancellationToken.None; - }); - - var profile = Patterns.CreateInstance(instance => + var options = Patterns.Configure(setup => + { + setup.CancellationToken = CancellationToken.None; + }); + + var profile = Patterns.CreateInstance(instance => + { + instance.Name = "health"; + }); + + bool wroteMessage = Patterns.TryInvoke(() => Console.WriteLine(profile.Name)); + int fallbackPort = Patterns.InvokeOrDefault(() => int.Parse("not-a-number"), -1); + bool recoverable = Patterns.IsRecoverableException(new InvalidOperationException("Transient.")); + + Console.WriteLine($"Token can cancel: {options.CancellationToken.CanBeCanceled}"); + Console.WriteLine($"TryInvoke succeeded: {wroteMessage}"); + Console.WriteLine($"Fallback port: {fallbackPort}"); + Console.WriteLine($"Recoverable: {recoverable}"); + } + + private sealed class EndpointProfile { - instance.Name = "health"; - }); - - bool wroteMessage = Patterns.TryInvoke(() => Console.WriteLine(profile.Name)); - int fallbackPort = Patterns.InvokeOrDefault(() => int.Parse("not-a-number"), -1); - bool recoverable = Patterns.IsRecoverableException(new InvalidOperationException("Transient.")); - - Console.WriteLine($"Token can cancel: {options.CancellationToken.CanBeCanceled}"); - Console.WriteLine($"TryInvoke succeeded: {wroteMessage}"); - Console.WriteLine($"Fallback port: {fallbackPort}"); - Console.WriteLine($"Recoverable: {recoverable}"); - } - - private sealed class EndpointProfile - { - public string Name { get; set; } + public string Name { get; set; } + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.ActivatorFactory.md b/.docfx/api/types/Cuemon.Reflection.ActivatorFactory.md index 925bc515c..1da49b4ba 100644 --- a/.docfx/api/types/Cuemon.Reflection.ActivatorFactory.md +++ b/.docfx/api/types/Cuemon.Reflection.ActivatorFactory.md @@ -7,22 +7,19 @@ example: The following example shows how to create instances of types at runtime using `ActivatorFactory`. It creates a `StringBuilder` with no arguments and a `DateTime` with constructor arguments, then prints each result. ```csharp +// Program.cs using System; using System.Text; using Cuemon.Reflection; -namespace Cuemon.Reflection; +var sb = ActivatorFactory.CreateInstance(); +sb.Append("Hello from activator"); +Console.WriteLine(sb.ToString()); -public class ActivatorFactoryExample -{ - public void Demonstrate() - { - var sb = ActivatorFactory.CreateInstance(); - sb.Append("Hello from activator"); - Console.WriteLine(sb.ToString()); - - var dt = ActivatorFactory.CreateInstance(2025, 12, 1); - Console.WriteLine($"Created: {dt:yyyy-MM-dd}"); - } -} +var dt = ActivatorFactory.CreateInstance(2025, 12, 1); +Console.WriteLine($"Created: {dt:yyyy-MM-dd}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.ActivatorOptions.md b/.docfx/api/types/Cuemon.Reflection.ActivatorOptions.md index 177acde82..e0e415d8d 100644 --- a/.docfx/api/types/Cuemon.Reflection.ActivatorOptions.md +++ b/.docfx/api/types/Cuemon.Reflection.ActivatorOptions.md @@ -7,31 +7,26 @@ example: The following example demonstrates how to use with to customize object creation with specific binding flags. ```csharp +// Program.cs using System; using System.Reflection; using Cuemon.Reflection; -namespace MyApp.Examples; - -public class ActivatorOptionsExample +// Direct instantiation of ActivatorOptions +var options = new ActivatorOptions { - public void Demonstrate() - { - // Direct instantiation of ActivatorOptions - var options = new ActivatorOptions - { - Flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance - }; - - // Create a Uri instance using a factory with explicit binding flags - var uri = ActivatorFactory.CreateInstance("http://example.com", o => - { - o.Flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance; - }); - - Console.WriteLine(uri.Host); + Flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance +}; -} -} +// Create a Uri instance using a factory with explicit binding flags +var uri = ActivatorFactory.CreateInstance("http://example.com", o => +{ + o.Flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance; +}); +Console.WriteLine(uri.Host); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.AssemblyContext.md b/.docfx/api/types/Cuemon.Reflection.AssemblyContext.md index 8b6055690..693b54baf 100644 --- a/.docfx/api/types/Cuemon.Reflection.AssemblyContext.md +++ b/.docfx/api/types/Cuemon.Reflection.AssemblyContext.md @@ -7,25 +7,22 @@ example: The following example demonstrates how to filter and enumerate loaded assemblies using `AssemblyContext`. It retrieves all assemblies whose name starts with "Cuemon" and prints each assembly name. ```csharp +// Program.cs using System; using System.Linq; using Cuemon.Reflection; -namespace Cuemon.Reflection; - -public class AssemblyContextExample +var assemblies = AssemblyContext.GetCurrentDomainAssemblies(options => { - public void Demonstrate() - { - var assemblies = AssemblyContext.GetCurrentDomainAssemblies(options => - { - options.AssemblyFilter = a => a.FullName?.StartsWith("Cuemon") == true; - }); + options.AssemblyFilter = a => a.FullName?.StartsWith("Cuemon") == true; +}); - foreach (var assembly in assemblies) - { - Console.WriteLine($"Assembly: {assembly.GetName().Name}"); - } - } +foreach (var assembly in assemblies) +{ + Console.WriteLine($"Assembly: {assembly.GetName().Name}"); } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.AssemblyContextOptions.md b/.docfx/api/types/Cuemon.Reflection.AssemblyContextOptions.md index 3a305c641..9f1b061d8 100644 --- a/.docfx/api/types/Cuemon.Reflection.AssemblyContextOptions.md +++ b/.docfx/api/types/Cuemon.Reflection.AssemblyContextOptions.md @@ -7,66 +7,74 @@ example: The following example demonstrates how to configure to control which assemblies are returned by [GetCurrentDomainAssemblies](https://docs.cuemon.net/api/dotnet/Cuemon.Reflection.AssemblyContext.html#Cuemon_Reflection_AssemblyContext_GetCurrentDomainAssemblies_System_Action_Cuemon_Reflection_AssemblyContextOptions__). ```csharp +// Program.cs using System; using System.Linq; using System.Reflection; using Cuemon.Reflection; +using MyApp.Examples; -namespace MyApp.Examples; +new AssemblyContextOptionsExample().FilterAssemblies(); -public class AssemblyContextOptionsExample +namespace MyApp.Examples { - public void FilterAssemblies() + public class AssemblyContextOptionsExample { - // Configure to include only assemblies whose name contains "Cuemon" - // and exclude the current assembly from results - var assemblies = AssemblyContext.GetCurrentDomainAssemblies(o => + public void FilterAssemblies() { - o.AssemblyFilter = assembly => - assembly.FullName.StartsWith("Cuemon", StringComparison.Ordinal); + // Configure to include only assemblies whose name contains "Cuemon" + // and exclude the current assembly from results + var assemblies = AssemblyContext.GetCurrentDomainAssemblies(o => + { + o.AssemblyFilter = assembly => + assembly.FullName.StartsWith("Cuemon", StringComparison.Ordinal); - o.ReferencedAssemblyFilter = assemblyName => - assemblyName.FullName.StartsWith("Cuemon", StringComparison.Ordinal); + o.ReferencedAssemblyFilter = assemblyName => + assemblyName.FullName.StartsWith("Cuemon", StringComparison.Ordinal); - o.IncludeReferencedAssemblies = true; + o.IncludeReferencedAssemblies = true; - // Remove the default exclusion of Cuemon.Core - o.ExcludedAssemblies.Clear(); - }); + // Remove the default exclusion of Cuemon.Core + o.ExcludedAssemblies.Clear(); + }); - foreach (var assembly in assemblies) - { - Console.WriteLine(assembly.GetName().Name); + foreach (var assembly in assemblies) + { + Console.WriteLine(assembly.GetName().Name); + } } - } - - public void UseDefaults() - { - // Default options exclude System and Microsoft assemblies - var options = new AssemblyContextOptions(); - Console.WriteLine($"IncludeReferencedAssemblies: {options.IncludeReferencedAssemblies}"); // true - Console.WriteLine($"AssemblyFilter: {(options.AssemblyFilter != null ? "set" : "null")}"); - Console.WriteLine($"ReferencedAssemblyFilter: {(options.ReferencedAssemblyFilter != null ? "set" : "null")}"); - Console.WriteLine($"ExcludedAssemblies count: {options.ExcludedAssemblies.Count}"); - } - public void GetCuemonAssemblies() - { - // Get all Cuemon assemblies in the current domain - var cuemonAssemblies = AssemblyContext.GetCurrentDomainAssemblies(o => + public void UseDefaults() { - o.AssemblyFilter = a => a.FullName.StartsWith("Cuemon", StringComparison.Ordinal); - o.ReferencedAssemblyFilter = an => an.FullName.StartsWith("Cuemon", StringComparison.Ordinal); - o.IncludeReferencedAssemblies = true; - o.ExcludedAssemblies.Clear(); - }); + // Default options exclude System and Microsoft assemblies + var options = new AssemblyContextOptions(); + Console.WriteLine($"IncludeReferencedAssemblies: {options.IncludeReferencedAssemblies}"); // true + Console.WriteLine($"AssemblyFilter: {(options.AssemblyFilter != null ? "set" : "null")}"); + Console.WriteLine($"ReferencedAssemblyFilter: {(options.ReferencedAssemblyFilter != null ? "set" : "null")}"); + Console.WriteLine($"ExcludedAssemblies count: {options.ExcludedAssemblies.Count}"); + } - Console.WriteLine($"Found {cuemonAssemblies.Count} Cuemon assemblies:"); - foreach (var asm in cuemonAssemblies) + public void GetCuemonAssemblies() { - Console.WriteLine($" - {asm.GetName().Name} v{asm.GetName().Version}"); + // Get all Cuemon assemblies in the current domain + var cuemonAssemblies = AssemblyContext.GetCurrentDomainAssemblies(o => + { + o.AssemblyFilter = a => a.FullName.StartsWith("Cuemon", StringComparison.Ordinal); + o.ReferencedAssemblyFilter = an => an.FullName.StartsWith("Cuemon", StringComparison.Ordinal); + o.IncludeReferencedAssemblies = true; + o.ExcludedAssemblies.Clear(); + }); + + Console.WriteLine($"Found {cuemonAssemblies.Count} Cuemon assemblies:"); + foreach (var asm in cuemonAssemblies) + { + Console.WriteLine($" - {asm.GetName().Name} v{asm.GetName().Version}"); + } } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.AssemblyDecoratorExtensions.md b/.docfx/api/types/Cuemon.Reflection.AssemblyDecoratorExtensions.md index ddd3d1dd2..e23ab807f 100644 --- a/.docfx/api/types/Cuemon.Reflection.AssemblyDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Reflection.AssemblyDecoratorExtensions.md @@ -7,6 +7,7 @@ example: `AssemblyDecoratorExtensions` provides extension methods on `Decorator.Enclose` for inspecting assembly metadata, loading embedded resources, and filtering types. This example wraps the entry assembly and calls `IsDebugBuild`, `GetAssemblyVersion`, `GetFileVersion`, and `GetProductVersion` to retrieve version information. It also demonstrates `GetTypes` with optional namespace and interface filters, and `GetManifestResources` with various match modes including `ContainsName`, `Extension`, and `Name`. Console output displays each version string, boolean flags, and resource character counts. ```csharp +// Program.cs using System; using System.Diagnostics; using System.IO; @@ -15,13 +16,6 @@ using System.Reflection; using Cuemon; using Cuemon.Reflection; -namespace MyApp.Examples; - -public class Example -{ - public void Run() - { - // Get the entry assembly to inspect var assembly = Assembly.GetExecutingAssembly(); var decorator = Decorator.Enclose(assembly); @@ -57,7 +51,9 @@ public class Example // Get a resource by exact name var singleResource = decorator.GetManifestResources("MyApp.Resources.data.xml", ManifestResourceMatch.Name); -}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.ManifestResourceMatch.md b/.docfx/api/types/Cuemon.Reflection.ManifestResourceMatch.md index 8744e8ef2..a7740e99c 100644 --- a/.docfx/api/types/Cuemon.Reflection.ManifestResourceMatch.md +++ b/.docfx/api/types/Cuemon.Reflection.ManifestResourceMatch.md @@ -7,33 +7,30 @@ example: The following example demonstrates how to use to specify how to locate embedded assembly resources. ```csharp +// Program.cs using System; using Cuemon.Reflection; -namespace MyApp.Examples; +var match = ManifestResourceMatch.Extension; -public class ManifestResourceMatchExample +switch (match) { - public void Demonstrate() - { - var match = ManifestResourceMatch.Extension; + case ManifestResourceMatch.Name: + Console.WriteLine("Match by exact resource name."); + break; + case ManifestResourceMatch.ContainsName: + Console.WriteLine("Match by partial name match."); + break; + case ManifestResourceMatch.Extension: + Console.WriteLine("Match by file extension (e.g., .json)."); + break; + case ManifestResourceMatch.ContainsExtension: + Console.WriteLine("Match by partial extension match."); + break; - switch (match) - { - case ManifestResourceMatch.Name: - Console.WriteLine("Match by exact resource name."); - break; - case ManifestResourceMatch.ContainsName: - Console.WriteLine("Match by partial name match."); - break; - case ManifestResourceMatch.Extension: - Console.WriteLine("Match by file extension (e.g., .json)."); - break; - case ManifestResourceMatch.ContainsExtension: - Console.WriteLine("Match by partial extension match."); - break; - -}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.MemberArgument.md b/.docfx/api/types/Cuemon.Reflection.MemberArgument.md index 141e62d9c..0b5151f8c 100644 --- a/.docfx/api/types/Cuemon.Reflection.MemberArgument.md +++ b/.docfx/api/types/Cuemon.Reflection.MemberArgument.md @@ -7,15 +7,10 @@ example: The following example demonstrates how to create and use MemberArgument instances to represent method parameters and their values, with priority support for ordering. ```csharp +// Program.cs using System; using Cuemon.Reflection; -namespace MyApp.Reflection -{ - public static class MemberArgumentExamples - { - public static void Demonstrate() - { // Create a MemberArgument to represent a method parameter and its value. var arg = new MemberArgument("id", 42); Console.WriteLine("Name: {0}", arg.Name); // id @@ -23,7 +18,7 @@ namespace MyApp.Reflection Console.WriteLine("Priority: {0}", arg.Priority); // 0 // Create arguments for use with MemberParser rehydration. - var args = new[] + var memberArguments = new[] { new MemberArgument("name", "Widget"), new MemberArgument("price", 19.99m), @@ -31,11 +26,11 @@ namespace MyApp.Reflection }; // Priority can control the order of processing. - args[0].Priority = 2; - args[1].Priority = 1; - args[2].Priority = 0; + memberArguments[0].Priority = 2; + memberArguments[1].Priority = 1; + memberArguments[2].Priority = 0; - foreach (var a in args) + foreach (var a in memberArguments) { Console.WriteLine("{0} = {1} (priority {2})", a.Name, a.Value, a.Priority); @@ -45,7 +40,9 @@ namespace MyApp.Reflection updatable.Priority = 5; Console.WriteLine("Updated: {0}", updatable); // [status, shipped, 5] -}}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.MemberArgumentDecoratorExtensions.md b/.docfx/api/types/Cuemon.Reflection.MemberArgumentDecoratorExtensions.md index 0a826291f..d602e629f 100644 --- a/.docfx/api/types/Cuemon.Reflection.MemberArgumentDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Reflection.MemberArgumentDecoratorExtensions.md @@ -7,39 +7,47 @@ example: The following example demonstrates how to reconstruct an exception from a recorded member argument stack using the class accessed through the class. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon; using Cuemon.Reflection; +using MyApp.Examples; -namespace MyApp.Examples; +Console.WriteLine(new MemberArgumentDecoratorExtensionsExample().ReconstructException()); -public class MemberArgumentDecoratorExtensionsExample +namespace MyApp.Examples { - public Exception ReconstructException() + public class MemberArgumentDecoratorExtensionsExample { - // Simulate a recorded stack of member arguments representing an exception chain - var stack = new Stack>(); - - var innerArgs = new List - { - new MemberArgument("type", typeof(InvalidOperationException)), - new MemberArgument("message", "Inner operation failed.") - }; - stack.Push(innerArgs); - - var outerArgs = new List + public Exception ReconstructException() { - new MemberArgument("type", typeof(ArgumentException)), - new MemberArgument("message", "Outer argument error."), - new MemberArgument("paramName", "myParam"), - }; - stack.Push(outerArgs); - - // Reconstruct the exception chain from the recorded arguments - return Decorator.Enclose(stack).CreateException(); - -} + // Simulate a recorded stack of member arguments representing an exception chain + var stack = new Stack>(); + + var innerArgs = new List + { + new MemberArgument("type", typeof(InvalidOperationException)), + new MemberArgument("message", "Inner operation failed.") + }; + stack.Push(innerArgs); + + var outerArgs = new List + { + new MemberArgument("type", typeof(ArgumentException)), + new MemberArgument("message", "Outer argument error."), + new MemberArgument("paramName", "myParam"), + }; + stack.Push(outerArgs); + + // Reconstruct the exception chain from the recorded arguments + return Decorator.Enclose(stack).CreateException(); + + } + } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.MemberInfoDecoratorExtensions.md b/.docfx/api/types/Cuemon.Reflection.MemberInfoDecoratorExtensions.md index 4d6d35d3d..55838040c 100644 --- a/.docfx/api/types/Cuemon.Reflection.MemberInfoDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Reflection.MemberInfoDecoratorExtensions.md @@ -7,11 +7,15 @@ example: `MemberInfoDecoratorExtensions` provides extension methods on `Decorator.Enclose` for checking whether a `MemberInfo` has one or more custom attributes via `HasAttribute`. This example gets `MemberInfo` for a method without attributes and another decorated with `[Obsolete]`, then calls `HasAttribute` with single (`ObsoleteAttribute`) and multiple attribute types on each. Console output shows `False` for the method without `ObsoleteAttribute`, `False` for `Obsolete` or `EditorBrowsable`, and `True` for the deprecated method, confirming correct attribute detection through the decorator pattern. ```csharp +// Program.cs using System; using System.ComponentModel; using System.Reflection; using Cuemon; using Cuemon.Reflection; +using MyApp.Reflection; + +new MemberInfoDecoratorExtensionsExample().Demonstrate(); namespace MyApp.Reflection { @@ -49,3 +53,7 @@ namespace MyApp.Reflection } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.MemberParser.md b/.docfx/api/types/Cuemon.Reflection.MemberParser.md index a0dc30e75..3f99e3d87 100644 --- a/.docfx/api/types/Cuemon.Reflection.MemberParser.md +++ b/.docfx/api/types/Cuemon.Reflection.MemberParser.md @@ -4,49 +4,57 @@ example: - *content --- -The following example shows how to hydrate a type from named reflection arguments. +The following example shows how to hydrate a type from named reflection arguments. The sample supplies named constructor and property arguments, selects a two-parameter constructor, and prints the hydrated values plus the processed argument names. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; using Cuemon.Reflection; +using MyApp.Examples; -namespace MyApp.Examples; +MemberParserExample.Demonstrate(); -public static class MemberParserExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class MemberParserExample { - var arguments = new List + public static void Demonstrate() { - new("sku", "SKU-42"), - new("price", 19.95m), - new("stock", 12) - }; - - var parser = new MemberParser(typeof(CatalogItem), arguments); - var item = (CatalogItem)parser.CreateInstance(ctor => ctor.GetParameters().Length == 2); - - Console.WriteLine(item.Sku); - Console.WriteLine(item.Price); - Console.WriteLine(item.Stock); - Console.WriteLine(string.Join(", ", parser.ProcessedMemberArguments.Select(argument => argument.Name))); + var arguments = new List + { + new("sku", "SKU-42"), + new("price", 19.95m), + new("stock", 12) + }; + + var parser = new MemberParser(typeof(CatalogItem), arguments); + var item = (CatalogItem)parser.CreateInstance(ctor => ctor.GetParameters().Length == 2); + + Console.WriteLine(item.Sku); + Console.WriteLine(item.Price); + Console.WriteLine(item.Stock); + Console.WriteLine(string.Join(", ", parser.ProcessedMemberArguments.Select(argument => argument.Name))); + } } -} - -public sealed class CatalogItem -{ - public CatalogItem(string sku, decimal price) + public sealed class CatalogItem { - Sku = sku; - Price = price; - } + public CatalogItem(string sku, decimal price) + { + Sku = sku; + Price = price; + } - public string Sku { get; } + public string Sku { get; } - public decimal Price { get; } + public decimal Price { get; } - public int Stock { get; set; } + public int Stock { get; set; } + } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.MemberReflection.md b/.docfx/api/types/Cuemon.Reflection.MemberReflection.md index 44e352b4a..235534a31 100644 --- a/.docfx/api/types/Cuemon.Reflection.MemberReflection.md +++ b/.docfx/api/types/Cuemon.Reflection.MemberReflection.md @@ -7,41 +7,36 @@ example: The following example demonstrates how to use to create custom for reflection-based member discovery. ```csharp +// Program.cs using System; using System.Reflection; -using Cuemon.Reflection; // for MemberReflection, MemberReflectionOptions - -namespace MyApp.Examples; - -public class MemberReflectionExample +using Cuemon.Reflection; + +// Create flags to find only public instance members (excluding inherited) +BindingFlags flags = new MemberReflection( + excludePrivate: true, + excludeStatic: true, + excludeInheritancePath: true); +Console.WriteLine(flags); +// Output: Instance, Public, DeclaredOnly + +// Use the static CreateFlags factory method +BindingFlags allFlags = MemberReflection.CreateFlags(); +Console.WriteLine(allFlags); +// Output: Instance, Static, Public, NonPublic + +// Configure via MemberReflectionOptions +BindingFlags customFlags = MemberReflection.CreateFlags(o => { - public void Demonstrate() - { - // Create flags to find only public instance members (excluding inherited) - BindingFlags flags = new MemberReflection( - excludePrivate: true, - excludeStatic: true, - excludeInheritancePath: true); - Console.WriteLine(flags); - // Output: Instance, Public, DeclaredOnly - - // Use the static CreateFlags factory method - BindingFlags allFlags = MemberReflection.CreateFlags(); - Console.WriteLine(allFlags); - // Output: Instance, Static, Public, NonPublic - - // Configure via MemberReflectionOptions - BindingFlags customFlags = MemberReflection.CreateFlags(o => - { - o.ExcludePrivate = true; - o.ExcludeStatic = true; - }); - - // Use with reflection - var members = typeof(string).GetMembers(customFlags); - Console.WriteLine(members.Length); // Number of public instance members on string - -} -} + o.ExcludePrivate = true; + o.ExcludeStatic = true; +}); +// Use with reflection +var members = typeof(string).GetMembers(customFlags); +Console.WriteLine(members.Length); // Number of public instance members on string ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.MemberReflectionOptions.md b/.docfx/api/types/Cuemon.Reflection.MemberReflectionOptions.md index 3719d97ff..81af5e189 100644 --- a/.docfx/api/types/Cuemon.Reflection.MemberReflectionOptions.md +++ b/.docfx/api/types/Cuemon.Reflection.MemberReflectionOptions.md @@ -7,51 +7,48 @@ example: The following example demonstrates how to use when generating a public API inventory for . ```csharp +// Program.cs using System; using System.Linq; using System.Reflection; using Cuemon; using Cuemon.Reflection; -namespace MyApp.Examples; +BindingFlags publicInstanceFlags = MemberReflection.CreateFlags(options => +{ + options.ExcludePrivate = true; + options.ExcludeStatic = true; +}); + +var publicDateSpanMembers = typeof(DateSpan) + .GetMembers(publicInstanceFlags) + .Select(member => member.Name) + .Distinct() + .OrderBy(name => name) + .Take(8); + +Console.WriteLine(string.Join(", ", publicDateSpanMembers)); + +BindingFlags declaredOnlyFlags = MemberReflection.CreateFlags(options => +{ + options.ExcludePrivate = true; + options.ExcludeStatic = true; + options.ExcludeInheritancePath = true; +}); + +Console.WriteLine(typeof(DateSpan).GetMethods(publicInstanceFlags).Length); +Console.WriteLine(typeof(DateSpan).GetMethods(declaredOnlyFlags).Length); -public static class MemberReflectionOptionsExample +var documentedOptions = new MemberReflectionOptions { - public static void Demonstrate() - { - BindingFlags publicInstanceFlags = MemberReflection.CreateFlags(options => - { - options.ExcludePrivate = true; - options.ExcludeStatic = true; - }); - - var publicDateSpanMembers = typeof(DateSpan) - .GetMembers(publicInstanceFlags) - .Select(member => member.Name) - .Distinct() - .OrderBy(name => name) - .Take(8); - - Console.WriteLine(string.Join(", ", publicDateSpanMembers)); - - BindingFlags declaredOnlyFlags = MemberReflection.CreateFlags(options => - { - options.ExcludePrivate = true; - options.ExcludeStatic = true; - options.ExcludeInheritancePath = true; - }); - - Console.WriteLine(typeof(DateSpan).GetMethods(publicInstanceFlags).Length); - Console.WriteLine(typeof(DateSpan).GetMethods(declaredOnlyFlags).Length); - - var documentedOptions = new MemberReflectionOptions - { - ExcludePrivate = true, - ExcludeStatic = true, - ExcludeInheritancePath = true - }; - - Console.WriteLine($"{documentedOptions.ExcludePrivate}/{documentedOptions.ExcludeStatic}/{documentedOptions.ExcludeInheritancePath}/{documentedOptions.ExcludePublic}"); - } -} + ExcludePrivate = true, + ExcludeStatic = true, + ExcludeInheritancePath = true +}; + +Console.WriteLine($"{documentedOptions.ExcludePrivate}/{documentedOptions.ExcludeStatic}/{documentedOptions.ExcludeInheritancePath}/{documentedOptions.ExcludePublic}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.MethodBaseOptions.md b/.docfx/api/types/Cuemon.Reflection.MethodBaseOptions.md index 69609179f..077d88627 100644 --- a/.docfx/api/types/Cuemon.Reflection.MethodBaseOptions.md +++ b/.docfx/api/types/Cuemon.Reflection.MethodBaseOptions.md @@ -7,45 +7,53 @@ example: `MethodBaseOptions` stores method lookup rules including binding flags, string comparison mode, and expected parameter types for use during reflection-based method resolution. This example configures options with `BindingFlags.Instance | BindingFlags.Public`, `StringComparison.OrdinalIgnoreCase`, and `typeof(decimal)` parameter types, then passes them to a custom `ResolveMethod` helper that searches the `PricingEngine` class for a method matching the name and parameter signature. Console output shows the resolved method name (`ApplyDiscount`) or `"not found"`, the binding flags, and the expected parameter type names (`Decimal, Decimal`). ```csharp +// Program.cs using System; using System.Linq; using System.Reflection; using Cuemon.Reflection; +using MyApp.Examples; -namespace MyApp.Examples; +MethodBaseOptionsExample.Demonstrate(); -public static class MethodBaseOptionsExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class MethodBaseOptionsExample { - var options = new MethodBaseOptions + public static void Demonstrate() { - Flags = BindingFlags.Instance | BindingFlags.Public, - Comparison = StringComparison.OrdinalIgnoreCase, - Types = new[] { typeof(decimal), typeof(decimal) } - }; + var options = new MethodBaseOptions + { + Flags = BindingFlags.Instance | BindingFlags.Public, + Comparison = StringComparison.OrdinalIgnoreCase, + Types = new[] { typeof(decimal), typeof(decimal) } + }; - MethodInfo method = ResolveMethod(typeof(PricingEngine), "applydiscount", options); + MethodInfo method = ResolveMethod(typeof(PricingEngine), "applydiscount", options); - Console.WriteLine(method == null ? "not found" : method.Name); - Console.WriteLine(options.Flags); - Console.WriteLine(string.Join(", ", options.Types.Select(type => type.Name))); - } + Console.WriteLine(method == null ? "not found" : method.Name); + Console.WriteLine(options.Flags); + Console.WriteLine(string.Join(", ", options.Types.Select(type => type.Name))); + } - private static MethodInfo ResolveMethod(Type source, string name, MethodBaseOptions options) - { - return source.GetMethods(options.Flags).FirstOrDefault(method => - method.Name.Equals(name, options.Comparison) && - method.GetParameters().Select(parameter => parameter.ParameterType) - .SequenceEqual(options.Types ?? Array.Empty())); + private static MethodInfo ResolveMethod(Type source, string name, MethodBaseOptions options) + { + return source.GetMethods(options.Flags).FirstOrDefault(method => + method.Name.Equals(name, options.Comparison) && + method.GetParameters().Select(parameter => parameter.ParameterType) + .SequenceEqual(options.Types ?? Array.Empty())); + } } -} - -public sealed class PricingEngine -{ - public decimal ApplyDiscount(decimal subtotal, decimal discount) + public sealed class PricingEngine { - return subtotal - discount; + public decimal ApplyDiscount(decimal subtotal, decimal discount) + { + return subtotal - discount; + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.MethodDescriptor.md b/.docfx/api/types/Cuemon.Reflection.MethodDescriptor.md index 3e47d0108..e96f68cf2 100644 --- a/.docfx/api/types/Cuemon.Reflection.MethodDescriptor.md +++ b/.docfx/api/types/Cuemon.Reflection.MethodDescriptor.md @@ -7,17 +7,12 @@ example: `MethodDescriptor` provides a structured representation of a method's metadata including its caller type, method name, parameters, and optional runtime arguments. This example creates a `MethodDescriptor` from `string.IndexOf`'s `MethodInfo`, inspects its `Caller` (`System.String`), `MethodName` (`IndexOf`), and `Parameters` (value and comparisonType), then appends runtime arguments via `AppendRuntimeArguments("Hello", StringComparison.OrdinalIgnoreCase)`. It also demonstrates the static `Create` factory and `MergeParameters` to combine parameter signatures with runtime values. Console output displays the caller full name, method name, signature, parameter list, runtime argument key-value pairs, and merged parameter values. ```csharp +// Program.cs using System; using System.Linq; using System.Reflection; using Cuemon.Reflection; -namespace MyApp.Reflection -{ - public static class MethodDescriptorExamples - { - public static void Demonstrate() - { // Create a MethodDescriptor from a MethodInfo. MethodInfo methodInfo = typeof(string).GetMethod("IndexOf", new[] { typeof(string), typeof(StringComparison) }); @@ -55,7 +50,9 @@ namespace MyApp.Reflection "test", 3); Console.WriteLine("Merged: input={0}, count={1}", merged["input"], merged["count"]); -}}}} -} - +}} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.MethodInfoDecoratorExtensions.md b/.docfx/api/types/Cuemon.Reflection.MethodInfoDecoratorExtensions.md index 106a33c26..151892a8c 100644 --- a/.docfx/api/types/Cuemon.Reflection.MethodInfoDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Reflection.MethodInfoDecoratorExtensions.md @@ -7,45 +7,52 @@ example: `MethodInfoDecoratorExtensions` provides extension methods on `Decorator.Enclose` for detecting whether a reflected method overrides a base class implementation via `IsOverridden`. This example retrieves `MethodInfo` for `PricingCalculator.Calculate` (base method), `RegionalPricingCalculator.Calculate` (overridden), and `RegionalPricingCalculator.FormatRegion` (local method), then calls `IsOverridden()` on each. Console output shows `False` for the base method, `True` for the overridden method, and `False` for the local method that does not override anything. ```csharp +// Program.cs using System; using System.Reflection; using Cuemon; using Cuemon.Reflection; +using MyApp.Examples; -namespace MyApp.Examples; +MethodInfoDecoratorExtensionsExample.Demonstrate(); -public static class MethodInfoDecoratorExtensionsExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class MethodInfoDecoratorExtensionsExample { - MethodInfo baseMethod = typeof(PricingCalculator).GetMethod(nameof(PricingCalculator.Calculate))!; - MethodInfo derivedMethod = typeof(RegionalPricingCalculator).GetMethod(nameof(PricingCalculator.Calculate))!; - MethodInfo localMethod = typeof(RegionalPricingCalculator).GetMethod(nameof(RegionalPricingCalculator.FormatRegion))!; - - Console.WriteLine(Decorator.Enclose(baseMethod).IsOverridden()); - Console.WriteLine(Decorator.Enclose(derivedMethod).IsOverridden()); - Console.WriteLine(Decorator.Enclose(localMethod).IsOverridden()); + public static void Demonstrate() + { + MethodInfo baseMethod = typeof(PricingCalculator).GetMethod(nameof(PricingCalculator.Calculate))!; + MethodInfo derivedMethod = typeof(RegionalPricingCalculator).GetMethod(nameof(PricingCalculator.Calculate))!; + MethodInfo localMethod = typeof(RegionalPricingCalculator).GetMethod(nameof(RegionalPricingCalculator.FormatRegion))!; + + Console.WriteLine(Decorator.Enclose(baseMethod).IsOverridden()); + Console.WriteLine(Decorator.Enclose(derivedMethod).IsOverridden()); + Console.WriteLine(Decorator.Enclose(localMethod).IsOverridden()); + } } -} - -public class PricingCalculator -{ - public virtual decimal Calculate(decimal subtotal) + public class PricingCalculator { - return subtotal; + public virtual decimal Calculate(decimal subtotal) + { + return subtotal; + } } -} - -public sealed class RegionalPricingCalculator : PricingCalculator -{ - public override decimal Calculate(decimal subtotal) + public sealed class RegionalPricingCalculator : PricingCalculator { - return subtotal * 1.25m; - } - - public string FormatRegion() - { - return "EU"; + public override decimal Calculate(decimal subtotal) + { + return subtotal * 1.25m; + } + + public string FormatRegion() + { + return "EU"; + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.MethodSignature.md b/.docfx/api/types/Cuemon.Reflection.MethodSignature.md index ec03029f3..1c255840e 100644 --- a/.docfx/api/types/Cuemon.Reflection.MethodSignature.md +++ b/.docfx/api/types/Cuemon.Reflection.MethodSignature.md @@ -7,31 +7,39 @@ example: The following example shows how to capture lightweight method metadata for logging or retry evidence. ```csharp +// Program.cs using System; using Cuemon.Reflection; +using MyApp.Examples; -namespace MyApp.Examples; +MethodSignatureExample.Demonstrate(); -public static class MethodSignatureExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class MethodSignatureExample { - var signature = new MethodSignature( - typeof(PaymentGateway).FullName ?? nameof(PaymentGateway), - nameof(PaymentGateway.Authorize), - new[] { typeof(string).Name, typeof(decimal).Name }, - new object[] { "INV-42", 19.95m }); + public static void Demonstrate() + { + var signature = new MethodSignature( + typeof(PaymentGateway).FullName ?? nameof(PaymentGateway), + nameof(PaymentGateway.Authorize), + new[] { typeof(string).Name, typeof(decimal).Name }, + new object[] { "INV-42", 19.95m }); - Console.WriteLine(signature.ToString()); - Console.WriteLine(string.Join(", ", signature.Parameters ?? Array.Empty())); - Console.WriteLine(signature.Arguments?.Length ?? 0); + Console.WriteLine(signature.ToString()); + Console.WriteLine(string.Join(", ", signature.Parameters ?? Array.Empty())); + Console.WriteLine(signature.Arguments?.Length ?? 0); + } } -} - -public sealed class PaymentGateway -{ - public void Authorize(string orderId, decimal amount) + public sealed class PaymentGateway { + public void Authorize(string orderId, decimal amount) + { + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.ParameterSignature.md b/.docfx/api/types/Cuemon.Reflection.ParameterSignature.md index ea46735e9..e4fca2b21 100644 --- a/.docfx/api/types/Cuemon.Reflection.ParameterSignature.md +++ b/.docfx/api/types/Cuemon.Reflection.ParameterSignature.md @@ -7,17 +7,12 @@ example: The following example demonstrates how to use to extract parameter information from a method. ```csharp +// Program.cs using System; using System.Linq; using System.Reflection; using Cuemon.Reflection; -namespace MyApp.Examples; - -public class ParameterSignatureExample -{ - public void Demonstrate() - { MethodInfo method = typeof(string).GetMethod("IndexOf", new[] { typeof(string), typeof(StringComparison) }); if (method != null) @@ -28,7 +23,9 @@ public class ParameterSignatureExample { Console.WriteLine($"Parameter: {signature.ParameterName}, Type: {signature.ParameterType.Name}"); -}}} -} - +}} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.PropertyInfoDecoratorExtensions.md b/.docfx/api/types/Cuemon.Reflection.PropertyInfoDecoratorExtensions.md index 166907c7e..98eb7f5ee 100644 --- a/.docfx/api/types/Cuemon.Reflection.PropertyInfoDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Reflection.PropertyInfoDecoratorExtensions.md @@ -7,38 +7,45 @@ example: `PropertyInfoDecoratorExtensions` provides extension methods on `Decorator.Enclose` for detecting auto-implemented properties and override behavior via `IsAutoProperty` and `IsOverridden`. This example retrieves `PropertyInfo` for `Product.Code` (auto-property), `Product.Label` (expression-bodied), and `FeaturedProduct.Summary` (overridden in a derived class), then calls `IsAutoProperty` on the first two and `IsOverridden` on the third. Console output shows `True` for the auto-property, `False` for the expression-bodied property, and `True` for the overridden property, confirming correct identification of property characteristics. ```csharp +// Program.cs using System; using System.Reflection; using Cuemon; using Cuemon.Reflection; +using MyApp.Examples; -namespace MyApp.Examples; +PropertyInfoDecoratorExtensionsExample.Demonstrate(); -public static class PropertyInfoDecoratorExtensionsExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class PropertyInfoDecoratorExtensionsExample { - PropertyInfo code = typeof(Product).GetProperty(nameof(Product.Code))!; - PropertyInfo label = typeof(Product).GetProperty(nameof(Product.Label))!; - PropertyInfo summary = typeof(FeaturedProduct).GetProperty(nameof(Product.Summary))!; - - Console.WriteLine(Decorator.Enclose(code).IsAutoProperty()); - Console.WriteLine(Decorator.Enclose(label).IsAutoProperty()); - Console.WriteLine(Decorator.Enclose(summary).IsOverridden()); + public static void Demonstrate() + { + PropertyInfo code = typeof(Product).GetProperty(nameof(Product.Code))!; + PropertyInfo label = typeof(Product).GetProperty(nameof(Product.Label))!; + PropertyInfo summary = typeof(FeaturedProduct).GetProperty(nameof(Product.Summary))!; + + Console.WriteLine(Decorator.Enclose(code).IsAutoProperty()); + Console.WriteLine(Decorator.Enclose(label).IsAutoProperty()); + Console.WriteLine(Decorator.Enclose(summary).IsOverridden()); + } } -} - -public class Product -{ - public string Code { get; set; } = string.Empty; - - public string Label => $"Product:{Code}"; + public class Product + { + public string Code { get; set; } = string.Empty; - public virtual string Summary => "standard"; -} + public string Label => $"Product:{Code}"; -public sealed class FeaturedProduct : Product -{ - public override string Summary => "featured"; + public virtual string Summary => "standard"; + } + public sealed class FeaturedProduct : Product + { + public override string Summary => "featured"; + } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.TargetFrameworkMoniker.md b/.docfx/api/types/Cuemon.Reflection.TargetFrameworkMoniker.md index cc36948e6..cb5891550 100644 --- a/.docfx/api/types/Cuemon.Reflection.TargetFrameworkMoniker.md +++ b/.docfx/api/types/Cuemon.Reflection.TargetFrameworkMoniker.md @@ -7,30 +7,27 @@ example: `TargetFrameworkMoniker` parses and resolves short target framework names such as `net10.0`, `net9.0`, `netstandard2.0`, and `net481` from framework names, assemblies, paths, or the current application context. ```csharp +// Program.cs using System; using System.Reflection; using Cuemon.Reflection; -namespace MyApp.Examples; +var parsed = TargetFrameworkMoniker.Parse(".NETCoreApp,Version=v10.0"); +var current = TargetFrameworkMoniker.ResolveCurrent(); +var library = TargetFrameworkMoniker.Resolve(typeof(TargetFrameworkMoniker).Assembly); +var outputPath = TargetFrameworkMoniker.ResolveFromPath(AppContext.BaseDirectory); -public class TargetFrameworkMonikerExample -{ - public void Demonstrate() - { - var parsed = TargetFrameworkMoniker.Parse(".NETCoreApp,Version=v10.0"); - var current = TargetFrameworkMoniker.ResolveCurrent(); - var library = TargetFrameworkMoniker.Resolve(typeof(TargetFrameworkMonikerExample).Assembly); - var outputPath = TargetFrameworkMoniker.ResolveFromPath(AppContext.BaseDirectory); - - Console.WriteLine($"Parsed TFM: {parsed}"); - Console.WriteLine($"Current TFM: {current}"); - Console.WriteLine($"Example assembly TFM: {library}"); - Console.WriteLine($"Output path TFM: {outputPath}"); +Console.WriteLine($"Parsed TFM: {parsed}"); +Console.WriteLine($"Current TFM: {current}"); +Console.WriteLine($"Example assembly TFM: {library}"); +Console.WriteLine($"Output path TFM: {outputPath}"); - if (TargetFrameworkMoniker.TryResolve(Assembly.GetExecutingAssembly(), out var executingAssemblyTfm)) - { - Console.WriteLine($"Executing assembly TFM: {executingAssemblyTfm}"); - } - } +if (TargetFrameworkMoniker.TryResolve(Assembly.GetExecutingAssembly(), out var executingAssemblyTfm)) +{ + Console.WriteLine($"Executing assembly TFM: {executingAssemblyTfm}"); } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.TypeNameOptions.md b/.docfx/api/types/Cuemon.Reflection.TypeNameOptions.md index 78d984cc7..79dfe6450 100644 --- a/.docfx/api/types/Cuemon.Reflection.TypeNameOptions.md +++ b/.docfx/api/types/Cuemon.Reflection.TypeNameOptions.md @@ -7,39 +7,36 @@ example: The following example demonstrates how to use `TypeNameOptions` to control the friendly name output of a `Type`. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Reflection; -namespace Examples; - -public class TypeNameFormattingExample +// Direct instantiation of TypeNameOptions +var options = new TypeNameOptions { - public void Demonstrate() - { - // Direct instantiation of TypeNameOptions - var options = new TypeNameOptions - { - FullName = true, - ExcludeGenericArguments = false - }; - - Type type = typeof(Console); - - string friendlyName = Decorator.Enclose(type).ToFriendlyName(o => - { - o.FullName = true; - o.ExcludeGenericArguments = false; - }); - // friendlyName == "System.Console" + FullName = true, + ExcludeGenericArguments = false +}; - friendlyName = Decorator.Enclose(type).ToFriendlyName(o => - { - o.FullName = false; - }); - // friendlyName == "Console" +Type type = typeof(Console); -} -} +string friendlyName = Decorator.Enclose(type).ToFriendlyName(o => +{ + o.FullName = true; + o.ExcludeGenericArguments = false; +}); +// friendlyName == "System.Console" +Console.WriteLine(friendlyName); +friendlyName = Decorator.Enclose(type).ToFriendlyName(o => +{ + o.FullName = false; +}); +// friendlyName == "Console" +Console.WriteLine(friendlyName); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Reflection.VersionResult.md b/.docfx/api/types/Cuemon.Reflection.VersionResult.md index 48c65b04f..c452b2509 100644 --- a/.docfx/api/types/Cuemon.Reflection.VersionResult.md +++ b/.docfx/api/types/Cuemon.Reflection.VersionResult.md @@ -7,32 +7,27 @@ example: The following example demonstrates how to use to work with both numerical and semantic (alphanumeric) version strings. ```csharp +// Program.cs using System; using Cuemon.Reflection; -namespace MyApp.Examples; - -public class VersionResultExample -{ - public void Demonstrate() - { - // Numerical version (parsable to System.Version) - var numeric = new VersionResult("1.2.3.4"); - Console.WriteLine($"Value: {numeric.Value}"); - Console.WriteLine($"HasAlphanumericVersion: {numeric.HasAlphanumericVersion}"); - Console.WriteLine($"IsSemanticVersion: {numeric.IsSemanticVersion()}"); - - // Semantic/alphanumeric version (not a pure numerical version) - var semantic = new VersionResult("2.0.0-beta.1"); - Console.WriteLine($"\nValue: {semantic.Value}"); - Console.WriteLine($"HasAlphanumericVersion: {semantic.HasAlphanumericVersion}"); - Console.WriteLine($"IsSemanticVersion: {semantic.IsSemanticVersion()}"); - - // Static helper check - var check = VersionResult.IsSemanticVersion("3.0.0-rc.1"); - Console.WriteLine($"\nIs '3.0.0-rc.1' semantic? {check}"); - -} -} - +// Numerical version (parsable to System.Version) +var numeric = new VersionResult("1.2.3.4"); +Console.WriteLine($"Value: {numeric.Value}"); +Console.WriteLine($"HasAlphanumericVersion: {numeric.HasAlphanumericVersion}"); +Console.WriteLine($"IsSemanticVersion: {numeric.IsSemanticVersion()}"); + +// Semantic/alphanumeric version (not a pure numerical version) +var semantic = new VersionResult("2.0.0-beta.1"); +Console.WriteLine($"\nValue: {semantic.Value}"); +Console.WriteLine($"HasAlphanumericVersion: {semantic.HasAlphanumericVersion}"); +Console.WriteLine($"IsSemanticVersion: {semantic.IsSemanticVersion()}"); + +// Static helper check +var check = VersionResult.IsSemanticVersion("3.0.0-rc.1"); +Console.WriteLine($"\nIs '3.0.0-rc.1' semantic? {check}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Resilience.AsyncTransientOperationOptions.md b/.docfx/api/types/Cuemon.Resilience.AsyncTransientOperationOptions.md index 4bd0c1939..25e357e5f 100644 --- a/.docfx/api/types/Cuemon.Resilience.AsyncTransientOperationOptions.md +++ b/.docfx/api/types/Cuemon.Resilience.AsyncTransientOperationOptions.md @@ -7,38 +7,47 @@ example: The following example demonstrates how to configure retry options for an asynchronous transient operation with exponential backoff. ```csharp +// Program.cs using System; using System.Threading.Tasks; using Cuemon.Resilience; +using Examples; -namespace Examples; +await new AsyncTransientOperationExample().ExecuteWithRetryAsync(); -public class AsyncTransientOperationExample +namespace Examples { - public async Task ExecuteWithRetryAsync() + public class AsyncTransientOperationExample { - // Direct instantiation of AsyncTransientOperationOptions - var transientOptions = new AsyncTransientOperationOptions + public async Task ExecuteWithRetryAsync() { - RetryAttempts = 3, - MaximumAllowedLatency = TimeSpan.FromSeconds(30) - }; - transientOptions.RetryStrategy = currentAttempt => TimeSpan.FromSeconds(Math.Pow(2, currentAttempt)); - transientOptions.DetectionStrategy = exception => exception is TimeoutException; + // Direct instantiation of AsyncTransientOperationOptions + var transientOptions = new AsyncTransientOperationOptions + { + RetryAttempts = 3, + MaximumAllowedLatency = TimeSpan.FromSeconds(30) + }; + transientOptions.RetryStrategy = currentAttempt => TimeSpan.FromSeconds(Math.Pow(2, currentAttempt)); + transientOptions.DetectionStrategy = exception => exception is TimeoutException; - var result = await TransientOperation.WithFuncAsync(async ct => - { - return await Task.FromResult(42); - }, o => - { - o.RetryAttempts = 3; - o.RetryStrategy = currentAttempt => TimeSpan.FromSeconds(Math.Pow(2, currentAttempt)); - o.MaximumAllowedLatency = TimeSpan.FromSeconds(30); - o.DetectionStrategy = exception => exception is TimeoutException; - }); - // result == 42 after up to 3 retries with exponential backoff + var result = await TransientOperation.WithFuncAsync(async ct => + { + return await Task.FromResult(42); + }, o => + { + o.RetryAttempts = 3; + o.RetryStrategy = currentAttempt => TimeSpan.FromSeconds(Math.Pow(2, currentAttempt)); + o.MaximumAllowedLatency = TimeSpan.FromSeconds(30); + o.DetectionStrategy = exception => exception is TimeoutException; + }); + // result == 42 after up to 3 retries with exponential backoff + Console.WriteLine(result); + } + } } -} - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Resilience.LatencyException.md b/.docfx/api/types/Cuemon.Resilience.LatencyException.md index 16836ca53..b132f4f9b 100644 --- a/.docfx/api/types/Cuemon.Resilience.LatencyException.md +++ b/.docfx/api/types/Cuemon.Resilience.LatencyException.md @@ -7,20 +7,17 @@ example: The following example demonstrates how to wrap a timeout-related failure in a . ```csharp +// Program.cs using System; using Cuemon.Resilience; -namespace MyApp.Examples; +var timeout = new TimeoutException("The database query timed out after 10 seconds."); +var exception = new LatencyException("Order processing exceeded the configured latency threshold.", timeout); -public static class LatencyExceptionExample -{ - public static void Demonstrate() - { - var timeout = new TimeoutException("The database query timed out after 10 seconds."); - var exception = new LatencyException("Order processing exceeded the configured latency threshold.", timeout); - - Console.WriteLine(exception.Message); - Console.WriteLine(exception.InnerException?.Message); - } -} +Console.WriteLine(exception.Message); +Console.WriteLine(exception.InnerException?.Message); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Resilience.TransientFaultEvidence.md b/.docfx/api/types/Cuemon.Resilience.TransientFaultEvidence.md index 8e899fdb3..068ad80ca 100644 --- a/.docfx/api/types/Cuemon.Resilience.TransientFaultEvidence.md +++ b/.docfx/api/types/Cuemon.Resilience.TransientFaultEvidence.md @@ -7,9 +7,13 @@ example: `TransientFaultEvidence` captures retry attempt details, recovery wait times, latency, and method signature information for transient fault handling scenarios. This example creates evidence with `attempts = 3`, `RecoveryWaitTime = 2s`, `TotalRecoveryWaitTime = 5s`, `Latency = 1500ms`, and a `MethodSignature` for `PaymentService.ProcessPayment`. It also demonstrates equality comparison between two identical evidence instances, and a minimal-info creation with `attempts = 1` and `Latency = 200ms` for simple scenarios. Console output displays the evidence's `ToString` representation, individual property values, equality results, and hash code consistency. ```csharp +// Program.cs using System; using Cuemon.Reflection; using Cuemon.Resilience; +using MyApp.Resilience; + +TransientFaultEvidenceExamples.CreateWithMethodSignature(); namespace MyApp.Resilience { @@ -68,3 +72,7 @@ namespace MyApp.Resilience } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Resilience.TransientFaultException.md b/.docfx/api/types/Cuemon.Resilience.TransientFaultException.md index 161d05e9c..009a86817 100644 --- a/.docfx/api/types/Cuemon.Resilience.TransientFaultException.md +++ b/.docfx/api/types/Cuemon.Resilience.TransientFaultException.md @@ -7,29 +7,26 @@ example: The following example demonstrates how to construct a with retry evidence. ```csharp +// Program.cs using System; using System.Reflection; using Cuemon.Reflection; using Cuemon.Resilience; -namespace MyApp.Examples; +var evidence = new TransientFaultEvidence( + attempts: 5, + recoveryWaitTime: TimeSpan.FromSeconds(2), + totalRecoveryWaitTime: TimeSpan.FromSeconds(10), + latency: TimeSpan.FromSeconds(1), + descriptor: MethodDescriptor.Create(MethodBase.GetCurrentMethod()!)); -public static class TransientFaultExceptionExample -{ - public static void Demonstrate() - { - var evidence = new TransientFaultEvidence( - attempts: 5, - recoveryWaitTime: TimeSpan.FromSeconds(2), - totalRecoveryWaitTime: TimeSpan.FromSeconds(10), - latency: TimeSpan.FromSeconds(1), - descriptor: MethodDescriptor.Create(MethodBase.GetCurrentMethod()!)); +var exception = new TransientFaultException("Operation failed after retries.", evidence); - var exception = new TransientFaultException("Operation failed after retries.", evidence); - - Console.WriteLine(exception.Message); - Console.WriteLine(exception.Evidence.Attempts); - Console.WriteLine(exception.Evidence.TotalRecoveryWaitTime); - } -} +Console.WriteLine(exception.Message); +Console.WriteLine(exception.Evidence.Attempts); +Console.WriteLine(exception.Evidence.TotalRecoveryWaitTime); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Resilience.TransientOperation.md b/.docfx/api/types/Cuemon.Resilience.TransientOperation.md index ac99e0da7..d203dc7cb 100644 --- a/.docfx/api/types/Cuemon.Resilience.TransientOperation.md +++ b/.docfx/api/types/Cuemon.Resilience.TransientOperation.md @@ -7,27 +7,35 @@ example: The following example shows how to execute an HTTP request with retry logic using `TransientOperation`. It configures three retry attempts with exponential backoff and prints the response length on success. ```csharp +// Program.cs using System; using System.Net.Http; using Cuemon.Resilience; -namespace Cuemon.Resilience; +new TransientOperationExample().Demonstrate(); -public class TransientOperationExample +namespace Cuemon.Resilience { - public void Demonstrate() + public class TransientOperationExample { - var result = TransientOperation.WithFunc(() => + public void Demonstrate() { - using var client = new HttpClient(); - return client.GetStringAsync("https://example.com").Result; - }, options => - { - options.RetryAttempts = 3; - options.RetryStrategy = attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)); - }); + var result = TransientOperation.WithFunc(() => + { + using var client = new HttpClient(); + return client.GetStringAsync("https://example.com").Result; + }, options => + { + options.RetryAttempts = 3; + options.RetryStrategy = attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)); + }); - Console.WriteLine($"Response length: {result.Length}"); + Console.WriteLine($"Response length: {result.Length}"); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Resilience.TransientOperationOptions.md b/.docfx/api/types/Cuemon.Resilience.TransientOperationOptions.md index 576986290..d8e25c909 100644 --- a/.docfx/api/types/Cuemon.Resilience.TransientOperationOptions.md +++ b/.docfx/api/types/Cuemon.Resilience.TransientOperationOptions.md @@ -7,30 +7,27 @@ example: The following example demonstrates how to configure for retry attempts, transient-fault detection, and latency limits. ```csharp +// Program.cs using System; using System.Net.Http; using Cuemon.Resilience; -namespace MyApp.Examples; - -public static class TransientOperationOptionsExample +var options = new TransientOperationOptions { - public static void Demonstrate() - { - var options = new TransientOperationOptions - { - RetryAttempts = 3, - RetryStrategy = attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)), - DetectionStrategy = exception => exception is HttpRequestException, - MaximumAllowedLatency = TimeSpan.FromSeconds(30) - }; + RetryAttempts = 3, + RetryStrategy = attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)), + DetectionStrategy = exception => exception is HttpRequestException, + MaximumAllowedLatency = TimeSpan.FromSeconds(30) +}; - options.ValidateOptions(); +options.ValidateOptions(); - Console.WriteLine(options.RetryAttempts); - Console.WriteLine(options.EnableRecovery); - Console.WriteLine(options.MaximumAllowedLatency); - Console.WriteLine(options.DetectionStrategy(new HttpRequestException("Network timeout simulated."))); - } -} +Console.WriteLine(options.RetryAttempts); +Console.WriteLine(options.EnableRecovery); +Console.WriteLine(options.MaximumAllowedLatency); +Console.WriteLine(options.DetectionStrategy(new HttpRequestException("Network timeout simulated."))); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Runtime.Caching.CacheEntry.md b/.docfx/api/types/Cuemon.Runtime.Caching.CacheEntry.md index 20dd5e373..336efbab4 100644 --- a/.docfx/api/types/Cuemon.Runtime.Caching.CacheEntry.md +++ b/.docfx/api/types/Cuemon.Runtime.Caching.CacheEntry.md @@ -7,23 +7,20 @@ example: The following example demonstrates how to register a cache entry with invalidation rules and inspect its expiration behavior. ```csharp +// Program.cs using System; using Cuemon.Runtime.Caching; -namespace MyApp.Examples; +var cache = new SlimMemoryCache(); +var entry = new CacheEntry("session", "cached-value", "docs"); -public static class CacheEntryExample -{ - public static void Demonstrate() - { - var cache = new SlimMemoryCache(); - var entry = new CacheEntry("session", "cached-value", "docs"); +cache.Add(entry, new CacheInvalidation(TimeSpan.FromSeconds(30))); - cache.Add(entry, new CacheInvalidation(TimeSpan.FromSeconds(30))); - - Console.WriteLine(entry.CanExpire); - Console.WriteLine(entry.HasExpired(entry.Accessed.AddSeconds(31))); - Console.WriteLine(entry.ToString().Contains("Key=session")); - } -} +Console.WriteLine(entry.CanExpire); +Console.WriteLine(entry.HasExpired(entry.Accessed.AddSeconds(31))); +Console.WriteLine(entry.ToString().Contains("Key=session")); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Runtime.Caching.CacheEntryEventArgs.md b/.docfx/api/types/Cuemon.Runtime.Caching.CacheEntryEventArgs.md index d1a8a736a..8abab7b6b 100644 --- a/.docfx/api/types/Cuemon.Runtime.Caching.CacheEntryEventArgs.md +++ b/.docfx/api/types/Cuemon.Runtime.Caching.CacheEntryEventArgs.md @@ -7,56 +7,65 @@ example: The following example demonstrates how is delivered when a dependency invalidates a cache entry. ```csharp +// Program.cs using System; using System.Threading.Tasks; using Cuemon.Runtime; using Cuemon.Runtime.Caching; +using MyApp.Examples; -namespace MyApp.Examples; +CacheEntryEventArgsExample.Demonstrate(); -public static class CacheEntryEventArgsExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class CacheEntryEventArgsExample { - var cache = new SlimMemoryCache(); - var dependency = new DependencyStub(); - var entry = new CacheEntry("key", "value"); - CacheEntryEventArgs captured = null; - - entry.Expired += (_, e) => + public static void Demonstrate() { - captured = e; - }; + var cache = new SlimMemoryCache(); + var dependency = new DependencyStub(); + var entry = new CacheEntry("key", "value"); + CacheEntryEventArgs captured = null; - cache.Add(entry, new CacheInvalidation(new[] { dependency })); - dependency.SignalChanged(); + entry.Expired += (_, e) => + { + captured = e; + }; - Console.WriteLine($"Cache entry expired: {captured is not null}"); - } + cache.Add(entry, new CacheInvalidation(new[] { dependency })); + dependency.SignalChanged(); - private sealed class DependencyStub : IDependency - { - public event EventHandler DependencyChanged; + Console.WriteLine($"Cache entry expired: {captured is not null}"); + } - public DateTime? UtcLastModified { get; private set; } + private sealed class DependencyStub : IDependency + { + public event EventHandler DependencyChanged; - public bool HasChanged { get; private set; } + public DateTime? UtcLastModified { get; private set; } - public void Start() - { - } + public bool HasChanged { get; private set; } - public Task StartAsync() - { - return Task.CompletedTask; - } + public void Start() + { + } - public void SignalChanged() - { - UtcLastModified = DateTime.UtcNow; - HasChanged = true; - DependencyChanged?.Invoke(this, new DependencyEventArgs(UtcLastModified.Value)); + public Task StartAsync() + { + return Task.CompletedTask; + } + + public void SignalChanged() + { + UtcLastModified = DateTime.UtcNow; + HasChanged = true; + DependencyChanged?.Invoke(this, new DependencyEventArgs(UtcLastModified.Value)); + } } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Runtime.Caching.CacheInvalidation.md b/.docfx/api/types/Cuemon.Runtime.Caching.CacheInvalidation.md index 32970ede3..ee5a8fb6a 100644 --- a/.docfx/api/types/Cuemon.Runtime.Caching.CacheInvalidation.md +++ b/.docfx/api/types/Cuemon.Runtime.Caching.CacheInvalidation.md @@ -7,29 +7,24 @@ example: The following example demonstrates how to use to define eviction policies for cache entries. ```csharp +// Program.cs using System; using Cuemon.Runtime.Caching; // for CacheInvalidation -namespace MyApp.Examples; - -public class CacheInvalidationExample -{ - public void Demonstrate() - { - // Absolute expiration at a specific UTC time - var absolute = new CacheInvalidation(new DateTime(2025, 12, 31, 23, 59, 59, DateTimeKind.Utc)); - Console.WriteLine(absolute.UseAbsoluteExpiration); // True - Console.WriteLine(absolute.AbsoluteExpiration); // 12/31/2025 23:59:59 - Console.WriteLine(absolute.UseSlidingExpiration); // False - Console.WriteLine(absolute.UseDependency); // False - - // Sliding expiration (entry expires after 30 minutes of inactivity) - var sliding = new CacheInvalidation(TimeSpan.FromMinutes(30)); - Console.WriteLine(sliding.UseSlidingExpiration); // True - Console.WriteLine(sliding.SlidingExpiration); // 00:30:00 - Console.WriteLine(sliding.UseAbsoluteExpiration); // False - -} -} +// Absolute expiration at a specific UTC time +var absolute = new CacheInvalidation(new DateTime(2025, 12, 31, 23, 59, 59, DateTimeKind.Utc)); +Console.WriteLine(absolute.UseAbsoluteExpiration); // True +Console.WriteLine(absolute.AbsoluteExpiration); // 12/31/2025 23:59:59 +Console.WriteLine(absolute.UseSlidingExpiration); // False +Console.WriteLine(absolute.UseDependency); // False +// Sliding expiration (entry expires after 30 minutes of inactivity) +var sliding = new CacheInvalidation(TimeSpan.FromMinutes(30)); +Console.WriteLine(sliding.UseSlidingExpiration); // True +Console.WriteLine(sliding.SlidingExpiration); // 00:30:00 +Console.WriteLine(sliding.UseAbsoluteExpiration); // False ``` + + + + diff --git a/.docfx/api/types/Cuemon.Runtime.Caching.CachingManager.md b/.docfx/api/types/Cuemon.Runtime.Caching.CachingManager.md index 9fa193062..165a2c764 100644 --- a/.docfx/api/types/Cuemon.Runtime.Caching.CachingManager.md +++ b/.docfx/api/types/Cuemon.Runtime.Caching.CachingManager.md @@ -7,27 +7,24 @@ example: The following example demonstrates how to get or add a cached value using `CachingManager.Cache`. It checks for an existing key, adds a value with a 5-minute expiration if not found, and verifies the cached instance is reused on subsequent accesses. ```csharp +// Program.cs using System; using Cuemon.Runtime.Caching; -namespace Cuemon.Runtime.Caching; - -public class CachingManagerExample +var cache = CachingManager.Cache; +var key = "myKey"; +var value = cache.Get(key); +if (value == null) { - public void Demonstrate() - { - var cache = CachingManager.Cache; - var key = "myKey"; - var value = cache.Get(key); - if (value == null) - { - cache.Add(key, DateTime.UtcNow, TimeSpan.FromMinutes(5)); - } - value = cache.Get(key); - Console.WriteLine($"Cached value: {value}"); - - var sameValue = cache.Get(key); - Console.WriteLine($"Same instance? {value == sameValue}"); - } + cache.Add(key, DateTime.UtcNow, TimeSpan.FromMinutes(5)); } +value = cache.Get(key); +Console.WriteLine($"Cached value: {value}"); + +var sameValue = cache.Get(key); +Console.WriteLine($"Same instance? {value == sameValue}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Runtime.Caching.SlimMemoryCache.md b/.docfx/api/types/Cuemon.Runtime.Caching.SlimMemoryCache.md index 9f826c351..7d8383023 100644 --- a/.docfx/api/types/Cuemon.Runtime.Caching.SlimMemoryCache.md +++ b/.docfx/api/types/Cuemon.Runtime.Caching.SlimMemoryCache.md @@ -7,16 +7,10 @@ example: `SlimMemoryCache` provides in-memory caching with absolute and sliding expiration, namespace grouping, and automatic cleanup. This example creates a cache with cleanup enabled (`FirstSweep = 30s`, `SucceedingSweep = 10s`), adds a config entry with absolute expiration, a session entry with sliding expiration under the `"sessions"` namespace, and updates the config entry via the indexer. It demonstrates safe retrieval with `TryGet`, key-based removal with `Remove`, namespace-based counting with `Count("data")`, and bulk namespace removal with `RemoveAll("data")`. Console output confirms the cached values, update status, removal success, and namespace counts before and after removal. ```csharp +// Program.cs using System; using Cuemon.Runtime.Caching; -namespace MyApp.Examples; - -public class Example -{ - public void Run() - { - // Create a cache with automatic cleanup var cache = new SlimMemoryCache(o => { @@ -59,7 +53,9 @@ public class Example cache.Dispose(); -}}} -} - +}} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Runtime.Caching.SlimMemoryCacheOptions.md b/.docfx/api/types/Cuemon.Runtime.Caching.SlimMemoryCacheOptions.md index b8e5a26c8..d1078fb6c 100644 --- a/.docfx/api/types/Cuemon.Runtime.Caching.SlimMemoryCacheOptions.md +++ b/.docfx/api/types/Cuemon.Runtime.Caching.SlimMemoryCacheOptions.md @@ -7,28 +7,25 @@ example: The following example demonstrates how to configure for sweep intervals and cache-key generation. ```csharp +// Program.cs using System; using Cuemon.Runtime.Caching; -namespace MyApp.Examples; - -public static class SlimMemoryCacheOptionsExample +var options = new SlimMemoryCacheOptions { - public static void Demonstrate() - { - var options = new SlimMemoryCacheOptions - { - EnableCleanup = false, - FirstSweep = TimeSpan.FromSeconds(10), - SucceedingSweep = TimeSpan.FromSeconds(30), - KeyProvider = (key, ns) => key.Length + (ns == CacheEntry.NoScope ? 0 : ns.Length) - }; + EnableCleanup = false, + FirstSweep = TimeSpan.FromSeconds(10), + SucceedingSweep = TimeSpan.FromSeconds(30), + KeyProvider = (key, ns) => key.Length + (ns == CacheEntry.NoScope ? 0 : ns.Length) +}; - options.ValidateOptions(); +options.ValidateOptions(); - Console.WriteLine(options.EnableCleanup); - Console.WriteLine(options.FirstSweep); - Console.WriteLine(options.KeyProvider("session", "docs")); - } -} +Console.WriteLine(options.EnableCleanup); +Console.WriteLine(options.FirstSweep); +Console.WriteLine(options.KeyProvider("session", "docs")); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Runtime.DependencyEventArgs.md b/.docfx/api/types/Cuemon.Runtime.DependencyEventArgs.md index edf894a44..0db29033b 100644 --- a/.docfx/api/types/Cuemon.Runtime.DependencyEventArgs.md +++ b/.docfx/api/types/Cuemon.Runtime.DependencyEventArgs.md @@ -7,8 +7,12 @@ example: `DependencyEventArgs` provides event data for dependency change notifications, carrying the UTC timestamp of the last modification. This example creates event args with `DateTime.UtcNow`, a specific past timestamp (`2026-06-01T12:00:00Z`), and the `Empty` sentinel representing no change. It also demonstrates raising a `DependencyChanged` event from a custom `DependencyMonitor` class and handling it to print the UTC timestamp. Console output displays the last modified timestamp in ISO 8601 format, confirms the `Empty` sentinel returns `MinValue`, and shows event-driven output. ```csharp +// Program.cs using System; using Cuemon.Runtime; +using MyApp.Runtime; + +DependencyEventArgsExamples.CreateEventArgs(); namespace MyApp.Runtime { @@ -58,4 +62,8 @@ namespace MyApp.Runtime } } } -``` \ No newline at end of file +``` + + + + \ No newline at end of file diff --git a/.docfx/api/types/Cuemon.Runtime.FileDependency.md b/.docfx/api/types/Cuemon.Runtime.FileDependency.md index 65c734256..63ca2dbea 100644 --- a/.docfx/api/types/Cuemon.Runtime.FileDependency.md +++ b/.docfx/api/types/Cuemon.Runtime.FileDependency.md @@ -7,35 +7,34 @@ example: `FileDependency` defers `FileWatcher` creation until monitoring begins by accepting a `Lazy` factory. This example creates a temporary `settings.json` file, wraps a `FileWatcher` in a `Lazy<>` with a 500ms polling period, and passes it to `FileDependency` with `breakTieOnChanged: true`. Key steps include checking `lazyWatcher.IsValueCreated` before and after `StartAsync` to confirm deferred creation, subscribing to `DependencyChanged`, and inspecting `HasChanged` after signaling. Console output shows the watcher creation status, `BreakTieOnChanged` value, and the changed state. ```csharp +// Program.cs using System; using System.IO; using System.Threading.Tasks; using Cuemon.Runtime; -namespace MyApp.Examples; +string directory = Path.Combine(Path.GetTempPath(), "cuemon-docs"); +Directory.CreateDirectory(directory); +string filePath = Path.Combine(directory, "settings.json"); +File.WriteAllText(filePath, "{ }"); -public static class FileDependencyExample +var lazyWatcher = new Lazy(() => new FileWatcher(filePath, false, options => { - public static async Task DemonstrateAsync() - { - string filePath = Path.Combine(Environment.CurrentDirectory, "settings.json"); - File.WriteAllText(filePath, "{ }"); + options.Period = TimeSpan.FromMilliseconds(500); +})); - var lazyWatcher = new Lazy(() => new FileWatcher(filePath, false, options => - { - options.Period = TimeSpan.FromMilliseconds(500); - })); +var dependency = new FileDependency(lazyWatcher, breakTieOnChanged: true); +dependency.DependencyChanged += static (_, e) => Console.WriteLine(e.UtcLastModified.ToString("O")); - var dependency = new FileDependency(lazyWatcher, breakTieOnChanged: true); - dependency.DependencyChanged += static (_, e) => Console.WriteLine(e.UtcLastModified.ToString("O")); +Console.WriteLine(lazyWatcher.IsValueCreated); +Console.WriteLine(dependency.BreakTieOnChanged); - Console.WriteLine(lazyWatcher.IsValueCreated); - Console.WriteLine(dependency.BreakTieOnChanged); +await dependency.StartAsync(); - await dependency.StartAsync(); - - Console.WriteLine(lazyWatcher.IsValueCreated); - Console.WriteLine(dependency.HasChanged); - } -} +Console.WriteLine(lazyWatcher.IsValueCreated); +Console.WriteLine(dependency.HasChanged); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Runtime.FileWatcher.md b/.docfx/api/types/Cuemon.Runtime.FileWatcher.md index 9fb807ac7..3199bdb09 100644 --- a/.docfx/api/types/Cuemon.Runtime.FileWatcher.md +++ b/.docfx/api/types/Cuemon.Runtime.FileWatcher.md @@ -7,35 +7,34 @@ example: The following example shows how to start a file watcher, observe change notifications, and pause signaling again. ```csharp +// Program.cs using System; using System.IO; using System.Threading; using Cuemon.Runtime; -namespace MyApp.Examples; +string directory = Path.Combine(Path.GetTempPath(), "cuemon-docs"); +Directory.CreateDirectory(directory); +string filePath = Path.Combine(directory, "health.txt"); +File.WriteAllText(filePath, "ready"); -public static class FileWatcherExample +using var watcher = new FileWatcher(filePath, readFile: true, options => { - public static void Demonstrate() - { - string filePath = Path.Combine(Environment.CurrentDirectory, "health.txt"); - File.WriteAllText(filePath, "ready"); - - using var watcher = new FileWatcher(filePath, readFile: true, options => - { - options.DueTime = TimeSpan.Zero; - options.Period = TimeSpan.FromSeconds(5); - options.DueTimeOnChanged = TimeSpan.FromMilliseconds(250); - }); - - watcher.Changed += static (_, e) => Console.WriteLine($"{e.UtcLastModified:O} ({e.Delayed.TotalMilliseconds} ms)"); - watcher.StartMonitoring(); - - Console.WriteLine(watcher.Path); - Console.WriteLine(watcher.ReadFile); - Console.WriteLine(watcher.UtcCreated.ToString("O")); - - watcher.ChangeSignaling(Timeout.InfiniteTimeSpan); - } -} + options.DueTime = TimeSpan.Zero; + options.Period = TimeSpan.FromSeconds(5); + options.DueTimeOnChanged = TimeSpan.FromMilliseconds(250); +}); + +watcher.Changed += static (_, e) => Console.WriteLine($"{e.UtcLastModified:O} ({e.Delayed.TotalMilliseconds} ms)"); +watcher.StartMonitoring(); + +Console.WriteLine(watcher.Path); +Console.WriteLine(watcher.ReadFile); +Console.WriteLine(watcher.UtcCreated.ToString("O")); + +watcher.ChangeSignaling(Timeout.InfiniteTimeSpan); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Runtime.Serialization.Formatters.Formatter.md b/.docfx/api/types/Cuemon.Runtime.Serialization.Formatters.Formatter.md index 496c6e336..10a4ac76b 100644 --- a/.docfx/api/types/Cuemon.Runtime.Serialization.Formatters.Formatter.md +++ b/.docfx/api/types/Cuemon.Runtime.Serialization.Formatters.Formatter.md @@ -7,22 +7,19 @@ example: The following example shows how to resolve .NET types from qualified type-name strings using the `Formatter` class. It demonstrates both a direct resolution and a safe TryGetType call that avoids exceptions. ```csharp +// Program.cs using System; using Cuemon.Runtime.Serialization.Formatters; -namespace Cuemon.Runtime.Serialization.Formatters; +var type = Formatter.GetType("System.DateTime, mscorlib"); +Console.WriteLine($"Resolved type: {type}"); -public class FormatterExample +if (Formatter.TryGetType("Cuemon.GuidStringOptions, Cuemon.Core", out var optionsType)) { - public void Demonstrate() - { - var type = Formatter.GetType("System.DateTime, mscorlib"); - Console.WriteLine($"Resolved type: {type}"); - - if (Formatter.TryGetType("Cuemon.GuidStringOptions, Cuemon.Core", out var optionsType)) - { - Console.WriteLine($"Found type: {optionsType}"); - } - } + Console.WriteLine($"Found type: {optionsType}"); } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Runtime.WatcherEventArgs.md b/.docfx/api/types/Cuemon.Runtime.WatcherEventArgs.md index d6b5dc2ab..87b6ede9f 100644 --- a/.docfx/api/types/Cuemon.Runtime.WatcherEventArgs.md +++ b/.docfx/api/types/Cuemon.Runtime.WatcherEventArgs.md @@ -7,22 +7,19 @@ example: The following example shows the information a watcher passes along when a resource change is raised. ```csharp +// Program.cs using System; using Cuemon.Runtime; -namespace MyApp.Examples; +var immediate = new WatcherEventArgs(DateTime.UtcNow); +var postponed = new WatcherEventArgs(DateTime.UtcNow.AddSeconds(-5), TimeSpan.FromMilliseconds(250)); +var empty = WatcherEventArgs.Empty; -public static class WatcherEventArgsExample -{ - public static void Demonstrate() - { - var immediate = new WatcherEventArgs(DateTime.UtcNow); - var postponed = new WatcherEventArgs(DateTime.UtcNow.AddSeconds(-5), TimeSpan.FromMilliseconds(250)); - var empty = WatcherEventArgs.Empty; - - Console.WriteLine(immediate.UtcLastModified.Kind); - Console.WriteLine(postponed.Delayed.TotalMilliseconds); - Console.WriteLine(empty.UtcLastModified == DateTime.MinValue); - } -} +Console.WriteLine(immediate.UtcLastModified.Kind); +Console.WriteLine(postponed.Delayed.TotalMilliseconds); +Console.WriteLine(empty.UtcLastModified == DateTime.MinValue); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Runtime.WatcherOptions.md b/.docfx/api/types/Cuemon.Runtime.WatcherOptions.md index 940949866..1ade7a6f1 100644 --- a/.docfx/api/types/Cuemon.Runtime.WatcherOptions.md +++ b/.docfx/api/types/Cuemon.Runtime.WatcherOptions.md @@ -7,23 +7,31 @@ example: The following example demonstrates how to configure a `WatcherOptions` for a file system watcher. ```csharp +// Program.cs using System; using Cuemon.Runtime; +using Examples; -namespace Examples; +Console.WriteLine(new WatcherConfigurationExample().ConfigureWatcher()); -public class WatcherConfigurationExample +namespace Examples { - public WatcherOptions ConfigureWatcher() + public class WatcherConfigurationExample { - return new WatcherOptions + public WatcherOptions ConfigureWatcher() { - DueTime = TimeSpan.FromSeconds(5), - DueTimeOnChanged = TimeSpan.FromSeconds(2), - Period = TimeSpan.FromMinutes(1) - }; + return new WatcherOptions + { + DueTime = TimeSpan.FromSeconds(5), + DueTimeOnChanged = TimeSpan.FromSeconds(2), + Period = TimeSpan.FromMinutes(1) + }; + } + } } -} - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.AesCryptor.md b/.docfx/api/types/Cuemon.Security.Cryptography.AesCryptor.md index f5de17cbe..eccf6ae02 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.AesCryptor.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.AesCryptor.md @@ -7,10 +7,14 @@ example: `AesCryptor` provides AES encryption and decryption with configurable key size, cipher mode, and padding. This example generates a 256-bit key and 128-bit IV using `AesCryptor.GenerateKey()` and `GenerateInitializationVector()`, encrypts `"This is a sensitive message that needs encryption."`, decrypts the ciphertext, and verifies the round-trip matches the original. It also demonstrates explicit CBC mode with PKCS7 padding via an options delegate, custom key sizes (`AesSize.Aes128` and `AesSize.Aes192`), and the default constructor that generates random credentials automatically. Console output confirms key and IV lengths, base64 ciphertext, round-trip success, and explicit options round-trip verification. ```csharp +// Program.cs using System; using System.Security.Cryptography; using System.Text; using Cuemon.Security.Cryptography; +using MyApp.Security; + +AesCryptorExamples.Demonstrate(); namespace MyApp.Security { @@ -87,5 +91,8 @@ namespace MyApp.Security } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.AesCryptorOptions.md b/.docfx/api/types/Cuemon.Security.Cryptography.AesCryptorOptions.md index 395dcf598..b8bc5200f 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.AesCryptorOptions.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.AesCryptorOptions.md @@ -7,71 +7,66 @@ example: The following example demonstrates how to configure AesCryptorOptions to specify cipher mode and padding when performing AES encryption and decryption. ```csharp +// Program.cs using System; using System.Security.Cryptography; using System.Text; using Cuemon.Security.Cryptography; -namespace MyApp.Security; +// Generate a key and initialization vector +byte[] key = AesCryptor.GenerateKey(); +byte[] iv = AesCryptor.GenerateInitializationVector(); -public class AesCryptorOptionsExample -{ - public void Demonstrate() - { - // Generate a key and initialization vector - byte[] key = AesCryptor.GenerateKey(); - byte[] iv = AesCryptor.GenerateInitializationVector(); - - // Create an AES cryptor with the key and IV - var cryptor = new AesCryptor(key, iv); - - // Encrypt data using default options (CBC mode, PKCS7 padding) - byte[] plaintext = Encoding.UTF8.GetBytes("Secret message."); - byte[] encrypted = cryptor.Encrypt(plaintext); - Console.WriteLine($"Encrypted ({encrypted.Length} bytes): {Convert.ToBase64String(encrypted)}"); +// Create an AES cryptor with the key and IV +var cryptor = new AesCryptor(key, iv); - // Decrypt with default options - byte[] decrypted = cryptor.Decrypt(encrypted); - Console.WriteLine($"Decrypted: {Encoding.UTF8.GetString(decrypted)}"); // Secret message. +// Encrypt data using default options (CBC mode, PKCS7 padding) +byte[] plaintext = Encoding.UTF8.GetBytes("Secret message."); +byte[] encrypted = cryptor.Encrypt(plaintext); +Console.WriteLine($"Encrypted ({encrypted.Length} bytes): {Convert.ToBase64String(encrypted)}"); - // Create options explicitly and copy settings via delegate - var defaultOptions = new AesCryptorOptions(); - defaultOptions.Mode = CipherMode.CBC; - defaultOptions.Padding = PaddingMode.PKCS7; +// Decrypt with default options +byte[] decrypted = cryptor.Decrypt(encrypted); +Console.WriteLine($"Decrypted: {Encoding.UTF8.GetString(decrypted)}"); // Secret message. - // Encrypt with explicit cipher mode and padding via delegate from AesCryptorOptions - byte[] plaintext2 = Encoding.UTF8.GetBytes("Configured encryption."); - byte[] encrypted2 = cryptor.Encrypt(plaintext2, o => - { - o.Mode = defaultOptions.Mode; - o.Padding = defaultOptions.Padding; - }); +// Create options explicitly and copy settings via delegate +var defaultOptions = new AesCryptorOptions(); +defaultOptions.Mode = CipherMode.CBC; +defaultOptions.Padding = PaddingMode.PKCS7; - // Decrypt using the same options - byte[] decrypted2 = cryptor.Decrypt(encrypted2, o => - { - o.Mode = defaultOptions.Mode; - o.Padding = defaultOptions.Padding; - }); - Console.WriteLine($"Decrypted: {Encoding.UTF8.GetString(decrypted2)}"); // Configured encryption. - - // Using ECB mode with Zeros padding (not recommended for production) - defaultOptions.Mode = CipherMode.ECB; - defaultOptions.Padding = PaddingMode.Zeros; - byte[] plaintext3 = Encoding.UTF8.GetBytes("Alternative mode."); - byte[] encrypted3 = cryptor.Encrypt(plaintext3, o => - { - o.Mode = defaultOptions.Mode; - o.Padding = defaultOptions.Padding; - }); - byte[] decrypted3 = cryptor.Decrypt(encrypted3, o => - { - o.Mode = defaultOptions.Mode; - o.Padding = defaultOptions.Padding; - }); - Console.WriteLine($"Decrypted: {Encoding.UTF8.GetString(decrypted3)}"); // Alternative mode. +// Encrypt with explicit cipher mode and padding via delegate from AesCryptorOptions +byte[] plaintext2 = Encoding.UTF8.GetBytes("Configured encryption."); +byte[] encrypted2 = cryptor.Encrypt(plaintext2, o => +{ + o.Mode = defaultOptions.Mode; + o.Padding = defaultOptions.Padding; +}); -} -} +// Decrypt using the same options +byte[] decrypted2 = cryptor.Decrypt(encrypted2, o => +{ + o.Mode = defaultOptions.Mode; + o.Padding = defaultOptions.Padding; +}); +Console.WriteLine($"Decrypted: {Encoding.UTF8.GetString(decrypted2)}"); // Configured encryption. +// Using ECB mode with Zeros padding (not recommended for production) +defaultOptions.Mode = CipherMode.ECB; +defaultOptions.Padding = PaddingMode.Zeros; +byte[] plaintext3 = Encoding.UTF8.GetBytes("Alternative mode."); +byte[] encrypted3 = cryptor.Encrypt(plaintext3, o => +{ + o.Mode = defaultOptions.Mode; + o.Padding = defaultOptions.Padding; +}); +byte[] decrypted3 = cryptor.Decrypt(encrypted3, o => +{ + o.Mode = defaultOptions.Mode; + o.Padding = defaultOptions.Padding; +}); +Console.WriteLine($"Decrypted: {Encoding.UTF8.GetString(decrypted3)}"); // Alternative mode. ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.AesKeyOptions.md b/.docfx/api/types/Cuemon.Security.Cryptography.AesKeyOptions.md index 9fc9dcc23..78da6188d 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.AesKeyOptions.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.AesKeyOptions.md @@ -7,8 +7,12 @@ example: The following example demonstrates how to configure AesKeyOptions to specify the key size and custom random string provider when generating AES keys. ```csharp +// Program.cs using System; using Cuemon.Security.Cryptography; +using MyApp.Security.Cryptography; + +AesKeyOptionsExamples.ConfigureKeySize(); namespace MyApp.Security.Cryptography { @@ -63,5 +67,8 @@ namespace MyApp.Security.Cryptography } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.AesSize.md b/.docfx/api/types/Cuemon.Security.Cryptography.AesSize.md index ce8aa896a..42583e577 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.AesSize.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.AesSize.md @@ -7,42 +7,37 @@ example: The following example demonstrates how to select AES key sizes using the AesSize enumeration when generating cryptographic keys. ```csharp +// Program.cs using System; using Cuemon.Security.Cryptography; -namespace MyApp.Security; +// AesSize specifies the key size for the AES symmetric algorithm: +// Aes128 = 128-bit key (16 bytes) +// Aes192 = 192-bit key (24 bytes) +// Aes256 = 256-bit key (32 bytes, default) -public class AesSizeExample -{ - public void Demonstrate() - { - // AesSize specifies the key size for the AES symmetric algorithm: - // Aes128 = 128-bit key (16 bytes) - // Aes192 = 192-bit key (24 bytes) - // Aes256 = 256-bit key (32 bytes, default) +// Generate a 256-bit key (default when no options are specified) +byte[] defaultKey = AesCryptor.GenerateKey(); +Console.WriteLine($"Default key length: {defaultKey.Length} bytes"); // 32 - // Generate a 256-bit key (default when no options are specified) - byte[] defaultKey = AesCryptor.GenerateKey(); - Console.WriteLine($"Default key length: {defaultKey.Length} bytes"); // 32 +// Generate a 128-bit key using AesSize.Aes128 +byte[] key128 = AesCryptor.GenerateKey(o => o.Size = AesSize.Aes128); +Console.WriteLine($"128-bit key length: {key128.Length} bytes"); // 16 - // Generate a 128-bit key using AesSize.Aes128 - byte[] key128 = AesCryptor.GenerateKey(o => o.Size = AesSize.Aes128); - Console.WriteLine($"128-bit key length: {key128.Length} bytes"); // 16 +// Generate a 192-bit key using AesSize.Aes192 +byte[] key192 = AesCryptor.GenerateKey(o => o.Size = AesSize.Aes192); +Console.WriteLine($"192-bit key length: {key192.Length} bytes"); // 24 - // Generate a 192-bit key using AesSize.Aes192 - byte[] key192 = AesCryptor.GenerateKey(o => o.Size = AesSize.Aes192); - Console.WriteLine($"192-bit key length: {key192.Length} bytes"); // 24 - - // Generate a 256-bit key explicitly using AesSize.Aes256 - byte[] key256 = AesCryptor.GenerateKey(o => o.Size = AesSize.Aes256); - Console.WriteLine($"256-bit key length: {key256.Length} bytes"); // 32 - - // Compare enum values directly - AesSize size = AesSize.Aes256; - Console.WriteLine($"Selected size: {size}"); // Aes256 - Console.WriteLine($"Is Aes256 selected: {size == AesSize.Aes256}"); // True - -} -} +// Generate a 256-bit key explicitly using AesSize.Aes256 +byte[] key256 = AesCryptor.GenerateKey(o => o.Size = AesSize.Aes256); +Console.WriteLine($"256-bit key length: {key256.Length} bytes"); // 32 +// Compare enum values directly +AesSize size = AesSize.Aes256; +Console.WriteLine($"Selected size: {size}"); // Aes256 +Console.WriteLine($"Is Aes256 selected: {size == AesSize.Aes256}"); // True ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.HmacMessageDigest5.md b/.docfx/api/types/Cuemon.Security.Cryptography.HmacMessageDigest5.md index 7b03a3be3..e5b76c546 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.HmacMessageDigest5.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.HmacMessageDigest5.md @@ -7,12 +7,16 @@ example: `HmacMessageDigest5` computes and verifies HMAC-MD5 message authentication codes with support for custom byte order and direct string input. This example creates a 64-byte secret key, computes the HMAC of `"Important: Transfer $100 to account 12345"`, then verifies it by recomputing with the same secret. A tampered message with a different account number produces a different HMAC, confirming tamper detection. It also demonstrates options-based construction with `Endianness.LittleEndian` and direct `ComputeHash(string)` overload. Console output shows the hex and base64 HMAC values, verification status (`True`), tamper detection (`False`), and options-based result. ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security; using Cuemon.Security.Cryptography; - using Cuemon; +using MyApp.Security; + +HmacMessageDigest5Examples.Demonstrate(); + namespace MyApp.Security { public static class HmacMessageDigest5Examples @@ -62,3 +66,7 @@ namespace MyApp.Security } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm1.md b/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm1.md index dd8644fa5..e73ff5d56 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm1.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm1.md @@ -7,23 +7,32 @@ example: The following example demonstrates how to compute an HMAC-SHA1 hash with . ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security.Cryptography; +using MyApp.Examples; -namespace MyApp.Examples; +HmacSecureHashAlgorithm1Example.Demonstrate(); -public static class HmacSecureHashAlgorithm1Example +namespace MyApp.Examples { - public static void Demonstrate() + public static class HmacSecureHashAlgorithm1Example { - var algorithm = new HmacSecureHashAlgorithm1(CreateSecret(), null); - var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("Authenticate this message")); + public static void Demonstrate() + { + var algorithm = new HmacSecureHashAlgorithm1(CreateSecret(), null); + var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("Authenticate this message")); - Console.WriteLine(result.GetBytes().Length); - Console.WriteLine(result.ToBase64String()); - } + Console.WriteLine(result.GetBytes().Length); + Console.WriteLine(result.ToBase64String()); + } - private static byte[] CreateSecret() => Encoding.UTF8.GetBytes("docs-secret-sha1"); + private static byte[] CreateSecret() => Encoding.UTF8.GetBytes("docs-secret-sha1"); + } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm256.md b/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm256.md index 28e96f458..4dcea7e3f 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm256.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm256.md @@ -7,23 +7,20 @@ example: The following example demonstrates how to compute an HMAC-SHA256 hash with . ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security.Cryptography; -namespace MyApp.Examples; +var secret = Encoding.UTF8.GetBytes("unittest-secret"); +var payload = Encoding.UTF8.GetBytes("Authenticate this message"); +var algorithm = new HmacSecureHashAlgorithm256(secret, null); +var result = algorithm.ComputeHash(payload); -public static class HmacSecureHashAlgorithm256Example -{ - public static void Demonstrate() - { - var secret = Encoding.UTF8.GetBytes("unittest-secret"); - var payload = Encoding.UTF8.GetBytes("Authenticate this message"); - var algorithm = new HmacSecureHashAlgorithm256(secret, null); - var result = algorithm.ComputeHash(payload); - - Console.WriteLine(result.GetBytes().Length); - Console.WriteLine(result.ToHexadecimalString()); - } -} +Console.WriteLine(result.GetBytes().Length); +Console.WriteLine(result.ToHexadecimalString()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm384.md b/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm384.md index b94f0964e..b9ef3d179 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm384.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm384.md @@ -7,22 +7,19 @@ example: The following example demonstrates how to compute an HMAC-SHA384 hash with . ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security.Cryptography; -namespace MyApp.Examples; +var secret = Encoding.UTF8.GetBytes("docs-secret-sha384"); +var algorithm = new HmacSecureHashAlgorithm384(secret, null); +var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("Payload for SHA-384")); -public static class HmacSecureHashAlgorithm384Example -{ - public static void Demonstrate() - { - var secret = Encoding.UTF8.GetBytes("docs-secret-sha384"); - var algorithm = new HmacSecureHashAlgorithm384(secret, null); - var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("Payload for SHA-384")); - - Console.WriteLine(result.GetBytes().Length); - Console.WriteLine(result.ToBase64String()); - } -} +Console.WriteLine(result.GetBytes().Length); +Console.WriteLine(result.ToBase64String()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm512.md b/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm512.md index 0758eedb3..53b825956 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm512.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.HmacSecureHashAlgorithm512.md @@ -7,23 +7,20 @@ example: The following example demonstrates how different payloads produce different HMAC-SHA512 values with . ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security.Cryptography; -namespace MyApp.Examples; +var secret = Encoding.UTF8.GetBytes("docs-secret-sha512"); +var algorithm = new HmacSecureHashAlgorithm512(secret, null); +var first = algorithm.ComputeHash(Encoding.UTF8.GetBytes("first")); +var second = algorithm.ComputeHash(Encoding.UTF8.GetBytes("second")); -public static class HmacSecureHashAlgorithm512Example -{ - public static void Demonstrate() - { - var secret = Encoding.UTF8.GetBytes("docs-secret-sha512"); - var algorithm = new HmacSecureHashAlgorithm512(secret, null); - var first = algorithm.ComputeHash(Encoding.UTF8.GetBytes("first")); - var second = algorithm.ComputeHash(Encoding.UTF8.GetBytes("second")); - - Console.WriteLine(first.GetBytes().Length); - Console.WriteLine(!first.Equals(second)); - } -} +Console.WriteLine(first.GetBytes().Length); +Console.WriteLine(!first.Equals(second)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.KeyedCryptoAlgorithm.md b/.docfx/api/types/Cuemon.Security.Cryptography.KeyedCryptoAlgorithm.md index f4a5c4226..6d9cf5fcd 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.KeyedCryptoAlgorithm.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.KeyedCryptoAlgorithm.md @@ -7,64 +7,59 @@ example: `KeyedCryptoAlgorithm` is an enumeration that selects an HMAC algorithm (SHA-256, SHA-384, SHA-512, SHA-1, or MD5) for keyed hashing operations. This example computes HMAC hashes for each algorithm using a shared key and sample data (`"The quick brown fox jumps over the lazy dog"`) with `HMACSHA256`, `HMACSHA384`, `HMACSHA512`, and `HMACSHA1`. It also uses a `KeyedCryptoAlgorithm` value in a switch expression to dynamically select the algorithm name, and demonstrates enum value comparison to confirm `HmacSha256 == 0`. Console output displays each hex hash and the selected algorithm name. ```csharp +// Program.cs using System; using System.Security.Cryptography; using System.Text; using Cuemon.Security.Cryptography; -namespace MyApp.Security -{ - public class KeyedCryptoAlgorithmExample - { - public void Demonstrate() - { - // KeyedCryptoAlgorithm specifies the HMAC algorithm to use. - // HmacMd5 = -2 (HMAC-MD5, 128 bits) - // HmacSha1 = -1 (HMAC-SHA1, 160 bits) - // HmacSha256 = 0 (HMAC-SHA256,256 bits) - // HmacSha384 = 1 (HMAC-SHA384,384 bits) - // HmacSha512 = 2 (HMAC-SHA512,512 bits) - - byte[] key = Encoding.UTF8.GetBytes("my-secret-key"); - byte[] data = Encoding.UTF8.GetBytes("The quick brown fox jumps over the lazy dog"); - - // HMAC-SHA256 (default/recommended) - using var hmacSha256 = new HMACSHA256(key); - byte[] hash256 = hmacSha256.ComputeHash(data); - Console.WriteLine($"HmacSha256: {BitConverter.ToString(hash256).Replace("-", "").ToLowerInvariant()}"); +// KeyedCryptoAlgorithm specifies the HMAC algorithm to use. +// HmacMd5 = -2 (HMAC-MD5, 128 bits) +// HmacSha1 = -1 (HMAC-SHA1, 160 bits) +// HmacSha256 = 0 (HMAC-SHA256,256 bits) +// HmacSha384 = 1 (HMAC-SHA384,384 bits) +// HmacSha512 = 2 (HMAC-SHA512,512 bits) - // HMAC-SHA384 - using var hmacSha384 = new HMACSHA384(key); - byte[] hash384 = hmacSha384.ComputeHash(data); - Console.WriteLine($"HmacSha384: {BitConverter.ToString(hash384).Replace("-", "").ToLowerInvariant()}"); +byte[] key = Encoding.UTF8.GetBytes("my-secret-key"); +byte[] data = Encoding.UTF8.GetBytes("The quick brown fox jumps over the lazy dog"); - // HMAC-SHA512 - using var hmacSha512 = new HMACSHA512(key); - byte[] hash512 = hmacSha512.ComputeHash(data); - Console.WriteLine($"HmacSha512: {BitConverter.ToString(hash512).Replace("-", "").ToLowerInvariant()}"); +// HMAC-SHA256 (default/recommended) +using var hmacSha256 = new HMACSHA256(key); +byte[] hash256 = hmacSha256.ComputeHash(data); +Console.WriteLine($"HmacSha256: {BitConverter.ToString(hash256).Replace("-", "").ToLowerInvariant()}"); - // HMAC-SHA1 - using var hmacSha1 = new HMACSHA1(key); - byte[] hashSha1 = hmacSha1.ComputeHash(data); - Console.WriteLine($"HmacSha1: {BitConverter.ToString(hashSha1).Replace("-", "").ToLowerInvariant()}"); +// HMAC-SHA384 +using var hmacSha384 = new HMACSHA384(key); +byte[] hash384 = hmacSha384.ComputeHash(data); +Console.WriteLine($"HmacSha384: {BitConverter.ToString(hash384).Replace("-", "").ToLowerInvariant()}"); - // Using KeyedCryptoAlgorithm to select algorithm dynamically - KeyedCryptoAlgorithm algorithm = KeyedCryptoAlgorithm.HmacSha384; - string algorithmName = algorithm switch - { - KeyedCryptoAlgorithm.HmacMd5 => "MD5", - KeyedCryptoAlgorithm.HmacSha1 => "SHA1", - KeyedCryptoAlgorithm.HmacSha256 => "SHA256", - KeyedCryptoAlgorithm.HmacSha384 => "SHA384", - KeyedCryptoAlgorithm.HmacSha512 => "SHA512", - _ => "SHA256" - }; - Console.WriteLine($"Selected HMAC algorithm: HMAC-{algorithmName}"); +// HMAC-SHA512 +using var hmacSha512 = new HMACSHA512(key); +byte[] hash512 = hmacSha512.ComputeHash(data); +Console.WriteLine($"HmacSha512: {BitConverter.ToString(hash512).Replace("-", "").ToLowerInvariant()}"); - // Enum value comparison - Console.WriteLine($"HmacSha256 == 0: {KeyedCryptoAlgorithm.HmacSha256 == (KeyedCryptoAlgorithm)0}"); // True +// HMAC-SHA1 +using var hmacSha1 = new HMACSHA1(key); +byte[] hashSha1 = hmacSha1.ComputeHash(data); +Console.WriteLine($"HmacSha1: {BitConverter.ToString(hashSha1).Replace("-", "").ToLowerInvariant()}"); -}} -} +// Using KeyedCryptoAlgorithm to select algorithm dynamically +KeyedCryptoAlgorithm algorithm = KeyedCryptoAlgorithm.HmacSha384; +string algorithmName = algorithm switch +{ + KeyedCryptoAlgorithm.HmacMd5 => "MD5", + KeyedCryptoAlgorithm.HmacSha1 => "SHA1", + KeyedCryptoAlgorithm.HmacSha256 => "SHA256", + KeyedCryptoAlgorithm.HmacSha384 => "SHA384", + KeyedCryptoAlgorithm.HmacSha512 => "SHA512", + _ => "SHA256" +}; +Console.WriteLine($"Selected HMAC algorithm: HMAC-{algorithmName}"); +// Enum value comparison +Console.WriteLine($"HmacSha256 == 0: {KeyedCryptoAlgorithm.HmacSha256 == (KeyedCryptoAlgorithm)0}"); // True ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.KeyedHashFactory.md b/.docfx/api/types/Cuemon.Security.Cryptography.KeyedHashFactory.md index 8847b59cc..4608d4e3f 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.KeyedHashFactory.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.KeyedHashFactory.md @@ -7,21 +7,18 @@ example: The following example shows how to compute an HMAC-SHA256 hash for message authentication using `KeyedHashFactory`. It creates a keyed hash algorithm with a secret key, hashes an input string, and prints the hexadecimal digest. ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security.Cryptography; -namespace Cuemon.Security.Cryptography; - -public class KeyedHashFactoryExample -{ - public void Demonstrate() - { - var secret = Encoding.UTF8.GetBytes("my-secret-key"); - var hmac = KeyedHashFactory.CreateHmacCryptoSha256(secret); - var input = "Message to authenticate"; - var hash = hmac.ComputeHash(Encoding.UTF8.GetBytes(input)); - Console.WriteLine($"HMAC-SHA256: {BitConverter.ToString(hash.To(bytes => bytes)).Replace("-", "")}"); - } -} +var secret = Encoding.UTF8.GetBytes("my-secret-key"); +var hmac = KeyedHashFactory.CreateHmacCryptoSha256(secret); +var input = "Message to authenticate"; +var hash = hmac.ComputeHash(Encoding.UTF8.GetBytes(input)); +Console.WriteLine($"HMAC-SHA256: {BitConverter.ToString(hash.To(bytes => bytes)).Replace("-", "")}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.MessageDigest5.md b/.docfx/api/types/Cuemon.Security.Cryptography.MessageDigest5.md index 3404b5fcc..c4b844ffe 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.MessageDigest5.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.MessageDigest5.md @@ -7,22 +7,19 @@ example: The following example demonstrates how to compute an MD5 hash with . ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security.Cryptography; -namespace MyApp.Examples; +var algorithm = new MessageDigest5(); +var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("The quick brown fox jumps over the lazy dog")); -public static class MessageDigest5Example -{ - public static void Demonstrate() - { - var algorithm = new MessageDigest5(); - var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("The quick brown fox jumps over the lazy dog")); - - Console.WriteLine(MessageDigest5.BitSize); - Console.WriteLine(result.GetBytes().Length); - Console.WriteLine(result.ToHexadecimalString()); - } -} +Console.WriteLine(MessageDigest5.BitSize); +Console.WriteLine(result.GetBytes().Length); +Console.WriteLine(result.ToHexadecimalString()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.SHA512256.md b/.docfx/api/types/Cuemon.Security.Cryptography.SHA512256.md index 5b3a2d117..060704581 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.SHA512256.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.SHA512256.md @@ -7,24 +7,21 @@ example: The following example demonstrates how to use the low-level implementation directly through . ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security.Cryptography; -namespace MyApp.Examples; +using var algorithm = new SHA512256(); -public static class SHA512256Example -{ - public static void Demonstrate() - { - using var algorithm = new SHA512256(); +var digest = algorithm.ComputeHash(Encoding.UTF8.GetBytes("Hello, world!")); +algorithm.Initialize(); +var secondDigest = algorithm.ComputeHash(Encoding.UTF8.GetBytes("Hello, world!")); - var digest = algorithm.ComputeHash(Encoding.UTF8.GetBytes("Hello, world!")); - algorithm.Initialize(); - var secondDigest = algorithm.ComputeHash(Encoding.UTF8.GetBytes("Hello, world!")); - - Console.WriteLine(digest.Length); - Console.WriteLine(digest.Length == secondDigest.Length); - } -} +Console.WriteLine(digest.Length); +Console.WriteLine(digest.Length == secondDigest.Length); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm1.md b/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm1.md index 6125a101a..938b37863 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm1.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm1.md @@ -7,21 +7,18 @@ example: The following example demonstrates how to compute a SHA-1 hash with . ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security.Cryptography; -namespace MyApp.Examples; +var algorithm = new SecureHashAlgorithm1(); +var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("legacy-compatible digest")); -public static class SecureHashAlgorithm1Example -{ - public static void Demonstrate() - { - var algorithm = new SecureHashAlgorithm1(); - var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("legacy-compatible digest")); - - Console.WriteLine(SecureHashAlgorithm1.BitSize); - Console.WriteLine(result.GetBytes().Length); - } -} +Console.WriteLine(SecureHashAlgorithm1.BitSize); +Console.WriteLine(result.GetBytes().Length); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm256.md b/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm256.md index b2ff5b3e3..4c051928c 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm256.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm256.md @@ -7,23 +7,20 @@ example: The following example demonstrates how to compute a SHA-256 hash with . ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security.Cryptography; -namespace MyApp.Examples; +var algorithm = new SecureHashAlgorithm256(); +var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("The quick brown fox jumps over the lazy dog")); +var repeated = algorithm.ComputeHash(Encoding.UTF8.GetBytes("The quick brown fox jumps over the lazy dog")); -public static class SecureHashAlgorithm256Example -{ - public static void Demonstrate() - { - var algorithm = new SecureHashAlgorithm256(); - var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("The quick brown fox jumps over the lazy dog")); - var repeated = algorithm.ComputeHash(Encoding.UTF8.GetBytes("The quick brown fox jumps over the lazy dog")); - - Console.WriteLine(SecureHashAlgorithm256.BitSize); - Console.WriteLine(result.GetBytes().Length); - Console.WriteLine(result.Equals(repeated)); - } -} +Console.WriteLine(SecureHashAlgorithm256.BitSize); +Console.WriteLine(result.GetBytes().Length); +Console.WriteLine(result.Equals(repeated)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm384.md b/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm384.md index ff31514cd..8e32bcc84 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm384.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm384.md @@ -7,21 +7,18 @@ example: The following example demonstrates how to compute a SHA-384 hash with . ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security.Cryptography; -namespace MyApp.Examples; +var algorithm = new SecureHashAlgorithm384(); +var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("Payload for SHA-384")); -public static class SecureHashAlgorithm384Example -{ - public static void Demonstrate() - { - var algorithm = new SecureHashAlgorithm384(); - var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("Payload for SHA-384")); - - Console.WriteLine(SecureHashAlgorithm384.BitSize); - Console.WriteLine(result.GetBytes().Length); - } -} +Console.WriteLine(SecureHashAlgorithm384.BitSize); +Console.WriteLine(result.GetBytes().Length); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm512.md b/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm512.md index 4d36a35e9..5facaff75 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm512.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm512.md @@ -7,21 +7,18 @@ example: The following example demonstrates how to compute a SHA-512 hash with . ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security.Cryptography; -namespace MyApp.Examples; +var algorithm = new SecureHashAlgorithm512(); +var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("Payload for SHA-512")); -public static class SecureHashAlgorithm512Example -{ - public static void Demonstrate() - { - var algorithm = new SecureHashAlgorithm512(); - var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("Payload for SHA-512")); - - Console.WriteLine(SecureHashAlgorithm512.BitSize); - Console.WriteLine(result.ToBase64String()); - } -} +Console.WriteLine(SecureHashAlgorithm512.BitSize); +Console.WriteLine(result.ToBase64String()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm512256.md b/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm512256.md index 7d4e3f218..0a5a3c8b8 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm512256.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.SecureHashAlgorithm512256.md @@ -7,21 +7,18 @@ example: The following example demonstrates how to compute a SHA-512/256 hash with . ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security.Cryptography; -namespace MyApp.Examples; +var algorithm = new SecureHashAlgorithm512256(null); +var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("Payload for SHA-512/256")); -public static class SecureHashAlgorithm512256Example -{ - public static void Demonstrate() - { - var algorithm = new SecureHashAlgorithm512256(null); - var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes("Payload for SHA-512/256")); - - Console.WriteLine(SecureHashAlgorithm512256.BitSize); - Console.WriteLine(result.GetBytes().Length); - } -} +Console.WriteLine(SecureHashAlgorithm512256.BitSize); +Console.WriteLine(result.GetBytes().Length); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.UnkeyedCryptoAlgorithm.md b/.docfx/api/types/Cuemon.Security.Cryptography.UnkeyedCryptoAlgorithm.md index 0c48dce7f..accb88b4c 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.UnkeyedCryptoAlgorithm.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.UnkeyedCryptoAlgorithm.md @@ -7,56 +7,51 @@ example: `UnkeyedCryptoAlgorithm` is an enumeration that selects a hash algorithm (SHA-256, SHA-384, SHA-512, SHA-1, MD5, or SHA-512/256) for unkeyed hashing. This example computes hashes for each algorithm using `"The quick brown fox jumps over the lazy dog"` with `SHA256`, `SHA384`, `SHA512`, and `SHA1`. It also uses an `UnkeyedCryptoAlgorithm` value (`Sha512`) to output the selected algorithm name, and demonstrates enum value comparison to confirm `Sha256 == 0`. Console output displays each hex hash and the selected algorithm name. ```csharp +// Program.cs using System; using System.Security.Cryptography; using System.Text; using Cuemon.Security.Cryptography; -namespace MyApp.Security -{ - public class UnkeyedCryptoAlgorithmExample - { - public void Demonstrate() - { - // UnkeyedCryptoAlgorithm specifies the hash algorithm to use. - // Md5 = -2 (MD5, 128 bits) - // Sha1 = -1 (SHA-1, 160 bits) - // Sha256 = 0 (SHA-256, 256 bits) - // Sha384 = 1 (SHA-384, 384 bits) - // Sha512 = 2 (SHA-512, 512 bits) - // Sha512Slash256 = 3 (SHA-512/256, 256 bits) - - byte[] data = Encoding.UTF8.GetBytes("The quick brown fox jumps over the lazy dog"); - - // SHA-256 (default/recommended) - using var sha256 = SHA256.Create(); - byte[] hash256 = sha256.ComputeHash(data); - Console.WriteLine($"Sha256: {BitConverter.ToString(hash256).Replace("-", "").ToLowerInvariant()}"); - - // SHA-384 - using var sha384 = SHA384.Create(); - byte[] hash384 = sha384.ComputeHash(data); - Console.WriteLine($"Sha384: {BitConverter.ToString(hash384).Replace("-", "").ToLowerInvariant()}"); - - // SHA-512 - using var sha512 = SHA512.Create(); - byte[] hash512 = sha512.ComputeHash(data); - Console.WriteLine($"Sha512: {BitConverter.ToString(hash512).Replace("-", "").ToLowerInvariant()}"); - - // SHA-1 - using var sha1 = SHA1.Create(); - byte[] hashSha1 = sha1.ComputeHash(data); - Console.WriteLine($"Sha1: {BitConverter.ToString(hashSha1).Replace("-", "").ToLowerInvariant()}"); - - // Using UnkeyedCryptoAlgorithm to select algorithm dynamically - UnkeyedCryptoAlgorithm algorithm = UnkeyedCryptoAlgorithm.Sha512; - Console.WriteLine($"Selected algorithm: {algorithm}"); // Sha512 - - // Enum value comparison - Console.WriteLine($"Sha256 == 0: {UnkeyedCryptoAlgorithm.Sha256 == (UnkeyedCryptoAlgorithm)0}"); // True - Console.WriteLine($"Bit size of Sha512: 512 bits"); - -}} -} - +// UnkeyedCryptoAlgorithm specifies the hash algorithm to use. +// Md5 = -2 (MD5, 128 bits) +// Sha1 = -1 (SHA-1, 160 bits) +// Sha256 = 0 (SHA-256, 256 bits) +// Sha384 = 1 (SHA-384, 384 bits) +// Sha512 = 2 (SHA-512, 512 bits) +// Sha512Slash256 = 3 (SHA-512/256, 256 bits) + +byte[] data = Encoding.UTF8.GetBytes("The quick brown fox jumps over the lazy dog"); + +// SHA-256 (default/recommended) +using var sha256 = SHA256.Create(); +byte[] hash256 = sha256.ComputeHash(data); +Console.WriteLine($"Sha256: {BitConverter.ToString(hash256).Replace("-", "").ToLowerInvariant()}"); + +// SHA-384 +using var sha384 = SHA384.Create(); +byte[] hash384 = sha384.ComputeHash(data); +Console.WriteLine($"Sha384: {BitConverter.ToString(hash384).Replace("-", "").ToLowerInvariant()}"); + +// SHA-512 +using var sha512 = SHA512.Create(); +byte[] hash512 = sha512.ComputeHash(data); +Console.WriteLine($"Sha512: {BitConverter.ToString(hash512).Replace("-", "").ToLowerInvariant()}"); + +// SHA-1 +using var sha1 = SHA1.Create(); +byte[] hashSha1 = sha1.ComputeHash(data); +Console.WriteLine($"Sha1: {BitConverter.ToString(hashSha1).Replace("-", "").ToLowerInvariant()}"); + +// Using UnkeyedCryptoAlgorithm to select algorithm dynamically +UnkeyedCryptoAlgorithm algorithm = UnkeyedCryptoAlgorithm.Sha512; +Console.WriteLine($"Selected algorithm: {algorithm}"); // Sha512 + +// Enum value comparison +Console.WriteLine($"Sha256 == 0: {UnkeyedCryptoAlgorithm.Sha256 == (UnkeyedCryptoAlgorithm)0}"); // True +Console.WriteLine($"Bit size of Sha512: 512 bits"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.Cryptography.UnkeyedHashFactory.md b/.docfx/api/types/Cuemon.Security.Cryptography.UnkeyedHashFactory.md index bd8c68a91..e86e7a812 100644 --- a/.docfx/api/types/Cuemon.Security.Cryptography.UnkeyedHashFactory.md +++ b/.docfx/api/types/Cuemon.Security.Cryptography.UnkeyedHashFactory.md @@ -7,24 +7,21 @@ example: The following example demonstrates how to compute SHA-256 and SHA-512 hashes for data integrity using `UnkeyedHashFactory`. It hashes a sample input and prints the hexadecimal digest for each algorithm. ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security.Cryptography; -namespace Cuemon.Security.Cryptography; +var sha256 = UnkeyedHashFactory.CreateCryptoSha256(); +var input = "Data to hash"; +var hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(input)); +Console.WriteLine($"SHA-256: {BitConverter.ToString(hash.GetBytes()).Replace("-", "")}"); -public class UnkeyedHashFactoryExample -{ - public void Demonstrate() - { - var sha256 = UnkeyedHashFactory.CreateCryptoSha256(); - var input = "Data to hash"; - var hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(input)); - Console.WriteLine($"SHA-256: {BitConverter.ToString(hash.GetBytes()).Replace("-", "")}"); - - var sha512 = UnkeyedHashFactory.CreateCryptoSha512(); - hash = sha512.ComputeHash(Encoding.UTF8.GetBytes(input)); - Console.WriteLine($"SHA-512: {BitConverter.ToString(hash.GetBytes()).Replace("-", "")}"); - } -} +var sha512 = UnkeyedHashFactory.CreateCryptoSha512(); +hash = sha512.ComputeHash(Encoding.UTF8.GetBytes(input)); +Console.WriteLine($"SHA-512: {BitConverter.ToString(hash.GetBytes()).Replace("-", "")}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheck32.md b/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheck32.md index 01c1c96f6..601f3b7f7 100644 --- a/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheck32.md +++ b/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheck32.md @@ -7,32 +7,29 @@ example: The following example shows how to compute a CRC-32 checksum with the common reflected configuration. ```csharp +// Program.cs using System; using System.Text; using Cuemon; using Cuemon.Security; -namespace MyApp.Examples; - -public static class CyclicRedundancyCheck32Example +var checksum = new CyclicRedundancyCheck32(setup: options => { - public static void Demonstrate() - { - var checksum = new CyclicRedundancyCheck32(setup: options => - { - options.ByteOrder = Endianness.BigEndian; - options.ReflectInput = true; - options.ReflectOutput = true; - }); + options.ByteOrder = Endianness.BigEndian; + options.ReflectInput = true; + options.ReflectOutput = true; +}); - HashResult result = checksum.ComputeHash(Encoding.ASCII.GetBytes("123456789")); +HashResult result = checksum.ComputeHash(Encoding.ASCII.GetBytes("123456789")); - Console.WriteLine(result.ToHexadecimalString().ToLowerInvariant()); - Console.WriteLine(checksum.InitialValue); - Console.WriteLine(checksum.FinalXor); +Console.WriteLine(result.ToHexadecimalString().ToLowerInvariant()); +Console.WriteLine(checksum.InitialValue); +Console.WriteLine(checksum.FinalXor); - var alternate = new CyclicRedundancyCheck32(polynomial: 0xEDB88320, initialValue: 0xFFFFFFFF, finalXor: 0xFFFFFFFF); - Console.WriteLine(alternate.ComputeHash("Cuemon").ToBase64String()); - } -} +var alternate = new CyclicRedundancyCheck32(polynomial: 0xEDB88320, initialValue: 0xFFFFFFFF, finalXor: 0xFFFFFFFF); +Console.WriteLine(alternate.ComputeHash("Cuemon").ToBase64String()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheck64.md b/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheck64.md index 6650288bc..9f84dd223 100644 --- a/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheck64.md +++ b/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheck64.md @@ -7,37 +7,32 @@ example: The following example demonstrates how to compute a 64-bit Cyclic Redundancy Check (CRC) checksum using the class. ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security; -namespace MyApp.Examples; +// Create CRC-64 instance with default ECMA-182 polynomial +var crc64 = new CyclicRedundancyCheck64(); -public class CyclicRedundancyCheck64Example -{ - public void Demonstrate() - { - // Create CRC-64 instance with default ECMA-182 polynomial - var crc64 = new CyclicRedundancyCheck64(); +// Compute checksum from ASCII input +byte[] data = Encoding.ASCII.GetBytes("123456789"); +HashResult result = crc64.ComputeHash(data); - // Compute checksum from ASCII input - byte[] data = Encoding.ASCII.GetBytes("123456789"); - HashResult result = crc64.ComputeHash(data); +// Display the checksum in hexadecimal +string hex = result.ToHexadecimalString(); +Console.WriteLine(hex); // 6c40df5f0b497347 - // Display the checksum in hexadecimal - string hex = result.ToHexadecimalString(); - Console.WriteLine(hex); // 6c40df5f0b497347 - - // Create CRC-64 with custom polynomial - var customCrc = new CyclicRedundancyCheck64( - polynomial: 0x42F0E1EBA9EA3693, - initialValue: 0xFFFFFFFFFFFFFFFF, - finalXor: 0xFFFFFFFFFFFFFFFF); - - HashResult customResult = customCrc.ComputeHash(data); - Console.WriteLine(customResult.ToHexadecimalString()); - -} -} +// Create CRC-64 with custom polynomial +var customCrc = new CyclicRedundancyCheck64( + polynomial: 0x42F0E1EBA9EA3693, + initialValue: 0xFFFFFFFFFFFFFFFF, + finalXor: 0xFFFFFFFFFFFFFFFF); +HashResult customResult = customCrc.ComputeHash(data); +Console.WriteLine(customResult.ToHexadecimalString()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheckAlgorithm.md b/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheckAlgorithm.md index 15ee26fbb..b41c62fe1 100644 --- a/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheckAlgorithm.md +++ b/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheckAlgorithm.md @@ -7,36 +7,31 @@ example: The following example demonstrates how to use the enum to select a specific CRC algorithm variant. ```csharp +// Program.cs using System; using Cuemon.Security; // for CyclicRedundancyCheckAlgorithm -namespace MyApp.Examples; +// Select commonly used CRC algorithms +CyclicRedundancyCheckAlgorithm crc32 = CyclicRedundancyCheckAlgorithm.Crc32; +CyclicRedundancyCheckAlgorithm crc32C = CyclicRedundancyCheckAlgorithm.Crc32C; +CyclicRedundancyCheckAlgorithm crc64 = CyclicRedundancyCheckAlgorithm.Crc64; -public class CyclicRedundancyCheckAlgorithmExample -{ - public void Demonstrate() - { - // Select commonly used CRC algorithms - CyclicRedundancyCheckAlgorithm crc32 = CyclicRedundancyCheckAlgorithm.Crc32; - CyclicRedundancyCheckAlgorithm crc32C = CyclicRedundancyCheckAlgorithm.Crc32C; - CyclicRedundancyCheckAlgorithm crc64 = CyclicRedundancyCheckAlgorithm.Crc64; - - Console.WriteLine(crc32); // Crc32 - Console.WriteLine(crc32C); // Crc32C - Console.WriteLine(crc64); // Crc64 - - // Switch on algorithm - string GetDescription(CyclicRedundancyCheckAlgorithm algo) => algo switch - { - CyclicRedundancyCheckAlgorithm.Crc32 => "CRC-32 (ISO-HDLC, PKZIP)", - CyclicRedundancyCheckAlgorithm.Crc32C => "CRC-32C (ISCSI, Castagnoli)", - CyclicRedundancyCheckAlgorithm.Crc64 => "CRC-64 (ECMA-182)", - _ => "Unknown" - }; +Console.WriteLine(crc32); // Crc32 +Console.WriteLine(crc32C); // Crc32C +Console.WriteLine(crc64); // Crc64 - Console.WriteLine(GetDescription(crc32C)); // CRC-32C (ISCSI, Castagnoli) - -} -} +// Switch on algorithm +string GetDescription(CyclicRedundancyCheckAlgorithm algo) => algo switch +{ + CyclicRedundancyCheckAlgorithm.Crc32 => "CRC-32 (ISO-HDLC, PKZIP)", + CyclicRedundancyCheckAlgorithm.Crc32C => "CRC-32C (ISCSI, Castagnoli)", + CyclicRedundancyCheckAlgorithm.Crc64 => "CRC-64 (ECMA-182)", + _ => "Unknown" +}; +Console.WriteLine(GetDescription(crc32C)); // CRC-32C (ISCSI, Castagnoli) ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheckOptions.md b/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheckOptions.md index 48189f4f0..54c7df9cb 100644 --- a/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheckOptions.md +++ b/.docfx/api/types/Cuemon.Security.CyclicRedundancyCheckOptions.md @@ -7,35 +7,32 @@ example: The following example shows how to reuse one `CyclicRedundancyCheckOptions` instance when configuring a checksum implementation. ```csharp +// Program.cs using System; using System.Text; using Cuemon; using Cuemon.Security; -namespace MyApp.Examples; - -public static class CyclicRedundancyCheckOptionsExample +var options = new CyclicRedundancyCheckOptions { - public static void Demonstrate() - { - var options = new CyclicRedundancyCheckOptions - { - ByteOrder = Endianness.LittleEndian, - ReflectInput = true, - ReflectOutput = true - }; + ByteOrder = Endianness.LittleEndian, + ReflectInput = true, + ReflectOutput = true +}; - var checksum = new CyclicRedundancyCheck32(setup: configured => - { - configured.ByteOrder = options.ByteOrder; - configured.ReflectInput = options.ReflectInput; - configured.ReflectOutput = options.ReflectOutput; - }); +var checksum = new CyclicRedundancyCheck32(setup: configured => +{ + configured.ByteOrder = options.ByteOrder; + configured.ReflectInput = options.ReflectInput; + configured.ReflectOutput = options.ReflectOutput; +}); - Console.WriteLine(options.ByteOrder); - Console.WriteLine(options.ReflectInput); - Console.WriteLine(options.ReflectOutput); - Console.WriteLine(checksum.ComputeHash(Encoding.ASCII.GetBytes("123456789")).ToHexadecimalString()); - } -} +Console.WriteLine(options.ByteOrder); +Console.WriteLine(options.ReflectInput); +Console.WriteLine(options.ReflectOutput); +Console.WriteLine(checksum.ComputeHash(Encoding.ASCII.GetBytes("123456789")).ToHexadecimalString()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.FowlerNollVo1024.md b/.docfx/api/types/Cuemon.Security.FowlerNollVo1024.md index 1eaf038c7..a55369edb 100644 --- a/.docfx/api/types/Cuemon.Security.FowlerNollVo1024.md +++ b/.docfx/api/types/Cuemon.Security.FowlerNollVo1024.md @@ -7,31 +7,28 @@ example: The following example shows how to compute 1024-bit Fowler-Noll-Vo hashes for the same payload with different algorithms. ```csharp +// Program.cs using System; using System.Text; using Cuemon; using Cuemon.Security; -namespace MyApp.Examples; - -public static class FowlerNollVo1024Example +var hasher = new FowlerNollVo1024(options => { - public static void Demonstrate() - { - var hasher = new FowlerNollVo1024(options => - { - options.Algorithm = FowlerNollVoAlgorithm.Fnv1a; - options.ByteOrder = Endianness.BigEndian; - }); + options.Algorithm = FowlerNollVoAlgorithm.Fnv1a; + options.ByteOrder = Endianness.BigEndian; +}); - HashResult orderHash = hasher.ComputeHash(Encoding.UTF8.GetBytes("order-42")); +HashResult orderHash = hasher.ComputeHash(Encoding.UTF8.GetBytes("order-42")); - Console.WriteLine(hasher.Bits); - Console.WriteLine(orderHash.GetBytes().Length); - Console.WriteLine(orderHash.ToHexadecimalString()); +Console.WriteLine(hasher.Bits); +Console.WriteLine(orderHash.GetBytes().Length); +Console.WriteLine(orderHash.ToHexadecimalString()); - var legacyHasher = new FowlerNollVo1024(options => options.Algorithm = FowlerNollVoAlgorithm.Fnv1); - Console.WriteLine(legacyHasher.ComputeHash("order-42").ToHexadecimalString()); - } -} +var legacyHasher = new FowlerNollVo1024(options => options.Algorithm = FowlerNollVoAlgorithm.Fnv1); +Console.WriteLine(legacyHasher.ComputeHash("order-42").ToHexadecimalString()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.FowlerNollVo128.md b/.docfx/api/types/Cuemon.Security.FowlerNollVo128.md index 7788fcc1c..a1567a145 100644 --- a/.docfx/api/types/Cuemon.Security.FowlerNollVo128.md +++ b/.docfx/api/types/Cuemon.Security.FowlerNollVo128.md @@ -7,45 +7,40 @@ example: The following example demonstrates how to compute 128-bit FNV-1a and FNV-1 hash values using FowlerNollVo128, with configurable algorithm variant and byte order. ```csharp +// Program.cs using System; using System.Text; using Cuemon; using Cuemon.Security; -namespace MyApp.Examples -{ - public class FowlerNollVo128Example - { - public void Demonstrate() - { - // Create a FNV-1a 128-bit hash (default algorithm). - var fnv = new FowlerNollVo128(); +// Create a FNV-1a 128-bit hash (default algorithm). +var fnv = new FowlerNollVo128(); - Console.WriteLine($"Bits: {fnv.Bits}"); // 128 - Console.WriteLine($"Algorithm: {fnv.Options.Algorithm}"); // Fnv1a +Console.WriteLine($"Bits: {fnv.Bits}"); // 128 +Console.WriteLine($"Algorithm: {fnv.Options.Algorithm}"); // Fnv1a - // Compute hash of a UTF-8 encoded string. - var data = Encoding.UTF8.GetBytes("Hello, World!"); - var hash = fnv.ComputeHash(data); +// Compute hash of a UTF-8 encoded string. +var data = Encoding.UTF8.GetBytes("Hello, World!"); +var hash = fnv.ComputeHash(data); - Console.WriteLine($"Hash (hex): {hash.ToHexadecimalString()}"); - Console.WriteLine($"Hash (b64): {hash.ToBase64String()}"); +Console.WriteLine($"Hash (hex): {hash.ToHexadecimalString()}"); +Console.WriteLine($"Hash (b64): {hash.ToBase64String()}"); - // Use FNV-1 instead of FNV-1a. - var fnv1 = new FowlerNollVo128(o => o.Algorithm = FowlerNollVoAlgorithm.Fnv1); - var hashFnv1 = fnv1.ComputeHash(data); - Console.WriteLine($"FNV-1 hash: {hashFnv1}"); +// Use FNV-1 instead of FNV-1a. +var fnv1 = new FowlerNollVo128(o => o.Algorithm = FowlerNollVoAlgorithm.Fnv1); +var hashFnv1 = fnv1.ComputeHash(data); +Console.WriteLine($"FNV-1 hash: {hashFnv1}"); - // Little-endian byte order. - var fnvLe = new FowlerNollVo128(o => o.ByteOrder = Endianness.LittleEndian); - var hashLe = fnvLe.ComputeHash(data); - Console.WriteLine($"LE hash: {hashLe.ToHexadecimalString()}"); - - // Verify hash with the built-in offset basis for empty input. - var emptyHash = fnv.ComputeHash(Array.Empty()); - Console.WriteLine($"Offset basis hash: {emptyHash.ToHexadecimalString()}"); - -}} -} +// Little-endian byte order. +var fnvLe = new FowlerNollVo128(o => o.ByteOrder = Endianness.LittleEndian); +var hashLe = fnvLe.ComputeHash(data); +Console.WriteLine($"LE hash: {hashLe.ToHexadecimalString()}"); +// Verify hash with the built-in offset basis for empty input. +var emptyHash = fnv.ComputeHash(Array.Empty()); +Console.WriteLine($"Offset basis hash: {emptyHash.ToHexadecimalString()}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.FowlerNollVo256.md b/.docfx/api/types/Cuemon.Security.FowlerNollVo256.md index 4e32bacae..ff96417b9 100644 --- a/.docfx/api/types/Cuemon.Security.FowlerNollVo256.md +++ b/.docfx/api/types/Cuemon.Security.FowlerNollVo256.md @@ -7,45 +7,40 @@ example: The following example demonstrates how to compute 256-bit FNV-1a hash values using FowlerNollVo256, with configurable byte order and integer conversion. ```csharp +// Program.cs using System; using System.Numerics; using System.Text; using Cuemon; using Cuemon.Security; -namespace MyApp.Examples -{ - public class FowlerNollVo256Example - { - public void Demonstrate() - { - // Create a FNV-1a 256-bit hash (default algorithm). - var fnv = new FowlerNollVo256(); - - Console.WriteLine($"Bits: {fnv.Bits}"); // 256 - Console.WriteLine($"Algorithm: {fnv.Options.Algorithm}"); // Fnv1a - - // Compute hash of a UTF-8 encoded string. - var data = Encoding.UTF8.GetBytes("The quick brown fox jumps over the lazy dog"); - var hash = fnv.ComputeHash(data); - - Console.WriteLine($"Hash (hex): {hash.ToHexadecimalString()}"); - Console.WriteLine($"Hash (b64): {hash.ToBase64String()}"); - Console.WriteLine($"Hash length: {hash.GetBytes().Length} bytes"); - - // Configure byte order independently. - var fnvLe = new FowlerNollVo256(o => - { - o.ByteOrder = Endianness.LittleEndian; - }); - var hashLe = fnvLe.ComputeHash(data); - Console.WriteLine($"LE hash: {hashLe.ToHexadecimalString()}"); - - // Convert hash to an integer using the built-in converter. - var asBigInt = hash.To(b => new BigInteger(b)); - Console.WriteLine($"As integer: {asBigInt}"); - -}} -} +// Create a FNV-1a 256-bit hash (default algorithm). +var fnv = new FowlerNollVo256(); + +Console.WriteLine($"Bits: {fnv.Bits}"); // 256 +Console.WriteLine($"Algorithm: {fnv.Options.Algorithm}"); // Fnv1a + +// Compute hash of a UTF-8 encoded string. +var data = Encoding.UTF8.GetBytes("The quick brown fox jumps over the lazy dog"); +var hash = fnv.ComputeHash(data); +Console.WriteLine($"Hash (hex): {hash.ToHexadecimalString()}"); +Console.WriteLine($"Hash (b64): {hash.ToBase64String()}"); +Console.WriteLine($"Hash length: {hash.GetBytes().Length} bytes"); + +// Configure byte order independently. +var fnvLe = new FowlerNollVo256(o => +{ + o.ByteOrder = Endianness.LittleEndian; +}); +var hashLe = fnvLe.ComputeHash(data); +Console.WriteLine($"LE hash: {hashLe.ToHexadecimalString()}"); + +// Convert hash to an integer using the built-in converter. +var asBigInt = hash.To(b => new BigInteger(b)); +Console.WriteLine($"As integer: {asBigInt}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.FowlerNollVo32.md b/.docfx/api/types/Cuemon.Security.FowlerNollVo32.md index 14ce908e7..43065df85 100644 --- a/.docfx/api/types/Cuemon.Security.FowlerNollVo32.md +++ b/.docfx/api/types/Cuemon.Security.FowlerNollVo32.md @@ -7,39 +7,34 @@ example: The following example demonstrates how to compute a 32-bit FNV-1a hash using the class. ```csharp +// Program.cs using System; using System.Text; using Cuemon; // for Endianness using Cuemon.Security; // for FowlerNollVo32 - using Cuemon; -namespace MyApp.Examples; - -public class FowlerNollVo32Example -{ - public void Demonstrate() - { - var fnv = new FowlerNollVo32(); - // Compute hash of a string - byte[] data = Encoding.UTF8.GetBytes("hello"); - var hash = fnv.ComputeHash(data); +var fnv = new FowlerNollVo32(); - Console.WriteLine(hash.ToHexadecimalString()); // F970D0C7 (big-endian default) - Console.WriteLine(hash.ToBase64String()); // +XDQxw== - Console.WriteLine(fnv.Bits); // 32 +// Compute hash of a string +byte[] data = Encoding.UTF8.GetBytes("hello"); +var hash = fnv.ComputeHash(data); - // Configure for little-endian output - var fnvLe = new FowlerNollVo32(o => o.ByteOrder = Endianness.LittleEndian); - byte[] hashBytes = fnvLe.ComputeHash(data).GetBytes(); - Console.WriteLine(BitConverter.ToString(hashBytes)); // C7-D0-70-F9 +Console.WriteLine(hash.ToHexadecimalString()); // F970D0C7 (big-endian default) +Console.WriteLine(hash.ToBase64String()); // +XDQxw== +Console.WriteLine(fnv.Bits); // 32 - // Use FNV-1 variant instead of FNV-1a - fnv.Options.Algorithm = FowlerNollVoAlgorithm.Fnv1; - hash = fnv.ComputeHash(data); - Console.WriteLine(hash.ToHexadecimalString()); // E973FD3B - -} -} +// Configure for little-endian output +var fnvLe = new FowlerNollVo32(o => o.ByteOrder = Endianness.LittleEndian); +byte[] hashBytes = fnvLe.ComputeHash(data).GetBytes(); +Console.WriteLine(BitConverter.ToString(hashBytes)); // C7-D0-70-F9 +// Use FNV-1 variant instead of FNV-1a +fnv.Options.Algorithm = FowlerNollVoAlgorithm.Fnv1; +hash = fnv.ComputeHash(data); +Console.WriteLine(hash.ToHexadecimalString()); // E973FD3B ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.FowlerNollVo512.md b/.docfx/api/types/Cuemon.Security.FowlerNollVo512.md index c4cb2ba7a..ba2ec7a58 100644 --- a/.docfx/api/types/Cuemon.Security.FowlerNollVo512.md +++ b/.docfx/api/types/Cuemon.Security.FowlerNollVo512.md @@ -7,45 +7,40 @@ example: The following example demonstrates how to compute 512-bit FNV-1a and FNV-1 hash values using FowlerNollVo512, with configurable algorithm variant and URL-safe Base64 output. ```csharp +// Program.cs using System; using System.Text; using Cuemon; using Cuemon.Security; -namespace MyApp.Examples -{ - public class FowlerNollVo512Example - { - public void Demonstrate() - { - // Create a FNV-1a 512-bit hash (default algorithm). - var fnv = new FowlerNollVo512(); +// Create a FNV-1a 512-bit hash (default algorithm). +var fnv = new FowlerNollVo512(); - Console.WriteLine($"Bits: {fnv.Bits}"); // 512 - Console.WriteLine($"Algorithm: {fnv.Options.Algorithm}"); // Fnv1a - Console.WriteLine($"Offset basis: {fnv.OffsetBasis}"); +Console.WriteLine($"Bits: {fnv.Bits}"); // 512 +Console.WriteLine($"Algorithm: {fnv.Options.Algorithm}"); // Fnv1a +Console.WriteLine($"Offset basis: {fnv.OffsetBasis}"); - // Compute hash of binary data. - var data = Encoding.UTF8.GetBytes("Cuemon FNV-512 example"); - var hash = fnv.ComputeHash(data); +// Compute hash of binary data. +var data = Encoding.UTF8.GetBytes("Cuemon FNV-512 example"); +var hash = fnv.ComputeHash(data); - Console.WriteLine($"Hash (hex): {hash.ToHexadecimalString()}"); - Console.WriteLine($"Hash (base64): {hash.ToBase64String()}"); +Console.WriteLine($"Hash (hex): {hash.ToHexadecimalString()}"); +Console.WriteLine($"Hash (base64): {hash.ToBase64String()}"); - // Using FNV-1 algorithm. - var fnv1 = new FowlerNollVo512(o => o.Algorithm = FowlerNollVoAlgorithm.Fnv1); - var hashFnv1 = fnv1.ComputeHash(data); - Console.WriteLine($"FNV-1 hash: {hashFnv1.ToHexadecimalString()}"); +// Using FNV-1 algorithm. +var fnv1 = new FowlerNollVo512(o => o.Algorithm = FowlerNollVoAlgorithm.Fnv1); +var hashFnv1 = fnv1.ComputeHash(data); +Console.WriteLine($"FNV-1 hash: {hashFnv1.ToHexadecimalString()}"); - // Raw bytes for further processing. - var bytes = hash.GetBytes(); - Console.WriteLine($"Byte length: {bytes.Length}"); // 64 (512 / 8) - - // URL-safe Base64 encoding. - var urlSafe = hash.ToUrlEncodedBase64String(); - Console.WriteLine($"URL-safe b64: {urlSafe}"); - -}} -} +// Raw bytes for further processing. +var bytes = hash.GetBytes(); +Console.WriteLine($"Byte length: {bytes.Length}"); // 64 (512 / 8) +// URL-safe Base64 encoding. +var urlSafe = hash.ToUrlEncodedBase64String(); +Console.WriteLine($"URL-safe b64: {urlSafe}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.FowlerNollVo64.md b/.docfx/api/types/Cuemon.Security.FowlerNollVo64.md index a2b532b24..86bd00bbe 100644 --- a/.docfx/api/types/Cuemon.Security.FowlerNollVo64.md +++ b/.docfx/api/types/Cuemon.Security.FowlerNollVo64.md @@ -7,38 +7,33 @@ example: The following example demonstrates how to compute a 64-bit Fowler-Noll-Vo (FNV) hash using the class. ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security; - using Cuemon; -namespace MyApp.Examples; - -public class FowlerNollVo64Example -{ - public void Demonstrate() - { - // Create FNV-1a 64-bit hash instance (default algorithm) - var fnv = new FowlerNollVo64(); - // Compute hash from a string - byte[] data = Encoding.UTF8.GetBytes("hello"); - HashResult hash = fnv.ComputeHash(data); +// Create FNV-1a 64-bit hash instance (default algorithm) +var fnv = new FowlerNollVo64(); - // Display the hash in hexadecimal format - Console.WriteLine(hash.ToHexadecimalString()); +// Compute hash from a string +byte[] data = Encoding.UTF8.GetBytes("hello"); +HashResult hash = fnv.ComputeHash(data); - // Switch to FNV-1 algorithm - fnv.Options.Algorithm = FowlerNollVoAlgorithm.Fnv1; - HashResult hashFnv1 = fnv.ComputeHash(data); - Console.WriteLine(hashFnv1.ToHexadecimalString()); +// Display the hash in hexadecimal format +Console.WriteLine(hash.ToHexadecimalString()); - // Change byte order to little endian - fnv.Options.ByteOrder = Endianness.LittleEndian; - HashResult hashLe = fnv.ComputeHash(data); - Console.WriteLine(hashLe.ToHexadecimalString()); - -} -} +// Switch to FNV-1 algorithm +fnv.Options.Algorithm = FowlerNollVoAlgorithm.Fnv1; +HashResult hashFnv1 = fnv.ComputeHash(data); +Console.WriteLine(hashFnv1.ToHexadecimalString()); +// Change byte order to little endian +fnv.Options.ByteOrder = Endianness.LittleEndian; +HashResult hashLe = fnv.ComputeHash(data); +Console.WriteLine(hashLe.ToHexadecimalString()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.FowlerNollVoAlgorithm.md b/.docfx/api/types/Cuemon.Security.FowlerNollVoAlgorithm.md index 812f892ed..ed7c7d6e2 100644 --- a/.docfx/api/types/Cuemon.Security.FowlerNollVoAlgorithm.md +++ b/.docfx/api/types/Cuemon.Security.FowlerNollVoAlgorithm.md @@ -36,3 +36,7 @@ public class FowlerNollVoAlgorithmExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.FowlerNollVoOptions.md b/.docfx/api/types/Cuemon.Security.FowlerNollVoOptions.md index f83366d99..240a565b5 100644 --- a/.docfx/api/types/Cuemon.Security.FowlerNollVoOptions.md +++ b/.docfx/api/types/Cuemon.Security.FowlerNollVoOptions.md @@ -36,9 +36,13 @@ public class FowlerNollVoOptionsExample Console.WriteLine("FNV-1a 32-bit (little-endian): {0}", hash.ToHexadecimalString()); // Output: - // FNV-1a 32-bit (little-endian): 7b56c21a + // FNV-1a 32-bit (little-endian): 34f7ec5a } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.HashFactory.md b/.docfx/api/types/Cuemon.Security.HashFactory.md index b18d21d78..decc46092 100644 --- a/.docfx/api/types/Cuemon.Security.HashFactory.md +++ b/.docfx/api/types/Cuemon.Security.HashFactory.md @@ -7,28 +7,25 @@ example: The following example shows how to compute non-cryptographic hashes using `HashFactory`. It demonstrates FNV-1a 32-bit, CRC-32, and FNV-1a 256-bit hashing of a sample input, printing each hexadecimal digest. ```csharp +// Program.cs using System; using System.Text; using Cuemon.Security; -namespace Cuemon.Security; +var fnvHash = HashFactory.CreateFnv32(); +var input = "Hello World"; +var hash = fnvHash.ComputeHash(Encoding.UTF8.GetBytes(input)); +Console.WriteLine($"FNV-1a 32-bit: {BitConverter.ToString(hash.To(bytes => bytes)).Replace("-", "")}"); -public class HashFactoryExample -{ - public void Demonstrate() - { - var fnvHash = HashFactory.CreateFnv32(); - var input = "Hello World"; - var hash = fnvHash.ComputeHash(Encoding.UTF8.GetBytes(input)); - Console.WriteLine($"FNV-1a 32-bit: {BitConverter.ToString(hash.To(bytes => bytes)).Replace("-", "")}"); +var crcHash = HashFactory.CreateCrc32(); +hash = crcHash.ComputeHash(Encoding.UTF8.GetBytes(input)); +Console.WriteLine($"CRC-32: {BitConverter.ToString(hash.To(bytes => bytes)).Replace("-", "")}"); - var crcHash = HashFactory.CreateCrc32(); - hash = crcHash.ComputeHash(Encoding.UTF8.GetBytes(input)); - Console.WriteLine($"CRC-32: {BitConverter.ToString(hash.To(bytes => bytes)).Replace("-", "")}"); - - var fnv256Hash = HashFactory.CreateFnv256(); - hash = fnv256Hash.ComputeHash(Encoding.UTF8.GetBytes(input)); - Console.WriteLine($"FNV-1a 256-bit: {BitConverter.ToString(hash.To(bytes => bytes)).Replace("-", "")}"); - } -} +var fnv256Hash = HashFactory.CreateFnv256(); +hash = fnv256Hash.ComputeHash(Encoding.UTF8.GetBytes(input)); +Console.WriteLine($"FNV-1a 256-bit: {BitConverter.ToString(hash.To(bytes => bytes)).Replace("-", "")}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.HashResult.md b/.docfx/api/types/Cuemon.Security.HashResult.md index 5a27d754b..e219ed55f 100644 --- a/.docfx/api/types/Cuemon.Security.HashResult.md +++ b/.docfx/api/types/Cuemon.Security.HashResult.md @@ -36,10 +36,14 @@ public class HashResultExample // HasValue: True // Hex: dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f // Base64: 3/1gIbsr1bCvZ2KQgJ7DpTGR3YHH9wpLKGiKNiGCmG8= - // Url-safe Base64: 3_1gIbsr1bCvZ2KQgJ7DpTGR3YHH9wpLKGiKNiGCmG8= + // Url-safe Base64: 3_1gIbsr1bCvZ2KQgJ7DpTGR3YHH9wpLKGiKNiGCmG8 // ToString: dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Security.NonCryptoAlgorithm.md b/.docfx/api/types/Cuemon.Security.NonCryptoAlgorithm.md index 217deb931..65d0bb177 100644 --- a/.docfx/api/types/Cuemon.Security.NonCryptoAlgorithm.md +++ b/.docfx/api/types/Cuemon.Security.NonCryptoAlgorithm.md @@ -42,3 +42,7 @@ public class NonCryptoAlgorithmExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.SortOrder.md b/.docfx/api/types/Cuemon.SortOrder.md index f951531ee..b5a45dca2 100644 --- a/.docfx/api/types/Cuemon.SortOrder.md +++ b/.docfx/api/types/Cuemon.SortOrder.md @@ -7,32 +7,41 @@ example: The following example demonstrates how to use the enum to indicate the direction of a sort operation in a custom comparer. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon; +using Contoso.Search; -namespace Contoso.Search; +SortOrderExample.Run(); -public sealed class SortOrderExample +namespace Contoso.Search { - public static void Run() + public sealed class SortOrderExample { - var names = new List { "Charlie", "Alice", "Bob" }; + public static void Run() + { + var names = new List { "Charlie", "Alice", "Bob" }; - Apply(names, SortOrder.Ascending); - Console.WriteLine(string.Join(", ", names)); + Apply(names, SortOrder.Ascending); + Console.WriteLine(string.Join(", ", names)); - Apply(names, SortOrder.Descending); - Console.WriteLine(string.Join(", ", names)); - } + Apply(names, SortOrder.Descending); + Console.WriteLine(string.Join(", ", names)); + } - private static void Apply(List names, SortOrder sortOrder) - { - names.Sort((left, right) => + private static void Apply(List names, SortOrder sortOrder) { - int result = string.Compare(left, right, StringComparison.Ordinal); - return sortOrder == SortOrder.Descending ? -result : result; - }); + names.Sort((left, right) => + { + int result = string.Compare(left, right, StringComparison.Ordinal); + return sortOrder == SortOrder.Descending ? -result : result; + }); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.StringDecoratorExtensions.md b/.docfx/api/types/Cuemon.StringDecoratorExtensions.md index 54049c541..345ee4f10 100644 --- a/.docfx/api/types/Cuemon.StringDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.StringDecoratorExtensions.md @@ -7,6 +7,7 @@ example: `StringDecoratorExtensions` provides extension methods on `Decorator.Enclose` for string manipulation including casing conversion, encoding, URI conversion, set operations, and content inspection. This example wraps `" Hello World! "` and applies `ToCasing` with `LowerCase`, `UpperCase`, and `TitleCase` modes, converts the string to a byte array and stream with configurable encoding, and extracts the differing portion between `"Hello World!"` and `"Hello Universe!"` using `Difference`. Key steps also include `StartsWith` checks with multiple candidate strings and `ContainsAny` for character matching. Console output confirms each transformed value, such as `" hello world! "` for lower-casing and `"Universe!"` for the set difference. ```csharp +// Program.cs using System; using System.Globalization; using System.IO; @@ -14,52 +15,58 @@ using System.Text; using Cuemon; using Cuemon.Text; -namespace MyApp.Examples; +string value = " Hello World! "; +var decorator = Decorator.Enclose(value); -public class Example -{ - public void Run() - { - - string value = " Hello World! "; - var decorator = Decorator.Enclose(value); +// Change casing via decorator +string lower = decorator.ToCasing(CasingMethod.LowerCase); // " hello world! " +string upper = decorator.ToCasing(CasingMethod.UpperCase); // " HELLO WORLD! " +string title = decorator.ToCasing(CasingMethod.TitleCase, new CultureInfo("en-US")); // " Hello World! " - // Change casing via decorator - string lower = decorator.ToCasing(CasingMethod.LowerCase); // " hello world! " - string upper = decorator.ToCasing(CasingMethod.UpperCase); // " HELLO WORLD! " - string title = decorator.ToCasing(CasingMethod.TitleCase, new CultureInfo("en-US")); // " Hello World! " +// Convert to byte array +byte[] bytes = decorator.ToByteArray(o => o.Encoding = Encoding.UTF8); - // Convert to byte array - byte[] bytes = decorator.ToByteArray(o => o.Encoding = Encoding.UTF8); +// Convert to stream +using Stream stream = decorator.ToStream(o => o.Encoding = Encoding.UTF8); - // Convert to stream - using Stream stream = decorator.ToStream(o => o.Encoding = Encoding.UTF8); +// Convert to URI +string url = "https://www.example.com"; +var uriDecorator = Decorator.Enclose(url); +Uri uri = uriDecorator.ToUri(); // https://www.example.com/ - // Convert to URI - string url = "https://www.example.com"; - var uriDecorator = Decorator.Enclose(url); - Uri uri = uriDecorator.ToUri(); // https://www.example.com/ +// Encoding conversions +string ascii = decorator.ToAsciiEncodedString(o => o.Encoding = Encoding.UTF8); // " Hello World! " (non-ASCII chars replaced with empty) +string encoded = decorator.ToEncodedString(o => +{ + o.TargetEncoding = Encoding.ASCII; + o.EncoderFallback = new EncoderReplacementFallback("?"); +}); - // Encoding conversions - string ascii = decorator.ToAsciiEncodedString(o => o.Encoding = Encoding.UTF8); // " Hello World! " (non-ASCII chars replaced with empty) - string encoded = decorator.ToEncodedString(o => - { - o.TargetEncoding = Encoding.ASCII; - o.EncoderFallback = new EncoderReplacementFallback("?"); - }); +// StartsWith checks +bool starts = decorator.StartsWith(" Hello"); // true +bool startsIgnore = decorator.StartsWith(StringComparison.OrdinalIgnoreCase, "hello"); // true +bool startsAny = decorator.StartsWith("Hi", "Hello"); // true - // StartsWith checks - bool starts = decorator.StartsWith(" Hello"); // true - bool startsIgnore = decorator.StartsWith(StringComparison.OrdinalIgnoreCase, "hello"); // true - bool startsAny = decorator.StartsWith("Hi", "Hello"); // true +// Set difference +var helloDecorator = Decorator.Enclose("Hello World!"); +string diff = helloDecorator.Difference("Hello Universe!"); // "Universe!" - // Set difference - var helloDecorator = Decorator.Enclose("Hello World!"); - string diff = helloDecorator.Difference("Hello Universe!"); // "Universe!" +// ContainsAny for characters +bool hasChar = decorator.ContainsAny('o', StringComparison.Ordinal); // true +bool hasChars = decorator.ContainsAny(StringComparison.Ordinal, 'x', 'y'); // false - // ContainsAny for characters - bool hasChar = decorator.ContainsAny('o', StringComparison.Ordinal); // true - bool hasChars = decorator.ContainsAny(StringComparison.Ordinal, 'x', 'y'); // false - } -} +Console.WriteLine(lower); +Console.WriteLine(upper); +Console.WriteLine(bytes.Length); +Console.WriteLine(uri); +Console.WriteLine(starts); +Console.WriteLine(startsIgnore); +Console.WriteLine(startsAny); +Console.WriteLine(diff); +Console.WriteLine(hasChar); +Console.WriteLine(hasChars); ``` + + + + diff --git a/.docfx/api/types/Cuemon.StringFactory.md b/.docfx/api/types/Cuemon.StringFactory.md index a97373239..06dd6e74c 100644 --- a/.docfx/api/types/Cuemon.StringFactory.md +++ b/.docfx/api/types/Cuemon.StringFactory.md @@ -7,39 +7,37 @@ example: The following example demonstrates how to use `StringFactory` to generate hexadecimal, binary, URL-safe Base64, protocol-relative URL, and URI scheme strings from .NET data types. ```csharp +// Program.cs using System; +using Cuemon; -namespace Cuemon; - -public class StringFactoryExample -{ - public void Demonstrate() - { - // Convert bytes to hexadecimal string - byte[] binaryData = { 0x0F, 0xA0, 0x01 }; - string hex = StringFactory.CreateHexadecimal(binaryData); - Console.WriteLine(hex); // 0fa001 - - // Convert string to hexadecimal representation - string hexFromString = StringFactory.CreateHexadecimal("Hello"); - Console.WriteLine(hexFromString); // 48656c6c6f - - // Create binary digit string from bytes - string binary = StringFactory.CreateBinaryDigits(new byte[] { 0, 1, 255 }); - Console.WriteLine(binary); // 000000000000000111111111 - - // Create URL-safe Base64 string - string urlSafe = StringFactory.CreateUrlEncodedBase64(new byte[] { 251, 255 }); - Console.WriteLine(urlSafe); // -_8 - - // Create a protocol-relative URL (// prefix replaces https://) - string relativeUrl = StringFactory.CreateProtocolRelativeUrl( - new Uri("https://www.cuemon.net/about")); - Console.WriteLine(relativeUrl); // //www.cuemon.net/about - - // Get string representation of a URI scheme enum - string scheme = StringFactory.CreateUriScheme(UriScheme.Https); - Console.WriteLine(scheme); // https - } -} +// Convert bytes to hexadecimal string +byte[] binaryData = { 0x0F, 0xA0, 0x01 }; +string hex = StringFactory.CreateHexadecimal(binaryData); +Console.WriteLine(hex); // 0fa001 + +// Convert string to hexadecimal representation +string hexFromString = StringFactory.CreateHexadecimal("Hello"); +Console.WriteLine(hexFromString); // 48656c6c6f + +// Create binary digit string from bytes +string binary = StringFactory.CreateBinaryDigits(new byte[] { 0, 1, 255 }); +Console.WriteLine(binary); // 000000000000000111111111 + +// Create URL-safe Base64 string +string urlSafe = StringFactory.CreateUrlEncodedBase64(new byte[] { 251, 255 }); +Console.WriteLine(urlSafe); // -_8 + +// Create a protocol-relative URL (// prefix replaces https://) +string relativeUrl = StringFactory.CreateProtocolRelativeUrl( + new Uri("https://www.cuemon.net/about")); +Console.WriteLine(relativeUrl); // //www.cuemon.net/about + +// Get string representation of a URI scheme enum +string scheme = StringFactory.CreateUriScheme(UriScheme.Https); +Console.WriteLine(scheme); // https ``` + + + + diff --git a/.docfx/api/types/Cuemon.StringReplacePair.md b/.docfx/api/types/Cuemon.StringReplacePair.md index 3a3d04da8..31ddda2d2 100644 --- a/.docfx/api/types/Cuemon.StringReplacePair.md +++ b/.docfx/api/types/Cuemon.StringReplacePair.md @@ -7,45 +7,40 @@ example: The following example demonstrates how to use the struct to perform bulk string replacement and removal operations. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon; // for StringReplacePair -namespace MyApp.Examples; +string input = "Hello World from Cuemon! Welcome to the World of .NET."; -public class StringReplacePairExample -{ - public void Demonstrate() - { - string input = "Hello World from Cuemon! Welcome to the World of .NET."; - - // Replace all occurrences of "World" with "Universe" (case-insensitive by default) - string result = StringReplacePair.ReplaceAll(input, "World", "Universe"); - Console.WriteLine(result); - // Output: Hello Universe from Cuemon! Welcome to the Universe of .NET. - - // Replace multiple pairs at once - var pairs = new StringReplacePair[] - { - new StringReplacePair("Hello", "Hi"), - new StringReplacePair("Cuemon", "Codebelt"), - new StringReplacePair(".NET", "dotnet") - }; - result = StringReplacePair.ReplaceAll(input, pairs); - Console.WriteLine(result); - // Output: Hi Universe from Codebelt! Welcome to the Universe of dotnet. - - // Remove specific words (case-sensitive ordinal comparison) - result = StringReplacePair.RemoveAll(input, StringComparison.Ordinal, "World", "Cuemon", "Welcome"); - Console.WriteLine(result); - // Output: Hello from ! to the of .NET. - - // Remove specific characters - result = StringReplacePair.RemoveAll(input, '.', '!'); - Console.WriteLine(result); - // Output: Hello World from Cuemon Welcome to the World of NET - -} -} +// Replace all occurrences of "World" with "Universe" (case-insensitive by default) +string result = StringReplacePair.ReplaceAll(input, "World", "Universe"); +Console.WriteLine(result); +// Output: Hello Universe from Cuemon! Welcome to the Universe of .NET. +// Replace multiple pairs at once +var pairs = new StringReplacePair[] +{ + new StringReplacePair("Hello", "Hi"), + new StringReplacePair("Cuemon", "Codebelt"), + new StringReplacePair(".NET", "dotnet") +}; +result = StringReplacePair.ReplaceAll(input, pairs); +Console.WriteLine(result); +// Output: Hi World from Codebelt! Welcome to the World of dotnet. + +// Remove specific words (case-sensitive ordinal comparison) +result = StringReplacePair.RemoveAll(input, StringComparison.Ordinal, "World", "Cuemon", "Welcome"); +Console.WriteLine(result); +// Output: Hello from ! to the of .NET. + +// Remove specific characters +result = StringReplacePair.RemoveAll(input, '.', '!'); +Console.WriteLine(result); +// Output: Hello World from Cuemon Welcome to the World of NET ``` + + + + diff --git a/.docfx/api/types/Cuemon.SuccessfulValue.md b/.docfx/api/types/Cuemon.SuccessfulValue.md index 615b7cf9d..da4bb2e12 100644 --- a/.docfx/api/types/Cuemon.SuccessfulValue.md +++ b/.docfx/api/types/Cuemon.SuccessfulValue.md @@ -7,29 +7,38 @@ example: The following example demonstrates how to use `SuccessfulValue` to represent a void operation that completed successfully, enabling consistent conditional-return patterns. ```csharp +// Program.cs using System; using Cuemon; +using Contoso.Startup; -namespace Contoso.Startup; +SuccessfulValueExample.Run(); -public sealed class SuccessfulValueExample +namespace Contoso.Startup { - public static void Run() + public sealed class SuccessfulValueExample { - ConditionalValue outcome = WarmUpCache(dependenciesReady: true); + public static void Run() + { + ConditionalValue outcome = WarmUpCache(dependenciesReady: true); - Console.WriteLine($"Succeeded: {outcome.Succeeded}"); - Console.WriteLine($"Failure is null: {outcome.Failure is null}"); - } + Console.WriteLine($"Succeeded: {outcome.Succeeded}"); + Console.WriteLine($"Failure is null: {outcome.Failure is null}"); + } - private static ConditionalValue WarmUpCache(bool dependenciesReady) - { - if (!dependenciesReady) + private static ConditionalValue WarmUpCache(bool dependenciesReady) { - return new UnsuccessfulValue(new InvalidOperationException("Dependencies are missing.")); - } + if (!dependenciesReady) + { + return new UnsuccessfulValue(new InvalidOperationException("Dependencies are missing.")); + } - return new SuccessfulValue(); + return new SuccessfulValue(); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.SuccessfulValue`1.md b/.docfx/api/types/Cuemon.SuccessfulValue`1.md index 56d95f8ef..3b712ca09 100644 --- a/.docfx/api/types/Cuemon.SuccessfulValue`1.md +++ b/.docfx/api/types/Cuemon.SuccessfulValue`1.md @@ -7,29 +7,38 @@ example: The following example demonstrates how to use `SuccessfulValue` to represent a typed operation that completed successfully, pairing a result value with a success signal. ```csharp +// Program.cs using System; using Cuemon; +using Contoso.Configuration; -namespace Contoso.Configuration; +SuccessfulValueOfTResultExample.Run(); -public sealed class SuccessfulValueOfTResultExample +namespace Contoso.Configuration { - public static void Run() + public sealed class SuccessfulValueOfTResultExample { - ConditionalValue outcome = ParsePort("443"); + public static void Run() + { + ConditionalValue outcome = ParsePort("443"); - Console.WriteLine($"Succeeded: {outcome.Succeeded}"); - Console.WriteLine($"Port: {outcome.Result}"); - } + Console.WriteLine($"Succeeded: {outcome.Succeeded}"); + Console.WriteLine($"Port: {outcome.Result}"); + } - private static ConditionalValue ParsePort(string text) - { - if (int.TryParse(text, out int port)) + private static ConditionalValue ParsePort(string text) { - return new SuccessfulValue(port); - } + if (int.TryParse(text, out int port)) + { + return new SuccessfulValue(port); + } - return new UnsuccessfulValue(new FormatException("The port number is invalid.")); + return new UnsuccessfulValue(new FormatException("The port number is invalid.")); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.SystemSnapshots.md b/.docfx/api/types/Cuemon.SystemSnapshots.md index 07e35b8f2..6ae92cf0e 100644 --- a/.docfx/api/types/Cuemon.SystemSnapshots.md +++ b/.docfx/api/types/Cuemon.SystemSnapshots.md @@ -7,15 +7,10 @@ example: The following example demonstrates how to use the `SystemSnapshots` flags enum to specify which system information categories to capture in a diagnostics snapshot. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.Examples -{ - public class SystemSnapshotsExample - { - public void Demonstrate() - { // SystemSnapshots is a flags enum controlling which system // information categories to capture. @@ -39,7 +34,9 @@ namespace MyApp.Examples Console.WriteLine($"Flags: {flags}"); // CaptureThreadInfo | CaptureProcessInfo Console.WriteLine($"Has thread info: {flags.HasFlag(SystemSnapshots.CaptureThreadInfo)}"); // True -}}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.TesterFuncFactory`3.md b/.docfx/api/types/Cuemon.TesterFuncFactory`3.md index d21af8768..fb2ccc80f 100644 --- a/.docfx/api/types/Cuemon.TesterFuncFactory`3.md +++ b/.docfx/api/types/Cuemon.TesterFuncFactory`3.md @@ -7,30 +7,39 @@ example: The following example demonstrates how to use `TesterFuncFactory` to encapsulate a tester function with its arguments for deferred execution with output extraction. ```csharp +// Program.cs using System; using Cuemon; +using Contoso.Validation; -namespace Contoso.Validation; +TesterFuncFactoryExample.Run(); -public sealed class TesterFuncFactoryExample +namespace Contoso.Validation { - public static void Run() + public sealed class TesterFuncFactoryExample { - var factory = new TesterFuncFactory, string, bool>( - (MutableTuple tuple, out string result) => - { - result = $"{tuple.Arg1},{tuple.Arg2},{tuple.Arg3}"; - return true; - }, - new MutableTuple(1, 2, 3)); + public static void Run() + { + var factory = new TesterFuncFactory, string, bool>( + (MutableTuple tuple, out string result) => + { + result = $"{tuple.Arg1},{tuple.Arg2},{tuple.Arg3}"; + return true; + }, + new MutableTuple(1, 2, 3)); - bool success = factory.ExecuteMethod(out string output); - var clone = (TesterFuncFactory, string, bool>)factory.Clone(); - clone.ExecuteMethod(out string clonedOutput); + bool success = factory.ExecuteMethod(out string output); + var clone = (TesterFuncFactory, string, bool>)factory.Clone(); + clone.ExecuteMethod(out string clonedOutput); - Console.WriteLine($"Success: {success}"); - Console.WriteLine(output); - Console.WriteLine(clonedOutput); + Console.WriteLine($"Success: {success}"); + Console.WriteLine(output); + Console.WriteLine(clonedOutput); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.TesterFunc`2.md b/.docfx/api/types/Cuemon.TesterFunc`2.md index 3753c7223..a6af345e2 100644 --- a/.docfx/api/types/Cuemon.TesterFunc`2.md +++ b/.docfx/api/types/Cuemon.TesterFunc`2.md @@ -7,25 +7,22 @@ example: The following example demonstrates the shared workflow for the family: call the delegate, capture the out value, and branch on the success result. ```csharp +// Program.cs using System; using Cuemon; -namespace MyApp.Examples; - -public static class TesterFuncExample +TesterFunc tryReadPort = (out int port) => { - public static void Demonstrate() - { - TesterFunc tryReadPort = (out int port) => - { - var configuredPort = "8080"; - return int.TryParse(configuredPort, out port); - }; + var configuredPort = "8080"; + return int.TryParse(configuredPort, out port); +}; - var success = tryReadPort(out var port); +var success = tryReadPort(out var port); - Console.WriteLine(success); - Console.WriteLine(port); - } -} +Console.WriteLine(success); +Console.WriteLine(port); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Text.AsyncEncodingOptions.md b/.docfx/api/types/Cuemon.Text.AsyncEncodingOptions.md index 2a719046e..830ef1c03 100644 --- a/.docfx/api/types/Cuemon.Text.AsyncEncodingOptions.md +++ b/.docfx/api/types/Cuemon.Text.AsyncEncodingOptions.md @@ -7,30 +7,29 @@ example: The following example demonstrates how to configure `AsyncEncodingOptions` with a cancellation token for use in asynchronous encoding operations. ```csharp +// Program.cs +using System; using System.Threading.Tasks; using System.Text; using System.Threading; using Cuemon.Text; -namespace MyApp.Examples; - -public class AsyncEncodingOptionsExample +using var cts = new CancellationTokenSource(); +var options = new AsyncEncodingOptions { - public void Demonstrate() - { - using var cts = new CancellationTokenSource(); - var options = new AsyncEncodingOptions - { - Encoding = Encoding.UTF8, - Preamble = PreambleSequence.Remove, - CancellationToken = cts.Token - }; - - // The options can be passed to async encoding methods - // that accept AsyncEncodingOptions. If cancellation is - // requested, the operation will be cancelled gracefully. - -} -} + Encoding = Encoding.UTF8, + Preamble = PreambleSequence.Remove, + CancellationToken = cts.Token +}; +// The options can be passed to async encoding methods +// that accept AsyncEncodingOptions. If cancellation is +// requested, the operation will be cancelled gracefully. +Console.WriteLine(options.Encoding.WebName); +Console.WriteLine(options.Preamble); +Console.WriteLine(options.CancellationToken.CanBeCanceled); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Text.ByteOrderMark.md b/.docfx/api/types/Cuemon.Text.ByteOrderMark.md index e9ee60861..b1688f98b 100644 --- a/.docfx/api/types/Cuemon.Text.ByteOrderMark.md +++ b/.docfx/api/types/Cuemon.Text.ByteOrderMark.md @@ -7,29 +7,26 @@ example: The following example demonstrates how to detect and remove byte order marks (BOM) from a UTF-8 byte array and detect encoding from a stream. The output shows the detected encoding name, the byte count after BOM removal, and the encoding detected from the stream. ```csharp +// Program.cs using System; using System.IO; using System.Text; using Cuemon.Text; -namespace Cuemon.Text; +var utf8Bytes = new byte[] { 0xEF, 0xBB, 0xBF, 0x48, 0x65, 0x6C, 0x6C, 0x6F }; +var encoding = ByteOrderMark.Decode(utf8Bytes); +Console.WriteLine($"Detected encoding: {encoding.EncodingName}"); -public class ByteOrderMarkExample -{ - public void Demonstrate() - { - var utf8Bytes = new byte[] { 0xEF, 0xBB, 0xBF, 0x48, 0x65, 0x6C, 0x6C, 0x6F }; - var encoding = ByteOrderMark.Decode(utf8Bytes); - Console.WriteLine($"Detected encoding: {encoding.EncodingName}"); - - var bytes = ByteOrderMark.Remove(utf8Bytes, Encoding.UTF8); - Console.WriteLine($"BOM removed, remaining length: {bytes.Length}"); +var bytes = ByteOrderMark.Remove(utf8Bytes, Encoding.UTF8); +Console.WriteLine($"BOM removed, remaining length: {bytes.Length}"); - using var stream = new MemoryStream(utf8Bytes); - if (ByteOrderMark.TryDetectEncoding(stream, out var detected)) - { - Console.WriteLine($"Stream encoding: {detected.EncodingName}"); - } - } +using var stream = new MemoryStream(utf8Bytes); +if (ByteOrderMark.TryDetectEncoding(stream, out var detected)) +{ + Console.WriteLine($"Stream encoding: {detected.EncodingName}"); } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Text.EncodingOptions.md b/.docfx/api/types/Cuemon.Text.EncodingOptions.md index 85a37a237..1b0a610cf 100644 --- a/.docfx/api/types/Cuemon.Text.EncodingOptions.md +++ b/.docfx/api/types/Cuemon.Text.EncodingOptions.md @@ -7,37 +7,32 @@ example: The following example demonstrates how to use to control encoding behavior, including preamble handling and encoding selection. ```csharp +// Program.cs using System; using System.Text; using Cuemon.Text; // for EncodingOptions, PreambleSequence -namespace MyApp.Examples; - -public class EncodingOptionsExample +// Create options with UTF-8 encoding, removing the BOM preamble +var options = new EncodingOptions { - public void Demonstrate() - { - // Create options with UTF-8 encoding, removing the BOM preamble - var options = new EncodingOptions - { - Encoding = Encoding.UTF8, - Preamble = PreambleSequence.Remove - }; - Console.WriteLine(options.Encoding.EncodingName); // Unicode (UTF-8) - Console.WriteLine(options.Preamble); // Remove - - // Create options that keep the preamble - var preserveOptions = new EncodingOptions - { - Encoding = Encoding.Unicode, - Preamble = PreambleSequence.Keep - }; - Console.WriteLine(preserveOptions.Preamble); // Keep - - // Encoding property validates for null - // options.Encoding = null; // throws ArgumentNullException - -} -} + Encoding = Encoding.UTF8, + Preamble = PreambleSequence.Remove +}; +Console.WriteLine(options.Encoding.EncodingName); // Unicode (UTF-8) +Console.WriteLine(options.Preamble); // Remove + +// Create options that keep the preamble +var preserveOptions = new EncodingOptions +{ + Encoding = Encoding.Unicode, + Preamble = PreambleSequence.Keep +}; +Console.WriteLine(preserveOptions.Preamble); // Keep +// Encoding property validates for null +// options.Encoding = null; // throws ArgumentNullException ``` + + + + diff --git a/.docfx/api/types/Cuemon.Text.EnumStringOptions.md b/.docfx/api/types/Cuemon.Text.EnumStringOptions.md index 0c2a5d3be..333f9d194 100644 --- a/.docfx/api/types/Cuemon.Text.EnumStringOptions.md +++ b/.docfx/api/types/Cuemon.Text.EnumStringOptions.md @@ -7,32 +7,27 @@ example: The following example demonstrates how to configure `EnumStringOptions` to control case sensitivity when parsing an enum from a string using `ParserFactory.FromEnum`. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Text; -namespace MyApp.Examples; - -public class EnumStringOptionsExample +// Direct instantiation of EnumStringOptions +var options = new EnumStringOptions { - public void Demonstrate() - { - // Direct instantiation of EnumStringOptions - var options = new EnumStringOptions - { - IgnoreCase = true - }; - - var parser = ParserFactory.FromEnum(); - - var result = (UriKind)parser.Parse("Relative", typeof(UriKind), o => - { - o.IgnoreCase = true; - }); + IgnoreCase = true +}; - Console.WriteLine(result); // outputs: Relative +var parser = ParserFactory.FromEnum(); -} -} +var result = (UriKind)parser.Parse("Relative", typeof(UriKind), o => +{ + o.IgnoreCase = true; +}); +Console.WriteLine(result); // outputs: Relative ``` + + + + diff --git a/.docfx/api/types/Cuemon.Text.FallbackEncodingOptions.md b/.docfx/api/types/Cuemon.Text.FallbackEncodingOptions.md index 949425529..c815d10c2 100644 --- a/.docfx/api/types/Cuemon.Text.FallbackEncodingOptions.md +++ b/.docfx/api/types/Cuemon.Text.FallbackEncodingOptions.md @@ -7,29 +7,29 @@ example: The following example demonstrates how to configure `FallbackEncodingOptions` to use exception fallbacks when encoding or decoding characters that are not supported by the target encoding. ```csharp +// Program.cs +using System; using System.Text; using Cuemon.Text; -namespace MyApp.Examples; - -public class FallbackEncodingOptionsExample +var options = new FallbackEncodingOptions { - public void Demonstrate() - { - var options = new FallbackEncodingOptions - { - TargetEncoding = Encoding.ASCII, - EncoderFallback = EncoderFallback.ExceptionFallback, - DecoderFallback = DecoderFallback.ExceptionFallback, - Encoding = Encoding.UTF8, - Preamble = PreambleSequence.Remove - }; - - // The options are ready to be used with encoding operations - // that respect FallbackEncodingOptions. When an unsupported - // character is encountered, an EncoderFallbackException will be thrown. - -} -} + TargetEncoding = Encoding.ASCII, + EncoderFallback = EncoderFallback.ExceptionFallback, + DecoderFallback = DecoderFallback.ExceptionFallback, + Encoding = Encoding.UTF8, + Preamble = PreambleSequence.Remove +}; +// The options are ready to be used with encoding operations +// that respect FallbackEncodingOptions. When an unsupported +// character is encountered, an EncoderFallbackException will be thrown. +Console.WriteLine(options.TargetEncoding.WebName); +Console.WriteLine(options.Preamble); +Console.WriteLine(options.EncoderFallback.MaxCharCount); +Console.WriteLine(options.DecoderFallback.MaxCharCount); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Text.GuidStringOptions.md b/.docfx/api/types/Cuemon.Text.GuidStringOptions.md index b14393991..af4ab53f1 100644 --- a/.docfx/api/types/Cuemon.Text.GuidStringOptions.md +++ b/.docfx/api/types/Cuemon.Text.GuidStringOptions.md @@ -7,34 +7,29 @@ example: The following example demonstrates how to configure `GuidStringOptions` to restrict which GUID formats are accepted when parsing with `ParserFactory.FromGuid`. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Text; -namespace MyApp.Examples; - -public class GuidStringOptionsExample +// Direct instantiation of GuidStringOptions +var options = new GuidStringOptions { - public void Demonstrate() - { - // Direct instantiation of GuidStringOptions - var options = new GuidStringOptions - { - Formats = GuidFormats.D - }; - - var parser = ParserFactory.FromGuid(); - var guidString = "{3f2504e0-4f89-41d3-9a0c-0305e82c3301}"; - - var result = parser.Parse(guidString, o => - { - o.Formats = GuidFormats.B; - }); + Formats = GuidFormats.D +}; - Console.WriteLine(result); - // outputs: 3f2504e0-4f89-41d3-9a0c-0305e82c3301 +var parser = ParserFactory.FromGuid(); +var guidString = "{3f2504e0-4f89-41d3-9a0c-0305e82c3301}"; -} -} +var result = parser.Parse(guidString, o => +{ + o.Formats = GuidFormats.B; +}); +Console.WriteLine(result); +// outputs: 3f2504e0-4f89-41d3-9a0c-0305e82c3301 ``` + + + + diff --git a/.docfx/api/types/Cuemon.Text.ParserFactory.md b/.docfx/api/types/Cuemon.Text.ParserFactory.md index 7cafb4ae8..f2edc77f0 100644 --- a/.docfx/api/types/Cuemon.Text.ParserFactory.md +++ b/.docfx/api/types/Cuemon.Text.ParserFactory.md @@ -7,26 +7,23 @@ example: The following example demonstrates parsing a GUID string, a Base64-encoded value, and a URI string using the factory methods provided by `ParserFactory`. Each parser is created via a dedicated factory method and then invoked to produce a strongly typed result. ```csharp +// Program.cs using System; using Cuemon.Text; -namespace Cuemon.Text; +var guidParser = ParserFactory.FromGuid(); +var result = guidParser.Parse("6B29FC40-CA47-1067-B31D-00DD010662DA"); +Console.WriteLine($"Parsed GUID: {result}"); -public class ParserFactoryExample -{ - public void Demonstrate() - { - var guidParser = ParserFactory.FromGuid(); - var result = guidParser.Parse("6B29FC40-CA47-1067-B31D-00DD010662DA"); - Console.WriteLine($"Parsed GUID: {result}"); +var base64Parser = ParserFactory.FromBase64(); +var bytes = base64Parser.Parse("SGVsbG8gV29ybGQ="); +Console.WriteLine($"Base64 decoded bytes: {bytes.Length}"); - var base64Parser = ParserFactory.FromBase64(); - var bytes = base64Parser.Parse("SGVsbG8gV29ybGQ="); - Console.WriteLine($"Base64 decoded bytes: {bytes.Length}"); - - var uriParser = ParserFactory.FromUri(); - var uri = uriParser.Parse("https://example.com/resource"); - Console.WriteLine($"Parsed URI: {uri}"); - } -} +var uriParser = ParserFactory.FromUri(); +var uri = uriParser.Parse("https://example.com/resource"); +Console.WriteLine($"Parsed URI: {uri}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Text.PreambleSequence.md b/.docfx/api/types/Cuemon.Text.PreambleSequence.md index f7f014e22..da7fe91b8 100644 --- a/.docfx/api/types/Cuemon.Text.PreambleSequence.md +++ b/.docfx/api/types/Cuemon.Text.PreambleSequence.md @@ -7,28 +7,23 @@ example: The following example demonstrates how to use `PreambleSequence` with `EncodingOptions` to control whether byte order marks (BOM) are preserved or removed. ```csharp +// Program.cs using System; using System.Text; using Cuemon.Text; -namespace MyApp.Examples; - -public class PreambleSequenceExample +var options = new EncodingOptions { - public void Demonstrate() - { - var options = new EncodingOptions - { - Encoding = Encoding.UTF8, - Preamble = PreambleSequence.Keep - }; - - var preambleAction = options.Preamble; - var encoding = options.Encoding; + Encoding = Encoding.UTF8, + Preamble = PreambleSequence.Keep +}; - Console.WriteLine(preambleAction); // outputs: Keep - -} -} +var preambleAction = options.Preamble; +var encoding = options.Encoding; +Console.WriteLine(preambleAction); // outputs: Keep ``` + + + + diff --git a/.docfx/api/types/Cuemon.Text.ProtocolRelativeUriStringOptions.md b/.docfx/api/types/Cuemon.Text.ProtocolRelativeUriStringOptions.md index a1e9acf30..afa69dd4a 100644 --- a/.docfx/api/types/Cuemon.Text.ProtocolRelativeUriStringOptions.md +++ b/.docfx/api/types/Cuemon.Text.ProtocolRelativeUriStringOptions.md @@ -7,32 +7,27 @@ example: The following example demonstrates how to configure ProtocolRelativeUriStringOptions to resolve protocol-relative URIs (such as //example.com/resource) by specifying the default protocol scheme. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Text; -namespace MyApp.Examples +// Configure how a protocol-relative URI (e.g., "//example.com/resource") +// is resolved to an absolute URI by specifying the default protocol. +var options = new ProtocolRelativeUriStringOptions { - public class ProtocolRelativeUriStringOptionsExample - { - public void Demonstrate() - { - // Configure how a protocol-relative URI (e.g., "//example.com/resource") - // is resolved to an absolute URI by specifying the default protocol. - var options = new ProtocolRelativeUriStringOptions - { - Protocol = UriScheme.Https, - RelativeReference = Alphanumeric.NetworkPathReference - }; + Protocol = UriScheme.Https, + RelativeReference = Alphanumeric.NetworkPathReference +}; - Console.WriteLine($"Protocol: {options.Protocol}"); - Console.WriteLine($"Relative reference: {options.RelativeReference}"); - - // Switch to HTTP for local development - options.Protocol = UriScheme.Http; - Console.WriteLine($"Updated protocol: {options.Protocol}"); - -}} -} +Console.WriteLine($"Protocol: {options.Protocol}"); +Console.WriteLine($"Relative reference: {options.RelativeReference}"); +// Switch to HTTP for local development +options.Protocol = UriScheme.Http; +Console.WriteLine($"Updated protocol: {options.Protocol}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Text.Stem.md b/.docfx/api/types/Cuemon.Text.Stem.md index b3f131d6b..59616eb9a 100644 --- a/.docfx/api/types/Cuemon.Text.Stem.md +++ b/.docfx/api/types/Cuemon.Text.Stem.md @@ -7,25 +7,22 @@ example: The following example demonstrates how to use `Stem` to build a URL path by attaching prefixes and suffixes without duplication. ```csharp +// Program.cs +using System; using Cuemon.Text; -namespace MyApp.Examples; - -public class StemExample -{ - public void Demonstrate() - { - var path = new Stem("api") - .AttachPrefix("/") - .AttachSuffix("/") - .AttachSuffix("v1") - .AttachSuffix("/") - .AttachSuffix("users"); - - var result = path.ToString(); - // result == "/api/v1/users" - -} -} +var path = new Stem("api") + .AttachPrefix("/") + .AttachSuffix("/") + .AttachSuffix("v1") + .AttachSuffix("/") + .AttachSuffix("users"); +var result = path.ToString(); +// result == "/api/v1/users" +Console.WriteLine(result); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Text.UriStringOptions.md b/.docfx/api/types/Cuemon.Text.UriStringOptions.md index 3a392b5ff..9d8ace86d 100644 --- a/.docfx/api/types/Cuemon.Text.UriStringOptions.md +++ b/.docfx/api/types/Cuemon.Text.UriStringOptions.md @@ -7,32 +7,29 @@ example: The following example demonstrates how to configure UriStringOptions to validate and inspect URI properties including kind and allowed schemes. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; using Cuemon; using Cuemon.Text; -namespace Contoso.Webhooks; - -public sealed class UriStringOptionsExample +var options = new UriStringOptions { - public static void Run() - { - var options = new UriStringOptions - { - Kind = UriKind.Absolute, - Schemes = new List { UriScheme.Https, UriScheme.Http } - }; + Kind = UriKind.Absolute, + Schemes = new List { UriScheme.Https, UriScheme.Http } +}; - options.ValidateOptions(); +options.ValidateOptions(); - bool allowsHttps = options.Schemes.Contains(UriScheme.Https); - int knownSchemes = UriStringOptions.AllUriSchemes.Count(); +bool allowsHttps = options.Schemes.Contains(UriScheme.Https); +int knownSchemes = UriStringOptions.AllUriSchemes.Count(); - Console.WriteLine($"Kind: {options.Kind}"); - Console.WriteLine($"Allows HTTPS: {allowsHttps}"); - Console.WriteLine($"Known schemes: {knownSchemes}"); - } -} +Console.WriteLine($"Kind: {options.Kind}"); +Console.WriteLine($"Allows HTTPS: {allowsHttps}"); +Console.WriteLine($"Known schemes: {knownSchemes}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Threading.AdvancedParallelFactory.md b/.docfx/api/types/Cuemon.Threading.AdvancedParallelFactory.md index 8113088fe..92b8d68b6 100644 --- a/.docfx/api/types/Cuemon.Threading.AdvancedParallelFactory.md +++ b/.docfx/api/types/Cuemon.Threading.AdvancedParallelFactory.md @@ -7,20 +7,18 @@ example: The following example demonstrates using `AdvancedParallelFactory` to compute an iterator value and evaluate a loop condition. The output shows the result of `5 + 3` and whether that result satisfies the greater-than-or-equal check of 8. ```csharp +// Program.cs using System; +using Cuemon; using Cuemon.Threading; -namespace Cuemon.Threading; +var next = AdvancedParallelFactory.Iterator(5, AssignmentOperator.Addition, 3); +Console.WriteLine($"5 + 3 = {next}"); -public class AdvancedParallelFactoryExample -{ - public void Demonstrate() - { - var next = AdvancedParallelFactory.Iterator(5, AssignmentOperator.Addition, 3); - Console.WriteLine($"5 + 3 = {next}"); - - var isComplete = AdvancedParallelFactory.Condition(next, RelationalOperator.GreaterThanOrEqual, 8); - Console.WriteLine($"Is loop condition met? {isComplete}"); - } -} +var isComplete = AdvancedParallelFactory.Condition(next, RelationalOperator.GreaterThanOrEqual, 8); +Console.WriteLine($"Is loop condition met? {isComplete}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Threading.AsyncActionFactory-1.md b/.docfx/api/types/Cuemon.Threading.AsyncActionFactory-1.md index cd424168b..335873f21 100644 --- a/.docfx/api/types/Cuemon.Threading.AsyncActionFactory-1.md +++ b/.docfx/api/types/Cuemon.Threading.AsyncActionFactory-1.md @@ -7,31 +7,28 @@ example: `AsyncActionFactory` encapsulates a deferred asynchronous action with typed arguments, with support for cloning for safe concurrent execution. This example creates a factory using `AsyncActionFactory.Create` with a lambda that takes a channel name (`"orders"`) and retry count (`3`), delays 10ms, and prints them, then calls `ExecuteMethodAsync` to run it. Key steps include cloning the factory via `(AsyncActionFactory>)factory.Clone()` and executing the clone separately. Console output displays `"orders:3"` for both the original and cloned execution, confirming that cloned factories produce identical results. ```csharp +// Program.cs using System; using System.Threading; using System.Threading.Tasks; using Cuemon; using Cuemon.Threading; -namespace MyApp.Examples; - -public static class AsyncActionFactoryExample -{ - public static async Task DemonstrateAsync() +var factory = AsyncActionFactory.Create( + async (channel, retryCount, cancellationToken) => { - var factory = AsyncActionFactory.Create( - async (channel, retryCount, cancellationToken) => - { - await Task.Delay(10, cancellationToken).ConfigureAwait(false); - Console.WriteLine($"{channel}:{retryCount}"); - }, - "orders", - 3); + await Task.Delay(10, cancellationToken).ConfigureAwait(false); + Console.WriteLine($"{channel}:{retryCount}"); + }, + "orders", + 3); - await factory.ExecuteMethodAsync(CancellationToken.None); +await factory.ExecuteMethodAsync(CancellationToken.None); - var clone = (AsyncActionFactory>)factory.Clone(); - await clone.ExecuteMethodAsync(CancellationToken.None); - } -} +var clone = (AsyncActionFactory>)factory.Clone(); +await clone.ExecuteMethodAsync(CancellationToken.None); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Threading.AsyncActionFactory.md b/.docfx/api/types/Cuemon.Threading.AsyncActionFactory.md index 3970dc935..8960a19da 100644 --- a/.docfx/api/types/Cuemon.Threading.AsyncActionFactory.md +++ b/.docfx/api/types/Cuemon.Threading.AsyncActionFactory.md @@ -7,30 +7,38 @@ example: `AsyncActionFactory` provides factory methods for creating deferred asynchronous actions with zero or more typed arguments, executed via `ExecuteMethodAsync`. This example creates an action that prints `"Async operation executed"` and another with a string argument that logs `"Hello from async action"` after a 10ms delay, then invokes each with `CancellationToken.None`. Key setup includes using `AsyncActionFactory.Create` with a lambda and passing arguments separately so the factory handles lifetime and error propagation. Console output confirms both actions execute successfully, with the parameterized action receiving and printing the supplied message. ```csharp +// Program.cs using System; using System.Threading; using System.Threading.Tasks; using Cuemon.Threading; -namespace Cuemon.Threading; +await new AsyncActionFactoryExample().DemonstrateAsync(); -public class AsyncActionFactoryExample +namespace Cuemon.Threading { - public async Task DemonstrateAsync() + public class AsyncActionFactoryExample { - var factory = AsyncActionFactory.Create(ct => + public async Task DemonstrateAsync() { - Console.WriteLine("Async operation executed"); - return Task.CompletedTask; - }); - await factory.ExecuteMethodAsync(CancellationToken.None); + var factory = AsyncActionFactory.Create(ct => + { + Console.WriteLine("Async operation executed"); + return Task.CompletedTask; + }); + await factory.ExecuteMethodAsync(CancellationToken.None); - var factoryWithArg = AsyncActionFactory.Create(async (string msg, CancellationToken ct) => - { - await Task.Delay(10, ct); - Console.WriteLine(msg); - }, "Hello from async action"); - await factoryWithArg.ExecuteMethodAsync(CancellationToken.None); + var factoryWithArg = AsyncActionFactory.Create(async (string msg, CancellationToken ct) => + { + await Task.Delay(10, ct); + Console.WriteLine(msg); + }, "Hello from async action"); + await factoryWithArg.ExecuteMethodAsync(CancellationToken.None); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Threading.AsyncFuncFactory.md b/.docfx/api/types/Cuemon.Threading.AsyncFuncFactory.md index b17b79834..0f1a0892f 100644 --- a/.docfx/api/types/Cuemon.Threading.AsyncFuncFactory.md +++ b/.docfx/api/types/Cuemon.Threading.AsyncFuncFactory.md @@ -7,31 +7,39 @@ example: `AsyncFuncFactory` provides factory methods for creating deferred asynchronous functions with zero or more typed arguments and a return value, executed via `ExecuteMethodAsync`. This example creates a function that returns `42` and another that sums two integers (`3` and `4`) after a 10ms delay, then invokes each with `CancellationToken.None`. Key setup includes using `AsyncFuncFactory.Create` with a lambda and passing arguments separately so the factory manages lifetime and error propagation. Console output displays `"Result: 42"` and `"Sum: 7"`, confirming both the parameterless and parameterized async function patterns. ```csharp +// Program.cs using System; using System.Threading; using System.Threading.Tasks; using Cuemon.Threading; -namespace Cuemon.Threading; +await new AsyncFuncFactoryExample().DemonstrateAsync(); -public class AsyncFuncFactoryExample +namespace Cuemon.Threading { - public async Task DemonstrateAsync() + public class AsyncFuncFactoryExample { - var factory = AsyncFuncFactory.Create(ct => + public async Task DemonstrateAsync() { - return Task.FromResult(42); - }); - var result = await factory.ExecuteMethodAsync(CancellationToken.None); - Console.WriteLine($"Result: {result}"); + var factory = AsyncFuncFactory.Create(ct => + { + return Task.FromResult(42); + }); + var result = await factory.ExecuteMethodAsync(CancellationToken.None); + Console.WriteLine($"Result: {result}"); - var factoryWithArg = AsyncFuncFactory.Create(async (int a, int b, CancellationToken ct) => - { - await Task.Delay(10, ct); - return a + b; - }, 3, 4); - var sum = await factoryWithArg.ExecuteMethodAsync(CancellationToken.None); - Console.WriteLine($"Sum: {sum}"); + var factoryWithArg = AsyncFuncFactory.Create(async (int a, int b, CancellationToken ct) => + { + await Task.Delay(10, ct); + return a + b; + }, 3, 4); + var sum = await factoryWithArg.ExecuteMethodAsync(CancellationToken.None); + Console.WriteLine($"Sum: {sum}"); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Threading.AsyncFuncFactory`2.md b/.docfx/api/types/Cuemon.Threading.AsyncFuncFactory`2.md index 7520a27b7..024c83de4 100644 --- a/.docfx/api/types/Cuemon.Threading.AsyncFuncFactory`2.md +++ b/.docfx/api/types/Cuemon.Threading.AsyncFuncFactory`2.md @@ -7,11 +7,15 @@ example: `AsyncFuncFactory` encapsulates a deferred asynchronous function with typed arguments and return value, with cloning support for safe concurrent use. This example creates a factory using `AsyncFuncFactory.Create` with a lambda that takes `"Hello"` and `"World"` and returns their combined length, then calls `ExecuteMethodAsync` to compute the result. Key steps include checking `HasDelegate` and `DelegateInfo` properties, and cloning the factory via `(AsyncFuncFactory, int>)factory.Clone()` to execute independently. Console output confirms `HasDelegate` is `True`, the combined length is `10`, and the cloned result is also `10`. ```csharp +// Program.cs using System; using System.Threading; using System.Threading.Tasks; using Cuemon; using Cuemon.Threading; +using MyApp.Examples; + +await new AsyncFuncFactoryExample().DemonstrateAsync(); namespace MyApp.Examples { @@ -45,5 +49,8 @@ namespace MyApp.Examples }} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Threading.AsyncOptions.md b/.docfx/api/types/Cuemon.Threading.AsyncOptions.md index e33fca7b4..ff61f92e8 100644 --- a/.docfx/api/types/Cuemon.Threading.AsyncOptions.md +++ b/.docfx/api/types/Cuemon.Threading.AsyncOptions.md @@ -7,36 +7,33 @@ example: The following example demonstrates how to configure AsyncOptions to provide a cancellation token for asynchronous operations. ```csharp +// Program.cs using System; using System.Threading; using System.Threading.Tasks; using Cuemon.Threading; -namespace Contoso.BackgroundJobs; +var defaults = new AsyncOptions(); +Console.WriteLine(defaults.CancellationToken == CancellationToken.None); -public sealed class AsyncOptionsExample +using var cts = new CancellationTokenSource(); +var options = new AsyncOptions { - public static async Task RunAsync() - { - var defaults = new AsyncOptions(); - Console.WriteLine(defaults.CancellationToken == CancellationToken.None); + CancellationTokenProvider = () => cts.Token +}; - using var cts = new CancellationTokenSource(); - var options = new AsyncOptions - { - CancellationTokenProvider = () => cts.Token - }; +cts.Cancel(); - cts.Cancel(); - - try - { - await Task.Delay(10, options.CancellationToken); - } - catch (OperationCanceledException) - { - Console.WriteLine("Cancelled as expected."); - } - } +try +{ + await Task.Delay(10, options.CancellationToken); +} +catch (OperationCanceledException) +{ + Console.WriteLine("Cancelled as expected."); } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Threading.AsyncPatterns.md b/.docfx/api/types/Cuemon.Threading.AsyncPatterns.md index d2c7960ce..0bc900130 100644 --- a/.docfx/api/types/Cuemon.Threading.AsyncPatterns.md +++ b/.docfx/api/types/Cuemon.Threading.AsyncPatterns.md @@ -7,37 +7,46 @@ example: `AsyncPatterns` provides safe asynchronous patterns for resource management, including `SafeInvokeAsync` that ensures proper disposal of `IDisposable` resources (CA2000 compliant). This example calls `SafeInvokeAsync` with a factory delegate creating a `MemoryStream`, an invocation delegate that writes `"Cuemon"` bytes to it and returns the stream, and a `CancellationToken`. The resulting stream is read back via `StreamReader` to confirm the content, and the `AsyncPatterns.Use` sentinel is compared with itself to verify static reference identity. Console output displays `"Cuemon"` and `True` for the reference comparison. ```csharp +// Program.cs using System; using System.IO; using System.Text; using System.Threading; using System.Threading.Tasks; using Cuemon.Threading; +using Contoso.Streaming; -namespace Contoso.Streaming; +await AsyncPatternsExample.RunAsync(); -public sealed class AsyncPatternsExample +namespace Contoso.Streaming { - public static async Task RunAsync() + public sealed class AsyncPatternsExample { - var result = await AsyncPatterns.SafeInvokeAsync( - () => new MemoryStream(), - async (stream, ct) => + public static async Task RunAsync() + { + var result = await AsyncPatterns.SafeInvokeAsync( + () => new MemoryStream(), + async (stream, ct) => + { + byte[] buffer = Encoding.UTF8.GetBytes("Cuemon"); + await stream.WriteAsync(buffer, 0, buffer.Length, ct); + stream.Position = 0; + return stream; + }, + ct: CancellationToken.None); + + using (result) + using (var reader = new StreamReader(result, Encoding.UTF8, true, 1024, true)) { - byte[] buffer = Encoding.UTF8.GetBytes("Cuemon"); - await stream.WriteAsync(buffer, 0, buffer.Length, ct); - stream.Position = 0; - return stream; - }, - ct: CancellationToken.None); + Console.WriteLine(await reader.ReadToEndAsync()); + } - using (result) - using (var reader = new StreamReader(result, Encoding.UTF8, true, 1024, true)) - { - Console.WriteLine(await reader.ReadToEndAsync()); + Console.WriteLine(ReferenceEquals(AsyncPatterns.Use, AsyncPatterns.Use)); } - - Console.WriteLine(ReferenceEquals(AsyncPatterns.Use, AsyncPatterns.Use)); } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Threading.AsyncRunOptions.md b/.docfx/api/types/Cuemon.Threading.AsyncRunOptions.md index 76c44118e..4a9edeeb4 100644 --- a/.docfx/api/types/Cuemon.Threading.AsyncRunOptions.md +++ b/.docfx/api/types/Cuemon.Threading.AsyncRunOptions.md @@ -7,49 +7,45 @@ example: The following example demonstrates how to use to configure timeout, retry delay, maximum attempts, and inherited cancellation for an asynchronous operation. ```csharp +// Program.cs using System; using System.Threading; using Cuemon.Threading; -namespace MyApp.Examples; - -public class AsyncRunOptionsExample +var options = new AsyncRunOptions { - public void Demonstrate() - { - var options = new AsyncRunOptions - { - Timeout = TimeSpan.FromSeconds(30), - Delay = TimeSpan.FromMilliseconds(500), - MaximumAttempts = 3 - }; - Console.WriteLine(options.Timeout); // 00:00:30 - Console.WriteLine(options.Delay); // 00:00:00.5000000 - Console.WriteLine(options.MaximumAttempts); // 3 - - // Use with cancellation support - var withCancellation = new AsyncRunOptions - { - Timeout = TimeSpan.FromSeconds(10), - CancellationToken = new CancellationTokenSource(5000).Token - }; - - // Zero-delay retries require an explicit attempt limit - var zeroDelay = new AsyncRunOptions - { - Timeout = TimeSpan.FromSeconds(1), - Delay = TimeSpan.Zero, - MaximumAttempts = 3 - }; - Console.WriteLine(zeroDelay.MaximumAttempts); // 3 - - // Defaults: timeout 5s, delay 100ms - var defaults = new AsyncRunOptions(); - Console.WriteLine(defaults.Timeout); // 00:00:05 - Console.WriteLine(defaults.Delay); // 00:00:00.1000000 - Console.WriteLine(defaults.MaximumAttempts); // 0 - Console.WriteLine(withCancellation.CancellationToken.CanBeCanceled); // True - } -} + Timeout = TimeSpan.FromSeconds(30), + Delay = TimeSpan.FromMilliseconds(500), + MaximumAttempts = 3 +}; +Console.WriteLine(options.Timeout); // 00:00:30 +Console.WriteLine(options.Delay); // 00:00:00.5000000 +Console.WriteLine(options.MaximumAttempts); // 3 + +// Use with cancellation support +var withCancellation = new AsyncRunOptions +{ + Timeout = TimeSpan.FromSeconds(10), + CancellationToken = new CancellationTokenSource(5000).Token +}; +// Zero-delay retries require an explicit attempt limit +var zeroDelay = new AsyncRunOptions +{ + Timeout = TimeSpan.FromSeconds(1), + Delay = TimeSpan.Zero, + MaximumAttempts = 3 +}; +Console.WriteLine(zeroDelay.MaximumAttempts); // 3 + +// Defaults: timeout 5s, delay 100ms +var defaults = new AsyncRunOptions(); +Console.WriteLine(defaults.Timeout); // 00:00:05 +Console.WriteLine(defaults.Delay); // 00:00:00.1000000 +Console.WriteLine(defaults.MaximumAttempts); // 0 +Console.WriteLine(withCancellation.CancellationToken.CanBeCanceled); // True ``` + + + + diff --git a/.docfx/api/types/Cuemon.Threading.AsyncTaskFactoryOptions.md b/.docfx/api/types/Cuemon.Threading.AsyncTaskFactoryOptions.md index a1247cf95..9c6a530de 100644 --- a/.docfx/api/types/Cuemon.Threading.AsyncTaskFactoryOptions.md +++ b/.docfx/api/types/Cuemon.Threading.AsyncTaskFactoryOptions.md @@ -7,37 +7,32 @@ example: The following example demonstrates how to configure `AsyncTaskFactoryOptions` to control task creation options and scheduler when using `AdvancedParallelFactory.For`. ```csharp +// Program.cs using System; using System.Threading.Tasks; using Cuemon; using Cuemon.Threading; -namespace MyApp.Examples; - -public class AsyncTaskFactoryOptionsExample +// Direct instantiation of AsyncTaskFactoryOptions +var factoryOptions = new AsyncTaskFactoryOptions { - public void Demonstrate() - { - // Direct instantiation of AsyncTaskFactoryOptions - var factoryOptions = new AsyncTaskFactoryOptions - { - CreationOptions = TaskCreationOptions.None, - PartitionSize = 2 - }; - - var rules = new ForLoopRuleset(0, 10, 1); - - AdvancedParallelFactory.For(rules, i => - { - Console.WriteLine($"Processing item {i}"); - }, o => - { - o.CreationOptions = TaskCreationOptions.None; - o.Scheduler = TaskScheduler.Default; - o.PartitionSize = 2; - }); + CreationOptions = TaskCreationOptions.None, + PartitionSize = 2 +}; -} -} +var rules = new ForLoopRuleset(0, 10, 1); +AdvancedParallelFactory.For(rules, i => +{ + Console.WriteLine($"Processing item {i}"); +}, o => +{ + o.CreationOptions = TaskCreationOptions.None; + o.Scheduler = TaskScheduler.Default; + o.PartitionSize = 2; +}); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Threading.AsyncWorkloadOptions.md b/.docfx/api/types/Cuemon.Threading.AsyncWorkloadOptions.md index 1984a0e28..48445a5e6 100644 --- a/.docfx/api/types/Cuemon.Threading.AsyncWorkloadOptions.md +++ b/.docfx/api/types/Cuemon.Threading.AsyncWorkloadOptions.md @@ -7,36 +7,44 @@ example: The following example demonstrates how to configure `AsyncWorkloadOptions` to control the partition size when processing items in parallel with `AdvancedParallelFactory.ForAsync`. ```csharp +// Program.cs using System; using System.Threading; using System.Threading.Tasks; using Cuemon; using Cuemon.Threading; +using MyApp.Examples; -namespace MyApp.Examples; +await new AsyncWorkloadOptionsExample().DemonstrateAsync(); -public class AsyncWorkloadOptionsExample +namespace MyApp.Examples { - public async Task DemonstrateAsync() + public class AsyncWorkloadOptionsExample { - // Direct instantiation of AsyncWorkloadOptions - var workloadOptions = new AsyncWorkloadOptions + public async Task DemonstrateAsync() { - PartitionSize = 4 - }; - - var rules = new ForLoopRuleset(0, 20, 1); - - await AdvancedParallelFactory.ForAsync(rules, (i, ct) => - { - Console.WriteLine($"Processing item {i}"); - return Task.CompletedTask; - }, o => - { - o.PartitionSize = 4; - }); - -} + // Direct instantiation of AsyncWorkloadOptions + var workloadOptions = new AsyncWorkloadOptions + { + PartitionSize = 4 + }; + + var rules = new ForLoopRuleset(0, 20, 1); + + await AdvancedParallelFactory.ForAsync(rules, (i, ct) => + { + Console.WriteLine($"Processing item {i}"); + return Task.CompletedTask; + }, o => + { + o.PartitionSize = 4; + }); + + } + } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Threading.Awaiter.md b/.docfx/api/types/Cuemon.Threading.Awaiter.md index b58db257d..3084b5c97 100644 --- a/.docfx/api/types/Cuemon.Threading.Awaiter.md +++ b/.docfx/api/types/Cuemon.Threading.Awaiter.md @@ -7,37 +7,45 @@ example: The following example retries an asynchronous operation until it succeeds or the retry window closes. The delegate returns `UnsuccessfulValue` twice before returning `SuccessfulValue`, and the configured cancellation token is observed between attempts. ```csharp +// Program.cs using System; using System.Threading; using System.Threading.Tasks; using Cuemon.Threading; -namespace Cuemon.Threading; +await new AwaiterExample().DemonstrateAsync(); -public class AwaiterExample +namespace Cuemon.Threading { - public async Task DemonstrateAsync() + public class AwaiterExample { - var attempt = 0; - var cancellationSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - - var result = await Awaiter.RunUntilSuccessfulOrTimeoutAsync(async () => + public async Task DemonstrateAsync() { - attempt++; - if (attempt < 3) + var attempt = 0; + var cancellationSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + + var result = await Awaiter.RunUntilSuccessfulOrTimeoutAsync(async () => { - await Task.Delay(50); - return new UnsuccessfulValue(); - } - return new SuccessfulValue(); - }, options => - { - options.Timeout = TimeSpan.FromSeconds(5); - options.Delay = TimeSpan.FromMilliseconds(100); - options.CancellationToken = cancellationSource.Token; - }); + attempt++; + if (attempt < 3) + { + await Task.Delay(50); + return new UnsuccessfulValue(); + } + return new SuccessfulValue(); + }, options => + { + options.Timeout = TimeSpan.FromSeconds(5); + options.Delay = TimeSpan.FromMilliseconds(100); + options.CancellationToken = cancellationSource.Token; + }); - Console.WriteLine($"Succeeded after {attempt} attempts: {result.Succeeded}"); + Console.WriteLine($"Succeeded after {attempt} attempts: {result.Succeeded}"); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Threading.ForLoopRuleset`1.md b/.docfx/api/types/Cuemon.Threading.ForLoopRuleset`1.md index 0a6649f10..0a951b7cb 100644 --- a/.docfx/api/types/Cuemon.Threading.ForLoopRuleset`1.md +++ b/.docfx/api/types/Cuemon.Threading.ForLoopRuleset`1.md @@ -7,34 +7,31 @@ example: The following example demonstrates how to define a for-loop ruleset using ForLoopRuleset with configurable start, end, step, relational operator, and assignment operator. ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon; using Cuemon.Threading; -namespace Contoso.Scheduling; +var rules = new ForLoopRuleset( + from: 0, + to: 5, + step: 1, + relation: RelationalOperator.LessThanOrEqual, + assignment: AssignmentOperator.Addition); -public sealed class ForLoopRulesetExample -{ - public static void Run() - { - var rules = new ForLoopRuleset( - from: 0, - to: 5, - step: 1, - relation: RelationalOperator.LessThanOrEqual, - assignment: AssignmentOperator.Addition); - - var values = new List(); - int current = rules.From; - - while (rules.Condition(current, rules.Relation, rules.To)) - { - values.Add(current); - current = rules.Iterator(current, rules.Assignment, rules.Step); - } +var values = new List(); +int current = rules.From; - Console.WriteLine(string.Join(", ", values)); - } +while (rules.Condition(current, rules.Relation, rules.To)) +{ + values.Add(current); + current = rules.Iterator(current, rules.Assignment, rules.Step); } + +Console.WriteLine(string.Join(", ", values)); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Threading.ParallelFactory.md b/.docfx/api/types/Cuemon.Threading.ParallelFactory.md index ba0cea2d0..0d291be7b 100644 --- a/.docfx/api/types/Cuemon.Threading.ParallelFactory.md +++ b/.docfx/api/types/Cuemon.Threading.ParallelFactory.md @@ -7,25 +7,22 @@ example: The following example demonstrates basic parallel loops using `ParallelFactory.For` and `ParallelFactory.ForEach`. Each iteration prints its index or item to the console, illustrating how the factory distributes work across threads. ```csharp +// Program.cs using System; using Cuemon.Threading; -namespace Cuemon.Threading; - -public class ParallelFactoryExample +ParallelFactory.For(0, 5, i => { - public void Demonstrate() - { - ParallelFactory.For(0, 5, i => - { - Console.WriteLine($"Processing iteration {i}"); - }); + Console.WriteLine($"Processing iteration {i}"); +}); - var items = new[] { "apple", "banana", "cherry" }; - ParallelFactory.ForEach(items, item => - { - Console.WriteLine($"Processing {item}"); - }); - } -} +var items = new[] { "apple", "banana", "cherry" }; +ParallelFactory.ForEach(items, item => +{ + Console.WriteLine($"Processing {item}"); +}); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Threading.RelationalOperator.md b/.docfx/api/types/Cuemon.Threading.RelationalOperator.md index a6f093437..5168d2c49 100644 --- a/.docfx/api/types/Cuemon.Threading.RelationalOperator.md +++ b/.docfx/api/types/Cuemon.Threading.RelationalOperator.md @@ -7,24 +7,19 @@ example: The following example demonstrates how to use `RelationalOperator` with `ForLoopRuleset` and `AdvancedParallelFactory` to perform parallel work. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Threading; -namespace MyApp.Examples; +var rules = new ForLoopRuleset(0, 10, 2, RelationalOperator.LessThan); -public class RelationalOperatorExample +AdvancedParallelFactory.For(rules, i => { - public void Demonstrate() - { - var rules = new ForLoopRuleset(0, 10, 2, RelationalOperator.LessThan); - - AdvancedParallelFactory.For(rules, i => - { - Console.WriteLine($"Processing iteration: {i}"); - }); - -} -} - + Console.WriteLine($"Processing iteration: {i}"); +}); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Threading.TimerFactory.md b/.docfx/api/types/Cuemon.Threading.TimerFactory.md index e15b38729..99f16b61e 100644 --- a/.docfx/api/types/Cuemon.Threading.TimerFactory.md +++ b/.docfx/api/types/Cuemon.Threading.TimerFactory.md @@ -7,24 +7,21 @@ example: The following example creates a non-capturing timer that fires every two seconds after an initial one-second delay. The callback prints "Timer ticked" each time it executes; the timer is disposed after five seconds. ```csharp +// Program.cs using System; using System.Threading; using Cuemon.Threading; -namespace Cuemon.Threading; +using var timer = TimerFactory.CreateNonCapturingTimer( + state => Console.WriteLine("Timer ticked"), + null, + TimeSpan.FromSeconds(1), + TimeSpan.FromSeconds(2)); -public class TimerFactoryExample -{ - public void Demonstrate() - { - using var timer = TimerFactory.CreateNonCapturingTimer( - state => Console.WriteLine("Timer ticked"), - null, - TimeSpan.FromSeconds(1), - TimeSpan.FromSeconds(2)); - - Console.WriteLine("Timer started (1s delay, 2s interval)"); - Thread.Sleep(5000); - } -} +Console.WriteLine("Timer started (1s delay, 2s interval)"); +Thread.Sleep(5000); ``` + + + + diff --git a/.docfx/api/types/Cuemon.TimeRange.md b/.docfx/api/types/Cuemon.TimeRange.md index 65428edde..2499259ba 100644 --- a/.docfx/api/types/Cuemon.TimeRange.md +++ b/.docfx/api/types/Cuemon.TimeRange.md @@ -7,35 +7,30 @@ example: The following example demonstrates how to use to represent a range between two values. ```csharp +// Program.cs using System; using Cuemon; // for TimeRange -namespace MyApp.Examples; +// Define working hours (09:00 to 17:30) +var workDay = new TimeRange( + TimeSpan.FromHours(9), + TimeSpan.FromHours(17.5)); -public class TimeRangeExample -{ - public void Demonstrate() - { - // Define working hours (09:00 to 17:30) - var workDay = new TimeRange( - TimeSpan.FromHours(9), - TimeSpan.FromHours(17.5)); +Console.WriteLine($"Start: {workDay.Start}"); // 09:00:00 +Console.WriteLine($"End: {workDay.End}"); // 17:30:00 +Console.WriteLine($"Duration: {workDay.Duration}"); // 08:30:00 - Console.WriteLine($"Start: {workDay.Start}"); // 09:00:00 - Console.WriteLine($"End: {workDay.End}"); // 17:30:00 - Console.WriteLine($"Duration: {workDay.Duration}"); // 08:30:00 - - // Use inherited formatting - Console.WriteLine(workDay.ToString("g", null)); - // Output: A duration of 00.08:30:00 between 09:00:00 and 17:30:00. - - // Create a short break range - var lunchBreak = new TimeRange( - TimeSpan.FromHours(12), - TimeSpan.FromHours(13)); - Console.WriteLine(lunchBreak.Duration); // 01:00:00 - -} -} +// Use inherited formatting +Console.WriteLine(workDay.ToString("g", null)); +// Output: A duration of 00.08:30:00 between 09:00:00 and 17:30:00. +// Create a short break range +var lunchBreak = new TimeRange( + TimeSpan.FromHours(12), + TimeSpan.FromHours(13)); +Console.WriteLine(lunchBreak.Duration); // 01:00:00 ``` + + + + diff --git a/.docfx/api/types/Cuemon.TimeUnit.md b/.docfx/api/types/Cuemon.TimeUnit.md index 27e2e878b..8a88fbd75 100644 --- a/.docfx/api/types/Cuemon.TimeUnit.md +++ b/.docfx/api/types/Cuemon.TimeUnit.md @@ -7,34 +7,29 @@ example: The following example demonstrates how to use the enum to convert a numeric value into a . ```csharp +// Program.cs using System; using Cuemon; // for Decorator and ToTimeSpan - using Cuemon; -namespace MyApp.Examples; - -public class TimeUnitExample -{ - public void Demonstrate() - { - double value = 2.5; - TimeSpan days = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Days); - Console.WriteLine(days); // 2.12:00:00 +double value = 2.5; - TimeSpan hours = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Hours); - Console.WriteLine(hours); // 02:30:00 +TimeSpan days = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Days); +Console.WriteLine(days); // 2.12:00:00 - TimeSpan minutes = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Minutes); - Console.WriteLine(minutes); // 00:02:30 +TimeSpan hours = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Hours); +Console.WriteLine(hours); // 02:30:00 - TimeSpan seconds = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Seconds); - Console.WriteLine(seconds); // 00:00:02.5000000 +TimeSpan minutes = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Minutes); +Console.WriteLine(minutes); // 00:02:30 - TimeSpan ticks = Decorator.Enclose(50000000.0).ToTimeSpan(TimeUnit.Ticks); - Console.WriteLine(ticks); // 00:00:05 - -} -} +TimeSpan seconds = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Seconds); +Console.WriteLine(seconds); // 00:00:02.5000000 +TimeSpan ticks = Decorator.Enclose(50000000.0).ToTimeSpan(TimeUnit.Ticks); +Console.WriteLine(ticks); // 00:00:05 ``` + + + + diff --git a/.docfx/api/types/Cuemon.Tweaker.md b/.docfx/api/types/Cuemon.Tweaker.md index c29b9e932..3efe2eca4 100644 --- a/.docfx/api/types/Cuemon.Tweaker.md +++ b/.docfx/api/types/Cuemon.Tweaker.md @@ -7,31 +7,29 @@ example: The following example demonstrates how to use `Tweaker` to apply inline transformations on values and objects: adjusting with a converter, altering in-place, and changing between types. ```csharp +// Program.cs using System; using System.Collections.Generic; +using Cuemon; -namespace Cuemon; +// Adjust: transform a value using a converter function +int doubled = Tweaker.Adjust(21, x => x * 2); +Console.WriteLine(doubled); // 42 -public class TweakerExample -{ - public void Demonstrate() - { - // Adjust: transform a value using a converter function - int doubled = Tweaker.Adjust(21, x => x * 2); - Console.WriteLine(doubled); // 42 +// Alter: modify an object in-place via an action delegate +var list = new List { "a", "b", "c" }; +Tweaker.Alter(list, lst => lst.Add("d")); +Console.WriteLine(string.Join(", ", list)); // a, b, c, d - // Alter: modify an object in-place via an action delegate - var list = new List { "a", "b", "c" }; - Tweaker.Alter(list, lst => lst.Add("d")); - Console.WriteLine(string.Join(", ", list)); // a, b, c, d +// Change: convert a value to a different type +string asString = Tweaker.Change(42, x => x.ToString()); +Console.WriteLine(asString); // 42 - // Change: convert a value to a different type - string asString = Tweaker.Change(42, x => x.ToString()); - Console.WriteLine(asString); // 42 - - // Adjust with null converter returns the original value unchanged - int same = Tweaker.Adjust(10, null as Func); - Console.WriteLine(same); // 10 - } -} +// Adjust with null converter returns the original value unchanged +int same = Tweaker.Adjust(10, null as Func); +Console.WriteLine(same); // 10 ``` + + + + diff --git a/.docfx/api/types/Cuemon.TypeArgumentException.md b/.docfx/api/types/Cuemon.TypeArgumentException.md index c6e42567d..2ce44c2fb 100644 --- a/.docfx/api/types/Cuemon.TypeArgumentException.md +++ b/.docfx/api/types/Cuemon.TypeArgumentException.md @@ -7,44 +7,53 @@ example: The following example demonstrates how to throw and catch a when a generic type argument does not satisfy expected constraints at runtime. ```csharp +// Program.cs using System; using System.IO; using Cuemon; +using Contoso.DependencyInjection; -namespace Contoso.DependencyInjection; +TypeArgumentExceptionExample.Run(); -public sealed class TypeArgumentExceptionExample +namespace Contoso.DependencyInjection { - public static void Run() + public sealed class TypeArgumentExceptionExample { - IDisposable disposable = Create(); - disposable.Dispose(); - - try + public static void Run() { - Create(); + IDisposable disposable = Create(); + disposable.Dispose(); + + try + { + Create(); + } + catch (TypeArgumentException ex) + { + Console.WriteLine($"{ex.ParamName}: {ex.Message}"); + } } - catch (TypeArgumentException ex) + + private static TService Create() + where TImplementation : class, new() { - Console.WriteLine($"{ex.ParamName}: {ex.Message}"); + if (!typeof(TService).IsAssignableFrom(typeof(TImplementation))) + { + throw new TypeArgumentException( + nameof(TImplementation), + $"{typeof(TImplementation).Name} must implement {typeof(TService).Name}."); + } + + return (TService)(object)new TImplementation(); } - } - private static TService Create() - where TImplementation : class, new() - { - if (!typeof(TService).IsAssignableFrom(typeof(TImplementation))) + private sealed class Widget { - throw new TypeArgumentException( - nameof(TImplementation), - $"{typeof(TImplementation).Name} must implement {typeof(TService).Name}."); } - - return (TService)(object)new TImplementation(); - } - - private sealed class Widget - { } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.TypeArgumentOutOfRangeException.md b/.docfx/api/types/Cuemon.TypeArgumentOutOfRangeException.md index 081b81c10..845a49c63 100644 --- a/.docfx/api/types/Cuemon.TypeArgumentOutOfRangeException.md +++ b/.docfx/api/types/Cuemon.TypeArgumentOutOfRangeException.md @@ -7,48 +7,57 @@ example: The following example demonstrates how to throw a when an enum-based type argument is outside the valid range. ```csharp +// Program.cs using System; using Cuemon; +using Contoso.Logging; -namespace Contoso.Logging; +TypeArgumentOutOfRangeExceptionExample.Run(); -public sealed class TypeArgumentOutOfRangeExceptionExample +namespace Contoso.Logging { - public static void Run() + public sealed class TypeArgumentOutOfRangeExceptionExample { - LogLevel parsed = ParseEnum("Warning"); - Console.WriteLine(parsed); - - try + public static void Run() { - ParseEnum("1"); + LogLevel parsed = ParseEnum("Warning"); + Console.WriteLine(parsed); + + try + { + ParseEnum("1"); + } + catch (TypeArgumentOutOfRangeException ex) + { + Console.WriteLine($"{ex.ParamName}: {ex.ActualValue}"); + } } - catch (TypeArgumentOutOfRangeException ex) + + private static TEnum ParseEnum(string text) + where TEnum : struct { - Console.WriteLine($"{ex.ParamName}: {ex.ActualValue}"); + if (!typeof(TEnum).IsEnum) + { + throw new TypeArgumentOutOfRangeException( + nameof(TEnum), + typeof(TEnum), + "Type arguments must be enum types."); + } + + return (TEnum)Enum.Parse(typeof(TEnum), text, ignoreCase: true); } - } - private static TEnum ParseEnum(string text) - where TEnum : struct - { - if (!typeof(TEnum).IsEnum) + private enum LogLevel { - throw new TypeArgumentOutOfRangeException( - nameof(TEnum), - typeof(TEnum), - "Type arguments must be enum types."); + Debug, + Information, + Warning, + Error } - - return (TEnum)Enum.Parse(typeof(TEnum), text, ignoreCase: true); - } - - private enum LogLevel - { - Debug, - Information, - Warning, - Error } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.TypeDecoratorExtensions.md b/.docfx/api/types/Cuemon.TypeDecoratorExtensions.md index 12a2dc9d6..1b83bdf5a 100644 --- a/.docfx/api/types/Cuemon.TypeDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.TypeDecoratorExtensions.md @@ -7,6 +7,7 @@ example: `TypeDecoratorExtensions` provides extension methods on `Decorator.Enclose` for deep reflection inspection of .NET types, including member enumeration, interface detection, attribute checking, and circular-reference detection. This example wraps `AuditedOrder` (annotated with `[DataContract]`) and calls `GetAllProperties`, `GetAllFields`, `GetAllEvents`, and `GetAllMethods` to enumerate members across the full hierarchy including its base `TrackedEntity`. It also uses predicate methods like `HasTypes` (for `FileStream` → `Stream`), `HasInterfaces`, `HasAttribute`, `HasEnumerableImplementation`, `IsNullable`, and `HasAnonymousCharacteristics` to classify type capabilities. Console output includes sorted member names, boolean capability flags, default values such as `00000000-0000-0000-0000-000000000000` for `Guid`, friendly type names like `IList`, and circular-reference detection results for a `LinkedNode` with a self-referencing loop. ```csharp +// Program.cs using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -16,100 +17,105 @@ using System.Linq; using System.Reflection; using System.Runtime.Serialization; using Cuemon; +using Contoso.Reflection; -namespace Contoso.Reflection; +TypeDecoratorExtensionsExample.Run(); -public sealed class TypeDecoratorExtensionsExample +namespace Contoso.Reflection { - public static void Run() + public sealed class TypeDecoratorExtensionsExample { - var orderType = Decorator.Enclose(typeof(AuditedOrder)); - var streamType = Decorator.Enclose(typeof(Stream)); - - var propertyNames = orderType.GetAllProperties().Select(property => property.Name).OrderBy(name => name).ToArray(); - var fieldNames = orderType.GetAllFields().Select(field => field.Name).OrderBy(name => name).ToArray(); - var eventNames = orderType.GetAllEvents().Select(@event => @event.Name).OrderBy(name => name).ToArray(); - var methodNames = orderType - .GetAllMethods() - .Where(method => method.DeclaringType == typeof(AuditedOrder) && !method.IsSpecialName) - .Select(method => method.Name) - .Distinct() - .OrderBy(name => name) - .ToArray(); - var orderOnlyProperties = orderType.GetRuntimePropertiesExceptOf().Select(property => property.Name).OrderBy(name => name).ToArray(); - - bool hasTypes = Decorator.Enclose(typeof(FileStream)).HasTypes(typeof(Stream)); - bool hasInterfaces = Decorator.Enclose(typeof(List<>)).HasInterfaces(typeof(IEnumerable<>)); - bool hasAttribute = orderType.HasAttribute(typeof(DataContractAttribute), typeof(DataMemberAttribute)); - bool hasComparable = Decorator.Enclose(typeof(string)).HasComparableImplementation(); - bool hasComparer = Decorator.Enclose(typeof(StringComparer)).HasComparerImplementation(); - bool hasDictionary = Decorator.Enclose(typeof(ReadOnlyDictionary)).HasDictionaryImplementation(); - bool hasEqualityComparer = Decorator.Enclose(typeof(StringComparer)).HasEqualityComparerImplementation(); - bool hasEnumerable = Decorator.Enclose(typeof(ConcurrentBag)).HasEnumerableImplementation(); - bool hasKeyValuePair = Decorator.Enclose(typeof(KeyValuePair)).HasKeyValuePairImplementation(); - bool isNullable = Decorator.Enclose(typeof(int?)).IsNullable(); - bool hasAnonymousCharacteristics = Decorator.Enclose(new { ReferenceNumber = "PO-42" }.GetType()).HasAnonymousCharacteristics(); - bool hasDefaultCtor = Decorator.Enclose(typeof(MemoryStream)).HasDefaultConstructor(); - bool isComplex = streamType.IsComplex(); - - object defaultValue = Decorator.Enclose(typeof(Guid)).GetDefaultValue(); - string friendlyName = Decorator.Enclose(typeof(IList)).ToFriendlyName(); - MethodBase publishMethod = orderType.MatchMember(nameof(AuditedOrder.Publish)); - - bool inheritedIncludesObject = streamType.GetInheritedTypes().Contains(typeof(object)); - bool derivedIncludesMemoryStream = streamType.GetDerivedTypes().Contains(typeof(MemoryStream)); - bool hierarchyIncludesFileStream = streamType.GetHierarchyTypes().Contains(typeof(FileStream)); - - var loop = LinkedNode.CreateLoop(); - bool hasCircularReference = Decorator.Enclose(typeof(LinkedNode)).HasCircularReference(loop, maxDepth: 1); - - Console.WriteLine(string.Join(", ", propertyNames)); - Console.WriteLine(string.Join(", ", fieldNames)); - Console.WriteLine(string.Join(", ", eventNames)); - Console.WriteLine(string.Join(", ", methodNames)); - Console.WriteLine(string.Join(", ", orderOnlyProperties)); - Console.WriteLine($"{hasTypes}, {hasInterfaces}, {hasAttribute}"); - Console.WriteLine($"{hasComparable}, {hasComparer}, {hasDictionary}, {hasEqualityComparer}, {hasEnumerable}, {hasKeyValuePair}"); - Console.WriteLine($"{isNullable}, {hasAnonymousCharacteristics}, {hasDefaultCtor}, {isComplex}"); - Console.WriteLine(defaultValue); - Console.WriteLine(friendlyName); - Console.WriteLine(publishMethod.Name); - Console.WriteLine($"{inheritedIncludesObject}, {derivedIncludesMemoryStream}, {hierarchyIncludesFileStream}, {hasCircularReference}"); + public static void Run() + { + var orderType = Decorator.Enclose(typeof(AuditedOrder)); + var streamType = Decorator.Enclose(typeof(Stream)); + + var propertyNames = orderType.GetAllProperties().Select(property => property.Name).OrderBy(name => name).ToArray(); + var fieldNames = orderType.GetAllFields().Select(field => field.Name).OrderBy(name => name).ToArray(); + var eventNames = orderType.GetAllEvents().Select(@event => @event.Name).OrderBy(name => name).ToArray(); + var methodNames = orderType + .GetAllMethods() + .Where(method => method.DeclaringType == typeof(AuditedOrder) && !method.IsSpecialName) + .Select(method => method.Name) + .Distinct() + .OrderBy(name => name) + .ToArray(); + var orderOnlyProperties = orderType.GetRuntimePropertiesExceptOf().Select(property => property.Name).OrderBy(name => name).ToArray(); + + bool hasTypes = Decorator.Enclose(typeof(FileStream)).HasTypes(typeof(Stream)); + bool hasInterfaces = Decorator.Enclose(typeof(List<>)).HasInterfaces(typeof(IEnumerable<>)); + bool hasAttribute = orderType.HasAttribute(typeof(DataContractAttribute), typeof(DataMemberAttribute)); + bool hasComparable = Decorator.Enclose(typeof(string)).HasComparableImplementation(); + bool hasComparer = Decorator.Enclose(typeof(StringComparer)).HasComparerImplementation(); + bool hasDictionary = Decorator.Enclose(typeof(ReadOnlyDictionary)).HasDictionaryImplementation(); + bool hasEqualityComparer = Decorator.Enclose(typeof(StringComparer)).HasEqualityComparerImplementation(); + bool hasEnumerable = Decorator.Enclose(typeof(ConcurrentBag)).HasEnumerableImplementation(); + bool hasKeyValuePair = Decorator.Enclose(typeof(KeyValuePair)).HasKeyValuePairImplementation(); + bool isNullable = Decorator.Enclose(typeof(int?)).IsNullable(); + bool hasAnonymousCharacteristics = Decorator.Enclose(new { ReferenceNumber = "PO-42" }.GetType()).HasAnonymousCharacteristics(); + bool hasDefaultCtor = Decorator.Enclose(typeof(MemoryStream)).HasDefaultConstructor(); + bool isComplex = streamType.IsComplex(); + + object defaultValue = Decorator.Enclose(typeof(Guid)).GetDefaultValue(); + string friendlyName = Decorator.Enclose(typeof(IList)).ToFriendlyName(); + MethodBase publishMethod = orderType.MatchMember(nameof(AuditedOrder.Publish)); + + bool inheritedIncludesObject = streamType.GetInheritedTypes().Contains(typeof(object)); + bool derivedIncludesMemoryStream = streamType.GetDerivedTypes().Contains(typeof(MemoryStream)); + bool hierarchyIncludesFileStream = streamType.GetHierarchyTypes().Contains(typeof(FileStream)); + + var loop = LinkedNode.CreateLoop(); + bool hasCircularReference = Decorator.Enclose(typeof(LinkedNode)).HasCircularReference(loop, maxDepth: 1); + + Console.WriteLine(string.Join(", ", propertyNames)); + Console.WriteLine(string.Join(", ", fieldNames)); + Console.WriteLine(string.Join(", ", eventNames)); + Console.WriteLine(string.Join(", ", methodNames)); + Console.WriteLine(string.Join(", ", orderOnlyProperties)); + Console.WriteLine($"{hasTypes}, {hasInterfaces}, {hasAttribute}"); + Console.WriteLine($"{hasComparable}, {hasComparer}, {hasDictionary}, {hasEqualityComparer}, {hasEnumerable}, {hasKeyValuePair}"); + Console.WriteLine($"{isNullable}, {hasAnonymousCharacteristics}, {hasDefaultCtor}, {isComplex}"); + Console.WriteLine(defaultValue); + Console.WriteLine(friendlyName); + Console.WriteLine(publishMethod.Name); + Console.WriteLine($"{inheritedIncludesObject}, {derivedIncludesMemoryStream}, {hierarchyIncludesFileStream}, {hasCircularReference}"); + } } -} - -[DataContract] -public sealed class AuditedOrder : TrackedEntity -{ - public string PublicNote; + [DataContract] + public sealed class AuditedOrder : TrackedEntity + { + public string PublicNote; - [DataMember] - public string ReferenceNumber { get; set; } = string.Empty; + [DataMember] + public string ReferenceNumber { get; set; } = string.Empty; - public string Status { get; set; } = string.Empty; + public string Status { get; set; } = string.Empty; - public event EventHandler Published; + public event EventHandler Published; - public void Publish() + public void Publish() + { + Published?.Invoke(this, EventArgs.Empty); + } + } + public abstract class TrackedEntity { - Published?.Invoke(this, EventArgs.Empty); + public DateTime CreatedAt { get; set; } } -} - -public abstract class TrackedEntity -{ - public DateTime CreatedAt { get; set; } -} - -public sealed class LinkedNode -{ - public LinkedNode Next { get; set; } - - public static LinkedNode CreateLoop() + public sealed class LinkedNode { - var node = new LinkedNode(); - node.Next = node; - return node; + public LinkedNode Next { get; set; } + + public static LinkedNode CreateLoop() + { + var node = new LinkedNode(); + node.Next = node; + return node; + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.UnsuccessfulValue.md b/.docfx/api/types/Cuemon.UnsuccessfulValue.md index 37b937783..d15ee2d47 100644 --- a/.docfx/api/types/Cuemon.UnsuccessfulValue.md +++ b/.docfx/api/types/Cuemon.UnsuccessfulValue.md @@ -7,32 +7,41 @@ example: The following example demonstrates how to use `UnsuccessfulValue` to represent a void operation that failed with an exception, providing a consistent way to signal failure without throwing. ```csharp +// Program.cs using System; using Cuemon; +using Contoso.Connections; -namespace Contoso.Connections; +UnsuccessfulValueExample.Run(); -public sealed class UnsuccessfulValueExample +namespace Contoso.Connections { - public static void Run() + public sealed class UnsuccessfulValueExample { - ConditionalValue outcome = OpenConnection(null); - - Console.WriteLine($"Succeeded: {outcome.Succeeded}"); - Console.WriteLine($"Failure: {outcome.Failure?.GetType().Name}"); - } - - private static ConditionalValue OpenConnection(string connectionString) - { - try + public static void Run() { - Validator.ThrowIfNullOrWhitespace(connectionString); - return new SuccessfulValue(); + ConditionalValue outcome = OpenConnection(null); + + Console.WriteLine($"Succeeded: {outcome.Succeeded}"); + Console.WriteLine($"Failure: {outcome.Failure?.GetType().Name}"); } - catch (Exception ex) + + private static ConditionalValue OpenConnection(string connectionString) { - return new UnsuccessfulValue(ex); + try + { + Validator.ThrowIfNullOrWhitespace(connectionString); + return new SuccessfulValue(); + } + catch (Exception ex) + { + return new UnsuccessfulValue(ex); + } } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.UnsuccessfulValue`1.md b/.docfx/api/types/Cuemon.UnsuccessfulValue`1.md index c938ce368..aaccaeda5 100644 --- a/.docfx/api/types/Cuemon.UnsuccessfulValue`1.md +++ b/.docfx/api/types/Cuemon.UnsuccessfulValue`1.md @@ -7,30 +7,39 @@ example: The following example demonstrates how to use `UnsuccessfulValue` to represent a typed operation that failed, carrying both the exception and a default result value. ```csharp +// Program.cs using System; using Cuemon; +using Contoso.Calculations; -namespace Contoso.Calculations; +UnsuccessfulValueOfTResultExample.Run(); -public sealed class UnsuccessfulValueOfTResultExample +namespace Contoso.Calculations { - public static void Run() + public sealed class UnsuccessfulValueOfTResultExample { - ConditionalValue outcome = Divide(10, 0); + public static void Run() + { + ConditionalValue outcome = Divide(10, 0); - Console.WriteLine($"Succeeded: {outcome.Succeeded}"); - Console.WriteLine($"Result: {outcome.Result}"); - Console.WriteLine($"Failure: {outcome.Failure?.GetType().Name}"); - } + Console.WriteLine($"Succeeded: {outcome.Succeeded}"); + Console.WriteLine($"Result: {outcome.Result}"); + Console.WriteLine($"Failure: {outcome.Failure?.GetType().Name}"); + } - private static ConditionalValue Divide(int dividend, int divisor) - { - if (divisor == 0) + private static ConditionalValue Divide(int dividend, int divisor) { - return new UnsuccessfulValue(new DivideByZeroException("Cannot divide by zero."), -1); - } + if (divisor == 0) + { + return new UnsuccessfulValue(new DivideByZeroException("Cannot divide by zero."), -1); + } - return new SuccessfulValue(dividend / divisor); + return new SuccessfulValue(dividend / divisor); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.UriScheme.md b/.docfx/api/types/Cuemon.UriScheme.md index 1cdefb3de..2af43a63b 100644 --- a/.docfx/api/types/Cuemon.UriScheme.md +++ b/.docfx/api/types/Cuemon.UriScheme.md @@ -7,22 +7,17 @@ example: The following example demonstrates how to use `UriScheme` with `StringFactory.CreateUriScheme` to generate URI scheme strings. ```csharp +// Program.cs using Cuemon; using System; -namespace MyApp.Examples; - -public class UriSchemeExample -{ - public void Demonstrate() - { - var httpsScheme = StringFactory.CreateUriScheme(UriScheme.Https); - var ftpScheme = StringFactory.CreateUriScheme(UriScheme.Ftp); - - Console.WriteLine(httpsScheme); // outputs: https:// - Console.WriteLine(ftpScheme); // outputs: ftp:// - -} -} +var httpsScheme = StringFactory.CreateUriScheme(UriScheme.Https); +var ftpScheme = StringFactory.CreateUriScheme(UriScheme.Ftp); +Console.WriteLine(httpsScheme); // outputs: https:// +Console.WriteLine(ftpScheme); // outputs: ftp:// ``` + + + + diff --git a/.docfx/api/types/Cuemon.Validator.md b/.docfx/api/types/Cuemon.Validator.md index c6c0f709e..ec67fcc6f 100644 --- a/.docfx/api/types/Cuemon.Validator.md +++ b/.docfx/api/types/Cuemon.Validator.md @@ -7,28 +7,37 @@ example: The following example demonstrates how to use the `Validator` class to guard against null, empty, and invalid arguments using precondition checks. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Linq; using Cuemon; +using Contoso.Routing; -namespace Contoso.Routing; +ValidatorExample.Run(); -public sealed class ValidatorExample +namespace Contoso.Routing { - public static void Run() + public sealed class ValidatorExample { - string endpoint = NormalizeEndpoint("https://api.cuemon.net", new[] { "v1", "health" }); - Console.WriteLine(endpoint); - } + public static void Run() + { + string endpoint = NormalizeEndpoint("https://api.cuemon.net", new[] { "v1", "health" }); + Console.WriteLine(endpoint); + } - private static string NormalizeEndpoint(string endpoint, IEnumerable segments) - { - Validator.ThrowIfNullOrWhitespace(endpoint); - Validator.ThrowIfSequenceNullOrEmpty(segments); - Validator.ThrowIfNotUri(endpoint, UriKind.Absolute); + private static string NormalizeEndpoint(string endpoint, IEnumerable segments) + { + Validator.ThrowIfNullOrWhitespace(endpoint); + Validator.ThrowIfSequenceNullOrEmpty(segments); + Validator.ThrowIfNotUri(endpoint, UriKind.Absolute); - return string.Join("/", new[] { endpoint.TrimEnd('/') }.Concat(segments)); + return string.Join("/", new[] { endpoint.TrimEnd('/') }.Concat(segments)); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.HierarchyDecoratorExtensions.md b/.docfx/api/types/Cuemon.Xml.HierarchyDecoratorExtensions.md index 23cb210ff..817f33ea4 100644 --- a/.docfx/api/types/Cuemon.Xml.HierarchyDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Xml.HierarchyDecoratorExtensions.md @@ -7,6 +7,7 @@ example: `HierarchyDecoratorExtensions` provides extension methods on `Decorator.Enclose` for inspecting XML serialization metadata on `IHierarchy` nodes. This example creates a `Hierarchy` tree with a `Person` node (annotated with `[XmlRoot("person")]`) and an `Address` child node, then uses decorator methods to call `GetXmlQualifiedEntity`, `TryGetXmlRootAttribute`, `TryGetXmlElementAttribute`, `TryGetXmlTextAttribute`, `TryGetXmlAttributeAttribute`, `IsNodeEnumerable`, `HasXmlIgnoreAttribute`, and `OrderByXmlAttributes`. Console output displays the qualified entity local name, boolean results for attribute detection, and the count of ordered nodes. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Extensions.Runtime; @@ -14,44 +15,51 @@ using Cuemon.Xml; using System.Collections.Generic; using System.Linq; using System.Xml.Serialization; +using MyApp.Examples; -namespace MyApp.Examples; +HierarchyDecoratorExtensionsExample.Demonstrate(); -public static class HierarchyDecoratorExtensionsExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class HierarchyDecoratorExtensionsExample { - var hierarchy = new Hierarchy(); - var root = hierarchy.Add(new Person { Name = "Alice" }); - var child = root.Add(new Address { City = "Paris" }); - - var decorator = Decorator.Enclose((IHierarchy)child); - var rootDecorator = Decorator.Enclose((IHierarchy)root); - var qualifiedEntity = decorator.GetXmlQualifiedEntity(); - var hasRoot = rootDecorator.TryGetXmlRootAttribute(out _); - var hasElement = decorator.TryGetXmlElementAttribute(out _); - var hasText = decorator.TryGetXmlTextAttribute(out _); - var hasAttribute = decorator.TryGetXmlAttributeAttribute(out _); - var ordered = Decorator.Enclose((IEnumerable>)new[] { root, child }).OrderByXmlAttributes().ToList(); - - Console.WriteLine(qualifiedEntity.LocalName); - Console.WriteLine(hasRoot); - Console.WriteLine(hasElement || hasText || hasAttribute); - Console.WriteLine(decorator.IsNodeEnumerable()); - Console.WriteLine(decorator.HasXmlIgnoreAttribute()); - Console.WriteLine(ordered.Count); - } + public static void Demonstrate() + { + var hierarchy = new Hierarchy(); + var root = hierarchy.Add(new Person { Name = "Alice" }); + var child = root.Add(new Address { City = "Paris" }); - [XmlRoot("person")] - private sealed class Person - { - public string Name { get; set; } - } + var decorator = Decorator.Enclose((IHierarchy)child); + var rootDecorator = Decorator.Enclose((IHierarchy)root); + var qualifiedEntity = decorator.GetXmlQualifiedEntity(); + var hasRoot = rootDecorator.TryGetXmlRootAttribute(out _); + var hasElement = decorator.TryGetXmlElementAttribute(out _); + var hasText = decorator.TryGetXmlTextAttribute(out _); + var hasAttribute = decorator.TryGetXmlAttributeAttribute(out _); + var ordered = Decorator.Enclose((IEnumerable>)new[] { root, child }).OrderByXmlAttributes().ToList(); - private sealed class Address - { - public string City { get; set; } + Console.WriteLine(qualifiedEntity.LocalName); + Console.WriteLine(hasRoot); + Console.WriteLine(hasElement || hasText || hasAttribute); + Console.WriteLine(decorator.IsNodeEnumerable()); + Console.WriteLine(decorator.HasXmlIgnoreAttribute()); + Console.WriteLine(ordered.Count); + } + + [XmlRoot("person")] + private sealed class Person + { + public string Name { get; set; } + } + + private sealed class Address + { + public string City { get; set; } + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.Linq.StringDecoratorExtensions.md b/.docfx/api/types/Cuemon.Xml.Linq.StringDecoratorExtensions.md index cce74dd8b..6e9222736 100644 --- a/.docfx/api/types/Cuemon.Xml.Linq.StringDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Xml.Linq.StringDecoratorExtensions.md @@ -7,17 +7,12 @@ example: `StringDecoratorExtensions` in the `Xml.Linq` namespace provides extension methods on `Decorator.Enclose` for validating and parsing XML strings into `XElement` objects. This example checks valid XML (`"value"`) with `IsXmlString` returning `True`, parses it via `TryParseXElement` and navigates to read the root name, item attribute, and value. Invalid XML (`"not xml at all"`) returns `False` for `IsXmlString` and `TryParseXElement` returns `false` with `null`. It also demonstrates `TryParseXElement` with `LoadOptions.PreserveWhitespace` to retain whitespace in the parsed output. Console output confirms each validation and parsing result. ```csharp +// Program.cs using System; using System.Xml.Linq; using Cuemon; using Cuemon.Xml.Linq; -namespace MyApp.Xml -{ - public class StringDecoratorExtensionsExample - { - public void Demonstrate() - { // Valid XML string var validXml = "value"; @@ -54,7 +49,9 @@ namespace MyApp.Xml { Console.WriteLine($"Preserved whitespace element: '{preserveElement}'"); -}}}}} -} - +}}} ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.Serialization.Converters.DefaultXmlConverter.md b/.docfx/api/types/Cuemon.Xml.Serialization.Converters.DefaultXmlConverter.md index 8c7e57418..8b684be7e 100644 --- a/.docfx/api/types/Cuemon.Xml.Serialization.Converters.DefaultXmlConverter.md +++ b/.docfx/api/types/Cuemon.Xml.Serialization.Converters.DefaultXmlConverter.md @@ -7,6 +7,7 @@ example: The following example demonstrates how can serialize and deserialize a simple XML value. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.IO; @@ -14,26 +15,22 @@ using Cuemon.Xml.Serialization; using Cuemon.Xml.Serialization.Converters; using System.Xml; -namespace MyApp.Examples; +var converter = new DefaultXmlConverter(new XmlQualifiedEntity("String"), new List()); -public static class DefaultXmlConverterExample +using var buffer = new MemoryStream(); +using (var writer = XmlWriter.Create(buffer, new XmlWriterSettings { OmitXmlDeclaration = true })) { - public static void Demonstrate() - { - var converter = new DefaultXmlConverter(new XmlQualifiedEntity("String"), new List()); - - using var buffer = new MemoryStream(); - using (var writer = XmlWriter.Create(buffer, new XmlWriterSettings { OmitXmlDeclaration = true })) - { - converter.WriteXml(writer, "Hello World"); - } + converter.WriteXml(writer, "Hello World"); +} - buffer.Position = 0; - using var reader = XmlReader.Create(buffer); - var value = (string)converter.ReadXml(reader, typeof(string)); +buffer.Position = 0; +using var reader = XmlReader.Create(buffer); +var value = (string)converter.ReadXml(reader, typeof(string)); - Console.WriteLine(value); - Console.WriteLine(converter.CanConvert(typeof(string))); - } -} +Console.WriteLine(value); +Console.WriteLine(converter.CanConvert(typeof(string))); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.Serialization.Converters.ExceptionConverter.md b/.docfx/api/types/Cuemon.Xml.Serialization.Converters.ExceptionConverter.md index b7f0275c8..41b56178e 100644 --- a/.docfx/api/types/Cuemon.Xml.Serialization.Converters.ExceptionConverter.md +++ b/.docfx/api/types/Cuemon.Xml.Serialization.Converters.ExceptionConverter.md @@ -7,6 +7,7 @@ example: `ExceptionConverter` in the `Xml.Serialization` namespace serializes `Exception` instances to XML and deserializes them back, with optional stack trace and `Data` dictionary inclusion. This example creates an outer `InvalidOperationException` with an inner `ArgumentNullException` and a `"Server"` data entry, configures an `XmlFormatter` with the converter including stack trace and data, and serializes to XML output showing ``, ``, ``, ``, and nested `` elements. It also demonstrates deserializing from an XML string back to an exception instance with `converter.ReadXml`, and serialization without stack trace or data for simpler output. Console output displays the XML content and restored message. ```csharp +// Program.cs using System; using System.IO; using System.Text; @@ -14,75 +15,83 @@ using System.Xml; using Cuemon.Xml.Serialization; using Cuemon.Xml.Serialization.Converters; using Cuemon.Xml.Serialization.Formatters; +using MyApp.Examples; -namespace MyApp.Examples; +new ExceptionConverterExample().SerializeExceptionWithStackTrace(); -public class ExceptionConverterExample +namespace MyApp.Examples { - public void SerializeExceptionWithStackTrace() + public class ExceptionConverterExample { - // Create an exception with inner exception and custom data - var inner = new ArgumentNullException("connectionString", "Value cannot be null."); - var outer = new InvalidOperationException("Failed to connect to the database.", inner); - outer.Data["Server"] = "db01.prod.example.com"; + public void SerializeExceptionWithStackTrace() + { + // Create an exception with inner exception and custom data + var inner = new ArgumentNullException("connectionString", "Value cannot be null."); + var outer = new InvalidOperationException("Failed to connect to the database.", inner); + outer.Data["Server"] = "db01.prod.example.com"; - // Configure the XML formatter with ExceptionConverter including stack trace and data - var options = new XmlFormatterOptions(); - options.Settings.Converters.Add(new ExceptionConverter(includeStackTrace: true, includeData: true)); + // Configure the XML formatter with ExceptionConverter including stack trace and data + var options = new XmlFormatterOptions(); + options.Settings.Converters.Add(new ExceptionConverter(includeStackTrace: true, includeData: true)); - // Serialize to XML - var formatter = new XmlFormatter(options); - using (var stream = formatter.Serialize(outer)) - using (var reader = new StreamReader(stream, Encoding.UTF8)) - { - string xml = reader.ReadToEnd(); - Console.WriteLine(xml); - // The output resembles: - // - // - // ... - // Failed to connect to the database. - // - // at ExceptionConverterExample.SerializeExceptionWithStackTrace() ... - // - // - // db01.prod.example.com - // - // ... - // + // Serialize to XML + var formatter = new XmlFormatter(options); + using (var stream = formatter.Serialize(outer)) + using (var reader = new StreamReader(stream, Encoding.UTF8)) + { + string xml = reader.ReadToEnd(); + Console.WriteLine(xml); + // The output resembles: + // + // + // ... + // Failed to connect to the database. + // + // at ExceptionConverterExample.SerializeExceptionWithStackTrace() ... + // + // + // db01.prod.example.com + // + // ... + // + } } - } - public void DeserializeExceptionFromXml() - { - string xml = @" - - MyApp - Something went wrong. -"; - - var converter = new ExceptionConverter(); - using (var reader = XmlReader.Create(new StringReader(xml))) + public void DeserializeExceptionFromXml() { - var restored = converter.ReadXml(typeof(InvalidOperationException), reader); - Console.WriteLine(restored.Message); // "Something went wrong." - } - } + string xml = @" + + MyApp + Something went wrong. + "; - public void SerializeWithoutStackTraceAndData() - { - var exception = new TimeoutException("The operation timed out."); - var options = new XmlFormatterOptions(); - options.Settings.Converters.Add(new ExceptionConverter()); // defaults: false, false + var converter = new ExceptionConverter(); + using (var reader = XmlReader.Create(new StringReader(xml))) + { + var restored = converter.ReadXml(typeof(InvalidOperationException), reader); + Console.WriteLine(restored.Message); // "Something went wrong." + } + } - var formatter = new XmlFormatter(options); - using (var stream = formatter.Serialize(exception)) - using (var reader = new StreamReader(stream, Encoding.UTF8)) + public void SerializeWithoutStackTraceAndData() { - string xml = reader.ReadToEnd(); - // Stack trace and Data are excluded from the output - Console.WriteLine(xml); + var exception = new TimeoutException("The operation timed out."); + var options = new XmlFormatterOptions(); + options.Settings.Converters.Add(new ExceptionConverter()); // defaults: false, false + + var formatter = new XmlFormatter(options); + using (var stream = formatter.Serialize(exception)) + using (var reader = new StreamReader(stream, Encoding.UTF8)) + { + string xml = reader.ReadToEnd(); + // Stack trace and Data are excluded from the output + Console.WriteLine(xml); + } } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.Serialization.Converters.FailureConverter.md b/.docfx/api/types/Cuemon.Xml.Serialization.Converters.FailureConverter.md index 089c683d1..06ebe3836 100644 --- a/.docfx/api/types/Cuemon.Xml.Serialization.Converters.FailureConverter.md +++ b/.docfx/api/types/Cuemon.Xml.Serialization.Converters.FailureConverter.md @@ -7,6 +7,7 @@ example: `FailureConverter` serializes `Failure` objects to XML via `XmlFormatter`, providing structured error output including exception type, source, and message. This example creates a `Failure` from an `InvalidOperationException("The requested resource was not found.")` with `Source = "MyApi"` and `FaultSensitivityDetails.None`, configures an `XmlFormatter` with the converter, and serializes to XML. The resulting XML output includes `` with `MyApi` and `The requested resource was not found.`, showing the default serialization format for failure objects. ```csharp +// Program.cs using System; using System.IO; using Cuemon.Diagnostics; @@ -14,12 +15,6 @@ using Cuemon.Xml.Serialization; using Cuemon.Xml.Serialization.Converters; using Cuemon.Xml.Serialization.Formatters; -namespace MyApp.Examples; - -public class FailureConverterExample -{ - public void SerializeFailureToXml() - { // Create a Failure from an exception var exception = new InvalidOperationException("The requested resource was not found.") { @@ -45,7 +40,9 @@ public class FailureConverterExample // The requested resource was not found. // -}} } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.Serialization.Converters.XmlConverterDecoratorExtensions.md b/.docfx/api/types/Cuemon.Xml.Serialization.Converters.XmlConverterDecoratorExtensions.md index 493ad45e2..762d1e462 100644 --- a/.docfx/api/types/Cuemon.Xml.Serialization.Converters.XmlConverterDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Xml.Serialization.Converters.XmlConverterDecoratorExtensions.md @@ -7,47 +7,43 @@ example: The following example demonstrates how to register and query XML converters with . ```csharp +// Program.cs using System; using System.Collections.Generic; using Cuemon; using Cuemon.Diagnostics; using Cuemon.Xml.Serialization.Converters; -namespace MyApp.Examples; - -public static class XmlConverterDecoratorExtensionsExample -{ - public static void Demonstrate() +var converters = new List(); +var decorator = Decorator.Enclose((IList)converters); + +decorator.AddDateTimeConverter(); +decorator.AddTimeSpanConverter(); +decorator.AddStringConverter(); +decorator.AddUriConverter(); +decorator.AddEnumerableConverter(); +decorator.AddExceptionConverter(false, false); +decorator.AddFailureConverter(); +decorator.AddExceptionDescriptorConverter(options => options.SensitivityDetails = FaultSensitivityDetails.All); +decorator.AddXmlConverter( + (writer, version, qe) => { - var converters = new List(); - var decorator = Decorator.Enclose((IList)converters); - - decorator.AddDateTimeConverter(); - decorator.AddTimeSpanConverter(); - decorator.AddStringConverter(); - decorator.AddUriConverter(); - decorator.AddEnumerableConverter(); - decorator.AddExceptionConverter(false, false); - decorator.AddFailureConverter(); - decorator.AddExceptionDescriptorConverter(options => options.SensitivityDetails = FaultSensitivityDetails.All); - decorator.AddXmlConverter( - (writer, version, qe) => - { - writer.WriteStartElement(qe?.LocalName ?? "Version"); - writer.WriteString(version.ToString()); - writer.WriteEndElement(); - }, - (reader, type) => Version.Parse(reader.ReadElementContentAsString()) - ); - decorator.InsertXmlConverter(0); - - var writerConverter = decorator.FirstOrDefaultWriterConverter(typeof(Version)); - var readerConverter = decorator.FirstOrDefaultReaderConverter(typeof(Uri)); - - Console.WriteLine(writerConverter != null); - Console.WriteLine(readerConverter != null); - Console.WriteLine(converters.Count); - } -} - + writer.WriteStartElement(qe?.LocalName ?? "Version"); + writer.WriteString(version.ToString()); + writer.WriteEndElement(); + }, + (reader, type) => Version.Parse(reader.ReadElementContentAsString()) +); +decorator.InsertXmlConverter(0); + +var writerConverter = decorator.FirstOrDefaultWriterConverter(typeof(Version)); +var readerConverter = decorator.FirstOrDefaultReaderConverter(typeof(Uri)); + +Console.WriteLine(writerConverter != null); +Console.WriteLine(readerConverter != null); +Console.WriteLine(converters.Count); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.Serialization.DynamicXmlConverter.md b/.docfx/api/types/Cuemon.Xml.Serialization.DynamicXmlConverter.md index 1717acec6..df14f5156 100644 --- a/.docfx/api/types/Cuemon.Xml.Serialization.DynamicXmlConverter.md +++ b/.docfx/api/types/Cuemon.Xml.Serialization.DynamicXmlConverter.md @@ -7,33 +7,41 @@ example: The following example creates a `DynamicXmlConverter` with custom read and write delegates. Writing the value 42 produces an XML fragment containing a `` element; the converter can also read it back from XML. ```csharp +// Program.cs using System; using System.IO; using System.Xml; using Cuemon.Xml.Serialization; -namespace Cuemon.Xml.Serialization; +new DynamicXmlConverterExample().Demonstrate(); -public class DynamicXmlConverterExample +namespace Cuemon.Xml.Serialization { - public void Demonstrate() + public class DynamicXmlConverterExample { - var converter = DynamicXmlConverter.Create( - writer: (w, value, entity) => - { - w.WriteElementString("Value", value.ToString()); - }, - reader: (r, type) => - { - r.ReadToDescendant("Value"); - return int.Parse(r.ReadElementContentAsString()); - }); + public void Demonstrate() + { + var converter = DynamicXmlConverter.Create( + writer: (w, value, entity) => + { + w.WriteElementString("Value", value.ToString()); + }, + reader: (r, type) => + { + r.ReadToDescendant("Value"); + return int.Parse(r.ReadElementContentAsString()); + }); - using var sw = new StringWriter(); - using var writer = XmlWriter.Create(sw); - converter.WriteXml(writer, 42); - writer.Flush(); - Console.WriteLine(sw.ToString()); + using var sw = new StringWriter(); + using var writer = XmlWriter.Create(sw); + converter.WriteXml(writer, 42); + writer.Flush(); + Console.WriteLine(sw.ToString()); + } } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.Serialization.DynamicXmlConverterCore.md b/.docfx/api/types/Cuemon.Xml.Serialization.DynamicXmlConverterCore.md index bfc99d7da..8210a0527 100644 --- a/.docfx/api/types/Cuemon.Xml.Serialization.DynamicXmlConverterCore.md +++ b/.docfx/api/types/Cuemon.Xml.Serialization.DynamicXmlConverterCore.md @@ -7,10 +7,14 @@ example: `DynamicXmlConverterCore` enables creating custom XML converters using read and write delegates, supporting both read/write and write-only scenarios. This example creates a `Person` class and builds a `DynamicXmlConverter` with a writer delegate that serializes `FirstName`, `LastName`, and `Age` as child elements and a reader delegate that deserializes them back. A `Person` instance is serialized to XML and deserialized to confirm round-trip fidelity, and a write-only converter is also demonstrated for scenarios where only serialization is needed. Console output displays the serialized XML, deserialized property values, and the converter's `CanRead`/`CanWrite` capabilities. ```csharp +// Program.cs using System; using System.IO; using System.Xml; using Cuemon.Xml.Serialization; +using MyApp.Xml; + +DynamicXmlConverterCoreExamples.Demonstrate(); namespace MyApp.Xml { @@ -57,8 +61,9 @@ namespace MyApp.Xml Console.WriteLine(xml.ToString()); // Read the Person back from XML. - using (var xmlReader = XmlReader.Create(new StringReader(xml.ToString()))) + using (var xmlReader = XmlReader.Create(new StringReader(xml.ToString()), new XmlReaderSettings { IgnoreWhitespace = true })) { + xmlReader.MoveToContent(); var deserialized = (Person)converter.ReadXml(xmlReader, typeof(Person)); Console.WriteLine("Deserialized: {0} {1}, Age {2}", deserialized.FirstName, deserialized.LastName, deserialized.Age); @@ -97,3 +102,7 @@ namespace MyApp.Xml } } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.Serialization.DynamicXmlSerializable.md b/.docfx/api/types/Cuemon.Xml.Serialization.DynamicXmlSerializable.md index 931bbbef3..9ca73d13a 100644 --- a/.docfx/api/types/Cuemon.Xml.Serialization.DynamicXmlSerializable.md +++ b/.docfx/api/types/Cuemon.Xml.Serialization.DynamicXmlSerializable.md @@ -7,31 +7,30 @@ example: The following example wraps an anonymous object with `DynamicXmlSerializable` and provides a custom writer that emits `Name` and `Score` child elements. The resulting XML is written to a `StringWriter` and printed to the console. ```csharp +// Program.cs using System; using System.IO; using System.Xml; using System.Xml.Serialization; using Cuemon.Xml.Serialization; -namespace Cuemon.Xml.Serialization; - -public class DynamicXmlSerializableExample -{ - public void Demonstrate() +var data = new { Name = "Alice", Score = 95 }; +var serializable = DynamicXmlSerializable.Create(data, + writer: (w, src) => { - var data = new { Name = "Alice", Score = 95 }; - var serializable = DynamicXmlSerializable.Create(data, - writer: (w, src) => - { - w.WriteElementString("Name", src.Name); - w.WriteElementString("Score", src.Score.ToString()); - }); + w.WriteStartElement("Person"); + w.WriteElementString("Name", src.Name); + w.WriteElementString("Score", src.Score.ToString()); + w.WriteEndElement(); + }); - using var sw = new StringWriter(); - using var writer = XmlWriter.Create(sw); - serializable.WriteXml(writer); - writer.Flush(); - Console.WriteLine(sw.ToString()); - } -} +using var sw = new StringWriter(); +using var writer = XmlWriter.Create(sw); +serializable.WriteXml(writer); +writer.Flush(); +Console.WriteLine(sw.ToString()); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.Serialization.Formatters.XmlFormatter.md b/.docfx/api/types/Cuemon.Xml.Serialization.Formatters.XmlFormatter.md index 3d3261a93..27c3820ca 100644 --- a/.docfx/api/types/Cuemon.Xml.Serialization.Formatters.XmlFormatter.md +++ b/.docfx/api/types/Cuemon.Xml.Serialization.Formatters.XmlFormatter.md @@ -7,35 +7,43 @@ example: The following example demonstrates how to serialize an object with . ```csharp +// Program.cs using System; using System.IO; using Cuemon.Xml.Serialization.Formatters; +using MyApp.Examples; -namespace MyApp.Examples; +XmlFormatterExample.Demonstrate(); -public static class XmlFormatterExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class XmlFormatterExample { - var formatter = new XmlFormatter(); - var person = new Person { Name = "John Doe", Age = 42 }; + public static void Demonstrate() + { + var formatter = new XmlFormatter(); + var person = new Person { Name = "John Doe", Age = 42 }; - using var stream = formatter.Serialize(person, typeof(Person)); - stream.Position = 0; + using var stream = formatter.Serialize(person, typeof(Person)); + stream.Position = 0; - using var reader = new StreamReader(stream); - var xml = reader.ReadToEnd(); + using var reader = new StreamReader(stream); + var xml = reader.ReadToEnd(); - Console.WriteLine(xml.Contains("John Doe")); - Console.WriteLine(xml.Contains("42")); - } + Console.WriteLine(xml.Contains("John Doe")); + Console.WriteLine(xml.Contains("42")); + } - private sealed class Person - { - public string Name { get; set; } + private sealed class Person + { + public string Name { get; set; } - public int Age { get; set; } + public int Age { get; set; } + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.Serialization.Formatters.XmlFormatterOptions.md b/.docfx/api/types/Cuemon.Xml.Serialization.Formatters.XmlFormatterOptions.md index 22f6875f1..11d462aaf 100644 --- a/.docfx/api/types/Cuemon.Xml.Serialization.Formatters.XmlFormatterOptions.md +++ b/.docfx/api/types/Cuemon.Xml.Serialization.Formatters.XmlFormatterOptions.md @@ -7,46 +7,41 @@ example: The following example demonstrates how to configure XmlFormatterOptions for custom media types, fault sensitivity details, and synchronization with XmlConvert settings. ```csharp +// Program.cs using System; using System.Collections.Generic; using System.Net.Http.Headers; using Cuemon.Diagnostics; using Cuemon.Xml.Serialization.Formatters; -namespace MyApp.Examples +// Configure XmlFormatter with custom settings. +var options = new XmlFormatterOptions { - public class XmlFormatterOptionsExample - { - public void Demonstrate() - { - // Configure XmlFormatter with custom settings. - var options = new XmlFormatterOptions - { - SynchronizeWithXmlConvert = true, - SensitivityDetails = FaultSensitivityDetails.None - }; - - // Customize the supported media types. - options.SupportedMediaTypes = new List - { - XmlFormatterOptions.DefaultMediaType, - new MediaTypeHeaderValue("text/xml"), - new MediaTypeHeaderValue("application/problem+xml") - }; - - Console.WriteLine($"Default media type: {XmlFormatterOptions.DefaultMediaType}"); // application/xml - Console.WriteLine($"Supported types: {options.SupportedMediaTypes.Count}"); // 3 - Console.WriteLine($"Synchronize: {options.SynchronizeWithXmlConvert}"); // True - - // Validate before use. - options.ValidateOptions(); - Console.WriteLine("Options are valid."); - - // Use with a formatter. - var formatter = new XmlFormatter(options); - Console.WriteLine($"Formatter created with {formatter.GetType().Name}."); - -}} -} + SynchronizeWithXmlConvert = true, + SensitivityDetails = FaultSensitivityDetails.None +}; +// Customize the supported media types. +options.SupportedMediaTypes = new List +{ + XmlFormatterOptions.DefaultMediaType, + new MediaTypeHeaderValue("text/xml"), + new MediaTypeHeaderValue("application/problem+xml") +}; + +Console.WriteLine($"Default media type: {XmlFormatterOptions.DefaultMediaType}"); // application/xml +Console.WriteLine($"Supported types: {options.SupportedMediaTypes.Count}"); // 3 +Console.WriteLine($"Synchronize: {options.SynchronizeWithXmlConvert}"); // True + +// Validate before use. +options.ValidateOptions(); +Console.WriteLine("Options are valid."); + +// Use with a formatter. +var formatter = new XmlFormatter(options); +Console.WriteLine($"Formatter created with {formatter.GetType().Name}."); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.Serialization.XmlConvert.md b/.docfx/api/types/Cuemon.Xml.Serialization.XmlConvert.md index fd2ea7f91..18e1f45e7 100644 --- a/.docfx/api/types/Cuemon.Xml.Serialization.XmlConvert.md +++ b/.docfx/api/types/Cuemon.Xml.Serialization.XmlConvert.md @@ -7,24 +7,22 @@ example: The following example configures default `XmlSerializerOptions` on `XmlConvert` with UTF-8 encoding and tab indentation, then reads back the defaults and prints the encoding name. This demonstrates how to override global XML serialization settings. ```csharp +// Program.cs using System; -using System.Text; using System.Xml; +using System.Text; using Cuemon.Xml.Serialization; +using XmlConvert = Cuemon.Xml.Serialization.XmlConvert; -namespace Cuemon.Xml.Serialization; - -public class XmlConvertExample +XmlConvert.DefaultSettings = () => new XmlSerializerOptions { - public void Demonstrate() - { - XmlConvert.DefaultSettings = () => new XmlSerializerOptions - { - Writer = new XmlWriterSettings { Encoding = Encoding.UTF8, IndentChars = Cuemon.Alphanumeric.Tab } - }; + Writer = new XmlWriterSettings { Encoding = Encoding.UTF8, IndentChars = " " } +}; - var settings = XmlConvert.DefaultSettings(); - Console.WriteLine($"Default encoding: {settings.Writer.Encoding.EncodingName}"); - } -} +var settings = XmlConvert.DefaultSettings(); +Console.WriteLine($"Default encoding: {settings.Writer.Encoding.EncodingName}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.Serialization.XmlQualifiedEntity.md b/.docfx/api/types/Cuemon.Xml.Serialization.XmlQualifiedEntity.md index b781c0f02..e39c65b86 100644 --- a/.docfx/api/types/Cuemon.Xml.Serialization.XmlQualifiedEntity.md +++ b/.docfx/api/types/Cuemon.Xml.Serialization.XmlQualifiedEntity.md @@ -7,56 +7,51 @@ example: `XmlQualifiedEntity` represents an XML element or attribute name with optional namespace and prefix, and can be created from XML serialization attributes. This example creates entities from a local name only (`"Order"`), with a namespace (`"http://example.com/orders"`), and with a prefix/namespace combination (`"o"`, `"Order"`, `"http://example.com/orders"`). It then creates entities from `XmlRootAttribute("PurchaseOrder")`, `XmlElementAttribute("LineItem")`, and `XmlAttributeAttribute("Quantity")`, and demonstrates using `XmlQualifiedEntity` with `XmlSerializerOptions` to set a custom root name. Console output displays each entity's `LocalName`, `Namespace`, `Prefix`, and decoration flags. ```csharp +// Program.cs using System; using System.Xml.Serialization; using Cuemon.Xml.Serialization; -namespace MyApp.Xml +// Create an entity from local name only +var entity1 = new XmlQualifiedEntity("Order"); +Console.WriteLine($"LocalName: {entity1.LocalName}"); // Order +Console.WriteLine($"Namespace: {entity1.Namespace}"); // (null) +Console.WriteLine($"Prefix: {entity1.Prefix}"); // (null) + +// Create an entity with local name and namespace +var entity2 = new XmlQualifiedEntity("Order", "http://example.com/orders"); +Console.WriteLine($"LocalName: {entity2.LocalName}, Namespace: {entity2.Namespace}"); + +// Create an entity with prefix, local name, and namespace +var entity3 = new XmlQualifiedEntity("o", "Order", "http://example.com/orders"); +Console.WriteLine($"Prefix: {entity3.Prefix}, LocalName: {entity3.LocalName}, Namespace: {entity3.Namespace}"); + +// Create from XmlRootAttribute +var rootAttr = new XmlRootAttribute("PurchaseOrder"); +var fromRoot = new XmlQualifiedEntity(rootAttr); +Console.WriteLine($"From XmlRoot: {fromRoot.LocalName} (Namespace: {fromRoot.Namespace})"); +Console.WriteLine($"HasXmlRootDecoration: {fromRoot.HasXmlRootDecoration}"); // True + +// Create from XmlElementAttribute +var elemAttr = new XmlElementAttribute("LineItem"); +var fromElement = new XmlQualifiedEntity(elemAttr); +Console.WriteLine($"From XmlElement: {fromElement.LocalName}"); +Console.WriteLine($"HasXmlElementDecoration: {fromElement.HasXmlElementDecoration}"); // True + +// Create from XmlAttributeAttribute +var attr = new XmlAttributeAttribute("Quantity"); +var fromAttribute = new XmlQualifiedEntity(attr); +Console.WriteLine($"From XmlAttribute: {fromAttribute.LocalName}"); +Console.WriteLine($"HasXmlAttributeDecoration: {fromAttribute.HasXmlAttributeDecoration}"); // True + +// Use with XmlSerializerOptions to set a custom root name +var options = new XmlSerializerOptions { - public class XmlQualifiedEntityExample - { - public void Demonstrate() - { - // Create an entity from local name only - var entity1 = new XmlQualifiedEntity("Order"); - Console.WriteLine($"LocalName: {entity1.LocalName}"); // Order - Console.WriteLine($"Namespace: {entity1.Namespace}"); // (null) - Console.WriteLine($"Prefix: {entity1.Prefix}"); // (null) - - // Create an entity with local name and namespace - var entity2 = new XmlQualifiedEntity("Order", "http://example.com/orders"); - Console.WriteLine($"LocalName: {entity2.LocalName}, Namespace: {entity2.Namespace}"); - - // Create an entity with prefix, local name, and namespace - var entity3 = new XmlQualifiedEntity("o", "Order", "http://example.com/orders"); - Console.WriteLine($"Prefix: {entity3.Prefix}, LocalName: {entity3.LocalName}, Namespace: {entity3.Namespace}"); - - // Create from XmlRootAttribute - var rootAttr = new XmlRootAttribute("PurchaseOrder"); - var fromRoot = new XmlQualifiedEntity(rootAttr); - Console.WriteLine($"From XmlRoot: {fromRoot.LocalName} (Namespace: {fromRoot.Namespace})"); - Console.WriteLine($"HasXmlRootDecoration: {fromRoot.HasXmlRootDecoration}"); // True - - // Create from XmlElementAttribute - var elemAttr = new XmlElementAttribute("LineItem"); - var fromElement = new XmlQualifiedEntity(elemAttr); - Console.WriteLine($"From XmlElement: {fromElement.LocalName}"); - Console.WriteLine($"HasXmlElementDecoration: {fromElement.HasXmlElementDecoration}"); // True - - // Create from XmlAttributeAttribute - var attr = new XmlAttributeAttribute("Quantity"); - var fromAttribute = new XmlQualifiedEntity(attr); - Console.WriteLine($"From XmlAttribute: {fromAttribute.LocalName}"); - Console.WriteLine($"HasXmlAttributeDecoration: {fromAttribute.HasXmlAttributeDecoration}"); // True - - // Use with XmlSerializerOptions to set a custom root name - var options = new XmlSerializerOptions - { - RootName = new XmlQualifiedEntity("CustomRoot", "http://example.com/schema") - }; - Console.WriteLine($"Options root name: {options.RootName.LocalName}"); - -}} -} - + RootName = new XmlQualifiedEntity("CustomRoot", "http://example.com/schema") +}; +Console.WriteLine($"Options root name: {options.RootName.LocalName}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.Serialization.XmlSerializer.md b/.docfx/api/types/Cuemon.Xml.Serialization.XmlSerializer.md index dfb2957ad..92b3db073 100644 --- a/.docfx/api/types/Cuemon.Xml.Serialization.XmlSerializer.md +++ b/.docfx/api/types/Cuemon.Xml.Serialization.XmlSerializer.md @@ -4,47 +4,55 @@ example: - *content --- -The following example demonstrates how to serialize and deserialize a simple object with . +The following example demonstrates how to serialize and deserialize a simple object with . It configures an `XmlSerializerOptions` root name, writes an `Order` to a stream, then reads the stream back and prints the customer and total. ```csharp +// Program.cs using System; using Cuemon.Xml.Serialization; +using MyApp.Examples; -namespace MyApp.Examples; +XmlSerializerExample.Demonstrate(); -public static class XmlSerializerExample +namespace MyApp.Examples { - public static void Demonstrate() + public static class XmlSerializerExample { - var serializer = XmlSerializer.Create(new XmlSerializerOptions + public static void Demonstrate() { - RootName = new XmlQualifiedEntity("Order") - }); + var serializer = XmlSerializer.Create(new XmlSerializerOptions + { + RootName = new XmlQualifiedEntity("Order") + }); - var order = new Order - { - Id = 1001, - Customer = "John Doe", - Total = 299.99m - }; + var order = new Order + { + Id = 1001, + Customer = "John Doe", + Total = 299.99m + }; - using var stream = serializer.Serialize(order, typeof(Order)); - stream.Position = 0; + using var stream = serializer.Serialize(order, typeof(Order)); + stream.Position = 0; - var deserialized = serializer.Deserialize(stream); + var deserialized = serializer.Deserialize(stream); - Console.WriteLine(deserialized.Customer); - Console.WriteLine(deserialized.Total); - } + Console.WriteLine(deserialized.Customer); + Console.WriteLine(deserialized.Total); + } - private sealed class Order - { - public int Id { get; set; } + private sealed class Order + { + public int Id { get; set; } - public string Customer { get; set; } + public string Customer { get; set; } - public decimal Total { get; set; } + public decimal Total { get; set; } + } } } - ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.Serialization.XmlSerializerOptions.md b/.docfx/api/types/Cuemon.Xml.Serialization.XmlSerializerOptions.md index bbd023fcb..6d024cd4e 100644 --- a/.docfx/api/types/Cuemon.Xml.Serialization.XmlSerializerOptions.md +++ b/.docfx/api/types/Cuemon.Xml.Serialization.XmlSerializerOptions.md @@ -7,28 +7,25 @@ example: The following example demonstrates how to configure for custom root names and XML reader/writer settings. ```csharp +// Program.cs using System; using System.Xml; using Cuemon.Xml.Serialization; -namespace MyApp.Examples; - -public static class XmlSerializerOptionsExample +var options = new XmlSerializerOptions { - public static void Demonstrate() - { - var options = new XmlSerializerOptions - { - RootName = new XmlQualifiedEntity("Invoice"), - FlattenCollectionItems = true, - Reader = new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore }, - Writer = new XmlWriterSettings { Indent = true } - }; + RootName = new XmlQualifiedEntity("Invoice"), + FlattenCollectionItems = true, + Reader = new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore }, + Writer = new XmlWriterSettings { Indent = true } +}; - Console.WriteLine(options.RootName.LocalName); - Console.WriteLine(options.FlattenCollectionItems); - Console.WriteLine(options.Writer.Indent); - Console.WriteLine(options.Converters.Count); - } -} +Console.WriteLine(options.RootName.LocalName); +Console.WriteLine(options.FlattenCollectionItems); +Console.WriteLine(options.Writer.Indent); +Console.WriteLine(options.Converters.Count); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.Serialization.XmlSerializerOptionsDecoratorExtensions.md b/.docfx/api/types/Cuemon.Xml.Serialization.XmlSerializerOptionsDecoratorExtensions.md index 51c4f909a..0b3e75648 100644 --- a/.docfx/api/types/Cuemon.Xml.Serialization.XmlSerializerOptionsDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Xml.Serialization.XmlSerializerOptionsDecoratorExtensions.md @@ -34,3 +34,7 @@ public class XmlSerializerOptionsDecoratorExtensionsExample } ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.StreamDecoratorExtensions.md b/.docfx/api/types/Cuemon.Xml.StreamDecoratorExtensions.md index e838f8b89..37073363d 100644 --- a/.docfx/api/types/Cuemon.Xml.StreamDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Xml.StreamDecoratorExtensions.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to create an from a stream and detect the XML encoding. ```csharp +// Program.cs using System; using System.IO; using System.Text; @@ -14,26 +15,21 @@ using System.Xml; using Cuemon; using Cuemon.Xml; -namespace MyApp.Examples; +const string xml = "hello"; -public static class StreamDecoratorExtensionsExample -{ - public static void Demonstrate() - { - const string xml = "hello"; +using var stream = new MemoryStream(Encoding.UTF8.GetBytes(xml)); +using XmlReader reader = Decorator.Enclose(stream).ToXmlReader(); +reader.MoveToContent(); - using var stream = new MemoryStream(Encoding.UTF8.GetBytes(xml)); - using XmlReader reader = Decorator.Enclose(stream).ToXmlReader(); - reader.MoveToContent(); +Console.WriteLine(reader.LocalName); - Console.WriteLine(reader.LocalName); - - using var detectStream = new MemoryStream(Encoding.UTF8.GetBytes(xml)); - var detected = Decorator.Enclose(detectStream).TryDetectXmlEncoding(out var encoding); - - Console.WriteLine(detected); - Console.WriteLine(encoding.EncodingName); - } -} +using var detectStream = new MemoryStream(Encoding.UTF8.GetBytes(xml)); +var detected = Decorator.Enclose(detectStream).TryDetectXmlEncoding(out var encoding); +Console.WriteLine(detected); +Console.WriteLine(encoding.EncodingName); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.StringDecoratorExtensions.md b/.docfx/api/types/Cuemon.Xml.StringDecoratorExtensions.md index 97d56a701..95d59e42b 100644 --- a/.docfx/api/types/Cuemon.Xml.StringDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Xml.StringDecoratorExtensions.md @@ -7,47 +7,41 @@ example: The following example demonstrates how to use the XML `StringDecoratorExtensions` to escape, unescape, and sanitize XML strings through the `IDecorator` interface. ```csharp +// Program.cs using System; using Cuemon; using Cuemon.Xml; -namespace MyApp.Examples; - -public class Example -{ - public void Run() - { - - // Escape XML characters in a string - var raw = ""; - var escaped = Decorator.Enclose(raw).EscapeXml(); - Console.WriteLine($"Escaped: {escaped}"); - // Output: <hello & 'world' "test"> - - // Unescape back to original - var unescaped = Decorator.Enclose(escaped).UnescapeXml(); - Console.WriteLine($"Unescaped: {unescaped}"); - // Output: - - // Sanitize a string to be a valid XML element name - var invalidName = "123order-details!.xml"; - var sanitizedName = Decorator.Enclose(invalidName).SanitizeXmlElementName(); - Console.WriteLine($"Sanitized element name: {sanitizedName}"); - // Output: order-details.xml - - // Sanitize XML element text (remove control characters) - var textWithControlChars = "Hello\x0001\x0002World"; - var cleanText = Decorator.Enclose(textWithControlChars).SanitizeXmlElementText(); - Console.WriteLine($"Clean text: {cleanText}"); - // Output: HelloWorld - - // Sanitize with CDATA section rules (removes ]]> sequences) - var cdataText = "Some data with ]]> embedded"; - var safeCdata = Decorator.Enclose(cdataText).SanitizeXmlElementText(cdataSection: true); - Console.WriteLine($"Safe CDATA: {safeCdata}"); - // Output: Some data with embedded - -} -} - +// Escape XML characters in a string +var raw = ""; +var escaped = Decorator.Enclose(raw).EscapeXml(); +Console.WriteLine($"Escaped: {escaped}"); +// Output: <hello & 'world' "test"> + +// Unescape back to original +var unescaped = Decorator.Enclose(escaped).UnescapeXml(); +Console.WriteLine($"Unescaped: {unescaped}"); +// Output: + +// Sanitize a string to be a valid XML element name +var invalidName = "123order-details!.xml"; +var sanitizedName = Decorator.Enclose(invalidName).SanitizeXmlElementName(); +Console.WriteLine($"Sanitized element name: {sanitizedName}"); +// Output: order-details.xml + +// Sanitize XML element text (remove control characters) +var textWithControlChars = "Hello\x0001\x0002World"; +var cleanText = Decorator.Enclose(textWithControlChars).SanitizeXmlElementText(); +Console.WriteLine($"Clean text: {cleanText}"); +// Output: HelloWorld + +// Sanitize with CDATA section rules (removes ]]> sequences) +var cdataText = "Some data with ]]> embedded"; +var safeCdata = Decorator.Enclose(cdataText).SanitizeXmlElementText(cdataSection: true); +Console.WriteLine($"Safe CDATA: {safeCdata}"); +// Output: Some data with embedded ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.XPath.XPathDocumentFactory.md b/.docfx/api/types/Cuemon.Xml.XPath.XPathDocumentFactory.md index 7cef3002e..4c84dffda 100644 --- a/.docfx/api/types/Cuemon.Xml.XPath.XPathDocumentFactory.md +++ b/.docfx/api/types/Cuemon.Xml.XPath.XPathDocumentFactory.md @@ -7,22 +7,19 @@ example: The following example creates an `XPathDocument` from an XML string using `XPathDocumentFactory`, then queries it with an XPath expression to retrieve the text content of an `` element. The resulting value "Hello" is written to the console. ```csharp +// Program.cs using System; using System.Xml.XPath; using Cuemon.Xml.XPath; -namespace Cuemon.Xml.XPath; +var xml = "Hello"; +var doc = XPathDocumentFactory.CreateDocument(xml); -public class XPathDocumentFactoryExample -{ - public void Demonstrate() - { - var xml = "Hello"; - var doc = XPathDocumentFactory.CreateDocument(xml); - - var navigator = doc.CreateNavigator(); - var value = navigator.SelectSingleNode("//item/text()")?.Value; - Console.WriteLine($"XPath result: {value}"); - } -} +var navigator = doc.CreateNavigator(); +var value = navigator.SelectSingleNode("//item/text()")?.Value; +Console.WriteLine($"XPath result: {value}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.XmlDocumentFactory.md b/.docfx/api/types/Cuemon.Xml.XmlDocumentFactory.md index 96b3b514a..0f7183860 100644 --- a/.docfx/api/types/Cuemon.Xml.XmlDocumentFactory.md +++ b/.docfx/api/types/Cuemon.Xml.XmlDocumentFactory.md @@ -7,24 +7,21 @@ example: The following example parses an XML string into an `XmlDocument` using `XmlDocumentFactory`, then navigates the document to read the root element name and a book's title attribute. The output displays "books" and "1984". ```csharp +// Program.cs using System; using System.Xml; using Cuemon.Xml; -namespace Cuemon.Xml; +var xml = ""; +var doc = XmlDocumentFactory.CreateDocument(xml); -public class XmlDocumentFactoryExample -{ - public void Demonstrate() - { - var xml = ""; - var doc = XmlDocumentFactory.CreateDocument(xml); +var root = doc.DocumentElement; +Console.WriteLine($"Root element: {root?.Name}"); - var root = doc.DocumentElement; - Console.WriteLine($"Root element: {root?.Name}"); - - var book = root?.SelectSingleNode("book"); - Console.WriteLine($"Title: {book?.Attributes?["title"]?.Value}"); - } -} +var book = root?.SelectSingleNode("book"); +Console.WriteLine($"Title: {book?.Attributes?["title"]?.Value}"); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.XmlEncodingOptions.md b/.docfx/api/types/Cuemon.Xml.XmlEncodingOptions.md index 26c6bfe91..1865af01f 100644 --- a/.docfx/api/types/Cuemon.Xml.XmlEncodingOptions.md +++ b/.docfx/api/types/Cuemon.Xml.XmlEncodingOptions.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to configure XmlEncodingOptions to control character encoding and XML declaration behavior when writing XML documents. ```csharp +// Program.cs using System; using System.IO; using System.Text; @@ -14,44 +15,38 @@ using System.Xml; using Cuemon.Text; using Cuemon.Xml; -namespace MyApp.Examples +// Configure XML encoding options. +var options = new XmlEncodingOptions { - public class XmlEncodingOptionsExample - { - public void Demonstrate() - { - // Configure XML encoding options. - var options = new XmlEncodingOptions - { - Encoding = Encoding.UTF8, - Preamble = EncodingOptions.DefaultPreambleSequence, - OmitXmlDeclaration = false - }; - - Console.WriteLine($"Encoding: {options.Encoding.WebName}"); // utf-8 - Console.WriteLine($"Omit XML declaration: {options.OmitXmlDeclaration}"); // False - - // Write XML with explicit encoding settings. - var settings = new XmlWriterSettings - { - Encoding = options.Encoding, - OmitXmlDeclaration = options.OmitXmlDeclaration, - Indent = true - }; - - using var writer = XmlWriter.Create(Stream.Null, settings); - writer.WriteStartDocument(); - writer.WriteStartElement("root"); - writer.WriteElementString("value", "Hello, World!"); - writer.WriteEndElement(); - writer.WriteEndDocument(); - writer.Flush(); - - // Omit the XML declaration. - options.OmitXmlDeclaration = true; - Console.WriteLine($"Omit XML declaration now: {options.OmitXmlDeclaration}"); // True - -}} -} + Encoding = Encoding.UTF8, + Preamble = EncodingOptions.DefaultPreambleSequence, + OmitXmlDeclaration = false +}; +Console.WriteLine($"Encoding: {options.Encoding.WebName}"); // utf-8 +Console.WriteLine($"Omit XML declaration: {options.OmitXmlDeclaration}"); // False + +// Write XML with explicit encoding settings. +var settings = new XmlWriterSettings +{ + Encoding = options.Encoding, + OmitXmlDeclaration = options.OmitXmlDeclaration, + Indent = true +}; + +using var writer = XmlWriter.Create(Stream.Null, settings); +writer.WriteStartDocument(); +writer.WriteStartElement("root"); +writer.WriteElementString("value", "Hello, World!"); +writer.WriteEndElement(); +writer.WriteEndDocument(); +writer.Flush(); + +// Omit the XML declaration. +options.OmitXmlDeclaration = true; +Console.WriteLine($"Omit XML declaration now: {options.OmitXmlDeclaration}"); // True ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.XmlReaderDecoratorExtensions.md b/.docfx/api/types/Cuemon.Xml.XmlReaderDecoratorExtensions.md index f31da1b04..fde0b9fc5 100644 --- a/.docfx/api/types/Cuemon.Xml.XmlReaderDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Xml.XmlReaderDecoratorExtensions.md @@ -7,6 +7,7 @@ example: The following example demonstrates how to move to the first XML element, chunk a document, and build a hierarchy from an . ```csharp +// Program.cs using System; using System.Collections.Generic; using System.IO; @@ -14,29 +15,25 @@ using System.Xml; using Cuemon; using Cuemon.Xml; -namespace MyApp.Examples; +const string xml = ""; -public static class XmlReaderDecoratorExtensionsExample -{ - public static void Demonstrate() - { - const string xml = ""; +using var reader = XmlReader.Create(new StringReader(xml)); +var hasElement = Decorator.Enclose(reader).MoveToFirstElement(); - using var reader = XmlReader.Create(new StringReader(xml)); - var hasElement = Decorator.Enclose(reader).MoveToFirstElement(); +Console.WriteLine(hasElement); +Console.WriteLine(reader.LocalName); - Console.WriteLine(hasElement); - Console.WriteLine(reader.LocalName); +using var chunkReader = XmlReader.Create(new StringReader(xml)); +var chunks = new List(Decorator.Enclose(chunkReader).Chunk(size: 2)); - using var chunkReader = XmlReader.Create(new StringReader(xml)); - var chunks = new List(Decorator.Enclose(chunkReader).Chunk(size: 2)); +Console.WriteLine(chunks.Count); - Console.WriteLine(chunks.Count); +using var hierarchyReader = XmlReader.Create(new StringReader(xml)); +var hierarchy = Decorator.Enclose(hierarchyReader).ToHierarchy(); - using var hierarchyReader = XmlReader.Create(new StringReader(xml)); - var hierarchy = Decorator.Enclose(hierarchyReader).ToHierarchy(); - - Console.WriteLine(hierarchy.Instance.Name); - } -} +Console.WriteLine(hierarchy.Instance.Name); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.XmlStreamFactory.md b/.docfx/api/types/Cuemon.Xml.XmlStreamFactory.md index f003880c3..6676e36c6 100644 --- a/.docfx/api/types/Cuemon.Xml.XmlStreamFactory.md +++ b/.docfx/api/types/Cuemon.Xml.XmlStreamFactory.md @@ -7,30 +7,27 @@ example: The following example builds an XML document inline using `XmlStreamFactory.CreateStream` with an `XmlWriter` delegate. The resulting stream is read back as a string, producing a well-formed XML document with a `` root element. ```csharp +// Program.cs using System; using System.IO; using System.Xml; using Cuemon.Xml; -namespace Cuemon.Xml; - -public class XmlStreamFactoryExample +using var stream = XmlStreamFactory.CreateStream(writer => { - public void Demonstrate() - { - using var stream = XmlStreamFactory.CreateStream(writer => - { - writer.WriteStartDocument(); - writer.WriteStartElement("Configuration"); - writer.WriteElementString("AppName", "MyApp"); - writer.WriteElementString("Version", "1.0"); - writer.WriteEndElement(); - writer.WriteEndDocument(); - }); + writer.WriteStartDocument(); + writer.WriteStartElement("Configuration"); + writer.WriteElementString("AppName", "MyApp"); + writer.WriteElementString("Version", "1.0"); + writer.WriteEndElement(); + writer.WriteEndDocument(); +}); - using var reader = new StreamReader(stream); - var xml = reader.ReadToEnd(); - Console.WriteLine(xml); - } -} +using var reader = new StreamReader(stream); +var xml = reader.ReadToEnd(); +Console.WriteLine(xml); ``` + + + + diff --git a/.docfx/api/types/Cuemon.Xml.XmlWriterDecoratorExtensions.md b/.docfx/api/types/Cuemon.Xml.XmlWriterDecoratorExtensions.md index d0dfe1982..0b5424a6a 100644 --- a/.docfx/api/types/Cuemon.Xml.XmlWriterDecoratorExtensions.md +++ b/.docfx/api/types/Cuemon.Xml.XmlWriterDecoratorExtensions.md @@ -4,62 +4,49 @@ example: - *content --- -`XmlWriterDecoratorExtensions` provides extension methods on `Decorator.Enclose` for serializing objects directly to `XmlWriter` with root element handling, conditional encapsulation, and custom root naming. This example creates an `XmlWriter` targeting a `StringWriter` with indented settings, then uses `WriteXmlRootElement` with a custom delegate that writes a root element, serializes an anonymous `Person` object, and conditionally wraps notes in an encapsulating `` element via `WriteEncapsulatingElementIfNotNull`. A second example shows `WriteObject` to serialize a `Version` with a custom `RootName = new XmlQualifiedEntity("Version")`. Console output displays both XML results with the correct element structure. +`XmlWriterDecoratorExtensions` provides extension methods on `Decorator.Enclose` for serializing objects directly to `XmlWriter` with root element handling, conditional encapsulation, and custom root naming. This example creates an `XmlWriter` targeting a `StringWriter` with indented settings, then uses `WriteXmlRootElement` with a custom delegate that writes a root element, serializes an anonymous `Person` object, and also demonstrates `WriteStartElement` plus `WriteEncapsulatingElementIfNotNull` for a `` element. A second example shows `WriteObject` to serialize a `Version` with a custom `RootName = new XmlQualifiedEntity("Version")`. Console output displays both XML results with the correct element structure. ```csharp +// Program.cs using System; using System.IO; -using System.Text; using System.Xml; using Cuemon; using Cuemon.Xml; using Cuemon.Xml.Serialization; -namespace MyApp.Examples; +var writer = new StringWriter(); +using var xmlWriter = XmlWriter.Create(writer, new XmlWriterSettings { Indent = true }); +var decorator = Decorator.Enclose(xmlWriter); -public class Example +var person = new { FirstName = "John", LastName = "Doe", Age = 30 }; +decorator.WriteXmlRootElement(person, (w, value, rootEntity) => { - public void Run() - { - - var writer = new StringWriter(); - var xmlWriter = XmlWriter.Create(writer, new XmlWriterSettings { Indent = true, Encoding = Encoding.UTF8, OmitXmlDeclaration = false }); - - var decorator = Decorator.Enclose(xmlWriter); - - // Write a root element and serialize an object - var person = new { FirstName = "John", LastName = "Doe", Age = 30 }; - decorator.WriteXmlRootElement(person, (w, value, rootEntity) => - { - decorator.WriteStartElement(rootEntity); // - decorator.WriteObject(value, typeof(object)); // serialized person content - decorator.WriteEncapsulatingElementIfNotNull("notes", new XmlQualifiedEntity("Notes"), (w2, notes) => - { - w2.WriteString(notes); // notes - }); - }); - - xmlWriter.Flush(); - string xml = writer.ToString(); - Console.WriteLine(xml); - - // Write an object directly without root element handling - var version = new Version(1, 0, 0, 0); - var xmlWriter2 = XmlWriter.Create(new StringWriter(), new XmlWriterSettings { Indent = true }); - var decorator2 = Decorator.Enclose(xmlWriter2); - decorator2.WriteObject(version, o => - { - o.Settings.RootName = new XmlQualifiedEntity("Version"); - }); - xmlWriter2.Flush(); - // - // 1 - // 0 - // 0 - // 0 - // - -} -} - + w.WriteElementString("FirstName", value.FirstName); + w.WriteElementString("LastName", value.LastName); + w.WriteElementString("Age", value.Age.ToString()); +}, new XmlQualifiedEntity("Person")); + +xmlWriter.Flush(); +Console.WriteLine(writer.ToString()); + +var manualWriter = new StringWriter(); +using var manualXmlWriter = XmlWriter.Create(manualWriter, new XmlWriterSettings { Indent = true }); +var manualDecorator = Decorator.Enclose(manualXmlWriter); +manualDecorator.WriteStartElement(new XmlQualifiedEntity("Person")); +manualDecorator.WriteEncapsulatingElementIfNotNull("Doe", new XmlQualifiedEntity("LastName"), (w, value) => w.WriteString(value)); +manualXmlWriter.WriteEndElement(); +manualXmlWriter.Flush(); +Console.WriteLine(manualWriter.ToString()); + +var versionWriter = new StringWriter(); +using var versionXmlWriter = XmlWriter.Create(versionWriter, new XmlWriterSettings { Indent = true }); +var versionDecorator = Decorator.Enclose(versionXmlWriter); +versionDecorator.WriteObject(new Version(1, 0, 0, 0), o => o.Settings.RootName = new XmlQualifiedEntity("Version")); +versionXmlWriter.Flush(); +Console.WriteLine(versionWriter.ToString()); ``` + + + + diff --git a/.docfx/api/types/System.Runtime.CompilerServices.CallerArgumentExpressionAttribute.md b/.docfx/api/types/System.Runtime.CompilerServices.CallerArgumentExpressionAttribute.md index 6307dde9e..697c1def2 100644 --- a/.docfx/api/types/System.Runtime.CompilerServices.CallerArgumentExpressionAttribute.md +++ b/.docfx/api/types/System.Runtime.CompilerServices.CallerArgumentExpressionAttribute.md @@ -7,32 +7,40 @@ example: The following example demonstrates `CallerArgumentExpressionAttribute` in a validation helper. `Validate` captures the source expression of its `condition` argument, so when `value > 0` is passed the console prints "Assertion passed: value > 0". ```csharp +// Program.cs using System; using System.Runtime.CompilerServices; -namespace System.Runtime.CompilerServices; +new CallerArgumentExpressionAttributeExample().Demonstrate(); -public class CallerArgumentExpressionAttributeExample +namespace System.Runtime.CompilerServices { - public void Demonstrate() + public class CallerArgumentExpressionAttributeExample { - var attr = new CallerArgumentExpressionAttribute("condition"); - Console.WriteLine(attr.ParameterName); // "condition" - - var value = 42; - Validate(value > 0); - } - - public void Validate(bool condition, [CallerArgumentExpression("condition")] string expression = null) - { - if (!condition) + public void Demonstrate() { - Console.WriteLine($"Assertion failed: {expression}"); + var attr = new CallerArgumentExpressionAttribute("condition"); + Console.WriteLine(attr.ParameterName); // "condition" + + var value = 42; + Validate(value > 0); } - else + + public void Validate(bool condition, [CallerArgumentExpression("condition")] string expression = null) { - Console.WriteLine($"Assertion passed: {expression}"); + if (!condition) + { + Console.WriteLine($"Assertion failed: {expression}"); + } + else + { + Console.WriteLine($"Assertion passed: {expression}"); + } } } } ``` + + + + diff --git a/.docfx/docfx.json b/.docfx/docfx.json index 2ffac3331..6eaff9b9a 100644 --- a/.docfx/docfx.json +++ b/.docfx/docfx.json @@ -23,10 +23,7 @@ ], "dest": "api/dotnet", "memberLayout": "separatePages", - "filter": "filterConfig.yml", - "properties": { - "TargetFramework": "net10.0" - } + "filter": "filterConfig.yml" }, { "src": [ @@ -55,10 +52,7 @@ ], "dest": "api/extensions/dotnet", "memberLayout": "separatePages", - "filter": "filterConfig.yml", - "properties": { - "TargetFramework": "net10.0" - } + "filter": "filterConfig.yml" }, { "src": [ @@ -74,10 +68,7 @@ ], "dest": "api/aspnet", "memberLayout": "separatePages", - "filter": "filterConfig.yml", - "properties": { - "TargetFramework": "net10.0" - } + "filter": "filterConfig.yml" }, { "src": [ @@ -97,10 +88,7 @@ ], "dest": "api/extensions/aspnet", "memberLayout": "separatePages", - "filter": "filterConfig.yml", - "properties": { - "TargetFramework": "net10.0" - } + "filter": "filterConfig.yml" } ], "build": { @@ -131,6 +119,11 @@ "files": [ "images/**" ] + }, + { + "files": [ + "run-actions/**" + ] } ], "globalMetadata": { diff --git a/.docfx/run-actions.manifest.json b/.docfx/run-actions.manifest.json new file mode 100644 index 000000000..7262784af --- /dev/null +++ b/.docfx/run-actions.manifest.json @@ -0,0 +1,12384 @@ +{ + "schemaVersion": 1, + "examples": [ + { + "id": "001da6f3e474ea17d273b61a", + "exampleId": "Cuemon.Extensions.Data.Integrity.FileInfoExtensions#1", + "uid": "Cuemon.Extensions.Data.Integrity.FileInfoExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Data.Integrity@11.0.0" + ], + "source": "using System;\nusing System.IO;\nusing System.Text;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Extensions.Data.Integrity;\n\nnamespace MyApp.Examples;\n\npublic class FileInfoExtensionsExample\n{\n public static void Main()\n {\n // Create a temporary file to work with\n string tempFile = Path.GetTempFileName();\n File.WriteAllText(tempFile, \"Hello, World!\", Encoding.UTF8);\n\n try\n {\n var fileInfo = new FileInfo(tempFile);\n\n // Generate a CacheValidator with default FNV-1a/128 hashing\n CacheValidator validator = fileInfo.GetCacheValidator();\n\n Console.WriteLine($\"File: {fileInfo.Name}\");\n Console.WriteLine($\"Created (UTC): {validator.Created}\");\n Console.WriteLine($\"Modified (UTC): {validator.Modified}\");\n Console.WriteLine($\"Checksum (hex): {validator.Checksum.ToHexadecimalString()}\");\n Console.WriteLine($\"Validation: {validator.Validation}\");\n\n // Combine with an additional semantic checksum\n validator.CombineWith(Encoding.UTF8.GetBytes(\"additional-context\"));\n Console.WriteLine($\"Combined checksum: {validator.Checksum.ToHexadecimalString()}\");\n }\n finally\n {\n File.Delete(tempFile);\n }\n }\n}" + } + }, + { + "id": "003f8f9bd4acab0cacdd2623", + "exampleId": "Cuemon.Net.ByteArrayDecoratorExtensions#1", + "uid": "Cuemon.Net.ByteArrayDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0", + "Cuemon.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon;\nusing Cuemon.Net;\nusing Cuemon.Text;\n\n// Create bytes containing characters that need URL encoding\nbyte[] data = Encoding.UTF8.GetBytes(\"hello world & more \");\n\n// URL-encode the bytes with default position (0) and length (all)\nbyte[] encoded = Decorator.Enclose(data).UrlEncode(0, data.Length);\nstring encodedString = Encoding.ASCII.GetString(encoded);\nConsole.WriteLine(encodedString); // \"hello+world+%26+more+%3cstuff%3e\"\n\n// Encode only a portion of the byte array\nbyte[] partial = Encoding.UTF8.GetBytes(\"a & b & c\");\nbyte[] encodedPartial = Decorator.Enclose(partial).UrlEncode(position: 0, bytesToRead: 5);\nstring partialString = Encoding.ASCII.GetString(encodedPartial);\nConsole.WriteLine(partialString); // \"a+%26+b\" (only first 5 bytes encoded)\n\n// Encode with custom encoding options\nbyte[] utf32Data = Encoding.UTF32.GetBytes(\"hello\");\nbyte[] utf32Encoded = Decorator.Enclose(utf32Data).UrlEncode(0, utf32Data.Length, o =>\n{\n o.Encoding = Encoding.UTF32;\n});\n\n// Handle empty byte arrays\nbyte[] empty = Array.Empty();\nbyte[] emptyEncoded = Decorator.Enclose(empty).UrlEncode(0, 0);\nConsole.WriteLine(emptyEncoded.Length); // 0" + } + }, + { + "id": "0047075140e13ef7255341b7", + "exampleId": "Cuemon.IO.AsyncStreamReaderOptions#1", + "uid": "Cuemon.IO.AsyncStreamReaderOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing Cuemon;\nusing Cuemon.IO;\nusing Cuemon.Text;\n\nbyte[] payload = Encoding.UTF8.GetPreamble()\n .Concat(Encoding.UTF8.GetBytes(\"Hej Cuemon\"))\n .ToArray();\n\nusing var stream = new MemoryStream(payload);\n\nvar options = new AsyncStreamReaderOptions\n{\n BufferSize = 4096,\n Encoding = EncodingOptions.DefaultEncoding,\n Preamble = PreambleSequence.Remove,\n LeaveOpen = true\n};\n\nstring text = await Decorator.Enclose(stream).ToEncodedStringAsync(setup =>\n{\n setup.BufferSize = options.BufferSize;\n setup.Encoding = options.Encoding;\n setup.Preamble = options.Preamble;\n setup.LeaveOpen = options.LeaveOpen;\n});\n\nConsole.WriteLine($\"{options.Encoding.WebName}:{text}\");" + } + }, + { + "id": "00a579ead39a5f214ec75d09", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.Headers.EntityTagCacheableValidator#1", + "uid": "Cuemon.Extensions.AspNetCore.Http.Headers.EntityTagCacheableValidator", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http.Headers;\nusing Cuemon.Extensions.AspNetCore.Http.Headers;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\n\nvar services = new ServiceCollection();\nservices.Configure(options =>\n{\n options.Validators.Add(new EntityTagCacheableValidator());\n});\n\nusing var provider = services.BuildServiceProvider();\nvar options = provider.GetRequiredService>().Value;\n\nConsole.WriteLine(options.Validators.Count);\nConsole.WriteLine(options.Validators[0] is EntityTagCacheableValidator);" + } + }, + { + "id": "018e3d3a34e0815dd96245b4", + "exampleId": "Cuemon.Security.FowlerNollVo512#1", + "uid": "Cuemon.Security.FowlerNollVo512", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon;\nusing Cuemon.Security;\n\n// Create a FNV-1a 512-bit hash (default algorithm).\nvar fnv = new FowlerNollVo512();\n\nConsole.WriteLine($\"Bits: {fnv.Bits}\"); // 512\nConsole.WriteLine($\"Algorithm: {fnv.Options.Algorithm}\"); // Fnv1a\nConsole.WriteLine($\"Offset basis: {fnv.OffsetBasis}\");\n\n// Compute hash of binary data.\nvar data = Encoding.UTF8.GetBytes(\"Cuemon FNV-512 example\");\nvar hash = fnv.ComputeHash(data);\n\nConsole.WriteLine($\"Hash (hex): {hash.ToHexadecimalString()}\");\nConsole.WriteLine($\"Hash (base64): {hash.ToBase64String()}\");\n\n// Using FNV-1 algorithm.\nvar fnv1 = new FowlerNollVo512(o => o.Algorithm = FowlerNollVoAlgorithm.Fnv1);\nvar hashFnv1 = fnv1.ComputeHash(data);\nConsole.WriteLine($\"FNV-1 hash: {hashFnv1.ToHexadecimalString()}\");\n\n// Raw bytes for further processing.\nvar bytes = hash.GetBytes();\nConsole.WriteLine($\"Byte length: {bytes.Length}\"); // 64 (512 / 8)\n\n// URL-safe Base64 encoding.\nvar urlSafe = hash.ToUrlEncodedBase64String();\nConsole.WriteLine($\"URL-safe b64: {urlSafe}\");" + } + }, + { + "id": "01a012d57f1bda4a0107ccce", + "exampleId": "Cuemon.DateTimeDecoratorExtensions#1", + "uid": "Cuemon.DateTimeDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\n// Get the Unix epoch (January 1st, 1970 UTC)\nvar unixEpoch = Decorator.Syntactic().GetUnixEpoch();\nConsole.WriteLine(unixEpoch); // 1/1/1970 12:00:00 AM\n\n// Convert a DateTime to Unix epoch time (seconds since 1970-01-01 UTC)\nvar utcNow = DateTime.UtcNow;\nvar unixTime = Decorator.Enclose(utcNow).ToUnixEpochTime();\nConsole.WriteLine(unixTime); // e.g., 1700000000\n\n// Convert from local DateTime to UTC-kind DateTime (same ticks, different kind)\nvar localTime = new DateTime(2024, 6, 15, 12, 0, 0, DateTimeKind.Local);\nvar utcKind = Decorator.Enclose(localTime).ToUtcKind();\nConsole.WriteLine(utcKind.Kind); // Utc\nConsole.WriteLine(utcKind.Ticks == localTime.Ticks); // True\n\n// Convert from UTC DateTime to local-kind DateTime\nvar utcTime = new DateTime(2024, 6, 15, 10, 0, 0, DateTimeKind.Utc);\nvar localKind = Decorator.Enclose(utcTime).ToLocalKind();\nConsole.WriteLine(localKind.Kind); // Local\nConsole.WriteLine(localKind.Ticks == utcTime.Ticks); // True\n\n// Strip kind information (set to Unspecified)\nvar defaultKind = Decorator.Enclose(utcTime).ToDefaultKind();\nConsole.WriteLine(defaultKind.Kind); // Unspecified\nConsole.WriteLine(defaultKind.Ticks == utcTime.Ticks); // True" + } + }, + { + "id": "023ab0ec6b67d9348ca5655e", + "exampleId": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationOptions#1", + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Claims;\nusing Cuemon.AspNetCore.Authentication.Digest;\n\nvar options = new DigestAuthenticationOptions\n{\n DigestAlgorithm = DigestCryptoAlgorithm.Sha256,\n Realm = \"docs-example\",\n RequireSecureConnection = false,\n Authenticator = (string username, out string password) =>\n {\n password = username == \"Agent\" ? \"Test\" : null;\n return password == null\n ? null\n : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, DigestAuthorizationHeader.Scheme));\n }\n};\n\noptions.ValidateOptions();\n\nConsole.WriteLine(options.DigestAlgorithm);" + } + }, + { + "id": "0323d469e14a42e0124cc6c6", + "exampleId": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeaderBuilder#1", + "uid": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeaderBuilder", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Globalization;\nusing System.Net.Http;\nusing Cuemon.AspNetCore.Authentication.Hmac;\n\nusing var request = new HttpRequestMessage(HttpMethod.Get, \"https://api.cuemon.net/resource?name=Agent\");\nrequest.Headers.Date = DateTimeOffset.Parse(\"2022-07-10T12:50:42Z\", CultureInfo.InvariantCulture);\nrequest.Headers.Host = \"api.cuemon.net\";\n\nvar builder = new HmacAuthorizationHeaderBuilder()\n .AddFromRequest(request)\n .AddClientId(\"Agent-Api\")\n .AddClientSecret(\"Test\")\n .AddCredentialScope(\"20220710/us-east-1/docs/request\");\n\nvar header = builder.Build();\n\nConsole.WriteLine(header.ToString());" + } + }, + { + "id": "038bf45ed91c27c8a5b3ff04", + "exampleId": "Cuemon.AspNetCore.Configuration.DynamicCacheBusting#1", + "uid": "Cuemon.AspNetCore.Configuration.DynamicCacheBusting", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.AspNetCore.Configuration;\nusing Microsoft.Extensions.Options;\n\nvar options = Options.Create(new DynamicCacheBustingOptions\n{\n PreferredLength = 8,\n PreferredCharacters = Alphanumeric.LettersAndNumbers,\n TimeToLive = TimeSpan.FromHours(12)\n});\n\nvar cacheBusting = new DynamicCacheBusting(options);\n\n// Version is regenerated when the configured TimeToLive has elapsed.\nstring version = cacheBusting.Version;\nConsole.WriteLine(version);" + } + }, + { + "id": "05809c54a9f1c09bb1c5903c", + "exampleId": "Cuemon.Data.QueryType#1", + "uid": "Cuemon.Data.QueryType", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ], + "source": "using System;\nusing Cuemon.Data;\n\nnamespace MyApp.Examples;\n\npublic class QueryTypeExample\n{\n public static void Main()\n {\n var operation = QueryType.Select;\n Console.WriteLine(\"Operation: {0} (value: {1})\", operation, (int)operation);\n\n operation = QueryType.Insert;\n Console.WriteLine(\"Operation: {0} (value: {1})\", operation, (int)operation);\n\n // Use in a switch expression\n string label = operation switch\n {\n QueryType.Select => \"Read\",\n QueryType.Insert => \"Create\",\n QueryType.Update => \"Update\",\n QueryType.Delete => \"Delete\",\n QueryType.Exists => \"Check existence\",\n _ => \"Unknown\"\n };\n Console.WriteLine(\"Label: {0}\", label);\n\n // Output:\n // Operation: Select (value: 0)\n // Operation: Insert (value: 2)\n // Label: Create\n\n}\n}" + } + }, + { + "id": "0583caae9b19a16d6379542e", + "exampleId": "Cuemon.Security.Cryptography.HmacSecureHashAlgorithm384#1", + "uid": "Cuemon.Security.Cryptography.HmacSecureHashAlgorithm384", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\n\nvar secret = Encoding.UTF8.GetBytes(\"docs-secret-sha384\");\nvar algorithm = new HmacSecureHashAlgorithm384(secret, null);\nvar result = algorithm.ComputeHash(Encoding.UTF8.GetBytes(\"Payload for SHA-384\"));\n\nConsole.WriteLine(result.GetBytes().Length);\nConsole.WriteLine(result.ToBase64String());" + } + }, + { + "id": "0589060aa19ff1221c8e4938", + "exampleId": "Cuemon.AspNetCore.Hosting.HostingEnvironmentOptions#1", + "uid": "Cuemon.AspNetCore.Hosting.HostingEnvironmentOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Extensions.Hosting@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Microsoft.Extensions.Hosting;\nusing Cuemon.AspNetCore.Hosting;\n\n var options = new HostingEnvironmentOptions\n{\n HeaderName = \"X-Environment\",\n SuppressHeaderPredicate = environment => environment.IsProduction()\n};\n\noptions.ValidateOptions();\nConsole.WriteLine(options.HeaderName);" + } + }, + { + "id": "05fda780457d8373cedc0c00", + "exampleId": "Cuemon.Extensions.Text.Json.JsonNamingPolicyExtensions#1", + "uid": "Cuemon.Extensions.Text.Json.JsonNamingPolicyExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "using System;\nusing System.Text.Json;\nusing Cuemon.Extensions.Text.Json;\n\nnamespace MyApp.Examples;\n\npublic class JsonNamingPolicyExtensionsExample\n{\n public static void Main()\n {\n // Apply camelCase naming policy\n JsonNamingPolicy camelCase = JsonNamingPolicy.CamelCase;\n string camelName = camelCase.DefaultOrConvertName(\"OrderDate\");\n Console.WriteLine(camelName); // Output: \"orderDate\"\n\n // When policy is null, the name is returned unaltered\n string unchanged = ((JsonNamingPolicy)null).DefaultOrConvertName(\"OrderDate\");\n Console.WriteLine(unchanged); // Output: \"OrderDate\"\n\n // Useful when working with configurable naming policies\n JsonSerializerOptions options = new JsonSerializerOptions\n {\n PropertyNamingPolicy = JsonNamingPolicy.CamelCase\n };\n\n string configuredName = options.PropertyNamingPolicy.DefaultOrConvertName(\"ShippingAddress\");\n Console.WriteLine(configuredName); // Output: \"shippingAddress\"\n\n}\n}" + } + }, + { + "id": "06baa6d44a12c6ec8db7e716", + "exampleId": "Cuemon.Extensions.TesterFuncFactory#1", + "uid": "Cuemon.Extensions.TesterFuncFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Extensions;\n\nTesterFunc tryParse = (string input, out int result) => int.TryParse(input, out result);\n\nvar factory = TesterFuncFactory.Create(tryParse, \"42\");\nbool success = factory.ExecuteMethod(out int value);\nConsole.WriteLine($\"Parsed: {value}, Success: {success}\");\n\nvar failFactory = TesterFuncFactory.Create(tryParse, \"not-a-number\");\nbool failed = failFactory.ExecuteMethod(out int fallback);\nConsole.WriteLine($\"Fallback: {fallback}, Success: {failed}\");" + } + }, + { + "id": "06e32e8efa4c20a5ae0f945f", + "exampleId": "Cuemon.UnsuccessfulValue#1", + "uid": "Cuemon.UnsuccessfulValue", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Contoso.Connections;\n\nUnsuccessfulValueExample.Run();\n\nnamespace Contoso.Connections\n{\n public sealed class UnsuccessfulValueExample\n {\n public static void Run()\n {\n ConditionalValue outcome = OpenConnection(null);\n\n Console.WriteLine($\"Succeeded: {outcome.Succeeded}\");\n Console.WriteLine($\"Failure: {outcome.Failure?.GetType().Name}\");\n }\n\n private static ConditionalValue OpenConnection(string connectionString)\n {\n try\n {\n Validator.ThrowIfNullOrWhitespace(connectionString);\n return new SuccessfulValue();\n }\n catch (Exception ex)\n {\n return new UnsuccessfulValue(ex);\n }\n }\n }\n}" + } + }, + { + "id": "0702c3c2c449c81c6a169630", + "exampleId": "Cuemon.Xml.Serialization.Converters.FailureConverter#1", + "uid": "Cuemon.Xml.Serialization.Converters.FailureConverter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing Cuemon.Diagnostics;\nusing Cuemon.Xml.Serialization;\nusing Cuemon.Xml.Serialization.Converters;\nusing Cuemon.Xml.Serialization.Formatters;\n\n // Create a Failure from an exception\n var exception = new InvalidOperationException(\"The requested resource was not found.\")\n {\n Source = \"MyApi\"\n };\n var failure = new Failure(exception, FaultSensitivityDetails.None);\n\n // Configure the XML formatter with the FailureConverter\n var options = new XmlFormatterOptions();\n options.Settings.Converters.Add(new FailureConverter());\n\n // Serialize to XML\n var formatter = new XmlFormatter(options);\n using (var stream = formatter.Serialize(failure))\n using (var reader = new StreamReader(stream))\n {\n string xml = reader.ReadToEnd();\n Console.WriteLine(xml);\n // The output resembles:\n // \n // \n // MyApi\n // The requested resource was not found.\n // \n\n}" + } + }, + { + "id": "07cb1b2ab9859c94b3bcb30f", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingFilter#1", + "uid": "Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingFilter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Mvc@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.Hosting@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.AspNetCore.Mvc.Filters.Diagnostics;\nusing Microsoft.Extensions.FileProviders;\nusing Microsoft.Extensions.Hosting;\nusing Microsoft.Extensions.Logging;\nusing Microsoft.Extensions.Options;\nusing MyApp.Examples;\n\nServerTimingFilterExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class ServerTimingFilterExample\n {\n public static void Demonstrate()\n {\n var options = Options.Create(new ServerTimingOptions\n {\n UseTimeMeasureProfiler = true,\n SuppressHeaderPredicate = _ => false\n });\n\n using var loggerFactory = LoggerFactory.Create(_ => { });\n var filter = new ServerTimingFilter(\n options,\n new SampleHostEnvironment(),\n loggerFactory.CreateLogger());\n\n Console.WriteLine(filter.Options.UseTimeMeasureProfiler);\n Console.WriteLine(filter.Options.SuppressHeaderPredicate is not null);\n }\n\n private sealed class SampleHostEnvironment : IHostEnvironment\n {\n public string EnvironmentName { get; set; } = Environments.Development;\n\n public string ApplicationName { get; set; } = nameof(ServerTimingFilterExample);\n\n public string ContentRootPath { get; set; } = AppContext.BaseDirectory;\n\n public IFileProvider ContentRootFileProvider { get; set; } = new NullFileProvider();\n }\n }\n}" + } + }, + { + "id": "08aec9f49e43cb171e73f34c", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.Throttling.ApplicationBuilderExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Http.Throttling.ApplicationBuilderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.AspNetCore.Http.Throttling;\nusing Cuemon.Extensions.AspNetCore.Http.Throttling;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.Extensions.DependencyInjection;\n\nvar services = new ServiceCollection();\nservices.AddLogging();\nservices.AddMemoryThrottlingCache();\nservices.AddThrottlingSentinelOptions(options =>\n{\n options.Quota = new ThrottleQuota(100, 1, TimeUnit.Minutes);\n options.ContextResolver = context => context.Connection.RemoteIpAddress?.ToString() ?? \"unknown\";\n});\n\nusing var provider = services.BuildServiceProvider();\nvar app = new ApplicationBuilder(provider);\napp.UseThrottlingSentinel(options =>\n{\n options.Quota = new ThrottleQuota(100, 1, TimeUnit.Minutes);\n options.ContextResolver = context => context.Connection.RemoteIpAddress?.ToString() ?? \"unknown\";\n});\n\nConsole.WriteLine(\"Throttling sentinel middleware configured.\");" + } + }, + { + "id": "08d377f47415311de1f46f2c", + "exampleId": "Cuemon.ConvertibleConverterDictionary#1", + "uid": "Cuemon.ConvertibleConverterDictionary", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon;\n\nvar converters = new ConvertibleConverterDictionary()\n .Add(value => BitConverter.GetBytes(value))\n .Add(value => BitConverter.GetBytes(value))\n .Add(value => Encoding.UTF8.GetBytes(value))\n .Add(value => BitConverter.GetBytes(value));\n\nConsole.WriteLine(converters.Count);\n\nConsole.WriteLine(converters.ContainsKey(typeof(int)));\nConsole.WriteLine(converters.ContainsKey(typeof(float)));\n\nif (converters.TryGetValue(typeof(string), out var stringConverter))\n{\n byte[] bytes = stringConverter(\"Hello\");\n Console.WriteLine(bytes.Length);\n Console.WriteLine(Encoding.UTF8.GetString(bytes));\n}\n\nvar intConverter = converters[typeof(int)];\nif (intConverter != null)\n{\n byte[] intBytes = intConverter(42);\n Console.WriteLine(BitConverter.ToInt32(intBytes));\n}\n\nforeach (var kvp in converters)\n{\n Console.WriteLine($\"{kvp.Key.Name} -> converter registered\");\n}\n\nconverters.Add(typeof(double), value => BitConverter.GetBytes(value.ToDouble(null)));\nConsole.WriteLine(converters.Count);\nConsole.WriteLine(converters.ContainsKey(typeof(double)));" + } + }, + { + "id": "0935da97633b9761817c0697", + "exampleId": "Cuemon.Extensions.Runtime.Hierarchy#1", + "uid": "Cuemon.Extensions.Runtime.Hierarchy", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.Extensions.Runtime;\n\nvar root = new Hierarchy();\nroot.Add(\"root\");\n\nvar child1 = root.Add(\"department\");\nvar child2 = root.Add(\"team\");\n\nchild1.Add(\"employee1\");\nchild1.Add(\"employee2\");\n\nConsole.WriteLine(root.GetPath());\nConsole.WriteLine(child1.GetPath(n => n.Instance.ToString().ToUpper()));\n\nvar matches = Hierarchy.Find(root, n => n.Instance.ToString().StartsWith(\"employee\"));\nConsole.WriteLine($\"Found {matches.Count()} node(s)\");\n\nvar obj = new { Name = \"Root\", Items = new[] { new { Id = 1 }, new { Id = 2 } } };\nIHierarchy tree = Hierarchy.GetObjectHierarchy(obj);\nConsole.WriteLine(tree.GetPath(n => n.InstanceType.Name));" + } + }, + { + "id": "0959d0815c30fd38b962ea99", + "exampleId": "Cuemon.Extensions.Diagnostics.FileVersionInfoExtensions#1", + "uid": "Cuemon.Extensions.Diagnostics.FileVersionInfoExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Diagnostics@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Diagnostics;\nusing System.Reflection;\nusing Cuemon.Extensions.Diagnostics;\nusing Cuemon.Reflection;\n\n// Get the FileVersionInfo for the current assembly.\nAssembly assembly = typeof(FileVersionInfoExtensions).Assembly;\nFileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);\n\nConsole.WriteLine(\"Assembly: {0}\", assembly.FullName);\nConsole.WriteLine(\"Original ProductVersion: {0}\", fvi.ProductVersion);\nConsole.WriteLine(\"Original FileVersion: {0}\", fvi.FileVersion);\n\n// Convert to a structured VersionResult using the extension methods.\n\n// ToProductVersion returns the NuGet/semantic version string (e.g., \"1.2.3-beta\").\nVersionResult productVersion = fvi.ToProductVersion();\nConsole.WriteLine(\"Product VersionResult: {0}\", productVersion.Value);\nConsole.WriteLine(\"Is semantic version? {0}\", productVersion.IsSemanticVersion());\nConsole.WriteLine(\"Has alphanumeric part? {0}\", productVersion.HasAlphanumericVersion);\n\n// ToFileVersion returns the file version string (e.g., \"1.2.3.0\").\nVersionResult fileVersion = fvi.ToFileVersion();\nConsole.WriteLine(\"File VersionResult: {0}\", fileVersion.Value);\n\n// Both VersionResult objects can be converted to System.Version.\nVersion numericVersion = fileVersion.ToVersion();\nConsole.WriteLine(\"Parsed as System.Version: {0}\", numericVersion);" + } + }, + { + "id": "0a3f204ebac75cfb9b9d91e1", + "exampleId": "Cuemon.SystemSnapshots#1", + "uid": "Cuemon.SystemSnapshots", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\n // SystemSnapshots is a flags enum controlling which system\n // information categories to capture.\n\n // Capture everything available.\n var all = SystemSnapshots.CaptureAll;\n Console.WriteLine($\"CaptureAll = {all}\"); // CaptureThreadInfo | CaptureProcessInfo | CaptureEnvironmentInfo\n\n // Capture only specific categories.\n var minimal = SystemSnapshots.CaptureThreadInfo | SystemSnapshots.CaptureProcessInfo;\n\n // Test if a flag is set.\n if (all.HasFlag(SystemSnapshots.CaptureEnvironmentInfo))\n {\n Console.WriteLine(\"Environment info will be captured.\");\n\n // Start with none and add incrementally.\n var flags = SystemSnapshots.None;\n flags |= SystemSnapshots.CaptureThreadInfo;\n flags |= SystemSnapshots.CaptureProcessInfo;\n\n Console.WriteLine($\"Flags: {flags}\"); // CaptureThreadInfo | CaptureProcessInfo\n Console.WriteLine($\"Has thread info: {flags.HasFlag(SystemSnapshots.CaptureThreadInfo)}\"); // True\n\n}" + } + }, + { + "id": "0b20929d513805aa08c4fadd", + "exampleId": "Cuemon.Reflection.MemberReflection#1", + "uid": "Cuemon.Reflection.MemberReflection", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Reflection;\nusing Cuemon.Reflection;\n\n// Create flags to find only public instance members (excluding inherited)\nBindingFlags flags = new MemberReflection(\n excludePrivate: true,\n excludeStatic: true,\n excludeInheritancePath: true);\nConsole.WriteLine(flags);\n// Output: Instance, Public, DeclaredOnly\n\n// Use the static CreateFlags factory method\nBindingFlags allFlags = MemberReflection.CreateFlags();\nConsole.WriteLine(allFlags);\n// Output: Instance, Static, Public, NonPublic\n\n// Configure via MemberReflectionOptions\nBindingFlags customFlags = MemberReflection.CreateFlags(o =>\n{\n o.ExcludePrivate = true;\n o.ExcludeStatic = true;\n});\n\n// Use with reflection\nvar members = typeof(string).GetMembers(customFlags);\nConsole.WriteLine(members.Length); // Number of public instance members on string" + } + }, + { + "id": "0b5c231f4e845e9b3a082eb2", + "exampleId": "Cuemon.DateTimeFormatPattern#1", + "uid": "Cuemon.DateTimeFormatPattern", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\nvar shortDate = DateTimeFormatPattern.ShortDate;\nvar longDateTime = DateTimeFormatPattern.LongDateTime;\n\nvar now = DateTime.Now;\nConsole.WriteLine($\"Selected pattern: {shortDate}\");\nConsole.WriteLine($\"Selected pattern: {longDateTime}\");" + } + }, + { + "id": "0baf760afd2a06d6f6ad4d4e", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable.CacheableAsyncResultFilterExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable.CacheableAsyncResultFilterExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Mvc.Filters.Cacheable;\nusing Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable;\nusing Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable.DocExamples;\n\nConsole.WriteLine(new CacheableAsyncResultFilterExtensionsExample().CreateDefaultProfile());\n\nnamespace Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable.DocExamples\n{\n public sealed class CacheableAsyncResultFilterExtensionsExample\n {\n public HttpCacheableOptions CreateDefaultProfile()\n {\n var options = new HttpCacheableOptions();\n options.Filters.AddLastModifiedHeader();\n options.Filters.AddEntityTagHeader();\n return options;\n }\n\n public HttpCacheableOptions CreateCustomProfile()\n {\n var options = new HttpCacheableOptions();\n options.Filters.AddFilter(entityTag =>\n {\n entityTag.UseEntityTagResponseParser = true;\n });\n options.Filters.InsertFilter(0);\n return options;\n }\n\n public void Describe()\n {\n var defaultProfile = CreateDefaultProfile();\n var customProfile = CreateCustomProfile();\n\n Console.WriteLine($\"{defaultProfile.Filters.Count} default filters, {customProfile.Filters.Count} custom filters.\");\n }\n }\n}" + } + }, + { + "id": "0c4231799dc4eda8b1ab2426", + "exampleId": "Cuemon.Extensions.AspNetCore.Configuration.AssemblyCacheBustingOptions#1", + "uid": "Cuemon.Extensions.AspNetCore.Configuration.AssemblyCacheBustingOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0", + "Cuemon.Security.Cryptography@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Extensions.AspNetCore.Configuration;\nusing Cuemon.Security.Cryptography;\nusing Microsoft.Extensions.Options;\n\nvar options = Options.Create(new AssemblyCacheBustingOptions\n{\n Assembly = typeof(AssemblyCacheBustingOptions).Assembly,\n Algorithm = UnkeyedCryptoAlgorithm.Sha256,\n PreferredCasing = CasingMethod.UpperCase,\n ReadByteForByteChecksum = true\n});\n\nvar cacheBusting = new AssemblyCacheBusting(options);\n\nConsole.WriteLine(cacheBusting.Version);" + } + }, + { + "id": "0c5947f274a0c2de45246900", + "exampleId": "Cuemon.Security.Cryptography.AesCryptor#1", + "uid": "Cuemon.Security.Cryptography.AesCryptor", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Cryptography;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\nusing MyApp.Security;\n\nAesCryptorExamples.Demonstrate();\n\nnamespace MyApp.Security\n{\n public class AesCryptorExamples\n {\n public static void Demonstrate()\n {\n // Generate a 256-bit key and 128-bit initialization vector.\n byte[] key = AesCryptor.GenerateKey();\n byte[] iv = AesCryptor.GenerateInitializationVector();\n\n Console.WriteLine(\"Key length: {0} bytes ({1} bits)\", key.Length, key.Length * 8);\n Console.WriteLine(\"IV length: {0} bytes ({1} bits)\", iv.Length, iv.Length * 8);\n\n // Create an AesCryptor instance with the generated key and IV.\n var cryptor = new AesCryptor(key, iv);\n\n // Encrypt a secret message.\n byte[] plaintext = Encoding.UTF8.GetBytes(\"This is a sensitive message that needs encryption.\");\n byte[] ciphertext = cryptor.Encrypt(plaintext);\n\n Console.WriteLine(\"Plaintext bytes: {0}\", plaintext.Length);\n Console.WriteLine(\"Ciphertext (base64): {0}\", Convert.ToBase64String(ciphertext));\n\n // Decrypt the ciphertext back to the original message.\n byte[] decrypted = cryptor.Decrypt(ciphertext);\n string roundtrip = Encoding.UTF8.GetString(decrypted);\n\n Console.WriteLine(\"Decrypted message: {0}\", roundtrip); // matches original\n\n // Use explicit AES options (CBC mode, PKCS7 padding).\n byte[] ciphertextExplicit = cryptor.Encrypt(plaintext, o =>\n {\n o.Mode = CipherMode.CBC;\n o.Padding = PaddingMode.PKCS7;\n });\n\n byte[] decryptedExplicit = cryptor.Decrypt(ciphertextExplicit, o =>\n {\n o.Mode = CipherMode.CBC;\n o.Padding = PaddingMode.PKCS7;\n });\n\n Console.WriteLine(\"Explicit options roundtrip: {0}\",\n Encoding.UTF8.GetString(decryptedExplicit) == roundtrip); // true\n }\n\n public static void GenerateKeysWithCustomSize()\n {\n // Generate a 128-bit key explicitly.\n byte[] key128 = AesCryptor.GenerateKey(o => o.Size = AesSize.Aes128);\n Console.WriteLine(\"128-bit key length: {0} bytes\", key128.Length); // 16\n\n // Generate a 192-bit key.\n byte[] key192 = AesCryptor.GenerateKey(o => o.Size = AesSize.Aes192);\n Console.WriteLine(\"192-bit key length: {0} bytes\", key192.Length); // 24\n\n // Default is 256-bit.\n byte[] key256 = AesCryptor.GenerateKey();\n Console.WriteLine(\"256-bit key length: {0} bytes\", key256.Length); // 32\n }\n\n public static void UseDefaultConstructor()\n {\n // Default constructor generates a random key and IV.\n var cryptor = new AesCryptor();\n\n byte[] data = Encoding.UTF8.GetBytes(\"Hello, world!\");\n byte[] encrypted = cryptor.Encrypt(data);\n byte[] decrypted = cryptor.Decrypt(encrypted);\n\n Console.WriteLine(\"Default constructor roundtrip: {0}\",\n Encoding.UTF8.GetString(decrypted)); // Hello, world!\n }\n }\n}" + } + }, + { + "id": "0cbd8cc55f8121bbbb33d33f", + "exampleId": "Cuemon.AspNetCore.Http.Throttling.MemoryThrottlingCache#1", + "uid": "Cuemon.AspNetCore.Http.Throttling.MemoryThrottlingCache", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http.Throttling;\n\n var cache = new MemoryThrottlingCache();\nvar request = new ThrottleRequest(new ThrottleQuota(10, TimeSpan.FromMinutes(1)));\n\ncache.TryAdd(\"client-1\", request);\nConsole.WriteLine(cache[\"client-1\"].Total);" + } + }, + { + "id": "0cce42e8751e5dbfa4a5daf3", + "exampleId": "Cuemon.Extensions.AspNetCore.Configuration.AssemblyCacheBusting#1", + "uid": "Cuemon.Extensions.AspNetCore.Configuration.AssemblyCacheBusting", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.AspNetCore.Configuration;\nusing Cuemon.Security.Cryptography;\nusing Microsoft.Extensions.Options;\n\nvar options = Options.Create(new AssemblyCacheBustingOptions\n{\n Algorithm = UnkeyedCryptoAlgorithm.Sha256,\n ReadByteForByteChecksum = true\n});\n\nvar cacheBusting = new AssemblyCacheBusting(options);\nstring version = cacheBusting.Version;\n\nConsole.WriteLine($\"Cache-busting version: {version}\");" + } + }, + { + "id": "0cfaac0e4511ead7ae17a260", + "exampleId": "Cuemon.Extensions.AspNetCore.Authentication.ServiceCollectionExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Authentication.ServiceCollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Authentication@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Authentication;\nusing Cuemon.Diagnostics;\nusing Cuemon.Extensions.AspNetCore.Authentication;\nusing Microsoft.Extensions.DependencyInjection;\n\nvar services = new ServiceCollection();\n\nservices.AddLogging();\nservices.AddInMemoryDigestAuthenticationNonceTracker();\nservices.AddAuthorizationResponseHandler(o =>\n{\n o.SensitivityDetails = FaultSensitivityDetails.All;\n});\n\nusing var provider = services.BuildServiceProvider();\n\nvar tracker = provider.GetRequiredService();\nvar added = tracker.TryAddEntry(\"docs-nonce\", 1);\nvar found = tracker.TryGetEntry(\"docs-nonce\", out var entry);\nvar responseHandler = provider.GetRequiredService();\n\nConsole.WriteLine($\"Nonce added: {added}; found: {found}; count: {entry?.Count}\");\nConsole.WriteLine($\"Configured fault sensitivity: {responseHandler.Options.SensitivityDetails}\");" + } + }, + { + "id": "0d625e800e03e40aa0398ff7", + "exampleId": "Cuemon.Extensions.Runtime.Serialization.HierarchySerializer#1", + "uid": "Cuemon.Extensions.Runtime.Serialization.HierarchySerializer", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.Runtime.Serialization;\nusing MyApp.Examples;\n\nHierarchySerializerExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class HierarchySerializerExample\n {\n private sealed class ReportRoot\n {\n public string Name { get; set; } = string.Empty;\n\n public ReportChild Child { get; set; } = new ReportChild();\n }\n\n private sealed class ReportChild\n {\n public int Count { get; set; }\n }\n\n public static void Demonstrate()\n {\n var serializer = new HierarchySerializer(new ReportRoot\n {\n Name = \"alpha\",\n Child = new ReportChild { Count = 7 }\n });\n\n Console.WriteLine(serializer.Nodes.InstanceType.Name);\n Console.WriteLine(serializer.Nodes.HasChildren);\n Console.WriteLine(serializer.ToString());\n }\n }\n}" + } + }, + { + "id": "0d7b317eceacd3bf2c673126", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.Throttling.ServiceCollectionExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Http.Throttling.ServiceCollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.AspNetCore.Http.Headers;\nusing Cuemon.AspNetCore.Http.Throttling;\nusing Cuemon.Extensions.AspNetCore.Http.Throttling;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\n\nvar services = new ServiceCollection();\nservices.AddMemoryThrottlingCache();\nservices.AddThrottlingCache();\nservices.AddThrottlingSentinelOptions(options =>\n{\n options.ContextResolver = context => context.Connection.RemoteIpAddress?.ToString() ?? \"unknown\";\n options.Quota = new ThrottleQuota(100, 1, TimeUnit.Minutes);\n options.TooManyRequestsMessage = \"API rate limit exceeded. Please wait before retrying.\";\n options.RateLimitHeaderName = \"X-RateLimit-Limit\";\n options.RateLimitRemainingHeaderName = \"X-RateLimit-Remaining\";\n options.RateLimitResetHeaderName = \"X-RateLimit-Reset\";\n options.RateLimitResetScope = RetryConditionScope.DeltaSeconds;\n options.UseRetryAfterHeader = true;\n});\n\nusing var provider = services.BuildServiceProvider();\nvar options = provider.GetRequiredService>().Value;\n\nConsole.WriteLine(options.RateLimitHeaderName);\nConsole.WriteLine(options.Quota != null);\nConsole.WriteLine(options.TooManyRequestsMessage);" + } + }, + { + "id": "0d874714a25636acf99ec6a2", + "exampleId": "Cuemon.Messaging.CorrelationToken#1", + "uid": "Cuemon.Messaging.CorrelationToken", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Messaging;\nusing MyApp.Examples;\n\nCorrelationTokenExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class CorrelationTokenExample\n {\n public static void Demonstrate()\n {\n var generated = new CorrelationToken();\n var provided = new CorrelationToken(\"order-2026-0001\");\n\n Console.WriteLine(generated.CorrelationId.Length == 32);\n Console.WriteLine(provided.ToString());\n Console.WriteLine(AttachToMessage(\"InventoryReserved\", provided));\n }\n\n private static string AttachToMessage(string messageType, ICorrelationToken token)\n {\n return $\"{messageType}:{token.CorrelationId}\";\n }\n }\n}" + } + }, + { + "id": "0eefa623c34dab3154b9615c", + "exampleId": "Cuemon.Extensions.Data.DataReaderExtensions#1", + "uid": "Cuemon.Extensions.Data.DataReaderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0", + "Cuemon.Extensions.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing Cuemon.Data;\nusing Cuemon.Extensions.Data;\n\nvar csv = \"Id,Name\\n1,Alice\\n2,Bob\";\nusing var reader = new DsvDataReader(new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(csv))));\n\nvar rows = reader.ToRows();\nConsole.WriteLine(rows.Count);\nConsole.WriteLine(rows.ColumnNames.Contains(\"Name\"));\n\nusing var columnReader = new DsvDataReader(new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(csv))));\ncolumnReader.Read();\nvar columns = columnReader.ToColumns();\n\nConsole.WriteLine(columns.Count);" + } + }, + { + "id": "0f19ce721851c5e0891be345", + "exampleId": "Cuemon.DayPart#1", + "uid": "Cuemon.DayPart", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon;\n\n var now = DateTime.Now.TimeOfDay;\n\n var current = DayPart.All.FirstOrDefault(dp =>\n now >= dp.Range.Start && now < dp.Range.End);\n\n Console.WriteLine($\"Current time: {now:hh\\\\:mm}\");\n Console.WriteLine($\"Day part: {current?.Name ?? \"Unknown\"}\");\n\n Console.WriteLine(\"All day parts:\");\n foreach (var part in DayPart.All)\n {\n Console.WriteLine($\" {part}\");\n\n}" + } + }, + { + "id": "0f8aabdb39b412c4d9167252", + "exampleId": "Cuemon.DateSpan#1", + "uid": "Cuemon.DateSpan", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\n// Create a DateSpan between two dates\nvar start = new DateTime(2020, 1, 1);\nvar end = new DateTime(2025, 6, 15);\nvar span = new DateSpan(start, end);\n\nConsole.WriteLine($\"Years: {span.Years}\"); // 5\nConsole.WriteLine($\"Months: {span.Months}\"); // 65\nConsole.WriteLine($\"Days: {span.Days}\"); // 1991\nConsole.WriteLine($\"Total days: {span.TotalDays:F1}\"); // 1991.0\n\n// Parse from ISO 8601 strings\nvar parsed = DateSpan.Parse(\"2020-01-01\", \"2025-06-15\");\nConsole.WriteLine(parsed.Years); // 5\n\n// Single DateSpan defaults the end to DateTime.Today\nvar fromPast = new DateSpan(new DateTime(2023, 1, 1));\nConsole.WriteLine($\"Days since 2023-01-01: {fromPast.TotalDays:F0}\");" + } + }, + { + "id": "1028749ad1e5b8e1d1858601", + "exampleId": "Cuemon.TypeDecoratorExtensions#1", + "uid": "Cuemon.TypeDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Concurrent;\nusing System.Collections.Generic;\nusing System.Collections.ObjectModel;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing System.Runtime.Serialization;\nusing Cuemon;\nusing Contoso.Reflection;\n\nTypeDecoratorExtensionsExample.Run();\n\nnamespace Contoso.Reflection\n{\n public sealed class TypeDecoratorExtensionsExample\n {\n public static void Run()\n {\n var orderType = Decorator.Enclose(typeof(AuditedOrder));\n var streamType = Decorator.Enclose(typeof(Stream));\n\n var propertyNames = orderType.GetAllProperties().Select(property => property.Name).OrderBy(name => name).ToArray();\n var fieldNames = orderType.GetAllFields().Select(field => field.Name).OrderBy(name => name).ToArray();\n var eventNames = orderType.GetAllEvents().Select(@event => @event.Name).OrderBy(name => name).ToArray();\n var methodNames = orderType\n .GetAllMethods()\n .Where(method => method.DeclaringType == typeof(AuditedOrder) && !method.IsSpecialName)\n .Select(method => method.Name)\n .Distinct()\n .OrderBy(name => name)\n .ToArray();\n var orderOnlyProperties = orderType.GetRuntimePropertiesExceptOf().Select(property => property.Name).OrderBy(name => name).ToArray();\n\n bool hasTypes = Decorator.Enclose(typeof(FileStream)).HasTypes(typeof(Stream));\n bool hasInterfaces = Decorator.Enclose(typeof(List<>)).HasInterfaces(typeof(IEnumerable<>));\n bool hasAttribute = orderType.HasAttribute(typeof(DataContractAttribute), typeof(DataMemberAttribute));\n bool hasComparable = Decorator.Enclose(typeof(string)).HasComparableImplementation();\n bool hasComparer = Decorator.Enclose(typeof(StringComparer)).HasComparerImplementation();\n bool hasDictionary = Decorator.Enclose(typeof(ReadOnlyDictionary)).HasDictionaryImplementation();\n bool hasEqualityComparer = Decorator.Enclose(typeof(StringComparer)).HasEqualityComparerImplementation();\n bool hasEnumerable = Decorator.Enclose(typeof(ConcurrentBag)).HasEnumerableImplementation();\n bool hasKeyValuePair = Decorator.Enclose(typeof(KeyValuePair)).HasKeyValuePairImplementation();\n bool isNullable = Decorator.Enclose(typeof(int?)).IsNullable();\n bool hasAnonymousCharacteristics = Decorator.Enclose(new { ReferenceNumber = \"PO-42\" }.GetType()).HasAnonymousCharacteristics();\n bool hasDefaultCtor = Decorator.Enclose(typeof(MemoryStream)).HasDefaultConstructor();\n bool isComplex = streamType.IsComplex();\n\n object defaultValue = Decorator.Enclose(typeof(Guid)).GetDefaultValue();\n string friendlyName = Decorator.Enclose(typeof(IList)).ToFriendlyName();\n MethodBase publishMethod = orderType.MatchMember(nameof(AuditedOrder.Publish));\n\n bool inheritedIncludesObject = streamType.GetInheritedTypes().Contains(typeof(object));\n bool derivedIncludesMemoryStream = streamType.GetDerivedTypes().Contains(typeof(MemoryStream));\n bool hierarchyIncludesFileStream = streamType.GetHierarchyTypes().Contains(typeof(FileStream));\n\n var loop = LinkedNode.CreateLoop();\n bool hasCircularReference = Decorator.Enclose(typeof(LinkedNode)).HasCircularReference(loop, maxDepth: 1);\n\n Console.WriteLine(string.Join(\", \", propertyNames));\n Console.WriteLine(string.Join(\", \", fieldNames));\n Console.WriteLine(string.Join(\", \", eventNames));\n Console.WriteLine(string.Join(\", \", methodNames));\n Console.WriteLine(string.Join(\", \", orderOnlyProperties));\n Console.WriteLine($\"{hasTypes}, {hasInterfaces}, {hasAttribute}\");\n Console.WriteLine($\"{hasComparable}, {hasComparer}, {hasDictionary}, {hasEqualityComparer}, {hasEnumerable}, {hasKeyValuePair}\");\n Console.WriteLine($\"{isNullable}, {hasAnonymousCharacteristics}, {hasDefaultCtor}, {isComplex}\");\n Console.WriteLine(defaultValue);\n Console.WriteLine(friendlyName);\n Console.WriteLine(publishMethod.Name);\n Console.WriteLine($\"{inheritedIncludesObject}, {derivedIncludesMemoryStream}, {hierarchyIncludesFileStream}, {hasCircularReference}\");\n }\n }\n [DataContract]\n public sealed class AuditedOrder : TrackedEntity\n {\n public string PublicNote;\n\n [DataMember]\n public string ReferenceNumber { get; set; } = string.Empty;\n\n public string Status { get; set; } = string.Empty;\n\n public event EventHandler Published;\n\n public void Publish()\n {\n Published?.Invoke(this, EventArgs.Empty);\n }\n }\n public abstract class TrackedEntity\n {\n public DateTime CreatedAt { get; set; }\n }\n public sealed class LinkedNode\n {\n public LinkedNode Next { get; set; }\n\n public static LinkedNode CreateLoop()\n {\n var node = new LinkedNode();\n node.Next = node;\n return node;\n }\n }\n}" + } + }, + { + "id": "106cceb80923ff6e464bbf26", + "exampleId": "Cuemon.Extensions.Text.Json.Utf8JsonWriterExtensions#1", + "uid": "Cuemon.Extensions.Text.Json.Utf8JsonWriterExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "using System;\nusing System.IO;\nusing System.Text;\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\nusing Cuemon.Extensions.Text.Json;\n\nnamespace MyApp.Examples;\n\npublic class Utf8JsonWriterExtensionsExample\n{\n public class Person\n {\n public string Name { get; set; }\n public int Age { get; set; }\n public string City { get; set; }\n\n public static void Main()\n {\n var person = new Person\n {\n Name = \"John Doe\",\n Age = 42,\n City = \"Copenhagen\"\n };\n\n var options = new JsonSerializerOptions\n {\n PropertyNamingPolicy = JsonNamingPolicy.CamelCase,\n WriteIndented = true,\n TypeInfoResolver = new DefaultJsonTypeInfoResolver()\n };\n\n using var stream = new MemoryStream();\n using var writer = new Utf8JsonWriter(stream, new JsonWriterOptions { Indented = true });\n\n // Write the object directly to the Utf8JsonWriter\n writer.WriteObject(person, options);\n writer.Flush();\n\n string json = Encoding.UTF8.GetString(stream.ToArray());\n Console.WriteLine(json);\n // Output:\n // {\n // \"name\": \"John Doe\",\n // \"age\": 42,\n // \"city\": \"Copenhagen\"\n // }\n\n}}\n}" + } + }, + { + "id": "108e4b7459222a698ecba7d7", + "exampleId": "Cuemon.Threading.ParallelFactory#1", + "uid": "Cuemon.Threading.ParallelFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Threading@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Threading;\n\nParallelFactory.For(0, 5, i =>\n{\n Console.WriteLine($\"Processing iteration {i}\");\n});\n\nvar items = new[] { \"apple\", \"banana\", \"cherry\" };\nParallelFactory.ForEach(items, item =>\n{\n Console.WriteLine($\"Processing {item}\");\n});" + } + }, + { + "id": "10f0fcc57e29c9d0b098b708", + "exampleId": "Cuemon.Data.SqlClient.SqlDataManager#1", + "uid": "Cuemon.Data.SqlClient.SqlDataManager", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data.SqlClient@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Data.SqlClient;\n\nvar manager = new SqlDataManager(o =>\n{\n o.ConnectionString = \"Server=.;Database=AdventureWorks;Trusted_Connection=True;TrustServerCertificate=True;\";\n});\n\nConsole.WriteLine(\"SqlDataManager configured for the AdventureWorks database.\");" + } + }, + { + "id": "115d97ca6a9d32b192f7457b", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandler#1", + "uid": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandler", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http;\nusing Cuemon.Diagnostics;\nusing Cuemon.AspNetCore.Diagnostics;\n\n var handler = HttpExceptionDescriptorResponseHandler.CreateDefaultFallbackHandler(FaultSensitivityDetails.None);\nvar exceptionDescriptor = new HttpExceptionDescriptor(new BadRequestException());\n\nusing var response = handler.ToHttpResponseMessage(exceptionDescriptor);\nConsole.WriteLine($\"{(int)response.StatusCode} {handler.ContentType.MediaType}\");" + } + }, + { + "id": "11f6aa21babd2163ff0c5418", + "exampleId": "Cuemon.Extensions.Text.EncodingOptionsExtensions#1", + "uid": "Cuemon.Extensions.Text.EncodingOptionsExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text@11.0.0" + ], + "source": "using System;\nusing System.IO;\nusing System.Text;\nusing Cuemon.Extensions.Text;\nusing Cuemon.Text;\n\nnamespace MyApp.Examples;\n\npublic class EncodingOptionsExtensionsExample\n{\n public static void Main()\n {\n // Create an EncodingOptions instance with a fallback encoding\n var options = new EncodingOptions { Encoding = Encoding.UTF8 };\n\n // Byte array with UTF-8 BOM\n byte[] utf8WithBom = { 0xEF, 0xBB, 0xBF, 0x48, 0x65, 0x6C, 0x6C, 0x6F };\n\n // Detect encoding from bytes\n Encoding detected = options.DetectUnicodeEncoding(utf8WithBom);\n Console.WriteLine($\"Detected encoding from bytes: {detected.EncodingName}\");\n\n // Stream with UTF-16 LE BOM\n using var stream = new MemoryStream();\n byte[] utf16Bom = { 0xFF, 0xFE, 0x48, 0x00, 0x65, 0x00, 0x6C, 0x00 };\n stream.Write(utf16Bom, 0, utf16Bom.Length);\n stream.Position = 0;\n\n Encoding streamEncoding = options.DetectUnicodeEncoding(stream);\n Console.WriteLine($\"Detected encoding from stream: {streamEncoding.EncodingName}\");\n\n // When no BOM is present, the fallback encoding is returned\n byte[] noBom = { 0x48, 0x65, 0x6C, 0x6C, 0x6F };\n Encoding fallback = options.DetectUnicodeEncoding(noBom);\n Console.WriteLine($\"Fallback encoding: {fallback.EncodingName}\");\n\n}\n}" + } + }, + { + "id": "120cfd2c5cc87d738cc55954", + "exampleId": "Cuemon.Security.Cryptography.SecureHashAlgorithm512256#1", + "uid": "Cuemon.Security.Cryptography.SecureHashAlgorithm512256", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\n\nvar algorithm = new SecureHashAlgorithm512256(null);\nvar result = algorithm.ComputeHash(Encoding.UTF8.GetBytes(\"Payload for SHA-512/256\"));\n\nConsole.WriteLine(SecureHashAlgorithm512256.BitSize);\nConsole.WriteLine(result.GetBytes().Length);" + } + }, + { + "id": "12ca8aa62e2f7567385910d7", + "exampleId": "Cuemon.AspNetCore.Builder.MiddlewareBuilderFactory#1", + "uid": "Cuemon.AspNetCore.Builder.MiddlewareBuilderFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Diagnostics;\nusing System.Threading.Tasks;\nusing Cuemon.AspNetCore.Builder;\nusing Cuemon.AspNetCore;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing MyApp.Examples;\n\nMiddlewareBuilderFactoryExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public class TimingMiddleware : Middleware\n {\n public TimingMiddleware(RequestDelegate next) : base(next) { }\n\n public override async Task InvokeAsync(HttpContext context)\n {\n var sw = Stopwatch.StartNew();\n await Next(context);\n sw.Stop();\n Console.WriteLine($\"{context.Request.Path} took {sw.ElapsedMilliseconds} ms\");\n }\n }\n public static class MiddlewareBuilderFactoryExample\n {\n public static void Demonstrate()\n {\n var builder = WebApplication.CreateBuilder().Build();\n\n MiddlewareBuilderFactory.UseMiddleware(builder);\n Console.WriteLine(\"TimingMiddleware registered.\");\n }\n }\n}" + } + }, + { + "id": "13c72b068bcf7ef5096f795e", + "exampleId": "Cuemon.Diagnostics.ProfilerOptions#1", + "uid": "Cuemon.Diagnostics.ProfilerOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Diagnostics@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Reflection;\nusing Cuemon.Diagnostics;\nusing Cuemon.Reflection;\nusing MyApp.Examples;\n\nProfilerOptionsExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class ProfilerOptionsExample\n {\n private sealed class SampleProfilerOptions : ProfilerOptions\n {\n }\n\n public static void Demonstrate()\n {\n ProfilerOptions options = new SampleProfilerOptions\n {\n MethodDescriptor = () => MethodDescriptor.Create(MethodBase.GetCurrentMethod()!).AppendRuntimeArguments(500),\n RuntimeParameters = new object[] { 500 }\n };\n\n Console.WriteLine(options.MethodDescriptor().MethodName);\n Console.WriteLine(options.MethodDescriptor().RuntimeArguments.Count);\n Console.WriteLine(options.RuntimeParameters.Length);\n }\n }\n}" + } + }, + { + "id": "13da71db47698122e73c6a86", + "exampleId": "Cuemon.Extensions.TypeExtensions#1", + "uid": "Cuemon.Extensions.TypeExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Concurrent;\nusing System.Collections.Generic;\nusing System.IO;\nusing Cuemon.Extensions;\n\nType listType = typeof(IList);\nType dictionaryType = typeof(ConcurrentDictionary);\nType comparerType = typeof(StringComparer);\nType nullableInt = typeof(int?);\n\nConsole.WriteLine(listType.ToFriendlyName());\nConsole.WriteLine(listType.ToFriendlyName(options => options.FullName = true));\nConsole.WriteLine(typeof(string).ToTypeCode());\nConsole.WriteLine(listType.HasEnumerableImplementation());\nConsole.WriteLine(typeof(string).HasComparableImplementation());\nConsole.WriteLine(dictionaryType.HasDictionaryImplementation());\nConsole.WriteLine(comparerType.HasEqualityComparerImplementation());\nConsole.WriteLine(comparerType.HasComparerImplementation());\nConsole.WriteLine(typeof(KeyValuePair).HasKeyValuePairImplementation());\nConsole.WriteLine(nullableInt.IsNullable());\nConsole.WriteLine(typeof(Stream).IsComplex());\nConsole.WriteLine(typeof(int).IsSimple());\nConsole.WriteLine(typeof(int).GetDefaultValue());\nConsole.WriteLine(typeof(FileStream).HasTypes(typeof(Stream)));\nConsole.WriteLine(typeof(List<>).HasInterfaces(typeof(IEnumerable<>)));\nConsole.WriteLine(typeof(string).HasAttributes(typeof(SerializableAttribute)));\nConsole.WriteLine(new { Name = \"sample\", Value = 42 }.GetType().HasAnonymousCharacteristics());" + } + }, + { + "id": "140d6619210398202cf76197", + "exampleId": "Cuemon.Extensions.Net.Http.HttpMethodExtensions#1", + "uid": "Cuemon.Extensions.Net.Http.HttpMethodExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0", + "Cuemon.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing Cuemon.Extensions.Net.Http;\nusing Cuemon.Net.Http;\n\n // Convert System.Net.Http.HttpMethod to the Cuemon HttpMethods enum\n HttpMethod getMethod = HttpMethod.Get;\n HttpMethods method = getMethod.ToHttpMethod();\n Console.WriteLine($\"{getMethod} -> {method}\"); // GET -> Get\n\n HttpMethod postMethod = HttpMethod.Post;\n HttpMethods post = postMethod.ToHttpMethod();\n Console.WriteLine($\"{postMethod} -> {post}\"); // POST -> Post\n\n // Custom HTTP methods are also supported\n var patchMethod = new HttpMethod(\"PATCH\");\n HttpMethods patch = patchMethod.ToHttpMethod();\n Console.WriteLine($\"{patchMethod} -> {patch}\"); // PATCH -> Patch\n\n // Check flags with bitwise operations\n if (method.HasFlag(HttpMethods.Get))\n {\n Console.WriteLine(\"This is a GET request.\");\n\n}" + } + }, + { + "id": "1514baffbe2c1bb164480f34", + "exampleId": "Cuemon.ByteArrayDecoratorExtensions#1", + "uid": "Cuemon.ByteArrayDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing Cuemon;\nusing Cuemon.Text;\n\n// Create a byte array from a string\nbyte[] data = Encoding.UTF8.GetBytes(\"Hello, World!\");\n\n// Convert bytes to a string with default UTF-8 encoding\nstring text = Decorator.Enclose(data).ToEncodedString();\nConsole.WriteLine(text); // \"Hello, World!\"\n\n// Convert bytes to a string with specific encoding\nbyte[] isoData = Encoding.GetEncoding(\"iso-8859-1\").GetBytes(\"Café\");\nstring isoText = Decorator.Enclose(isoData).ToEncodedString(o =>\n{\n o.Encoding = Encoding.GetEncoding(\"iso-8859-1\");\n});\nConsole.WriteLine(isoText); // \"Café\"\n\n// Convert bytes to a seekable Stream\nusing Stream stream = Decorator.Enclose(data).ToStream();\nConsole.WriteLine(stream.Length); // 13\nConsole.WriteLine(stream.CanSeek); // True\n\n// Read the stream back\nusing var reader = new StreamReader(stream);\nstring fromStream = reader.ReadToEnd();\nConsole.WriteLine(fromStream); // \"Hello, World!\"" + } + }, + { + "id": "1606e801e97aec9f8c33cbf0", + "exampleId": "Cuemon.Extensions.AspNetCore.Xml.ServiceCollectionExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Xml.ServiceCollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Xml@11.0.0", + "Cuemon.Xml@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.AspNetCore.Xml;\nusing Cuemon.Xml.Serialization.Formatters;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\n\nvar services = new ServiceCollection();\nservices.Configure(options =>\n{\n options.SynchronizeWithXmlConvert = true;\n});\nservices.AddMinimalXmlOptions(options =>\n{\n options.SynchronizeWithXmlConvert = true;\n});\n\nusing var provider = services.BuildServiceProvider();\nvar options = provider.GetRequiredService>().Value;\nConsole.WriteLine(options.SynchronizeWithXmlConvert);" + } + }, + { + "id": "161acb78ac404a151737d057", + "exampleId": "Cuemon.Security.FowlerNollVoOptions#1", + "uid": "Cuemon.Security.FowlerNollVoOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "using System.Text;\nusing System;\nusing Cuemon.Security;\n\nusing Cuemon;\nnamespace MyApp.Examples;\n\npublic class FowlerNollVoOptionsExample\n{\n public static void Main()\n {\n // Create a FowlerNollVoOptions instance to configure the hash algorithm\n var fnvOptions = new FowlerNollVoOptions();\n fnvOptions.Algorithm = FowlerNollVoAlgorithm.Fnv1a;\n fnvOptions.ByteOrder = Endianness.LittleEndian;\n\n // Apply configuration through the setup delegate\n var fnv32 = new FowlerNollVo32(o =>\n {\n o.Algorithm = fnvOptions.Algorithm;\n o.ByteOrder = fnvOptions.ByteOrder;\n });\n\n byte[] data = Encoding.UTF8.GetBytes(\"Hello, World!\");\n HashResult hash = fnv32.ComputeHash(data);\n\n Console.WriteLine(\"FNV-1a 32-bit (little-endian): {0}\", hash.ToHexadecimalString());\n\n // Output:\n // FNV-1a 32-bit (little-endian): 34f7ec5a\n\n}\n}" + } + }, + { + "id": "191234b3da08096eb7c7766a", + "exampleId": "Cuemon.Extensions.AspNetCore.Authentication.AuthorizationResponseHandler#1", + "uid": "Cuemon.Extensions.AspNetCore.Authentication.AuthorizationResponseHandler", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Authentication@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.AspNetCore.Authentication;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Logging;\nusing Microsoft.Extensions.Options;\n\nvar services = new ServiceCollection();\n\nservices.Configure(options =>\n{\n options.SensitivityDetails = Cuemon.Diagnostics.FaultSensitivityDetails.All;\n});\n\nservices.AddLogging();\n\nusing var provider = services.BuildServiceProvider();\nvar logger = provider.GetRequiredService>();\nvar options = provider.GetRequiredService>();\nvar handler = new AuthorizationResponseHandler(logger, options);\n\nConsole.WriteLine($\"Configured fault sensitivity: {handler.Options.SensitivityDetails}\");" + } + }, + { + "id": "19250224edac84ec8bb55732", + "exampleId": "Cuemon.ObjectDecoratorExtensions#1", + "uid": "Cuemon.ObjectDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "using System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing Cuemon;\n\nnamespace DocExamples\n{\n public static class ObjectDecoratorExamples\n {\n public static void Main()\n {\n // Convert a string to an integer\n object input = \"42\";\n int result = Decorator.Enclose(input).ChangeType();\n Console.WriteLine($\"Converted string to int: {result} (type: {result.GetType().Name})\");\n\n // Convert a string to DateTime (UTC)\n object dateInput = \"2024-01-15T10:30:00Z\";\n DateTime dateResult = Decorator.Enclose(dateInput).ChangeType();\n Console.WriteLine($\"Converted to DateTime: {dateResult} (Kind: {dateResult.Kind})\");\n\n // Convert with a fallback value\n object invalidInput = \"not-a-number\";\n int fallbackResult = Decorator.Enclose(invalidInput).ChangeTypeOrDefault(42);\n Console.WriteLine($\"Conversion with fallback: {fallbackResult}\");\n\n // Convert a string to an enum\n object enumInput = \"Ascending\";\n var enumResult = Decorator.Enclose(enumInput).ChangeType();\n Console.WriteLine($\"Converted to SortOrder: {enumResult}\");\n\n // Traverse a hierarchical tree structure\n var grandchild = new TreeNode { Name = \"Grandchild\" };\n var child1 = new TreeNode { Name = \"Child1\", Children = { grandchild } };\n var child2 = new TreeNode { Name = \"Child2\" };\n var root = new TreeNode { Name = \"Root\", Children = { child1, child2 } };\n\n var allNodes = Decorator.Enclose(root).TraverseWhileNotEmpty(node => node.Children);\n foreach (var node in allNodes)\n {\n Console.WriteLine($\"Visited: {node.Name}\");\n }\n\n var property = typeof(TreeNode).GetProperty(nameof(TreeNode.Name));\n var resolvedName = Decorator.Enclose((object)root).DefaultPropertyValueResolver(property);\n Console.WriteLine($\"Resolved property value: {resolvedName}\");\n }\n\n private class TreeNode\n {\n public string Name { get; set; }\n public List Children { get; } = new List();\n }\n }\n}" + } + }, + { + "id": "1927379364aef60e8d1ccb00", + "exampleId": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeader#1", + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeader", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Authentication.Digest;\n\nvar header = new DigestAuthorizationHeader(\n realm: \"docs-example\",\n nonce: \"abc123\",\n opaque: \"opaque456\",\n algorithm: \"SHA-256\",\n userName: \"Agent\",\n uri: \"/resource\",\n nc: \"00000001\",\n cNonce: \"client-nonce\",\n qop: \"auth\",\n response: \"deadbeef\");\n\nvar parsed = DigestAuthorizationHeader.Create(header.ToString());\n\nConsole.WriteLine(parsed.UserName);\nConsole.WriteLine(parsed.Response);" + } + }, + { + "id": "1951eb28808739078f8a7b09", + "exampleId": "Cuemon.GuidFormats#1", + "uid": "Cuemon.GuidFormats", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon; // for GuidFormats\nusing Cuemon.Text; // for ParserFactory, GuidStringOptions\n\nvar parser = ParserFactory.FromGuid();\n\n// Accept only digit (D) and brace (B) formats\nGuid g1 = parser.Parse(\"12345678-1234-1234-1234-123456789abc\",\n o => o.Formats = GuidFormats.D | GuidFormats.B);\nConsole.WriteLine(g1); // 12345678-1234-1234-1234-123456789abc\n\nGuid g2 = parser.Parse(\"{12345678-1234-1234-1234-123456789abc}\",\n o => o.Formats = GuidFormats.D | GuidFormats.B);\nConsole.WriteLine(g2);\n\n// TryParse with number format (N) - using Hyphens, so it would fail\nbool ok = parser.TryParse(\"12345678123412341234123456789abc\", out Guid g3,\n o => o.Formats = GuidFormats.N);\nConsole.WriteLine(ok); // True - only N is selected and input has no hyphens\n\n// Fail: brace format but only D selected\nok = parser.TryParse(\"{12345678-1234-1234-1234-123456789abc}\", out Guid g4,\n o => o.Formats = GuidFormats.D);\nConsole.WriteLine(ok); // False" + } + }, + { + "id": "196f08bdc120b1c7dd82ec5f", + "exampleId": "Cuemon.Extensions.IO.StringExtensions#1", + "uid": "Cuemon.Extensions.IO.StringExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.IO@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing System.Threading.Tasks;\nusing Cuemon.Extensions.IO;\n\nconst string json = \"{\\\"key\\\":\\\"value\\\"}\";\n\nusing Stream stream = json.ToStream(options =>\n{\n options.Encoding = Encoding.UTF8;\n});\n\nusing Stream asyncStream = await json.ToStreamAsync();\nusing TextReader reader = json.ToTextReader();\n\nConsole.WriteLine(stream.Length > 0);\nConsole.WriteLine((await asyncStream.ToEncodedStringAsync()) == json);\nConsole.WriteLine(reader.ReadToEnd());" + } + }, + { + "id": "19924051bce122ddccb0bb7d", + "exampleId": "Cuemon.SuccessfulValue`1#1", + "uid": "Cuemon.SuccessfulValue`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Contoso.Configuration;\n\nSuccessfulValueOfTResultExample.Run();\n\nnamespace Contoso.Configuration\n{\n public sealed class SuccessfulValueOfTResultExample\n {\n public static void Run()\n {\n ConditionalValue outcome = ParsePort(\"443\");\n\n Console.WriteLine($\"Succeeded: {outcome.Succeeded}\");\n Console.WriteLine($\"Port: {outcome.Result}\");\n }\n\n private static ConditionalValue ParsePort(string text)\n {\n if (int.TryParse(text, out int port))\n {\n return new SuccessfulValue(port);\n }\n\n return new UnsuccessfulValue(new FormatException(\"The port number is invalid.\"));\n }\n }\n}" + } + }, + { + "id": "1a767e8d30b243e513213f74", + "exampleId": "Cuemon.Collections.Generic.ReferenceComparer`1#1", + "uid": "Cuemon.Collections.Generic.ReferenceComparer`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon.Collections.Generic;\n\n// ReferenceComparer compares objects by their inheritance depth.\n// Objects with a deeper inheritance chain are considered \"greater.\"\n\n// Compare two strings (string derives from object → depth 2)\nstring hello = \"hello\";\nstring world = \"world\";\nIComparer comparer = ReferenceComparer.Default;\n\nint result1 = comparer.Compare(hello, world);\nConsole.WriteLine($\"string vs string: {result1}\"); // 0 (same depth)\n\n// Compare a string with an Exception (deeper hierarchy)\nvar exception = new InvalidOperationException();\nint result2 = comparer.Compare(hello, exception);\nConsole.WriteLine($\"string vs Exception: {result2}\"); // -1 (string is shallower)\n\n// Compare an ArgumentNullException (depth 4) with Exception (depth 3)\nvar argEx = new ArgumentNullException();\nint result3 = comparer.Compare(argEx, exception);\nConsole.WriteLine($\"ArgumentNullException vs Exception: {result3}\"); // 1 (deeper)\n\n// Compare with null values\nint result4 = comparer.Compare(hello, null);\nConsole.WriteLine($\"string vs null: {result4}\"); // 1 (non-null is greater)\n\nint result5 = comparer.Compare(null, hello);\nConsole.WriteLine($\"null vs string: {result5}\"); // -1 (null is lesser)\n\nint result6 = comparer.Compare(null, null);\nConsole.WriteLine($\"null vs null: {result6}\"); // 0 (both null)" + } + }, + { + "id": "1abbfde24b1a74290bb9aca9", + "exampleId": "Cuemon.IO.StreamReaderOptions#1", + "uid": "Cuemon.IO.StreamReaderOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing Cuemon.IO;\nusing Cuemon.Text;\n\n// Default options: UTF-8 without BOM, 81920 buffer\nvar defaultOptions = new StreamReaderOptions();\nConsole.WriteLine($\"Default encoding: {defaultOptions.Encoding.EncodingName}\"); // UTF-8\nConsole.WriteLine($\"Default preamble: {defaultOptions.Preamble}\"); // Remove\nConsole.WriteLine($\"Default buffer size: {defaultOptions.BufferSize}\"); // 81920\n\n// Read a UTF-32 file with a smaller buffer\nvar utf32Options = new StreamReaderOptions\n{\n Encoding = Encoding.UTF32,\n Preamble = PreambleSequence.Keep,\n BufferSize = 4096\n};\n\n// Create a StreamReader using these options\nbyte[] data = Encoding.UTF32.GetBytes(\"Hello, World!\");\nusing var stream = new MemoryStream(data);\nusing var reader = new StreamReader(stream, utf32Options.Encoding, false, utf32Options.BufferSize);\n\nstring content = reader.ReadToEnd();\nConsole.WriteLine($\"Read content: {content}\");\n\n// Options for reading with explicit BOM handling\nvar bomOptions = new StreamReaderOptions\n{\n Encoding = Encoding.UTF8,\n Preamble = PreambleSequence.Keep\n};\nConsole.WriteLine($\"BOM preamble: {bomOptions.Preamble}\"); // Keep" + } + }, + { + "id": "1acf06e643f58130b6e7337b", + "exampleId": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationHandler#1", + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationHandler", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Claims;\nusing Cuemon.AspNetCore.Authentication;\nusing Cuemon.AspNetCore.Authentication.Digest;\nusing Microsoft.AspNetCore.Authentication;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\nusing MyApp.Examples;\n\nDigestAuthenticationHandlerExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class DigestAuthenticationHandlerExample\n {\n public static void Demonstrate()\n {\n var services = new ServiceCollection();\n\n services.AddLogging();\n services.AddSingleton();\n services.AddAuthentication(DigestAuthorizationHeader.Scheme)\n .AddScheme(DigestAuthorizationHeader.Scheme, options =>\n {\n options.Realm = \"docs-example\";\n options.RequireSecureConnection = false;\n options.Authenticator = (string username, out string password) =>\n {\n password = username == \"Agent\" ? \"Test\" : null;\n return password == null\n ? null\n : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, DigestAuthorizationHeader.Scheme));\n };\n });\n\n using var provider = services.BuildServiceProvider();\n var options = provider.GetRequiredService>().Get(DigestAuthorizationHeader.Scheme);\n\n Console.WriteLine($\"Authentication realm: {options.Realm}\");\n }\n }\n}" + } + }, + { + "id": "1baeacb0165e21bb6bfa3442", + "exampleId": "Cuemon.AspNetCore.Mvc.TimeBasedObjectResultOptions`1#1", + "uid": "Cuemon.AspNetCore.Mvc.TimeBasedObjectResultOptions`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Mvc;\n\nvar options = new TimeBasedObjectResultOptions\n{\n TimestampProvider = value => value,\n ChangedTimestampProvider = value => value.AddHours(1)\n};\n\n// Validate that the required properties are configured\noptions.ValidateOptions();\n\nvar created = new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc);\nConsole.WriteLine($\"Created: {options.TimestampProvider(created)}\");\nConsole.WriteLine($\"Modified: {options.ChangedTimestampProvider(created)}\");" + } + }, + { + "id": "1d56ab970eff694bc48ec6bf", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Throttling.ThrottlingSentinelFilter#1", + "uid": "Cuemon.AspNetCore.Mvc.Filters.Throttling.ThrottlingSentinelFilter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.AspNetCore.Http.Throttling;\nusing Cuemon.AspNetCore.Mvc.Filters.Throttling;\nusing Microsoft.Extensions.Options;\n\nvar options = Options.Create(new ThrottlingSentinelOptions\n{\n ContextResolver = _ => \"developer-workstation\",\n Quota = new ThrottleQuota(10, 5, TimeUnit.Seconds)\n});\n\nvar filter = new ThrottlingSentinelFilter(options, new MemoryThrottlingCache());\n\nConsole.WriteLine(filter.Options.Quota.RateLimit);\nConsole.WriteLine(filter.Options.UseRetryAfterHeader);" + } + }, + { + "id": "1d623769997244f50b8ff9fd", + "exampleId": "Cuemon.ObjectPortrayalOptions#1", + "uid": "Cuemon.ObjectPortrayalOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Contoso.Diagnostics;\n\nObjectPortrayalOptionsExample.Run();\n\nnamespace Contoso.Diagnostics\n{\n public sealed class ObjectPortrayalOptionsExample\n {\n public static void Run()\n {\n var options = new ObjectPortrayalOptions\n {\n BypassOverrideCheck = true,\n Delimiter = \"; \",\n NullValue = \"(none)\"\n };\n\n var profile = new SampleProfile { Name = \"Alice\", Nickname = null };\n\n string portrayal = Generate.ObjectPortrayal(profile, setup =>\n {\n setup.BypassOverrideCheck = options.BypassOverrideCheck;\n setup.Delimiter = options.Delimiter;\n setup.NullValue = options.NullValue;\n });\n\n Console.WriteLine(portrayal);\n }\n\n private sealed class SampleProfile\n {\n public string Name { get; set; }\n\n public string Nickname { get; set; }\n }\n }\n}" + } + }, + { + "id": "1dd46290fd954e19986cbfdb", + "exampleId": "Cuemon.Security.Cryptography.KeyedHashFactory#1", + "uid": "Cuemon.Security.Cryptography.KeyedHashFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\n\nvar secret = Encoding.UTF8.GetBytes(\"my-secret-key\");\nvar hmac = KeyedHashFactory.CreateHmacCryptoSha256(secret);\nvar input = \"Message to authenticate\";\nvar hash = hmac.ComputeHash(Encoding.UTF8.GetBytes(input));\nConsole.WriteLine($\"HMAC-SHA256: {BitConverter.ToString(hash.To(bytes => bytes)).Replace(\"-\", \"\")}\");" + } + }, + { + "id": "1ed4b7c31349df56241cefcb", + "exampleId": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationMiddleware#1", + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationMiddleware", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Claims;\nusing System.Threading.Tasks;\nusing Cuemon.AspNetCore.Authentication.Digest;\nusing MyApp.Examples;\n\nDigestAuthenticationMiddlewareExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class DigestAuthenticationMiddlewareExample\n {\n public static void Demonstrate()\n {\n var middleware = new DigestAuthenticationMiddleware(_ => Task.CompletedTask, options =>\n {\n options.Realm = \"docs-example\";\n options.RequireSecureConnection = false;\n options.Authenticator = (string username, out string password) =>\n {\n password = username == \"Agent\" ? \"Test\" : null;\n return password == null ? null : new ClaimsPrincipal(new ClaimsIdentity());\n };\n });\n\n Console.WriteLine(middleware.Options.Realm);\n }\n }\n}" + } + }, + { + "id": "20370480b604ca996bdc483d", + "exampleId": "Cuemon.Validator#1", + "uid": "Cuemon.Validator", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon;\nusing Contoso.Routing;\n\nValidatorExample.Run();\n\nnamespace Contoso.Routing\n{\n public sealed class ValidatorExample\n {\n public static void Run()\n {\n string endpoint = NormalizeEndpoint(\"https://api.cuemon.net\", new[] { \"v1\", \"health\" });\n Console.WriteLine(endpoint);\n }\n\n private static string NormalizeEndpoint(string endpoint, IEnumerable segments)\n {\n Validator.ThrowIfNullOrWhitespace(endpoint);\n Validator.ThrowIfSequenceNullOrEmpty(segments);\n Validator.ThrowIfNotUri(endpoint, UriKind.Absolute);\n\n return string.Join(\"/\", new[] { endpoint.TrimEnd('/') }.Concat(segments));\n }\n }\n}" + } + }, + { + "id": "2076d7705c147ef0b68ce943", + "exampleId": "Cuemon.Diagnostics.FaultResolver#1", + "uid": "Cuemon.Diagnostics.FaultResolver", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Diagnostics@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Diagnostics;\nusing MyApp.Examples;\n\nnew FaultResolverExample().Demonstrate();\n\nnamespace MyApp.Examples\n{\n public class FaultResolverExample\n {\n public void Demonstrate()\n {\n // Register a resolver that handles ArgumentNullException\n var resolver = new FaultResolver(\n validator: ex => ex is ArgumentNullException,\n descriptor: ex =>\n {\n var argEx = (ArgumentNullException)ex;\n return new ExceptionDescriptor(\n argEx,\n \"ERR_NULL_ARG\",\n $\"The parameter '{argEx.ParamName}' cannot be null.\");\n });\n\n // Try to resolve an ArgumentNullException\n var testEx = new ArgumentNullException(\"value\");\n bool resolved = resolver.TryResolveFault(testEx, out ExceptionDescriptor result);\n\n Console.WriteLine(resolved); // True\n Console.WriteLine(result.Code); // ERR_NULL_ARG\n Console.WriteLine(result.Message); // The parameter 'value' cannot be null.\n Console.WriteLine(result.Failure.Message); // value\n\n // Try to resolve an unrelated exception\n var otherEx = new InvalidOperationException(\"not handled\");\n resolved = resolver.TryResolveFault(otherEx, out result);\n Console.WriteLine(resolved); // False\n Console.WriteLine(result is null); // True\n\n }\n }\n}" + } + }, + { + "id": "20db73386a90b6c65197f9ac", + "exampleId": "Cuemon.Extensions.AspNetCore.Diagnostics.ServiceCollectionExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Diagnostics.ServiceCollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.Diagnostics;\nusing Cuemon.Extensions.AspNetCore.Diagnostics;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\n\nvar services = new ServiceCollection();\nservices.AddServerTiming(options =>\n{\n options.TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(10);\n});\n\nservices.AddFaultDescriptorOptions(options =>\n{\n options.SensitivityDetails = FaultSensitivityDetails.All;\n options.RootHelpLink = new Uri(\"https://example.com/help\");\n});\n\nservices.AddExceptionDescriptorOptions(options =>\n{\n options.SensitivityDetails = FaultSensitivityDetails.None;\n});\n\nservices.AddServerTimingOptions(options =>\n{\n options.TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(50);\n});\n\nservices.PostConfigureAllExceptionDescriptorOptions(options =>\n{\n options.SensitivityDetails = FaultSensitivityDetails.FailureWithStackTrace;\n});\n\nusing var provider = services.BuildServiceProvider();\nvar serverTiming = provider.GetRequiredService>().Value;\nvar fault = provider.GetRequiredService>().Value;\nvar exception = provider.GetRequiredService>().Value;\n\nConsole.WriteLine(serverTiming.TimeMeasureCompletedThreshold.TotalMilliseconds);\nConsole.WriteLine(fault.SensitivityDetails);\nConsole.WriteLine(exception.SensitivityDetails);" + } + }, + { + "id": "20f32bdaa2bfef37a9946193", + "exampleId": "Cuemon.Security.CyclicRedundancyCheck32#1", + "uid": "Cuemon.Security.CyclicRedundancyCheck32", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon;\nusing Cuemon.Security;\n\nvar checksum = new CyclicRedundancyCheck32(setup: options =>\n{\n options.ByteOrder = Endianness.BigEndian;\n options.ReflectInput = true;\n options.ReflectOutput = true;\n});\n\nHashResult result = checksum.ComputeHash(Encoding.ASCII.GetBytes(\"123456789\"));\n\nConsole.WriteLine(result.ToHexadecimalString().ToLowerInvariant());\nConsole.WriteLine(checksum.InitialValue);\nConsole.WriteLine(checksum.FinalXor);\n\nvar alternate = new CyclicRedundancyCheck32(polynomial: 0xEDB88320, initialValue: 0xFFFFFFFF, finalXor: 0xFFFFFFFF);\nConsole.WriteLine(alternate.ComputeHash(\"Cuemon\").ToBase64String());" + } + }, + { + "id": "216072929a2ccbe653e42ecc", + "exampleId": "Cuemon.Text.EnumStringOptions#1", + "uid": "Cuemon.Text.EnumStringOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Text;\n\n// Direct instantiation of EnumStringOptions\nvar options = new EnumStringOptions\n{\n IgnoreCase = true\n};\n\nvar parser = ParserFactory.FromEnum();\n\nvar result = (UriKind)parser.Parse(\"Relative\", typeof(UriKind), o =>\n{\n o.IgnoreCase = true;\n});\n\nConsole.WriteLine(result); // outputs: Relative" + } + }, + { + "id": "2188df40437c953f3b2421e4", + "exampleId": "Cuemon.Diagnostics.FaultSensitivityDetails#1", + "uid": "Cuemon.Diagnostics.FaultSensitivityDetails", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Diagnostics; // for FaultSensitivityDetails, ExceptionDescriptor, FaultResolver\n\n// Create an exception descriptor with failure details\nvar descriptor = new ExceptionDescriptor(\n new InvalidOperationException(\"Something went wrong.\"),\n \"ERR_OPERATION_FAILED\",\n \"The requested operation could not be completed.\");\n\n// FaultSensitivityDetails.None (default) - excludes all sensitive details\nFaultSensitivityDetails details = FaultSensitivityDetails.None;\nConsole.WriteLine(details); // None\n\n// Include the Failure (exception) property\ndetails = FaultSensitivityDetails.Failure;\nConsole.WriteLine(details); // Failure\n\n// Include both Failure and StackTrace\ndetails = FaultSensitivityDetails.FailureWithStackTrace;\nConsole.WriteLine(details); // Failure, StackTrace\n\n// Include everything (development environments only)\ndetails = FaultSensitivityDetails.All;\nConsole.WriteLine(details); // Failure, StackTrace, Data, Evidence\n\n// Combine flags manually\ndetails = FaultSensitivityDetails.Failure | FaultSensitivityDetails.Data;\nConsole.WriteLine(details); // FailureWithData\n\n// Check if a specific flag is set\nbool hasStackTrace = details.HasFlag(FaultSensitivityDetails.StackTrace);\nConsole.WriteLine(hasStackTrace); // False\n\nbool hasFailure = details.HasFlag(FaultSensitivityDetails.Failure);\nConsole.WriteLine(hasFailure); // True" + } + }, + { + "id": "21ef239bffe3560880cf78ba", + "exampleId": "Cuemon.Extensions.Text.Json.DynamicJsonConverter#1", + "uid": "Cuemon.Extensions.Text.Json.DynamicJsonConverter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\nusing Cuemon.Extensions.Text.Json;\n\nvar options = new JsonSerializerOptions\n{\n TypeInfoResolver = new DefaultJsonTypeInfoResolver()\n};\noptions.Converters.Add(DynamicJsonConverter.Create(\n writer: (utf8Writer, value, _) => utf8Writer.WriteStringValue(value.ToString()),\n reader: (ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions jsonOptions) => Version.Parse(reader.GetString())\n));\n\nvar version = new Version(\"5.0.0\");\nstring json = JsonSerializer.Serialize(version, options);\nConsole.WriteLine(json);\n\nvar deserialized = JsonSerializer.Deserialize(\"\\\"6.0.0\\\"\", options);\nConsole.WriteLine(deserialized);" + } + }, + { + "id": "22a83c612018cfd3ed666dc7", + "exampleId": "Cuemon.Text.ProtocolRelativeUriStringOptions#1", + "uid": "Cuemon.Text.ProtocolRelativeUriStringOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Text;\n\n// Configure how a protocol-relative URI (e.g., \"//example.com/resource\")\n// is resolved to an absolute URI by specifying the default protocol.\nvar options = new ProtocolRelativeUriStringOptions\n{\n Protocol = UriScheme.Https,\n RelativeReference = Alphanumeric.NetworkPathReference\n};\n\nConsole.WriteLine($\"Protocol: {options.Protocol}\");\nConsole.WriteLine($\"Relative reference: {options.RelativeReference}\");\n\n// Switch to HTTP for local development\noptions.Protocol = UriScheme.Http;\nConsole.WriteLine($\"Updated protocol: {options.Protocol}\");" + } + }, + { + "id": "22faa847b32c90ee22e4a46d", + "exampleId": "Cuemon.Extensions.Runtime.Caching.CacheEnumerableExtensions#1", + "uid": "Cuemon.Extensions.Runtime.Caching.CacheEnumerableExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Runtime.Caching@11.0.0", + "Cuemon.Runtime.Caching@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.Runtime.Caching;\nusing Cuemon.Runtime.Caching;\n\nICacheEnumerable cache = new SlimMemoryCache();\n\nvar timestamp = cache.GetOrAdd(\"current-time\", TimeSpan.FromSeconds(30), () => DateTime.UtcNow.ToString(\"O\"));\nvar cachedAgain = cache.GetOrAdd(\"current-time\", TimeSpan.FromSeconds(30), () => \"should-not-be-used\");\n\nvar memoized = cache.Memoize(TimeSpan.FromSeconds(30), () => 42);\n\nConsole.WriteLine(timestamp == cachedAgain);\nConsole.WriteLine(memoized());" + } + }, + { + "id": "2329156f7195300efb2c9872", + "exampleId": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticator#1", + "uid": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticator", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Claims;\nusing Cuemon.AspNetCore.Authentication.Hmac;\n\nHmacAuthenticator authenticator = (string clientId, out string clientSecret) =>\n{\n clientSecret = clientId == \"Agent-Api\" ? \"Test\" : null;\n return clientSecret == null\n ? null\n : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, clientId) }, HmacFields.Scheme));\n};\n\nvar principal = authenticator(\"Agent-Api\", out var secret);\n\nConsole.WriteLine(secret);\nConsole.WriteLine(principal?.Identity?.Name);" + } + }, + { + "id": "2341a0177c75331dffc7002e", + "exampleId": "Cuemon.AspNetCore.Authentication.Digest.DigestHashFactory#1", + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestHashFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.AspNetCore.Authentication.Digest;\nusing Cuemon.Security;\n\nHash hash = DigestHashFactory.CreateCrypto(DigestCryptoAlgorithm.Sha256);\n\nvar bytes = Encoding.UTF8.GetBytes(\"hello-world\");\nvar result = hash.ComputeHash(bytes);\n\nConsole.WriteLine(result.ToHexadecimalString());" + } + }, + { + "id": "23f73e719e754b425fa1c58f", + "exampleId": "Cuemon.Extensions.AspNetCore.Text.Json.ServiceCollectionExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Text.Json.ServiceCollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Text.Json@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Diagnostics;\nusing Cuemon.Extensions.AspNetCore.Text.Json;\nusing Cuemon.Extensions.Text.Json.Formatters;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\n\nvar services = new ServiceCollection();\nservices.Configure(options =>\n{\n options.SensitivityDetails = FaultSensitivityDetails.All;\n});\nservices.AddMinimalJsonOptions(options =>\n{\n options.SensitivityDetails = FaultSensitivityDetails.All;\n});\n\nusing var provider = services.BuildServiceProvider();\nvar options = provider.GetRequiredService>().Value;\nConsole.WriteLine(options.SensitivityDetails);" + } + }, + { + "id": "2490d13995181c455228acbf", + "exampleId": "Cuemon.Threading.AsyncOptions#1", + "uid": "Cuemon.Threading.AsyncOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Cuemon.Threading;\n\nvar defaults = new AsyncOptions();\nConsole.WriteLine(defaults.CancellationToken == CancellationToken.None);\n\nusing var cts = new CancellationTokenSource();\nvar options = new AsyncOptions\n{\n CancellationTokenProvider = () => cts.Token\n};\n\ncts.Cancel();\n\ntry\n{\n await Task.Delay(10, options.CancellationToken);\n}\ncatch (OperationCanceledException)\n{\n Console.WriteLine(\"Cancelled as expected.\");\n}" + } + }, + { + "id": "266e4575eee346409f229e66", + "exampleId": "Cuemon.Extensions.Xml.DateTimeExtensions#1", + "uid": "Cuemon.Extensions.Xml.DateTimeExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Xml;\nusing Cuemon.Extensions.Xml;\n\nDateTime utcNow = DateTime.UtcNow;\n\n// Format as XML UTC string (appends \"Z\" for UTC)\nstring xmlUtc = utcNow.ToString(XmlDateTimeSerializationMode.Utc);\nConsole.WriteLine(xmlUtc);\n// Output: 2026-06-16T12:34:56.789Z\n\n// Convert local time to XML local string (includes offset)\nDateTime localNow = DateTime.Now;\nstring xmlLocal = localNow.ToString(XmlDateTimeSerializationMode.Local);\nConsole.WriteLine(xmlLocal);\n// Output: 2026-06-16T14:34:56.789+02:00\n\n// Round-trip format preserves the Kind information\nstring xmlRoundtrip = utcNow.ToString(XmlDateTimeSerializationMode.RoundtripKind);\nConsole.WriteLine(xmlRoundtrip);\n// Output: 2026-06-16T12:34:56.789Z\n\n// Unspecified mode drops any time zone info\nstring xmlUnspecified = utcNow.ToString(XmlDateTimeSerializationMode.Unspecified);\nConsole.WriteLine(xmlUnspecified);" + } + }, + { + "id": "2678a6514e3cd9e8c0c6b4b5", + "exampleId": "Cuemon.Diagnostics.MemberEvidence#1", + "uid": "Cuemon.Diagnostics.MemberEvidence", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing System.Reflection;\nusing Cuemon;\nusing Cuemon.Collections.Generic;\nusing Cuemon.Diagnostics;\n\ntry\n{\n throw ExceptionInsights.Embed(\n new ArgumentNullException(\"value\", \"Value cannot be null.\"),\n MethodBase.GetCurrentMethod(),\n Arguments.ToArray(\"value\"),\n SystemSnapshots.CaptureAll);\n}\ncatch (Exception ex)\n{\n var descriptor = ExceptionDescriptor.Extract(ex);\n if (descriptor.Evidence.TryGetValue(\"Thrower\", out var thrower) &&\n thrower is MemberEvidence evidence)\n {\n Console.WriteLine($\"Signature: {evidence.MemberSignature}\");\n\n Console.WriteLine($\"Runtime parameters: {evidence.RuntimeParameters.Count}\");\n foreach (var kvp in evidence.RuntimeParameters)\n {\n Console.WriteLine($\" {kvp.Key} = {kvp.Value}\");\n }\n }\n}" + } + }, + { + "id": "26e45cb8042b55e1ea8cf867", + "exampleId": "Cuemon.Extensions.Globalization.RegionInfoExtensions#1", + "uid": "Cuemon.Extensions.Globalization.RegionInfoExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Globalization;\nusing System.Linq;\nusing Cuemon.Extensions.Globalization;\n\n// Get cultures associated with a specific region\nvar region = new RegionInfo(\"US\");\n\nvar cultures = region.GetCultures().ToList();\nConsole.WriteLine($\"Cultures for {region.EnglishName} ({region.TwoLetterISORegionName}):\");\nforeach (var culture in cultures)\n{\n Console.WriteLine($\" {culture.Name} - {culture.EnglishName}\");\n}\n\n// Try another region\nvar japan = new RegionInfo(\"JP\");\nvar jpCultures = japan.GetCultures().ToList();\nConsole.WriteLine($\"\\nCultures for {japan.EnglishName}:\");\nforeach (var culture in jpCultures)\n{\n Console.WriteLine($\" {culture.Name} - {culture.EnglishName}\");\n}" + } + }, + { + "id": "275a28ae5bde827889dbdded", + "exampleId": "Cuemon.Extensions.Xml.XmlReaderExtensions#1", + "uid": "Cuemon.Extensions.Xml.XmlReaderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Linq;\nusing System.Xml;\nusing Cuemon.Extensions.Xml;\nusing DocExamples;\n\nXmlReaderExtensionsExample.Demonstrate();\n\nnamespace DocExamples\n{\n public static class XmlReaderExtensionsExample\n {\n private const string XmlDocument = \"FirstSecond\";\n\n public static void Demonstrate()\n {\n Console.WriteLine(GetRootName());\n Console.WriteLine(DescribeHierarchy());\n Console.WriteLine(ReadFirstChunk());\n Console.WriteLine(CopyXml());\n }\n\n private static string GetRootName()\n {\n using var xmlReader = XmlReader.Create(new StringReader(XmlDocument));\n return xmlReader.MoveToFirstElement() ? xmlReader.LocalName : string.Empty;\n }\n\n private static string DescribeHierarchy()\n {\n using var xmlReader = XmlReader.Create(new StringReader(XmlDocument));\n var hierarchy = xmlReader.ToHierarchy();\n var childNames = string.Join(\", \", hierarchy.GetChildren().Select(child => child.Instance.Name));\n return $\"{hierarchy.Instance.Name}: {childNames}\";\n }\n\n private static string ReadFirstChunk()\n {\n using var xmlReader = XmlReader.Create(new StringReader(XmlDocument));\n using var firstChunk = xmlReader.Chunk(1, settings => settings.Indent = true).First();\n\n firstChunk.MoveToFirstElement();\n return firstChunk.ReadOuterXml();\n }\n\n private static string CopyXml()\n {\n using var xmlReader = XmlReader.Create(new StringReader(XmlDocument));\n using var xmlStream = xmlReader.ToStream();\n using var streamReader = new StreamReader(xmlStream);\n\n return streamReader.ReadToEnd();\n }\n }\n}" + } + }, + { + "id": "280bd3d9741b5d089f53bebf", + "exampleId": "Cuemon.Extensions.Net.DictionaryExtensions#1", + "uid": "Cuemon.Extensions.Net.DictionaryExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon.Extensions.Net;\n\n// Build a query string from a dictionary\nvar parameters = new Dictionary\n{\n { \"search\", new[] { \"dotnet\" } },\n { \"page\", new[] { \"1\" } },\n { \"tags\", new[] { \"aspnet\", \"core\" } }\n};\n\n// Convert to a query string (not URL-encoded)\nstring queryString = parameters.ToQueryString();\nConsole.WriteLine(queryString);\n// Output: search=dotnet&page=1&tags=aspnet&tags=core\n\n// URL-encode the values\nstring encoded = parameters.ToQueryString(urlEncode: true);\nConsole.WriteLine(encoded);\n// Output: search=dotnet&page=1&tags=aspnet&tags=core\n\n// Useful for building API request URLs\nvar empty = new Dictionary();\nstring emptyQs = empty.ToQueryString();\nConsole.WriteLine($\"Empty: '{emptyQs}'\"); // Empty: ''" + } + }, + { + "id": "283726b85cb19e69a554cb19", + "exampleId": "Cuemon.Extensions.Text.Json.Converters.StringEnumConverter#1", + "uid": "Cuemon.Extensions.Text.Json.Converters.StringEnumConverter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\nusing Cuemon.Extensions.Text.Json.Converters;\nusing MyApp.Examples;\n\nnew StringEnumConverterExample().Demonstrate();\n\nnamespace MyApp.Examples\n{\n public class StringEnumConverterExample\n {\n public void Demonstrate()\n {\n var options = new JsonSerializerOptions\n {\n TypeInfoResolver = new DefaultJsonTypeInfoResolver(),\n PropertyNamingPolicy = JsonNamingPolicy.CamelCase\n };\n options.Converters.Add(new StringEnumConverter());\n\n var payload = new { Day = DayOfWeek.Friday, Status = UriKind.Relative };\n\n string json = JsonSerializer.Serialize(payload, options);\n Console.WriteLine(json);\n // { \"day\": \"Friday\", \"status\": \"Relative\" }\n\n var restored = JsonSerializer.Deserialize(json, options);\n Console.WriteLine(restored.Day); // Friday\n }\n\n public class Payload\n {\n public DayOfWeek Day { get; set; }\n public UriKind Status { get; set; }\n }\n }\n}" + } + }, + { + "id": "28f9172c8596f162b1edf979", + "exampleId": "Cuemon.Extensions.Text.Json.Converters.TransientFaultExceptionConverter#1", + "uid": "Cuemon.Extensions.Text.Json.Converters.TransientFaultExceptionConverter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing System.Text.Json.Serialization.Metadata;\nusing Cuemon.Extensions.Text.Json.Converters;\nusing Cuemon.Extensions.Text.Json;\nusing Cuemon.Extensions.Text.Json.Formatters;\nusing Cuemon.Reflection;\nusing Cuemon.Resilience;\nusing MyApp.Examples;\n\nnew TransientFaultExceptionConverterExample().SerializeTransientFaultException();\n\nnamespace MyApp.Examples\n{\n public class TransientFaultExceptionConverterExample\n {\n public void SerializeTransientFaultException()\n {\n // Create a transient fault exception with evidence\n var evidence = new TransientFaultEvidence(\n attempts: 3,\n recoveryWaitTime: TimeSpan.FromSeconds(2),\n totalRecoveryWaitTime: TimeSpan.FromSeconds(6),\n latency: TimeSpan.FromMilliseconds(500),\n descriptor: new MethodSignature(\n \"MyService\",\n \"ConnectAsync\",\n new[] { \"connectionString\" },\n new object[] { \"server=db;timeout=30\" }));\n\n var exception = new TransientFaultException(\n \"Failed to connect after 3 retries.\",\n new TimeoutException(\"Connection timed out.\"),\n evidence);\n\n // Configure JSON formatter with the converter\n var options = new JsonFormatterOptions();\n options.Settings.TypeInfoResolver = new DefaultJsonTypeInfoResolver();\n options.Settings.Converters.Add(new TransientFaultExceptionConverter());\n\n // Serialize to JSON\n var formatter = new JsonFormatter(options);\n using (var stream = formatter.Serialize(exception))\n using (var reader = new StreamReader(stream))\n {\n string json = reader.ReadToEnd();\n Console.WriteLine(json);\n // The output includes exception details, inner exception, and evidence:\n // {\n // \"type\": \"Cuemon.Resilience.TransientFaultException\",\n // \"message\": \"Failed to connect after 3 retries.\",\n // \"evidence\": {\n // \"attempts\": 3,\n // ...\n // }\n // }\n }\n }\n\n public void DeserializeTransientFaultException()\n {\n string json = @\"{\n \"\"type\"\": \"\"Cuemon.Resilience.TransientFaultException\"\",\n \"\"message\"\": \"\"Failed to connect after 3 retries.\"\",\n \"\"evidence\"\": {\n \"\"attempts\"\": 3,\n \"\"recoveryWaitTime\"\": \"\"00:00:02\"\",\n \"\"totalRecoveryWaitTime\"\": \"\"00:00:06\"\",\n \"\"latency\"\": \"\"00:00:00.500\"\",\n \"\"descriptor\"\": {\n \"\"caller\"\": \"\"MyService\"\",\n \"\"methodName\"\": \"\"ConnectAsync\"\",\n \"\"parameters\"\": [\"\"connectionString\"\"],\n \"\"arguments\"\": [\"\"server=db;timeout=30\"\"]\n }\";\n\n var options = new JsonFormatterOptions();\n options.Settings.TypeInfoResolver = new DefaultJsonTypeInfoResolver();\n options.Settings.Converters.Add(new TransientFaultExceptionConverter());\n\n using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(json)))\n {\n var formatter = new JsonFormatter(options);\n var exception = formatter.Deserialize(stream);\n\n Console.WriteLine(exception.Message);\n Console.WriteLine($\"Evidence - Attempts: {exception.Evidence.Attempts}\");\n }\n }\n }\n}" + } + }, + { + "id": "2906e01a88f2eff6cd2750ae", + "exampleId": "Cuemon.Extensions.IO.ByteArrayExtensions#1", + "uid": "Cuemon.Extensions.IO.ByteArrayExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.IO@11.0.0" + ], + "source": "// Program.cs\nusing System.Threading;\nusing System;\nusing System.IO;\nusing System.Text;\nusing System.Threading.Tasks;\nusing Cuemon.Extensions.IO;\n\nbyte[] data = Encoding.UTF8.GetBytes(\"Hello, World!\");\n\n// Convert a byte array to a seekable Stream (synchronous)\nusing Stream stream = data.ToStream();\nConsole.WriteLine(stream.Length); // 13\nConsole.WriteLine(stream.CanSeek); // True\n\n// Read the content back\nusing var reader = new StreamReader(stream);\nstring content = reader.ReadToEnd();\nConsole.WriteLine(content); // \"Hello, World!\"\n\n// Convert a byte array to a Stream (asynchronous)\nusing Stream asyncStream = await data.ToStreamAsync();\n\n// Verify the async stream content\nusing var asyncReader = new StreamReader(asyncStream);\nstring asyncContent = asyncReader.ReadToEnd();\nConsole.WriteLine(asyncContent); // \"Hello, World!\"\n\n// Use cancellation with the async overload\nusing var cts = new System.Threading.CancellationTokenSource();\nusing Stream cancelStream = await data.ToStreamAsync(cts.Token);" + } + }, + { + "id": "296181754f9fd3e46901c11f", + "exampleId": "Cuemon.Runtime.FileWatcher#1", + "uid": "Cuemon.Runtime.FileWatcher", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Threading;\nusing Cuemon.Runtime;\n\nstring directory = Path.Combine(Path.GetTempPath(), \"cuemon-docs\");\nDirectory.CreateDirectory(directory);\nstring filePath = Path.Combine(directory, \"health.txt\");\nFile.WriteAllText(filePath, \"ready\");\n\nusing var watcher = new FileWatcher(filePath, readFile: true, options =>\n{\n options.DueTime = TimeSpan.Zero;\n options.Period = TimeSpan.FromSeconds(5);\n options.DueTimeOnChanged = TimeSpan.FromMilliseconds(250);\n});\n\nwatcher.Changed += static (_, e) => Console.WriteLine($\"{e.UtcLastModified:O} ({e.Delayed.TotalMilliseconds} ms)\");\nwatcher.StartMonitoring();\n\nConsole.WriteLine(watcher.Path);\nConsole.WriteLine(watcher.ReadFile);\nConsole.WriteLine(watcher.UtcCreated.ToString(\"O\"));\n\nwatcher.ChangeSignaling(Timeout.InfiniteTimeSpan);" + } + }, + { + "id": "2971220cd0c6bfed6f7cd376", + "exampleId": "Cuemon.Threading.AsyncTaskFactoryOptions#1", + "uid": "Cuemon.Threading.AsyncTaskFactoryOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading.Tasks;\nusing Cuemon;\nusing Cuemon.Threading;\n\n// Direct instantiation of AsyncTaskFactoryOptions\nvar factoryOptions = new AsyncTaskFactoryOptions\n{\n CreationOptions = TaskCreationOptions.None,\n PartitionSize = 2\n};\n\nvar rules = new ForLoopRuleset(0, 10, 1);\n\nAdvancedParallelFactory.For(rules, i =>\n{\n Console.WriteLine($\"Processing item {i}\");\n}, o =>\n{\n o.CreationOptions = TaskCreationOptions.None;\n o.Scheduler = TaskScheduler.Default;\n o.PartitionSize = 2;\n});" + } + }, + { + "id": "2975928484698884dfa22fb6", + "exampleId": "Cuemon.ExceptionDecoratorExtensions#1", + "uid": "Cuemon.ExceptionDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon;\n\nException nested = new InvalidOperationException(\n \"Request failed.\",\n new ArgumentException(\"Endpoint is invalid.\", new TimeoutException(\"The call timed out.\")));\n\nvar flattened = Decorator.Enclose(nested).Flatten().ToList();\n\nException aggregate = new AggregateException(\n new InvalidOperationException(\"Retry later.\"),\n new TimeoutException(\"The call timed out.\"));\n\nvar aggregateInner = Decorator.Enclose(aggregate).Flatten().ToList();\n\nConsole.WriteLine($\"Nested chain: {string.Join(\" -> \", flattened.Select(ex => ex.GetType().Name))}\");\nConsole.WriteLine($\"Aggregate count: {aggregateInner.Count}\");" + } + }, + { + "id": "29e064a70e1661eca27c6aac", + "exampleId": "Cuemon.Reflection.MethodBaseOptions#1", + "uid": "Cuemon.Reflection.MethodBaseOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing System.Reflection;\nusing Cuemon.Reflection;\nusing MyApp.Examples;\n\nMethodBaseOptionsExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class MethodBaseOptionsExample\n {\n public static void Demonstrate()\n {\n var options = new MethodBaseOptions\n {\n Flags = BindingFlags.Instance | BindingFlags.Public,\n Comparison = StringComparison.OrdinalIgnoreCase,\n Types = new[] { typeof(decimal), typeof(decimal) }\n };\n\n MethodInfo method = ResolveMethod(typeof(PricingEngine), \"applydiscount\", options);\n\n Console.WriteLine(method == null ? \"not found\" : method.Name);\n Console.WriteLine(options.Flags);\n Console.WriteLine(string.Join(\", \", options.Types.Select(type => type.Name)));\n }\n\n private static MethodInfo ResolveMethod(Type source, string name, MethodBaseOptions options)\n {\n return source.GetMethods(options.Flags).FirstOrDefault(method =>\n method.Name.Equals(name, options.Comparison) &&\n method.GetParameters().Select(parameter => parameter.ParameterType)\n .SequenceEqual(options.Types ?? Array.Empty()));\n }\n }\n public sealed class PricingEngine\n {\n public decimal ApplyDiscount(decimal subtotal, decimal discount)\n {\n return subtotal - discount;\n }\n }\n}" + } + }, + { + "id": "2a20c0efa15f4e2a7068c857", + "exampleId": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationMiddleware#1", + "uid": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationMiddleware", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading.Tasks;\nusing Cuemon.AspNetCore.Authentication.Basic;\n\nvar middleware = new BasicAuthenticationMiddleware(_ => Task.CompletedTask, options =>\n{\n options.Realm = \"docs-example\";\n options.RequireSecureConnection = false;\n options.Authenticator = (username, password) => null;\n});\n\nConsole.WriteLine(middleware.Options.Realm);" + } + }, + { + "id": "2ab423a8efab4e86e799dab4", + "exampleId": "Cuemon.StringReplacePair#1", + "uid": "Cuemon.StringReplacePair", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon; // for StringReplacePair\n\nstring input = \"Hello World from Cuemon! Welcome to the World of .NET.\";\n\n// Replace all occurrences of \"World\" with \"Universe\" (case-insensitive by default)\nstring result = StringReplacePair.ReplaceAll(input, \"World\", \"Universe\");\nConsole.WriteLine(result);\n// Output: Hello Universe from Cuemon! Welcome to the Universe of .NET.\n\n// Replace multiple pairs at once\nvar pairs = new StringReplacePair[]\n{\n new StringReplacePair(\"Hello\", \"Hi\"),\n new StringReplacePair(\"Cuemon\", \"Codebelt\"),\n new StringReplacePair(\".NET\", \"dotnet\")\n};\nresult = StringReplacePair.ReplaceAll(input, pairs);\nConsole.WriteLine(result);\n// Output: Hi World from Codebelt! Welcome to the World of dotnet.\n\n// Remove specific words (case-sensitive ordinal comparison)\nresult = StringReplacePair.RemoveAll(input, StringComparison.Ordinal, \"World\", \"Cuemon\", \"Welcome\");\nConsole.WriteLine(result);\n// Output: Hello from ! to the of .NET.\n\n// Remove specific characters\nresult = StringReplacePair.RemoveAll(input, '.', '!');\nConsole.WriteLine(result);\n// Output: Hello World from Cuemon Welcome to the World of NET" + } + }, + { + "id": "2c19882a597c57df7fe45532", + "exampleId": "Cuemon.Data.DatabaseWatcher#1", + "uid": "Cuemon.Data.DatabaseWatcher", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Data;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Cuemon.Data;\nusing Cuemon.Runtime;\nusing MyApp.Data;\n\nawait new DatabaseWatcherExample().DemonstrateAsync();\n\nnamespace MyApp.Data\n{\n public sealed class DatabaseWatcherExample\n {\n public async Task DemonstrateAsync()\n {\n var table = new DataTable();\n table.Columns.Add(\"Id\", typeof(int));\n table.Columns.Add(\"Name\", typeof(string));\n table.Rows.Add(1, \"Alpha\");\n\n using var connection = new InMemoryConnection();\n var watcher = new SampleDatabaseWatcher(connection, _ => table.CreateDataReader(), options =>\n {\n options.DueTime = Timeout.InfiniteTimeSpan;\n options.Period = Timeout.InfiniteTimeSpan;\n });\n\n var changedSignals = 0;\n watcher.Changed += (_, args) =>\n {\n changedSignals++;\n Console.WriteLine($\"Detected a change at {args.UtcLastModified:O}.\");\n };\n\n await watcher.SignalAsync();\n Console.WriteLine($\"Initial checksum: {watcher.Checksum}\");\n\n table.Rows[0][\"Name\"] = \"Beta\";\n\n await watcher.SignalAsync();\n Console.WriteLine($\"Signals raised: {changedSignals}\");\n Console.WriteLine($\"Updated checksum: {watcher.Checksum}\");\n }\n\n private sealed class SampleDatabaseWatcher : DatabaseWatcher\n {\n public SampleDatabaseWatcher(IDbConnection connection, Func readerFactory, Action setup = null)\n : base(connection, readerFactory, setup)\n {\n }\n\n public Task SignalAsync()\n {\n return HandleSignalingAsync();\n }\n }\n\n private sealed class InMemoryConnection : IDbConnection\n {\n public string ConnectionString { get; set; } = string.Empty;\n\n public int ConnectionTimeout => 0;\n\n public string Database => \"Sample\";\n\n public ConnectionState State { get; private set; } = ConnectionState.Closed;\n\n public IDbTransaction BeginTransaction()\n {\n throw new NotSupportedException();\n }\n\n public IDbTransaction BeginTransaction(IsolationLevel il)\n {\n throw new NotSupportedException();\n }\n\n public void ChangeDatabase(string databaseName)\n {\n throw new NotSupportedException();\n }\n\n public void Close()\n {\n State = ConnectionState.Closed;\n }\n\n public IDbCommand CreateCommand()\n {\n throw new NotSupportedException();\n }\n\n public void Open()\n {\n State = ConnectionState.Open;\n }\n\n public void Dispose()\n {\n Close();\n }\n }\n }\n}" + } + }, + { + "id": "2c4918dbab6057df574256d0", + "exampleId": "Cuemon.Extensions.Text.StringExtensions#1", + "uid": "Cuemon.Extensions.Text.StringExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Extensions.Text;\nusing Cuemon.Text;\n\n// ToEncodedString - encodes a string to a different encoding with fallback handling\nvar withSpecialChars = \"Café au lait: 2,50 €\";\n\n// Default: uses ExceptionFallback, will throw for unrepresentable chars\nvar encoded = withSpecialChars.ToEncodedString(o =>\n{\n o.TargetEncoding = Encoding.UTF8;\n});\nConsole.WriteLine(encoded); // \"Café au lait: 2,50 €\"\n\n// Convert to ASCII with replacement fallback\nvar asciiResult = withSpecialChars.ToEncodedString(o =>\n{\n o.TargetEncoding = Encoding.ASCII;\n o.EncoderFallback = new EncoderReplacementFallback(\"?\");\n});\nConsole.WriteLine(asciiResult); // \"Caf? au lait: 2,50 ?\"\n\n// Convert to UTF-16 (Unicode)\nvar unicode = withSpecialChars.ToEncodedString(o =>\n{\n o.TargetEncoding = Encoding.Unicode;\n o.EncoderFallback = new EncoderReplacementFallback(\"?\");\n});\nConsole.WriteLine(unicode);\n\n// ToAsciiEncodedString - quick ASCII conversion\nvar asciiQuick = withSpecialChars.ToAsciiEncodedString();\nConsole.WriteLine(asciiQuick); // \"Cafe au lait: 2,50 \"\n// Uses EncoderReplacementFallback(\"\") by default, so unsupported chars are removed silently\n\n// ToAsciiEncodedString with custom encoding options\nvar asciiCustom = withSpecialChars.ToAsciiEncodedString(o =>\n{\n o.Preamble = PreambleSequence.Remove;\n o.Encoding = Encoding.UTF8;\n});\nConsole.WriteLine(asciiCustom); // same result, no BOM\n\n// Practical example: sanitize user input to safe ASCII\nvar userInput = \"Hello World — 2025 ©\";\nvar sanitized = userInput.ToAsciiEncodedString();\nConsole.WriteLine(sanitized); // \"Hello World 2025 \" (em dash and copyright removed)" + } + }, + { + "id": "2cae07aa3e75c422e0f7696d", + "exampleId": "Cuemon.Reflection.MemberReflectionOptions#1", + "uid": "Cuemon.Reflection.MemberReflectionOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing System.Reflection;\nusing Cuemon;\nusing Cuemon.Reflection;\n\nBindingFlags publicInstanceFlags = MemberReflection.CreateFlags(options =>\n{\n options.ExcludePrivate = true;\n options.ExcludeStatic = true;\n});\n\nvar publicDateSpanMembers = typeof(DateSpan)\n .GetMembers(publicInstanceFlags)\n .Select(member => member.Name)\n .Distinct()\n .OrderBy(name => name)\n .Take(8);\n\nConsole.WriteLine(string.Join(\", \", publicDateSpanMembers));\n\nBindingFlags declaredOnlyFlags = MemberReflection.CreateFlags(options =>\n{\n options.ExcludePrivate = true;\n options.ExcludeStatic = true;\n options.ExcludeInheritancePath = true;\n});\n\nConsole.WriteLine(typeof(DateSpan).GetMethods(publicInstanceFlags).Length);\nConsole.WriteLine(typeof(DateSpan).GetMethods(declaredOnlyFlags).Length);\n\nvar documentedOptions = new MemberReflectionOptions\n{\n ExcludePrivate = true,\n ExcludeStatic = true,\n ExcludeInheritancePath = true\n};\n\nConsole.WriteLine($\"{documentedOptions.ExcludePrivate}/{documentedOptions.ExcludeStatic}/{documentedOptions.ExcludeInheritancePath}/{documentedOptions.ExcludePublic}\");" + } + }, + { + "id": "2ccde57a5295495b513a2f7f", + "exampleId": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticator#1", + "uid": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticator", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Claims;\nusing Cuemon.AspNetCore.Authentication.Basic;\n\nBasicAuthenticator authenticator = (username, password) =>\n{\n return username == \"Agent\" && password == \"Test\"\n ? new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, BasicAuthorizationHeader.Scheme))\n : null;\n};\n\nvar principal = authenticator(\"Agent\", \"Test\");\n\nConsole.WriteLine(principal?.Identity?.Name);" + } + }, + { + "id": "2ec062c453287d1f8826ee0f", + "exampleId": "Cuemon.Text.UriStringOptions#1", + "uid": "Cuemon.Text.UriStringOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon;\nusing Cuemon.Text;\n\nvar options = new UriStringOptions\n{\n Kind = UriKind.Absolute,\n Schemes = new List { UriScheme.Https, UriScheme.Http }\n};\n\noptions.ValidateOptions();\n\nbool allowsHttps = options.Schemes.Contains(UriScheme.Https);\nint knownSchemes = UriStringOptions.AllUriSchemes.Count();\n\nConsole.WriteLine($\"Kind: {options.Kind}\");\nConsole.WriteLine($\"Allows HTTPS: {allowsHttps}\");\nConsole.WriteLine($\"Known schemes: {knownSchemes}\");" + } + }, + { + "id": "2efa38c4a9d4f4b0ee6ae79c", + "exampleId": "Cuemon.Security.FowlerNollVo128#1", + "uid": "Cuemon.Security.FowlerNollVo128", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon;\nusing Cuemon.Security;\n\n// Create a FNV-1a 128-bit hash (default algorithm).\nvar fnv = new FowlerNollVo128();\n\nConsole.WriteLine($\"Bits: {fnv.Bits}\"); // 128\nConsole.WriteLine($\"Algorithm: {fnv.Options.Algorithm}\"); // Fnv1a\n\n// Compute hash of a UTF-8 encoded string.\nvar data = Encoding.UTF8.GetBytes(\"Hello, World!\");\nvar hash = fnv.ComputeHash(data);\n\nConsole.WriteLine($\"Hash (hex): {hash.ToHexadecimalString()}\");\nConsole.WriteLine($\"Hash (b64): {hash.ToBase64String()}\");\n\n// Use FNV-1 instead of FNV-1a.\nvar fnv1 = new FowlerNollVo128(o => o.Algorithm = FowlerNollVoAlgorithm.Fnv1);\nvar hashFnv1 = fnv1.ComputeHash(data);\nConsole.WriteLine($\"FNV-1 hash: {hashFnv1}\");\n\n// Little-endian byte order.\nvar fnvLe = new FowlerNollVo128(o => o.ByteOrder = Endianness.LittleEndian);\nvar hashLe = fnvLe.ComputeHash(data);\nConsole.WriteLine($\"LE hash: {hashLe.ToHexadecimalString()}\");\n\n// Verify hash with the built-in offset basis for empty input.\nvar emptyHash = fnv.ComputeHash(Array.Empty());\nConsole.WriteLine($\"Offset basis hash: {emptyHash.ToHexadecimalString()}\");" + } + }, + { + "id": "2efa476c04f95b3dce4fb775", + "exampleId": "Cuemon.Extensions.Net.HttpStatusCodeExtensions#1", + "uid": "Cuemon.Extensions.Net.HttpStatusCodeExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ], + "source": "using System;\nusing System.Net;\nusing Cuemon.Extensions.Net;\n\nnamespace DocExamples\n{\n public static class HttpStatusCodeExtensionsExample\n {\n public static void Main()\n {\n HttpStatusCode statusCode = HttpStatusCode.NotFound;\n\n // Check the status code HTTP range\n bool isInfo = statusCode.IsInformationStatusCode();\n bool isSuccess = statusCode.IsSuccessStatusCode();\n bool isRedirect = statusCode.IsRedirectionStatusCode();\n bool isClientError = statusCode.IsClientErrorStatusCode();\n bool isServerError = statusCode.IsServerErrorStatusCode();\n\n Console.WriteLine($\"HTTP {(int)statusCode} ({statusCode}):\");\n Console.WriteLine($\" Informational (100-199): {isInfo}\");\n Console.WriteLine($\" Successful (200-299): {isSuccess}\");\n Console.WriteLine($\" Redirection (300-399): {isRedirect}\");\n Console.WriteLine($\" Client Error (400-499): {isClientError}\");\n Console.WriteLine($\" Server Error (500-599): {isServerError}\");\n\n // Verify common status codes\n Console.WriteLine($\"\\n200 OK is success: {HttpStatusCode.OK.IsSuccessStatusCode()}\");\n Console.WriteLine($\"301 Moved is redirect: {HttpStatusCode.MovedPermanently.IsRedirectionStatusCode()}\");\n Console.WriteLine($\"403 Forbidden is client error: {HttpStatusCode.Forbidden.IsClientErrorStatusCode()}\");\n Console.WriteLine($\"500 Error is server error: {HttpStatusCode.InternalServerError.IsServerErrorStatusCode()}\");\n Console.WriteLine($\"100 Continue is informational: {HttpStatusCode.Continue.IsInformationStatusCode()}\");\n\n}}\n}" + } + }, + { + "id": "2fe613375cced2433dbfebfc", + "exampleId": "Cuemon.Data.DataTransfer#1", + "uid": "Cuemon.Data.DataTransfer", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Data;\nusing Cuemon.Data;\n\nvar table = new DataTable(\"Products\");\ntable.Columns.Add(\"Id\", typeof(int));\ntable.Columns.Add(\"Name\", typeof(string));\ntable.Columns.Add(\"Price\", typeof(decimal));\ntable.Rows.Add(1, \"Widget\", 9.99m);\ntable.Rows.Add(2, \"Gadget\", 24.95m);\n\nusing IDataReader reader = table.CreateDataReader();\n\n// Convert reader rows to a collection\nDataTransferRowCollection rows = DataTransfer.GetRows(reader);\nConsole.WriteLine($\"Row count: {rows.Count}\");\nConsole.WriteLine($\"Columns: {string.Join(\", \", rows.ColumnNames)}\");\n\n// Access data by column name\nforeach (DataTransferRow row in rows)\n{\n Console.WriteLine($\"{row[\"Id\"]}: {row[\"Name\"]} @ {row[\"Price\"]:C}\");\n}\n\n// Re-read and get columns\nreader.Dispose();\nusing IDataReader reader2 = table.CreateDataReader();\nreader2.Read();\nDataTransferColumnCollection columns = DataTransfer.GetColumns(reader2);\nConsole.WriteLine($\"Column count: {columns.Count}\");\nConsole.WriteLine($\"First column: {columns[0].Name} ({columns[0].DataType.Name})\");" + } + }, + { + "id": "30451220407512250e37b6a5", + "exampleId": "Cuemon.Extensions.VerticalDirection#1", + "uid": "Cuemon.Extensions.VerticalDirection", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions;\n\nvar upward = VerticalDirection.Up;\nvar downward = (VerticalDirection)Enum.Parse(typeof(VerticalDirection), \"Down\");\n\nConsole.WriteLine($\"{upward} = {(int)upward}\");\nConsole.WriteLine($\"{downward} = {(int)downward}\");\nConsole.WriteLine(default(VerticalDirection));" + } + }, + { + "id": "309a745320819cef16751645", + "exampleId": "Cuemon.Xml.Serialization.DynamicXmlConverterCore#1", + "uid": "Cuemon.Xml.Serialization.DynamicXmlConverterCore", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Xml;\nusing Cuemon.Xml.Serialization;\nusing MyApp.Xml;\n\nDynamicXmlConverterCoreExamples.Demonstrate();\n\nnamespace MyApp.Xml\n{\n public static class DynamicXmlConverterCoreExamples\n {\n public static void Demonstrate()\n {\n // Use the DynamicXmlConverter factory to create a converter for a custom type.\n // This converter knows how to read and write instances of Person to/from XML.\n DynamicXmlConverterCore converter = (DynamicXmlConverterCore)DynamicXmlConverter.Create(\n writer: (xmlWriter, person, element) =>\n {\n xmlWriter.WriteStartElement(element?.LocalName ?? \"Person\");\n xmlWriter.WriteElementString(\"FirstName\", person.FirstName);\n xmlWriter.WriteElementString(\"LastName\", person.LastName);\n xmlWriter.WriteElementString(\"Age\", person.Age.ToString());\n xmlWriter.WriteEndElement();\n },\n reader: (xmlReader, type) =>\n {\n var person = new Person();\n xmlReader.ReadStartElement();\n person.FirstName = xmlReader.ReadElementContentAsString(\"FirstName\", \"\");\n person.LastName = xmlReader.ReadElementContentAsString(\"LastName\", \"\");\n person.Age = xmlReader.ReadElementContentAsInt(\"Age\", \"\");\n xmlReader.ReadEndElement();\n return person;\n });\n\n converter.RootName = new XmlQualifiedEntity(\"Person\");\n\n // The returned converter is an XmlConverter instance.\n Console.WriteLine(\"Can convert Person: {0}\", converter.CanConvert(typeof(Person)));\n Console.WriteLine(\"Can read: {0}\", converter.CanRead); // true\n Console.WriteLine(\"Can write: {0}\", converter.CanWrite); // true\n\n // Write a Person instance to XML.\n var person = new Person { FirstName = \"John\", LastName = \"Doe\", Age = 30 };\n var xml = new StringWriter();\n using (var xmlWriter = XmlWriter.Create(xml, new XmlWriterSettings { Indent = true }))\n {\n converter.WriteXml(xmlWriter, person);\n }\n Console.WriteLine(xml.ToString());\n\n // Read the Person back from XML.\n using (var xmlReader = XmlReader.Create(new StringReader(xml.ToString()), new XmlReaderSettings { IgnoreWhitespace = true }))\n {\n xmlReader.MoveToContent();\n var deserialized = (Person)converter.ReadXml(xmlReader, typeof(Person));\n Console.WriteLine(\"Deserialized: {0} {1}, Age {2}\",\n deserialized.FirstName, deserialized.LastName, deserialized.Age);\n }\n }\n\n public static void DemonstrateWriteOnly()\n {\n // Create a write-only converter (no reader delegate).\n var writeOnly = DynamicXmlConverter.Create(\n writer: (w, p, e) =>\n {\n w.WriteStartElement(e?.LocalName ?? \"Person\");\n w.WriteAttributeString(\"name\", p.FirstName + \" \" + p.LastName);\n w.WriteEndElement();\n });\n\n Console.WriteLine(\"Can read: {0}\", writeOnly.CanRead); // false\n Console.WriteLine(\"Can write: {0}\", writeOnly.CanWrite); // true\n\n var person = new Person { FirstName = \"Jane\", LastName = \"Smith\", Age = 25 };\n var xml = new StringWriter();\n using (var xmlWriter = XmlWriter.Create(xml))\n {\n writeOnly.WriteXml(xmlWriter, person);\n }\n Console.WriteLine(xml.ToString());\n }\n }\n\n public class Person\n {\n public string FirstName { get; set; }\n public string LastName { get; set; }\n public int Age { get; set; }\n }\n}" + } + }, + { + "id": "3181bc691922627d3c09ae4f", + "exampleId": "Cuemon.IO.FileInfoOptions#1", + "uid": "Cuemon.IO.FileInfoOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing Cuemon.IO;\n\n// Default options: BytesToRead = 0 (read entire file)\nvar defaultOptions = new FileInfoOptions();\nConsole.WriteLine($\"Default bytes to read: {defaultOptions.BytesToRead}\"); // 0\n\n// Read only the first 100 bytes of a file\nvar headerOptions = new FileInfoOptions\n{\n BytesToRead = 100\n};\n\n// Read only the first 16 bytes (e.g., for file signature detection)\nvar signatureOptions = new FileInfoOptions\n{\n BytesToRead = 16\n};\n\nstring tempFile = Path.GetTempFileName();\ntry\n{\n File.WriteAllText(tempFile, new string('A', 1000));\n\n // Demonstrate how BytesToRead limits the data read\n using var fileStream = File.OpenRead(tempFile);\n byte[] buffer = new byte[headerOptions.BytesToRead];\n int bytesRead = fileStream.Read(buffer, 0, headerOptions.BytesToRead);\n Console.WriteLine($\"Requested {headerOptions.BytesToRead} bytes, read {bytesRead} bytes\");\n}\nfinally\n{\n File.Delete(tempFile);\n}\n\n// BytesToRead of 0 means no limit\nvar noLimitOptions = new FileInfoOptions\n{\n BytesToRead = 0\n};\nConsole.WriteLine($\"BytesToRead = 0 means no limit: {noLimitOptions.BytesToRead}\");" + } + }, + { + "id": "31b8c5f63efa314e3e1981b1", + "exampleId": "Cuemon.Extensions.Text.Json.Converters.StringFlagsEnumConverter#1", + "uid": "Cuemon.Extensions.Text.Json.Converters.StringFlagsEnumConverter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\nusing Cuemon.Extensions.Text.Json.Converters;\n\nvar options = new JsonSerializerOptions\n{\n TypeInfoResolver = new DefaultJsonTypeInfoResolver(),\n PropertyNamingPolicy = JsonNamingPolicy.CamelCase\n};\noptions.Converters.Add(new StringFlagsEnumConverter());\n\nvar value = FileShare.Read | FileShare.Write;\n\nstring json = JsonSerializer.Serialize(value, options);\nConsole.WriteLine(json);\n// [\"Read\", \"Write\"]\n\nvar restored = JsonSerializer.Deserialize(json, options);\nConsole.WriteLine(restored); // Read, Write" + } + }, + { + "id": "31f27abdd71359ad7af83a56", + "exampleId": "Cuemon.Extensions.Net.Http.UriExtensions#1", + "uid": "Cuemon.Extensions.Net.Http.UriExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ], + "source": "// Program.cs\nusing System.Text;\nusing System;\nusing System.IO;\nusing System.Net;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Cuemon.Extensions.Net.Http;\nusing MyApp.Http;\n\nawait new UriExtensionsExample().DemonstrateAsync();\n\nnamespace MyApp.Http\n{\n public class UriExtensionsExample\n {\n public async Task DemonstrateAsync()\n {\n // Configure a test HTTP client factory that returns predictable responses\n UriExtensions.DefaultHttpClientFactory = new StubHttpClientFactory(HttpStatusCode.OK);\n\n var location = new Uri(\"https://example.com/api/items\");\n\n // GET request\n using (var response = await location.HttpGetAsync())\n {\n Console.WriteLine($\"GET: {response.StatusCode}\"); // 200\n }\n\n // DELETE request\n using (var response = await location.HttpDeleteAsync())\n {\n Console.WriteLine($\"DELETE: {response.StatusCode}\"); // 200\n }\n\n // HEAD request\n using (var response = await location.HttpHeadAsync())\n {\n Console.WriteLine($\"HEAD: {response.StatusCode}\"); // 200\n }\n\n // OPTIONS request\n using (var response = await location.HttpOptionsAsync())\n {\n Console.WriteLine($\"OPTIONS: {response.StatusCode}\"); // 200\n }\n\n // POST with string content type\n using (var response = await location.HttpPostAsync(\n \"application/json\", ToStream(\"{\\\"name\\\":\\\"New Item\\\"}\")))\n {\n Console.WriteLine($\"POST: {response.StatusCode}\"); // 200\n }\n\n // POST with MediaTypeHeaderValue\n using (var response = await location.HttpPostAsync(\n MediaTypeHeaderValue.Parse(\"application/json; charset=utf-8\"),\n ToStream(\"{\\\"name\\\":\\\"Another\\\"}\")))\n {\n Console.WriteLine($\"POST (typed): {response.StatusCode}\"); // 200\n }\n\n // PUT\n using (var response = await location.HttpPutAsync(\n \"application/json\", ToStream(\"{\\\"name\\\":\\\"Updated\\\"}\")))\n {\n Console.WriteLine($\"PUT: {response.StatusCode}\"); // 200\n }\n\n // PATCH\n using (var response = await location.HttpPatchAsync(\n \"application/json-patch+json\", ToStream(\"[{\\\"op\\\":\\\"replace\\\",\\\"path\\\":\\\"/name\\\",\\\"value\\\":\\\"Patched\\\"}]\")))\n {\n Console.WriteLine($\"PATCH: {response.StatusCode}\"); // 200\n }\n\n // TRACE\n using (var response = await location.HttpTraceAsync())\n {\n Console.WriteLine($\"TRACE: {response.StatusCode}\"); // 200\n }\n\n // Generic HTTP method with string content type\n using (var response = await location.HttpAsync(\n HttpMethod.Post, \"text/plain\", ToStream(\"Hello\")))\n {\n Console.WriteLine($\"Generic POST: {response.StatusCode}\"); // 200\n }\n\n // Generic HTTP method with typed content type\n using (var response = await location.HttpAsync(\n HttpMethod.Put,\n MediaTypeHeaderValue.Parse(\"application/octet-stream\"),\n ToStream(\"binary\")))\n {\n Console.WriteLine($\"Generic PUT: {response.StatusCode}\"); // 200\n }\n\n // Full control via HttpRequestOptions\n using (var response = await location.HttpAsync(o =>\n {\n o.Request.Method = HttpMethod.Get;\n o.Request.Headers.Add(\"X-Custom\", \"my-value\");\n o.CancellationToken = CancellationToken.None;\n }))\n {\n Console.WriteLine($\"Custom GET: {response.StatusCode}\"); // 200\n }\n\n // Use cancellation token\n using var cts = new CancellationTokenSource();\n cts.CancelAfter(TimeSpan.FromSeconds(5));\n try\n {\n using var response = await location.HttpGetAsync(cts.Token);\n Console.WriteLine($\"Cancellable GET: {response.StatusCode}\");\n }\n catch (TaskCanceledException)\n {\n Console.WriteLine(\"Request was cancelled.\");\n }\n }\n\n private static Stream ToStream(string value)\n {\n var bytes = Encoding.UTF8.GetBytes(value);\n return new MemoryStream(bytes);\n }\n }\n\n /// \n /// A stub factory that returns an HttpClient backed by a handler\n /// that returns a fixed status code for all requests.\n /// \n internal class StubHttpClientFactory : IHttpClientFactory\n {\n private readonly HttpStatusCode _statusCode;\n\n public StubHttpClientFactory(HttpStatusCode statusCode)\n {\n _statusCode = statusCode;\n }\n\n public HttpClient CreateClient(string name)\n {\n return new HttpClient(new StubHttpMessageHandler(_statusCode));\n }\n }\n\n internal class StubHttpMessageHandler : HttpMessageHandler\n {\n private readonly HttpStatusCode _statusCode;\n\n public StubHttpMessageHandler(HttpStatusCode statusCode)\n {\n _statusCode = statusCode;\n }\n\n protected override Task SendAsync(\n HttpRequestMessage request, CancellationToken ct)\n {\n var response = new HttpResponseMessage(_statusCode)\n {\n Content = new StringContent(\"OK\"),\n RequestMessage = request\n };\n return Task.FromResult(response);\n }\n }\n}" + } + }, + { + "id": "3241bf02f377dc7283d5e00c", + "exampleId": "Cuemon.Security.Cryptography.UnkeyedHashFactory#1", + "uid": "Cuemon.Security.Cryptography.UnkeyedHashFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\n\nvar sha256 = UnkeyedHashFactory.CreateCryptoSha256();\nvar input = \"Data to hash\";\nvar hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(input));\nConsole.WriteLine($\"SHA-256: {BitConverter.ToString(hash.GetBytes()).Replace(\"-\", \"\")}\");\n\nvar sha512 = UnkeyedHashFactory.CreateCryptoSha512();\nhash = sha512.ComputeHash(Encoding.UTF8.GetBytes(input));\nConsole.WriteLine($\"SHA-512: {BitConverter.ToString(hash.GetBytes()).Replace(\"-\", \"\")}\");" + } + }, + { + "id": "326670a2521fcdd5b4b2d6b6", + "exampleId": "Cuemon.Net.Http.HttpDependency#1", + "uid": "Cuemon.Net.Http.HttpDependency", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing System.Threading.Tasks;\nusing Cuemon.Net.Http;\nusing MyApp.Net;\n\nnew HttpDependencyExample().Demonstrate();\n\nnamespace MyApp.Net\n{\n public class HttpDependencyExample\n {\n public void Demonstrate()\n {\n // Create an HttpWatcher that monitors changes to a URI resource\n var watcherFactory = new Lazy(() =>\n {\n var location = new Uri(\"https://example.com/api/status\");\n return new HttpWatcher(location, o =>\n {\n o.ReadResponseBody = false; // use HEAD requests (checks ETag/Last-Modified)\n o.Period = TimeSpan.FromSeconds(30);\n });\n });\n\n // Create a dependency that wraps the watcher\n var dependency = new HttpDependency(watcherFactory);\n\n // Subscribe to change notifications\n dependency.DependencyChanged += (sender, args) =>\n {\n Console.WriteLine($\"Resource changed at: {args.UtcLastModified}\");\n };\n\n // Call StartAsync when you are ready to begin polling the URI.\n // The watcher will poll every 30 seconds and raise DependencyChanged when a change is detected.\n Console.WriteLine(\"HttpDependency configured for https://example.com/api/status.\");\n }\n }\n}" + } + }, + { + "id": "3328fbd569b1713b52a4f681", + "exampleId": "Cuemon.AspNetCore.Http.UnauthorizedException#1", + "uid": "Cuemon.AspNetCore.Http.UnauthorizedException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http;\n\nconst string authenticationScheme = \"Bearer\";\nvar exception = new UnauthorizedException(\n $\"The request is missing a valid {authenticationScheme} token.\",\n new InvalidOperationException(\"Token validation failed.\"));\n\nConsole.WriteLine(exception.StatusCode);\nConsole.WriteLine(exception.Message);\nConsole.WriteLine(exception.InnerException?.Message);" + } + }, + { + "id": "33419500b12b973d4ae0a372", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpFaultResolverDecoratorExtensions#1", + "uid": "Cuemon.AspNetCore.Diagnostics.HttpFaultResolverDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.AspNetCore.Http;\nusing Cuemon;\nusing Examples;\n\nConsole.WriteLine(new FaultResolverRegistrationExample().RegisterResolvers());\n\nnamespace Examples\n{\n public class FaultResolverRegistrationExample\n {\n public IList RegisterResolvers()\n {\n var resolvers = new List();\n\n // Add a resolver for NotFoundException (404)\n Decorator.Enclose(resolvers).AddHttpFaultResolver(\n message: \"The requested resource was not found.\",\n helpLink: new Uri(\"https://example.com/errors/404\"));\n\n // Add a resolver for UnauthorizedException (401) with a custom code\n Decorator.Enclose(resolvers).AddHttpFaultResolver(\n statusCode: 401,\n code: \"UNAUTHORIZED\",\n message: \"Authentication is required.\");\n\n return resolvers;\n\n }\n }\n}" + } + }, + { + "id": "338531210f0e333b32ed4f22", + "exampleId": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationHandler#1", + "uid": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationHandler", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Claims;\nusing Cuemon.AspNetCore.Authentication.Hmac;\nusing Microsoft.AspNetCore.Authentication;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\nusing MyApp.Examples;\n\nHmacAuthenticationHandlerExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class HmacAuthenticationHandlerExample\n {\n public static void Demonstrate()\n {\n const string authenticationScheme = \"hmac-docs\";\n var services = new ServiceCollection();\n\n services.AddLogging();\n services.AddAuthentication(authenticationScheme)\n .AddScheme(authenticationScheme, options =>\n {\n options.AuthenticationScheme = authenticationScheme;\n options.RequireSecureConnection = false;\n options.Authenticator = (string clientId, out string clientSecret) =>\n {\n clientSecret = clientId == \"Agent-Api\" ? \"Test\" : null;\n return clientSecret == null\n ? null\n : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, clientId) }, authenticationScheme));\n };\n });\n\n using var provider = services.BuildServiceProvider();\n var options = provider.GetRequiredService>().Get(authenticationScheme);\n\n Console.WriteLine($\"Authentication scheme: {options.AuthenticationScheme}\");\n }\n }\n}" + } + }, + { + "id": "33a9eebead040400ebcea602", + "exampleId": "Cuemon.Extensions.Text.Json.Converters.JsonConverterCollectionExtensions#1", + "uid": "Cuemon.Extensions.Text.Json.Converters.JsonConverterCollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Text.Json;\nusing System.Text.Json.Serialization;\nusing System.Text.Json.Serialization.Metadata;\nusing Cuemon;\nusing Cuemon.Diagnostics;\nusing Cuemon.Extensions.Text.Json.Converters;\nusing Cuemon.Extensions.Text.Json.Formatters;\n\nvar converters = new List();\nconverters.AddDateTimeConverter(\"yyyy-MM-dd HH:mm:ss\", CultureInfo.InvariantCulture);\nconverters.AddStringEnumConverter();\nconverters.AddStringFlagsEnumConverter();\nconverters.AddExceptionConverter(true, false);\nconverters.AddFailureConverter();\nconverters.AddTransientFaultExceptionConverter();\nconverters.AddExceptionDescriptorConverterOf(\n o => o.SensitivityDetails = FaultSensitivityDetails.All);\nconverters.AddDataPairConverter();\nconverters.RemoveAllOf();\nconverters.RemoveAllOf(typeof(TimeSpan));\n\nvar formatter = new JsonFormatter(o =>\n{\n o.Settings.TypeInfoResolver = new DefaultJsonTypeInfoResolver();\n o.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;\n foreach (var converter in converters)\n {\n o.Settings.Converters.Add(converter);\n }\n});\n\nvar person = new { FullName = \"Alice Johnson\", BirthDate = new DateTime(1990, 6, 15) };\nusing var jsonStream = JsonFormatter.SerializeObject(person, options =>\n{\n options.Settings.TypeInfoResolver = new DefaultJsonTypeInfoResolver();\n options.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;\n foreach (var converter in converters)\n {\n options.Settings.Converters.Add(converter);\n }\n});\njsonStream.Position = 0;\nusing var reader = new System.IO.StreamReader(jsonStream);\nstring json = reader.ReadToEnd();\nConsole.WriteLine(json);" + } + }, + { + "id": "3425b34190ca70c78e09169b", + "exampleId": "Cuemon.AspNetCore.Http.Headers.UserAgentSentinelMiddleware#1", + "uid": "Cuemon.AspNetCore.Http.Headers.UserAgentSentinelMiddleware", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.Options;\nusing Microsoft.Net.Http.Headers;\nusing Cuemon.AspNetCore.Http.Headers;\n\nawait UserAgentSentinelMiddlewareExample.DemonstrateAsync();\n\nnamespace Cuemon.AspNetCore.Http.Headers\n{\n public static class UserAgentSentinelMiddlewareExample\n {\n public static async Task DemonstrateAsync()\n {\n var context = new DefaultHttpContext();\n var options = Options.Create(new UserAgentSentinelOptions\n {\n RequireUserAgentHeader = true,\n ValidateUserAgentHeader = true,\n AllowedUserAgents = new List { \"Cuemon-Agent\" }\n });\n\n context.Request.Headers[HeaderNames.UserAgent] = \"Cuemon-Agent\";\n\n var middleware = new UserAgentSentinelMiddleware(\n httpContext =>\n {\n httpContext.Response.StatusCode = StatusCodes.Status200OK;\n return Task.CompletedTask;\n },\n options);\n\n await middleware.InvokeAsync(context);\n Console.WriteLine(context.Response.StatusCode);\n }\n }\n}" + } + }, + { + "id": "3497bf7eb6ead0a41a1c7f1f", + "exampleId": "Cuemon.AspNetCore.Http.Throttling.ThrottleRequest#1", + "uid": "Cuemon.AspNetCore.Http.Throttling.ThrottleRequest", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http.Throttling;\n\n var request = new ThrottleRequest(new ThrottleQuota(10, TimeSpan.FromMinutes(1)));\nrequest.IncrementTotal();\n\nConsole.WriteLine(request.Total);" + } + }, + { + "id": "34dd40245556c272d2dd3d26", + "exampleId": "Cuemon.AspNetCore.Mvc.CacheableObjectResultOptions`1#1", + "uid": "Cuemon.AspNetCore.Mvc.CacheableObjectResultOptions`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Cryptography;\nusing System.Text;\nusing Cuemon.AspNetCore.Mvc;\n\nvar options = new CacheableObjectResultOptions\n{\n ChecksumProvider = value => SHA256.HashData(Encoding.UTF8.GetBytes(value)),\n WeakChecksumProvider = _ => false,\n TimestampProvider = _ => DateTime.UtcNow,\n ChangedTimestampProvider = _ => DateTime.UtcNow\n};\n\noptions.ValidateOptions();\n\nvar data = \"hello-world\";\nbyte[] checksum = options.ChecksumProvider(data);\nConsole.WriteLine($\"Checksum length: {checksum.Length}\"); // 32 bytes (SHA256)\nConsole.WriteLine($\"Created: {options.TimestampProvider(data)}\");" + } + }, + { + "id": "36718f58d3842855ac0ecc47", + "exampleId": "Cuemon.AspNetCore.Http.UnsupportedMediaTypeException#1", + "uid": "Cuemon.AspNetCore.Http.UnsupportedMediaTypeException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http;\n\ntry\n{\n throw new UnsupportedMediaTypeException(\"text/html\");\n}\ncatch (UnsupportedMediaTypeException ex)\n{\n Console.WriteLine(ex.StatusCode); // 415\n}" + } + }, + { + "id": "3698a43fb3254212d9728bdf", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.ViewDataDictionaryExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.ViewDataDictionaryExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing Cuemon.AspNetCore.Mvc;\nusing Cuemon.Extensions.AspNetCore.Mvc;\nusing Microsoft.AspNetCore.Mvc;\nusing Microsoft.AspNetCore.Mvc.ModelBinding;\nusing Microsoft.AspNetCore.Mvc.Razor;\nusing Microsoft.AspNetCore.Mvc.Rendering;\nusing Microsoft.AspNetCore.Mvc.ViewFeatures;\nusing Microsoft.AspNetCore.Routing;\nusing Cuemon.Extensions.AspNetCore.Mvc.DocExamples;\n\nViewDataDictionaryExtensionsExample.Demonstrate();\n\nnamespace Cuemon.Extensions.AspNetCore.Mvc.DocExamples\n{\n public class RegionController : Controller\n {\n public IActionResult Index()\n {\n var model = new RegionPageModel(\"Regions\", \"Northern Europe\", \"Danish\");\n ViewData.AddBreadcrumbs(this, model, page => page.Labels);\n return new EmptyResult();\n }\n\n public IActionResult Region(string regionName, string regionDisplayName)\n {\n var model = new RegionPageModel(\"Regions\", regionDisplayName, \"Danish\");\n ViewData.AddBreadcrumbs(this, model, page => page.Labels);\n return new EmptyResult();\n }\n\n public IActionResult Culture(string regionName, string regionDisplayName, string cultureName)\n {\n var model = new RegionPageModel(\"Regions\", regionDisplayName, cultureName);\n ViewData.AddBreadcrumbs(this, model, page => page.Labels);\n return new EmptyResult();\n }\n }\n public static class ViewDataDictionaryExtensionsExample\n {\n public static void Demonstrate()\n {\n var controller = new RegionController\n {\n ControllerContext = new ControllerContext\n {\n RouteData = new RouteData()\n }\n };\n controller.ControllerContext.RouteData.Values[\"controller\"] = \"Region\";\n controller.ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary());\n\n var model = new RegionPageModel(\"Regions\", \"Northern Europe\", \"Danish\");\n controller.ViewData.AddBreadcrumbs(controller, model, page => page.Labels);\n\n var razorPage = new ExampleRazorPage\n {\n ViewContext = new ViewContext\n {\n RouteData = controller.ControllerContext.RouteData\n }\n };\n var breadcrumbs = controller.ViewData.GetBreadcrumbs(razorPage).ToList();\n foreach (var breadcrumb in breadcrumbs)\n {\n Console.WriteLine($\"{breadcrumb.Label} ({breadcrumb.ControllerName}/{breadcrumb.ActionName})\");\n }\n }\n }\n public sealed class ExampleRazorPage : RazorPage\n {\n public override Task ExecuteAsync() => Task.CompletedTask;\n }\n public sealed class RegionPageModel\n {\n public RegionPageModel(params string[] labels)\n {\n Labels = labels;\n }\n\n public IReadOnlyList Labels { get; }\n }\n}" + } + }, + { + "id": "36a7fa492f2fe4d8b40fa625", + "exampleId": "Cuemon.Reflection.ActivatorFactory#1", + "uid": "Cuemon.Reflection.ActivatorFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Reflection;\n\nvar sb = ActivatorFactory.CreateInstance();\nsb.Append(\"Hello from activator\");\nConsole.WriteLine(sb.ToString());\n\nvar dt = ActivatorFactory.CreateInstance(2025, 12, 1);\nConsole.WriteLine($\"Created: {dt:yyyy-MM-dd}\");" + } + }, + { + "id": "36aa9c4dcf443d4b791a19b7", + "exampleId": "Cuemon.Extensions.Net.Http.SlimHttpClientFactoryOptions#1", + "uid": "Cuemon.Extensions.Net.Http.SlimHttpClientFactoryOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing Cuemon.Extensions.Net.Http;\n\n// Direct instantiation of SlimHttpClientFactoryOptions\nvar factoryOptions = new SlimHttpClientFactoryOptions\n{\n HandlerLifetime = TimeSpan.FromSeconds(30)\n};\n\nvar factory = new SlimHttpClientFactory(\n () => new HttpClientHandler(),\n o =>\n {\n o.HandlerLifetime = TimeSpan.FromSeconds(30);\n });\n\n// Create a named client\nusing var client = factory.CreateClient(\"MyApi\");\nclient.BaseAddress = new Uri(\"https://api.example.com\");\n\nConsole.WriteLine($\"Client ready: {client.BaseAddress}\");" + } + }, + { + "id": "378f2cb9e4e9b97a25319b50", + "exampleId": "Cuemon.Threading.AdvancedParallelFactory#1", + "uid": "Cuemon.Threading.AdvancedParallelFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Threading;\n\nvar next = AdvancedParallelFactory.Iterator(5, AssignmentOperator.Addition, 3);\nConsole.WriteLine($\"5 + 3 = {next}\");\n\nvar isComplete = AdvancedParallelFactory.Condition(next, RelationalOperator.GreaterThanOrEqual, 8);\nConsole.WriteLine($\"Is loop condition met? {isComplete}\");" + } + }, + { + "id": "37f40b9fa3c262d6ee82d474", + "exampleId": "Cuemon.Data.TokenBuilder#1", + "uid": "Cuemon.Data.TokenBuilder", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Data;\n\n// Build a token string with 4 fields, comma-delimited, double-quote qualified\nvar builder = new TokenBuilder(',', '\"', 4);\n\nbuilder.Append(\"Alice\");\nbuilder.Append(\",30,\");\nbuilder.Append(\"New York\");\n\nConsole.WriteLine($\"Is valid: {builder.IsValid}\"); // false - only 3 of 4 tokens\nConsole.WriteLine($\"Current: '{builder}'\");\n\n// Append the last field to complete the token row\nbuilder.Append(\"Engineer\");\nConsole.WriteLine($\"Is valid: {builder.IsValid}\"); // true\nConsole.WriteLine($\"Complete: '{builder}'\");\n\n// TokenBuilder is used internally by DsvDataReader for multi-line quoted fields\n// It accumulates input until the expected number of tokens is reached\nvar csvBuilder = new TokenBuilder(';', '\\\"', 3);\ncsvBuilder.Append(\"Product A\");\ncsvBuilder.Append(\"Description with ; semicolon\");\ncsvBuilder.Append(\"$49.99\");\n\nConsole.WriteLine($\"CSV line: '{csvBuilder}'\");\nConsole.WriteLine($\"Tokens: {csvBuilder.Tokens}\");" + } + }, + { + "id": "380d9162584a0d1f996f0f51", + "exampleId": "Cuemon.ArgumentReservedKeywordException#1", + "uid": "Cuemon.ArgumentReservedKeywordException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\nvar reservedKeywords = new[] { \"select\", \"insert\", \"update\", \"delete\", \"from\", \"where\" };\ntry\n{\n var columnName = \"select\";\n if (Array.Exists(reservedKeywords, keyword => string.Equals(keyword, columnName, StringComparison.OrdinalIgnoreCase)))\n {\n throw new ArgumentReservedKeywordException(\"sortBy\", columnName, \"Value must not be a reserved SQL keyword.\");\n }\n}\ncatch (ArgumentReservedKeywordException ex)\n{\n Console.WriteLine(ex.Message);\n Console.WriteLine(ex.ParamName);\n}" + } + }, + { + "id": "396a26c3c4044f3f7f24a942", + "exampleId": "Cuemon.Data.Integrity.ChecksumBuilderDecoratorExtensions#1", + "uid": "Cuemon.Data.Integrity.ChecksumBuilderDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Security;\n\n// Create a ChecksumBuilder wrapped in a Decorator\nvar builder = new ChecksumBuilder(() => HashFactory.CreateFnv128());\nvar decorator = Decorator.Enclose(builder);\n\n// Combine various typed values using the decorator extensions\ndecorator.CombineWith(42); // int\ndecorator.CombineWith(3.14); // double\ndecorator.CombineWith(\"tag\"); // string\n\nConsole.WriteLine($\"Combined checksum: {builder}\");\n\n// The extensions return the inner builder for chaining\nvar combined = decorator.CombineWith(12345L); // long\nConsole.WriteLine($\"Returned type: {combined.GetType().Name}\");\n\n// Extension methods also work with short, float, ushort, uint, ulong\nvar shortDecorator = Decorator.Enclose(new ChecksumBuilder(() => HashFactory.CreateFnv32()));\nshortDecorator.CombineWith((short)100);\nshortDecorator.CombineWith(3.14f);\nshortDecorator.CombineWith(42u);\n\nConsole.WriteLine($\"Short builder: {shortDecorator.Inner}\");" + } + }, + { + "id": "3a45aa3985c05f063c7c9208", + "exampleId": "Cuemon.AspNetCore.Http.GoneException#1", + "uid": "Cuemon.AspNetCore.Http.GoneException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http;\n\nGoneExceptionExample.Demonstrate();\n\nnamespace Cuemon.AspNetCore.Http\n{\n public static class GoneExceptionExample\n {\n public static void Demonstrate()\n {\n var exception = CreateArchivedEndpointException(\"/v1/orders\");\n\n Console.WriteLine(exception.Message);\n Console.WriteLine(exception.StatusCode);\n }\n\n private static GoneException CreateArchivedEndpointException(string route)\n {\n return new GoneException($\"The resource at '{route}' has been retired.\");\n }\n }\n}" + } + }, + { + "id": "3b28b53c450a6c66e223b00a", + "exampleId": "Cuemon.Runtime.Caching.CacheEntry#1", + "uid": "Cuemon.Runtime.Caching.CacheEntry", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Runtime.Caching@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Runtime.Caching;\n\nvar cache = new SlimMemoryCache();\nvar entry = new CacheEntry(\"session\", \"cached-value\", \"docs\");\n\ncache.Add(entry, new CacheInvalidation(TimeSpan.FromSeconds(30)));\n\nConsole.WriteLine(entry.CanExpire);\nConsole.WriteLine(entry.HasExpired(entry.Accessed.AddSeconds(31)));\nConsole.WriteLine(entry.ToString().Contains(\"Key=session\"));" + } + }, + { + "id": "3b469bb8d03f3c851d439824", + "exampleId": "Cuemon.Security.Cryptography.SecureHashAlgorithm512#1", + "uid": "Cuemon.Security.Cryptography.SecureHashAlgorithm512", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\n\nvar algorithm = new SecureHashAlgorithm512();\nvar result = algorithm.ComputeHash(Encoding.UTF8.GetBytes(\"Payload for SHA-512\"));\n\nConsole.WriteLine(SecureHashAlgorithm512.BitSize);\nConsole.WriteLine(result.ToBase64String());" + } + }, + { + "id": "3b5f060e17513c9295871392", + "exampleId": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeader#1", + "uid": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeader", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Authentication.Basic;\n\nvar header = new BasicAuthorizationHeader(\"Agent\", \"Test\");\nvar parsed = BasicAuthorizationHeader.Create(header.ToString());\n\nConsole.WriteLine(parsed.UserName);\nConsole.WriteLine(parsed.Password);" + } + }, + { + "id": "3c570e4be310f90ecd8e1ce1", + "exampleId": "Cuemon.Runtime.WatcherOptions#1", + "uid": "Cuemon.Runtime.WatcherOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Runtime;\nusing Examples;\n\nConsole.WriteLine(new WatcherConfigurationExample().ConfigureWatcher());\n\nnamespace Examples\n{\n public class WatcherConfigurationExample\n {\n public WatcherOptions ConfigureWatcher()\n {\n return new WatcherOptions\n {\n DueTime = TimeSpan.FromSeconds(5),\n DueTimeOnChanged = TimeSpan.FromSeconds(2),\n Period = TimeSpan.FromMinutes(1)\n };\n\n }\n }\n}" + } + }, + { + "id": "3ca6246bd7b92fef1399e250", + "exampleId": "Cuemon.Collections.Generic.PartitionerCollection`1#1", + "uid": "Cuemon.Collections.Generic.PartitionerCollection`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon.Collections.Generic;\n\n var numbers = new List();\n for (int i = 1; i <= 50; i++) numbers.Add(i);\n\n // Process in partitions of 12 items each\n var partitioner = new PartitionerCollection(numbers, partitionSize: 12);\n\n Console.WriteLine($\"Total items: {partitioner.Count}\");\n Console.WriteLine($\"Partition size: {partitioner.PartitionSize}\");\n Console.WriteLine($\"Total partitions: {partitioner.PartitionsCount}\");\n Console.WriteLine($\"Items remaining: {partitioner.Remaining}\");\n Console.WriteLine();\n\n int partitionIndex = 0;\n while (partitioner.HasPartitions)\n {\n partitionIndex++;\n Console.Write($\"Partition {partitionIndex}: \");\n foreach (var item in partitioner)\n {\n Console.Write($\"{item} \");\n Console.WriteLine();\n\n Console.WriteLine();\n Console.WriteLine($\"Iterated count: {partitioner.IteratedCount}\");\n Console.WriteLine($\"Has remaining partitions: {partitioner.HasPartitions}\");\n\n}}" + } + }, + { + "id": "3cdf2c3b0adc0e028fa64fc7", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseFormatter`1#1", + "uid": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseFormatter`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing Cuemon.Configuration;\nusing Cuemon.Net.Http;\nusing Cuemon.AspNetCore.Diagnostics;\n\nHttpExceptionDescriptorResponseFormatterExample.Demonstrate();\n\nnamespace Cuemon.AspNetCore.Diagnostics\n{\n public static class HttpExceptionDescriptorResponseFormatterExample\n {\n public static void Demonstrate()\n {\n var formatter = new HttpExceptionDescriptorResponseFormatter(_ => { });\n\n formatter.Populate((exceptionDescriptor, mediaType) =>\n new StringContent($\"{exceptionDescriptor.StatusCode}:{mediaType.MediaType}\"));\n\n var exceptionDescriptor = new HttpExceptionDescriptor(\n new InvalidOperationException(\"boom\"),\n 418,\n \"Teapot\",\n \"Short and stout\");\n\n using var response = formatter.ExceptionDescriptorHandlers.First().ToHttpResponseMessage(exceptionDescriptor);\n Console.WriteLine(response.Content.ReadAsStringAsync().GetAwaiter().GetResult());\n }\n\n private sealed class SampleFormatterOptions : IContentNegotiation, IParameterObject\n {\n public IReadOnlyCollection SupportedMediaTypes { get; } =\n new[] { new MediaTypeHeaderValue(\"text/plain\") };\n }\n }\n}" + } + }, + { + "id": "3cf6ccbbe5b170a6c71d8dcc", + "exampleId": "Cuemon.Resilience.LatencyException#1", + "uid": "Cuemon.Resilience.LatencyException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Resilience@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Resilience;\n\nvar timeout = new TimeoutException(\"The database query timed out after 10 seconds.\");\nvar exception = new LatencyException(\"Order processing exceeded the configured latency threshold.\", timeout);\n\nConsole.WriteLine(exception.Message);\nConsole.WriteLine(exception.InnerException?.Message);" + } + }, + { + "id": "3d27d308c780a23b0b019aee", + "exampleId": "Cuemon.Reflection.MethodInfoDecoratorExtensions#1", + "uid": "Cuemon.Reflection.MethodInfoDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Reflection;\nusing Cuemon;\nusing Cuemon.Reflection;\nusing MyApp.Examples;\n\nMethodInfoDecoratorExtensionsExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class MethodInfoDecoratorExtensionsExample\n {\n public static void Demonstrate()\n {\n MethodInfo baseMethod = typeof(PricingCalculator).GetMethod(nameof(PricingCalculator.Calculate))!;\n MethodInfo derivedMethod = typeof(RegionalPricingCalculator).GetMethod(nameof(PricingCalculator.Calculate))!;\n MethodInfo localMethod = typeof(RegionalPricingCalculator).GetMethod(nameof(RegionalPricingCalculator.FormatRegion))!;\n\n Console.WriteLine(Decorator.Enclose(baseMethod).IsOverridden());\n Console.WriteLine(Decorator.Enclose(derivedMethod).IsOverridden());\n Console.WriteLine(Decorator.Enclose(localMethod).IsOverridden());\n }\n }\n public class PricingCalculator\n {\n public virtual decimal Calculate(decimal subtotal)\n {\n return subtotal;\n }\n }\n public sealed class RegionalPricingCalculator : PricingCalculator\n {\n public override decimal Calculate(decimal subtotal)\n {\n return subtotal * 1.25m;\n }\n\n public string FormatRegion()\n {\n return \"EU\";\n }\n }\n}" + } + }, + { + "id": "3dbd1a9e97c17497277c18d3", + "exampleId": "Cuemon.AspNetCore.Authentication.NonceTrackerEntry#1", + "uid": "Cuemon.AspNetCore.Authentication.NonceTrackerEntry", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Authentication;\n\nvar entry = new NonceTrackerEntry(1, DateTime.UtcNow);\nConsole.WriteLine($\"Count: {entry.Count}, Created: {entry.Created}\");" + } + }, + { + "id": "3ddedc003c170d6e2f9598e3", + "exampleId": "Cuemon.Extensions.MethodDescriptorExtensions#1", + "uid": "Cuemon.Extensions.MethodDescriptorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Reflection;\nusing Cuemon.Extensions;\nusing Cuemon.Reflection;\n\nMethodInfo writeLine = typeof(Console).GetMethod(nameof(Console.WriteLine), new[] { typeof(string) });\nMethodInfo newGuid = typeof(Guid).GetMethod(nameof(Guid.NewGuid), BindingFlags.Public | BindingFlags.Static);\n\nMethodDescriptor withParameters = MethodDescriptor.Create(writeLine);\nMethodDescriptor withoutParameters = MethodDescriptor.Create(newGuid);\n\nConsole.WriteLine(withParameters.HasParameters());\nConsole.WriteLine(withoutParameters.HasParameters());\nConsole.WriteLine(withParameters.Method.Name);\nConsole.WriteLine(withParameters.Caller?.Name);" + } + }, + { + "id": "3ec5f5ad48174f484467c21a", + "exampleId": "Cuemon.Diagnostics.AsyncTimeMeasureOptions#1", + "uid": "Cuemon.Diagnostics.AsyncTimeMeasureOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Diagnostics@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading;\nusing Cuemon.Diagnostics;\nusing Cuemon.Reflection;\n\nvar options = new AsyncTimeMeasureOptions\n{\n TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(100),\n CancellationToken = CancellationToken.None,\n MethodDescriptor = () => MethodDescriptor.Create(typeof(AsyncTimeMeasureOptions).GetMethod(nameof(ToString))!),\n RuntimeParameters = new object[] { \"warmup\" }\n};\n\nConsole.WriteLine(options.TimeMeasureCompletedThreshold);\nConsole.WriteLine(options.CancellationToken.CanBeCanceled);\nConsole.WriteLine(options.MethodDescriptor().MethodName);\nConsole.WriteLine(options.RuntimeParameters.Length);" + } + }, + { + "id": "3f32907bd26e45c902b55415", + "exampleId": "Cuemon.Diagnostics.TimeMeasureProfiler`1#1", + "uid": "Cuemon.Diagnostics.TimeMeasureProfiler`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Diagnostics@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading;\nusing Cuemon.Diagnostics;\nusing MyApp.Examples;\n\nnew TimeMeasureProfilerOfTExample().Demonstrate();\n\nnamespace MyApp.Examples\n{\n public class TimeMeasureProfilerOfTExample\n {\n public void Demonstrate()\n {\n // TimeMeasure.WithFunc returns a TimeMeasureProfiler\n TimeMeasureProfiler profiler = TimeMeasure.WithFunc(() =>\n {\n Thread.Sleep(100);\n return 42;\n });\n\n Console.WriteLine($\"Result: {profiler.Result}\"); // 42\n Console.WriteLine($\"Elapsed: {profiler.Elapsed}\"); // ~00:00:00.100\n Console.WriteLine($\"IsRunning: {profiler.IsRunning}\"); // False\n Console.WriteLine($\"Member: {profiler.Member}\"); // \n Console.WriteLine(profiler.ToString());\n // Output: took 00:00:00.100 to execute.\n\n }\n }\n}" + } + }, + { + "id": "3f6dedaa279ad5c1e62aabcc", + "exampleId": "Cuemon.Xml.Serialization.Converters.DefaultXmlConverter#1", + "uid": "Cuemon.Xml.Serialization.Converters.DefaultXmlConverter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing Cuemon.Xml.Serialization;\nusing Cuemon.Xml.Serialization.Converters;\nusing System.Xml;\n\nvar converter = new DefaultXmlConverter(new XmlQualifiedEntity(\"String\"), new List());\n\nusing var buffer = new MemoryStream();\nusing (var writer = XmlWriter.Create(buffer, new XmlWriterSettings { OmitXmlDeclaration = true }))\n{\n converter.WriteXml(writer, \"Hello World\");\n}\n\nbuffer.Position = 0;\nusing var reader = XmlReader.Create(buffer);\nvar value = (string)converter.ReadXml(reader, typeof(string));\n\nConsole.WriteLine(value);\nConsole.WriteLine(converter.CanConvert(typeof(string)));" + } + }, + { + "id": "3fa40350e64c54af5412345c", + "exampleId": "Cuemon.FuncFactory`2#1", + "uid": "Cuemon.FuncFactory`2", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\nvar factory = new FuncFactory, string>(\n tuple => $\"{tuple.Arg1}-{tuple.Arg2:D3}\",\n new MutableTuple(\"Item\", 7));\n\nstring result = factory.ExecuteMethod();\nvar clone = (FuncFactory, string>)factory.Clone();\n\nConsole.WriteLine(result);\nConsole.WriteLine(clone.ExecuteMethod());" + } + }, + { + "id": "3febff6ede30c55f989abf1d", + "exampleId": "Cuemon.Security.Cryptography.AesSize#1", + "uid": "Cuemon.Security.Cryptography.AesSize", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Security.Cryptography;\n\n// AesSize specifies the key size for the AES symmetric algorithm:\n// Aes128 = 128-bit key (16 bytes)\n// Aes192 = 192-bit key (24 bytes)\n// Aes256 = 256-bit key (32 bytes, default)\n\n// Generate a 256-bit key (default when no options are specified)\nbyte[] defaultKey = AesCryptor.GenerateKey();\nConsole.WriteLine($\"Default key length: {defaultKey.Length} bytes\"); // 32\n\n// Generate a 128-bit key using AesSize.Aes128\nbyte[] key128 = AesCryptor.GenerateKey(o => o.Size = AesSize.Aes128);\nConsole.WriteLine($\"128-bit key length: {key128.Length} bytes\"); // 16\n\n// Generate a 192-bit key using AesSize.Aes192\nbyte[] key192 = AesCryptor.GenerateKey(o => o.Size = AesSize.Aes192);\nConsole.WriteLine($\"192-bit key length: {key192.Length} bytes\"); // 24\n\n// Generate a 256-bit key explicitly using AesSize.Aes256\nbyte[] key256 = AesCryptor.GenerateKey(o => o.Size = AesSize.Aes256);\nConsole.WriteLine($\"256-bit key length: {key256.Length} bytes\"); // 32\n\n// Compare enum values directly\nAesSize size = AesSize.Aes256;\nConsole.WriteLine($\"Selected size: {size}\"); // Aes256\nConsole.WriteLine($\"Is Aes256 selected: {size == AesSize.Aes256}\"); // True" + } + }, + { + "id": "3aac83bb28540493975983f4", + "exampleId": "Cuemon.Xml.XmlEncodingOptions#1", + "uid": "Cuemon.Xml.XmlEncodingOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing System.Xml;\nusing Cuemon.Text;\nusing Cuemon.Xml;\n\n// Configure XML encoding options.\nvar options = new XmlEncodingOptions\n{\n Encoding = Encoding.UTF8,\n Preamble = EncodingOptions.DefaultPreambleSequence,\n OmitXmlDeclaration = false\n};\n\nConsole.WriteLine($\"Encoding: {options.Encoding.WebName}\"); // utf-8\nConsole.WriteLine($\"Omit XML declaration: {options.OmitXmlDeclaration}\"); // False\n\n// Write XML with explicit encoding settings.\nvar settings = new XmlWriterSettings\n{\n Encoding = options.Encoding,\n OmitXmlDeclaration = options.OmitXmlDeclaration,\n Indent = true\n};\n\nusing var writer = XmlWriter.Create(Stream.Null, settings);\nwriter.WriteStartDocument();\nwriter.WriteStartElement(\"root\");\nwriter.WriteElementString(\"value\", \"Hello, World!\");\nwriter.WriteEndElement();\nwriter.WriteEndDocument();\nwriter.Flush();\n\n// Omit the XML declaration.\noptions.OmitXmlDeclaration = true;\nConsole.WriteLine($\"Omit XML declaration now: {options.OmitXmlDeclaration}\"); // True" + } + }, + { + "id": "40281d8326ddd29f2ee45664", + "exampleId": "Cuemon.Extensions.Text.Json.JsonSerializerOptionsExtensions#1", + "uid": "Cuemon.Extensions.Text.Json.JsonSerializerOptionsExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "using System;\nusing System.Text.Json;\nusing Cuemon.Extensions.Text.Json;\n\nnamespace MyApp.Examples;\n\npublic class JsonSerializerOptionsExtensionsExample\n{\n public static void Main()\n {\n // Create base options with a camelCase naming policy\n var baseOptions = new JsonSerializerOptions\n {\n PropertyNamingPolicy = JsonNamingPolicy.CamelCase,\n WriteIndented = true\n };\n\n // Clone the options and override the WriteIndented setting\n JsonSerializerOptions cloned = baseOptions.Clone(options =>\n {\n options.WriteIndented = false;\n });\n Console.WriteLine($\"Original WriteIndented: {baseOptions.WriteIndented}\"); // True\n Console.WriteLine($\"Cloned WriteIndented: {cloned.WriteIndented}\"); // False\n\n // SetPropertyName converts property names according to the naming policy\n string propertyName = baseOptions.SetPropertyName(\"OrderDate\");\n Console.WriteLine($\"Converted property name: {propertyName}\"); // Output: \"orderDate\"\n\n // When no naming policy is set, the name is returned unaltered\n var plainOptions = new JsonSerializerOptions();\n string unchanged = plainOptions.SetPropertyName(\"OrderDate\");\n Console.WriteLine($\"Unchanged property name: {unchanged}\"); // Output: \"OrderDate\"\n\n}\n}" + } + }, + { + "id": "40fe571a68ed6d1303ff9d33", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpEntityTagHeaderFilter#1", + "uid": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpEntityTagHeaderFilter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Mvc.Filters.Cacheable;\n\nvar filter = new HttpEntityTagHeaderFilter(o => o.UseEntityTagResponseParser = true);\nvar options = new HttpCacheableOptions();\noptions.Filters.Add(filter);\n\nConsole.WriteLine(filter.Options.UseEntityTagResponseParser);\nConsole.WriteLine(options.Filters.Count);" + } + }, + { + "id": "40ffa641c4095bb1836c0463", + "exampleId": "Cuemon.Security.NonCryptoAlgorithm#1", + "uid": "Cuemon.Security.NonCryptoAlgorithm", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "using System;\nusing Cuemon.Security;\n\nnamespace MyApp.Examples;\n\npublic class NonCryptoAlgorithmExample\n{\n public static void Main()\n {\n NonCryptoAlgorithm[] algorithms = \n {\n NonCryptoAlgorithm.Fnv32,\n NonCryptoAlgorithm.Fnv64,\n NonCryptoAlgorithm.Fnv128,\n NonCryptoAlgorithm.Fnv256,\n NonCryptoAlgorithm.Fnv512,\n NonCryptoAlgorithm.Fnv1024\n };\n\n foreach (var algo in algorithms)\n {\n Console.WriteLine(\"{0} (value: {1})\", algo, (int)algo);\n\n // Output:\n // Fnv32 (value: 0)\n // Fnv64 (value: 1)\n // Fnv128 (value: 2)\n // Fnv256 (value: 3)\n // Fnv512 (value: 4)\n // Fnv1024 (value: 5)\n\n}}\n}" + } + }, + { + "id": "4123c6922ad7b0b26087495b", + "exampleId": "Cuemon.Runtime.Caching.CacheInvalidation#1", + "uid": "Cuemon.Runtime.Caching.CacheInvalidation", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Runtime.Caching@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Runtime.Caching; // for CacheInvalidation\n\n// Absolute expiration at a specific UTC time\nvar absolute = new CacheInvalidation(new DateTime(2025, 12, 31, 23, 59, 59, DateTimeKind.Utc));\nConsole.WriteLine(absolute.UseAbsoluteExpiration); // True\nConsole.WriteLine(absolute.AbsoluteExpiration); // 12/31/2025 23:59:59\nConsole.WriteLine(absolute.UseSlidingExpiration); // False\nConsole.WriteLine(absolute.UseDependency); // False\n\n// Sliding expiration (entry expires after 30 minutes of inactivity)\nvar sliding = new CacheInvalidation(TimeSpan.FromMinutes(30));\nConsole.WriteLine(sliding.UseSlidingExpiration); // True\nConsole.WriteLine(sliding.SlidingExpiration); // 00:30:00\nConsole.WriteLine(sliding.UseAbsoluteExpiration); // False" + } + }, + { + "id": "41e66d37f58ed90ef34eeeef", + "exampleId": "Cuemon.Extensions.Hosting.HostEnvironmentExtensions#1", + "uid": "Cuemon.Extensions.Hosting.HostEnvironmentExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Hosting@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0", + "Microsoft.Extensions.Hosting@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nusing var host = Host.CreateDefaultBuilder()\n .UseEnvironment(Cuemon.Extensions.Hosting.Environments.LocalDevelopment)\n .Build();\n\nvar environment = host.Services.GetRequiredService();\nConsole.WriteLine(environment.IsLocalDevelopment());\nConsole.WriteLine(environment.IsNonProduction());" + } + }, + { + "id": "42a26341576df948b9bb2430", + "exampleId": "Cuemon.Extensions.DependencyInjection.ServiceCollectionExtensions#2", + "uid": "Cuemon.Extensions.DependencyInjection.ServiceCollectionExtensions", + "fenceOrdinal": 2, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.DependencyInjection@11.0.0" + ], + "source": "using System;\nusing Cuemon.Configuration;\nusing Cuemon.Extensions.DependencyInjection;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\n\nnamespace Delivery.Configuration;\n\npublic static class DeliveryApplication\n{\n public static void Main()\n {\n Action setup = options =>\n {\n options.MaxAttempts = 3;\n options.RetryDelay = TimeSpan.FromSeconds(5);\n };\n var services = new ServiceCollection();\n services.AddConfiguredOptions(setup);\n services.Configure(options => options.MaxAttempts = 4);\n\n using (var provider = services.BuildServiceProvider())\n {\n var delivery = provider.GetRequiredService();\n var microsoftOptions = provider.GetRequiredService>().Value;\n Console.WriteLine($\"Attempts: {delivery.MaxAttempts}; retry budget: {delivery.RetryBudget.TotalSeconds} seconds\");\n Console.WriteLine($\"Shared default instance: {ReferenceEquals(delivery, microsoftOptions)}\");\n\n var configure = provider.GetRequiredService>();\n var fresh = new DeliveryOptions();\n configure(fresh);\n Console.WriteLine($\"Primary configurator attempts: {fresh.MaxAttempts}\");\n }\n }\n}\n\npublic sealed class DeliveryOptions : IPostConfigurableParameterObject, IValidatableParameterObject\n{\n public int MaxAttempts { get; set; }\n\n public TimeSpan RetryDelay { get; set; }\n\n public TimeSpan RetryBudget { get; private set; }\n\n public void PostConfigureOptions()\n {\n RetryBudget = TimeSpan.FromTicks(RetryDelay.Ticks * (MaxAttempts - 1));\n }\n\n public void ValidateOptions()\n {\n if (MaxAttempts < 1 || RetryDelay < TimeSpan.Zero)\n {\n throw new InvalidOperationException(\"Delivery requires at least one attempt and a nonnegative retry delay.\");\n }\n }\n}" + } + }, + { + "id": "439d502fc2a2ac0ece7c9a8a", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcCoreBuilderExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcCoreBuilderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text.Json;\nusing System.Text.Json.Serialization;\nusing Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json;\nusing Microsoft.Extensions.DependencyInjection;\n\nvar services = new ServiceCollection();\nservices.AddLogging();\nvar builder = services.AddMvcCore();\n\nbuilder.AddJsonFormatters(options =>\n{\n options.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;\n options.Settings.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;\n});\n\nbuilder.AddJsonFormattersOptions(options =>\n{\n options.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;\n});\n\nusing var provider = services.BuildServiceProvider();\nConsole.WriteLine(\"MVC Core JSON formatters configured.\");" + } + }, + { + "id": "43e15cf103357bbad8066400", + "exampleId": "Cuemon.Extensions.Globalization.StatisticalRegionExtensions#1", + "uid": "Cuemon.Extensions.Globalization.StatisticalRegionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Globalization;\nusing System.Linq;\nusing Cuemon.Extensions.Globalization;\nusing Cuemon.Globalization;\n\n// Access regions via the World class\nvar world = World.GetStatisticalRegion(\"001\");\nvar europe = World.GetStatisticalRegion(\"150\");\nvar westernEurope = World.GetStatisticalRegion(\"155\");\nvar denmark = World.GetCountry(\"208\"); // Denmark M.49 code\nvar usa = World.GetCountry(\"840\"); // United States M.49 code\n\n// Classify by kind using the extension methods\nbool isWorld = world.IsWorld(); // true\nbool isRegion = europe.IsRegion(); // true (continent)\nbool isSubregion = westernEurope.IsSubregion(); // true\nbool isCountry = denmark.IsCountryOrTerritory(); // true\nbool isArea = europe.IsArea(); // true (not a country)\nbool isCountryArea = denmark.IsArea(); // false (is a country)\n\n// Check intermediate regions (sub-Saharan Africa, Latin America)\nvar subSaharanAfrica = World.GetStatisticalRegion(\"202\");\nbool isIntermediate = subSaharanAfrica.IsIntermediateRegion(); // true\n\n// Verify hierarchy\nbool denmarkIsInEurope = denmark.Parent.IsSubregion(); // true (Northern Europe, M.49: 154)\n\n// Check if a country has associated .NET RegionInfo\nbool hasRegionInfo = usa.HasRegionInfo(); // true (US has RegionInfo)\nbool noRegionInfo = world.HasRegionInfo(); // false (World is not a country)\n\n// Check if a region has ISO codes\nbool hasIso = denmark.HasIsoCodes(); // true\n\n// Iterate all countries\nint countryCount = world.Countries.Count();\nConsole.WriteLine($\"Total countries/territories: {countryCount}\");\n\n// Find a country by RegionInfo\nvar regionInfo = new RegionInfo(\"US\");\nvar usaByRegion = World.GetCountry(regionInfo);\nConsole.WriteLine(usaByRegion.IsCountryOrTerritory()); // True\n\n// Traverse the hierarchy\nforeach (var ancestor in denmark.GetAncestors())\n{\n Console.WriteLine($\"{ancestor.Name} ({ancestor.Kind})\");\n// \"Northern Europe (Subregion)\"\n// \"Europe (Region)\"\n// \"World (World)\"\n\n}" + } + }, + { + "id": "4408680283ba9c5ceec80e59", + "exampleId": "Cuemon.Reflection.MemberArgument#1", + "uid": "Cuemon.Reflection.MemberArgument", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Reflection;\n\n // Create a MemberArgument to represent a method parameter and its value.\n var arg = new MemberArgument(\"id\", 42);\n Console.WriteLine(\"Name: {0}\", arg.Name); // id\n Console.WriteLine(\"Value: {0}\", arg.Value); // 42\n Console.WriteLine(\"Priority: {0}\", arg.Priority); // 0\n\n // Create arguments for use with MemberParser rehydration.\n var memberArguments = new[]\n {\n new MemberArgument(\"name\", \"Widget\"),\n new MemberArgument(\"price\", 19.99m),\n new MemberArgument(\"quantity\", 100)\n };\n\n // Priority can control the order of processing.\n memberArguments[0].Priority = 2;\n memberArguments[1].Priority = 1;\n memberArguments[2].Priority = 0;\n\n foreach (var a in memberArguments)\n {\n Console.WriteLine(\"{0} = {1} (priority {2})\", a.Name, a.Value, a.Priority);\n\n // Update a value after creation.\n var updatable = new MemberArgument(\"status\", \"pending\");\n updatable.Value = \"shipped\";\n updatable.Priority = 5;\n Console.WriteLine(\"Updated: {0}\", updatable); // [status, shipped, 5]\n\n}" + } + }, + { + "id": "441806c905cfc583ffaa10bf", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpCacheableOptions#1", + "uid": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpCacheableOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Mvc.Filters.Cacheable;\nusing Microsoft.Net.Http.Headers;\n\nvar options = new HttpCacheableOptions\n{\n CacheControl = new CacheControlHeaderValue\n {\n MaxAge = TimeSpan.FromMinutes(15),\n Public = true,\n MustRevalidate = false\n }\n};\n\noptions.Filters.Add(new HttpEntityTagHeaderFilter(o => o.UseEntityTagResponseParser = true));\noptions.Filters.Add(new HttpLastModifiedHeaderFilter());\n\nConsole.WriteLine(options.UseCacheControl);\nConsole.WriteLine(options.Filters.Count);\nConsole.WriteLine(options.CacheControl.MaxAge);" + } + }, + { + "id": "44457624f72a018856da7cdb", + "exampleId": "Cuemon.AspNetCore.Mvc.ForbiddenResult#1", + "uid": "Cuemon.AspNetCore.Mvc.ForbiddenResult", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Mvc;\nusing Microsoft.AspNetCore.Http;\n\nvar forbidden = new ForbiddenResult();\nvar disguised = new ForbiddenResult(StatusCodes.Status404NotFound);\n\nConsole.WriteLine(forbidden.StatusCode);\nConsole.WriteLine(disguised.StatusCode);" + } + }, + { + "id": "454fd225893181847ca8ef17", + "exampleId": "Cuemon.Threading.AsyncActionFactory`1#1", + "uid": "Cuemon.Threading.AsyncActionFactory`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Cuemon;\nusing Cuemon.Threading;\n\nvar factory = AsyncActionFactory.Create(\n async (channel, retryCount, cancellationToken) =>\n {\n await Task.Delay(10, cancellationToken).ConfigureAwait(false);\n Console.WriteLine($\"{channel}:{retryCount}\");\n },\n \"orders\",\n 3);\n\nawait factory.ExecuteMethodAsync(CancellationToken.None);\n\nvar clone = (AsyncActionFactory>)factory.Clone();\nawait clone.ExecuteMethodAsync(CancellationToken.None);" + } + }, + { + "id": "455fdc5793763e974d21a5e3", + "exampleId": "Cuemon.Extensions.AspNetCore.Xml.Formatters.ServiceCollectionExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Xml.Formatters.ServiceCollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore.Xml@11.0.0", + "Cuemon.Xml@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.Extensions.AspNetCore.Xml.Formatters;\nusing Cuemon.Xml.Serialization.Formatters;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\n\nvar services = new ServiceCollection();\nservices.AddXmlFormatterOptions(options =>\n{\n options.SynchronizeWithXmlConvert = true;\n});\nservices.AddXmlExceptionResponseFormatter();\n\nusing var provider = services.BuildServiceProvider();\nvar options = provider.GetRequiredService>().Value;\nvar formatters = provider.GetServices().ToList();\n\nConsole.WriteLine(options.SynchronizeWithXmlConvert);\nConsole.WriteLine(formatters.Count);" + } + }, + { + "id": "468539edc62a30bb2cca15ef", + "exampleId": "Cuemon.Extensions.AspNetCore.Data.Integrity.CacheValidatorExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Data.Integrity.CacheValidatorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Extensions.AspNetCore.Data.Integrity;\nusing Microsoft.Net.Http.Headers;\n\nCacheValidator weakValidator = CacheValidatorFactory.CreateValidator(typeof(CacheValidatorExtensions).Assembly);\nEntityTagHeaderValue weakEntityTag = weakValidator.ToEntityTagHeaderValue();\n\nCacheValidator strongValidator = CacheValidatorFactory.CreateValidator(\n typeof(CacheValidatorExtensions).Assembly,\n setup: options => options.BytesToRead = int.MaxValue);\n\nEntityTagHeaderValue strongEntityTag = strongValidator.ToEntityTagHeaderValue();\n\nConsole.WriteLine(weakEntityTag);\nConsole.WriteLine(strongEntityTag);" + } + }, + { + "id": "4746b9af704ee48f922818b8", + "exampleId": "Cuemon.DateTimeRange#1", + "uid": "Cuemon.DateTimeRange", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\n// Create a date-time range representing January 2026\nvar start = new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc);\nvar end = new DateTime(2026, 1, 31, 23, 59, 59, DateTimeKind.Utc);\nvar range = new DateTimeRange(start, end);\n\n// Access start and end points\nConsole.WriteLine($\"Start: {range.Start:O}\"); // 2026-01-01T00:00:00.0000000Z\nConsole.WriteLine($\"End: {range.End:O}\"); // 2026-01-31T23:59:59.0000000Z\n\n// Duration between start and end\nConsole.WriteLine($\"Duration: {range.Duration.Days} days\"); // 30 days\nConsole.WriteLine($\"Duration: {range.Duration}\"); // 30.23:59:59\n\n// Default ToString() uses sortable format\nConsole.WriteLine(range.ToString()); // \"2026-01-01T00:00:00\"\n\n// Custom format with invariant culture\nConsole.WriteLine(range.ToString(\"d\", null)); // \"1/1/2026 ... 1/31/2026\"\n\n// Equality comparison via the inherited IEqualityComparer>\nvar sameRange = new DateTimeRange(start, end);\nConsole.WriteLine(range.Equals(range, sameRange)); // True\n\nvar differentRange = new DateTimeRange(start, new DateTime(2026, 2, 1));\nConsole.WriteLine(range.Equals(range, differentRange)); // False\n\n// Hash code based on start and end\nvar hash = range.GetHashCode(range);\nConsole.WriteLine($\"Hash: {hash}\");\n\n// Practical use: measure a business period\nvar quarterStart = new DateTime(2026, 4, 1);\nvar quarterEnd = new DateTime(2026, 6, 30);\nvar q1 = new DateTimeRange(quarterStart, quarterEnd);\nConsole.WriteLine($\"Q2 2026 lasts {q1.Duration.TotalDays} days.\"); // 90 days" + } + }, + { + "id": "4753838b822eca025c49605f", + "exampleId": "Cuemon.Diagnostics.ExceptionDescriptorOptions#1", + "uid": "Cuemon.Diagnostics.ExceptionDescriptorOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Diagnostics; // for ExceptionDescriptorOptions, FaultSensitivityDetails\n\n// Create options that include only the stack trace\nvar options = new ExceptionDescriptorOptions\n{\n SensitivityDetails = FaultSensitivityDetails.StackTrace\n};\nConsole.WriteLine(options.SensitivityDetails); // StackTrace\n\n// Create options that include stack trace and exception data\nvar verbose = new ExceptionDescriptorOptions\n{\n SensitivityDetails =\n FaultSensitivityDetails.StackTrace |\n FaultSensitivityDetails.Data\n};\n\n// Verify flags are set\nbool hasStack = verbose.SensitivityDetails.HasFlag(FaultSensitivityDetails.StackTrace);\nbool hasData = verbose.SensitivityDetails.HasFlag(FaultSensitivityDetails.Data);\nConsole.WriteLine(hasStack); // True\nConsole.WriteLine(hasData); // True\n\n// Default is none\nvar defaults = new ExceptionDescriptorOptions();\nConsole.WriteLine(defaults.SensitivityDetails); // None" + } + }, + { + "id": "47c3dab1c5f689db98d9745e", + "exampleId": "Cuemon.Extensions.AspNetCore.Data.Integrity.ChecksumBuilderExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Data.Integrity.ChecksumBuilderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Extensions.AspNetCore.Data.Integrity;\nusing Cuemon.Security;\n\nvar builder = new ChecksumBuilder(() => HashFactory.CreateFnv128());\nbuilder.CombineWith(Encoding.UTF8.GetBytes(\"content-data\"));\n\nvar strongTag = builder.ToEntityTagHeaderValue();\nvar weakTag = builder.ToEntityTagHeaderValue(isWeak: true);\n\nConsole.WriteLine(strongTag.Tag.ToString());\nConsole.WriteLine(weakTag.IsWeak);" + } + }, + { + "id": "47d39a9a485701d47a367386", + "exampleId": "Cuemon.Extensions.AspNetCore.Authentication.ApplicationBuilderExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Authentication.ApplicationBuilderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Authentication@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Claims;\nusing Cuemon.Extensions.AspNetCore.Authentication;\nusing Microsoft.AspNetCore.Authentication;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.Extensions.DependencyInjection;\n\nvar services = new ServiceCollection();\n\nservices.AddLogging();\nservices.AddInMemoryDigestAuthenticationNonceTracker();\nservices.AddAuthentication(\"docs\")\n .AddScheme(Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeader.Scheme, _ => { })\n .AddScheme(Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeader.Scheme, _ => { })\n .AddScheme(\"hmac-docs\", _ => { });\n\nvar app = new ApplicationBuilder(services.BuildServiceProvider());\n\nvar basicBuilder = app.UseBasicAuthentication(options =>\n{\n options.Realm = \"SecureArea\";\n options.Authenticator = (username, password) =>\n {\n if (username == \"admin\" && password == \"secret\")\n {\n return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, \"Basic\"));\n }\n\n return null;\n };\n options.RequireSecureConnection = false;\n});\n\nvar digestBuilder = app.UseDigestAccessAuthentication(options =>\n{\n options.Realm = \"SecureArea\";\n options.Authenticator = (string username, out string password) =>\n {\n password = \"storedPassword\";\n return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, \"Digest\"));\n };\n options.RequireSecureConnection = false;\n});\n\nvar hmacBuilder = app.UseHmacAuthentication(options =>\n{\n options.AuthenticationScheme = \"MyHmac\";\n options.Authenticator = (string clientId, out string clientSecret) =>\n {\n clientSecret = \"storedSecret\";\n return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, clientId) }, \"Hmac\"));\n };\n options.RequireSecureConnection = false;\n});\n\nConsole.WriteLine($\"Basic middleware returned the application builder: {ReferenceEquals(app, basicBuilder)}\");\nConsole.WriteLine($\"Digest middleware returned the application builder: {ReferenceEquals(app, digestBuilder)}\");\nConsole.WriteLine($\"HMAC middleware returned the application builder: {ReferenceEquals(app, hmacBuilder)}\");" + } + }, + { + "id": "483a8ab83e467fcdef3648ad", + "exampleId": "Cuemon.Threading.AsyncRunOptions#1", + "uid": "Cuemon.Threading.AsyncRunOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading;\nusing Cuemon.Threading;\n\nvar options = new AsyncRunOptions\n{\n Timeout = TimeSpan.FromSeconds(30),\n Delay = TimeSpan.FromMilliseconds(500),\n MaximumAttempts = 3\n};\nConsole.WriteLine(options.Timeout); // 00:00:30\nConsole.WriteLine(options.Delay); // 00:00:00.5000000\nConsole.WriteLine(options.MaximumAttempts); // 3\n\n// Use with cancellation support\nvar withCancellation = new AsyncRunOptions\n{\n Timeout = TimeSpan.FromSeconds(10),\n CancellationToken = new CancellationTokenSource(5000).Token\n};\n\n// Zero-delay retries require an explicit attempt limit\nvar zeroDelay = new AsyncRunOptions\n{\n Timeout = TimeSpan.FromSeconds(1),\n Delay = TimeSpan.Zero,\n MaximumAttempts = 3\n};\nConsole.WriteLine(zeroDelay.MaximumAttempts); // 3\n\n// Defaults: timeout 5s, delay 100ms\nvar defaults = new AsyncRunOptions();\nConsole.WriteLine(defaults.Timeout); // 00:00:05\nConsole.WriteLine(defaults.Delay); // 00:00:00.1000000\nConsole.WriteLine(defaults.MaximumAttempts); // 0\nConsole.WriteLine(withCancellation.CancellationToken.CanBeCanceled); // True" + } + }, + { + "id": "483e201dc25f9f254c080d9a", + "exampleId": "Cuemon.Xml.Serialization.DynamicXmlConverter#1", + "uid": "Cuemon.Xml.Serialization.DynamicXmlConverter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Xml;\nusing Cuemon.Xml.Serialization;\n\nnew DynamicXmlConverterExample().Demonstrate();\n\nnamespace Cuemon.Xml.Serialization\n{\n public class DynamicXmlConverterExample\n {\n public void Demonstrate()\n {\n var converter = DynamicXmlConverter.Create(\n writer: (w, value, entity) =>\n {\n w.WriteElementString(\"Value\", value.ToString());\n },\n reader: (r, type) =>\n {\n r.ReadToDescendant(\"Value\");\n return int.Parse(r.ReadElementContentAsString());\n });\n\n using var sw = new StringWriter();\n using var writer = XmlWriter.Create(sw);\n converter.WriteXml(writer, 42);\n writer.Flush();\n Console.WriteLine(sw.ToString());\n }\n }\n}" + } + }, + { + "id": "4a207fae86885e2e8c2a151a", + "exampleId": "Cuemon.Security.Cryptography.HmacMessageDigest5#1", + "uid": "Cuemon.Security.Cryptography.HmacMessageDigest5", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security;\nusing Cuemon.Security.Cryptography;\nusing Cuemon;\nusing MyApp.Security;\n\nHmacMessageDigest5Examples.Demonstrate();\n\nnamespace MyApp.Security\n{\n public static class HmacMessageDigest5Examples\n {\n public static void Demonstrate()\n {\n // Define a secret key (minimum 64 bytes recommended for HMAC-MD5).\n byte[] secret = Encoding.UTF8.GetBytes(\n \"ThisIsASecretKeyThatShouldBeAtLeastSixtyFourBytesLongForBestResults1234567\");\n\n // Create an HMAC-MD5 instance with the secret.\n var hmacMd5 = new HmacMessageDigest5(secret, null);\n\n // Compute the HMAC of a message.\n byte[] message = Encoding.UTF8.GetBytes(\"Important: Transfer $100 to account 12345\");\n HashResult hash = hmacMd5.ComputeHash(message);\n\n Console.WriteLine(\"HMAC-MD5 (hex): {0}\", hash.ToHexadecimalString());\n Console.WriteLine(\"HMAC-MD5 (base64): {0}\", hash.ToBase64String());\n\n // Verify the HMAC by recomputing with the same secret.\n var verifier = new HmacMessageDigest5(secret, null);\n HashResult expected = verifier.ComputeHash(message);\n bool isValid = hash.Equals(expected);\n Console.WriteLine(\"HMAC valid: {0}\", isValid); // true\n\n // Tampered message produces a different HMAC.\n byte[] tampered = Encoding.UTF8.GetBytes(\"Important: Transfer $100 to account 99999\");\n HashResult tamperedHash = hmacMd5.ComputeHash(tampered);\n Console.WriteLine(\"Tampered HMAC matches: {0}\", hash.Equals(tamperedHash)); // false\n\n // Compute HMAC from string directly (UTF-8 encoding by default).\n HashResult fromString = hmacMd5.ComputeHash(\"Hello, HMAC!\");\n Console.WriteLine(\"String HMAC: {0}\", fromString);\n }\n\n public static void DemonstrateWithOptions()\n {\n byte[] secret = Encoding.UTF8.GetBytes(\"my-secret-key\");\n var hmacMd5 = new HmacMessageDigest5(secret, o =>\n {\n o.ByteOrder = Endianness.LittleEndian;\n });\n HashResult result = hmacMd5.ComputeHash(Encoding.UTF8.GetBytes(\"test data\"));\n Console.WriteLine(\"HMAC-MD5 (little-endian): {0}\", result.ToHexadecimalString());\n }\n }\n}" + } + }, + { + "id": "4a36d0deb95a5d971eee1fa5", + "exampleId": "Cuemon.Extensions.IO.TextReaderExtensions#1", + "uid": "Cuemon.Extensions.IO.TextReaderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.IO@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing Cuemon.Extensions.IO;\n\nconst string input = \"line one\\nline two\\nline three\";\n\nusing var linesReader = input.ToTextReader();\nvar lines = linesReader.ReadAllLines().ToList();\n\nusing var asyncLinesReader = input.ToTextReader();\nusing var writer = new StringWriter();\nvar asyncLines = await asyncLinesReader.ReadAllLinesAsync();\n\nusing var copyReader = input.ToTextReader();\nawait copyReader.CopyToAsync(writer);\n\nConsole.WriteLine(lines.Count);\nConsole.WriteLine(asyncLines.Count);\nConsole.WriteLine(writer.ToString().Contains(\"line two\"));" + } + }, + { + "id": "4a3f1a622982da3e2b42c470", + "exampleId": "Cuemon.AspNetCore.Http.TooManyRequestsException#1", + "uid": "Cuemon.AspNetCore.Http.TooManyRequestsException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http;\n\n// Create a TooManyRequestsException with default message\nvar ex = new TooManyRequestsException();\nConsole.WriteLine(ex.StatusCode); // 429\nConsole.WriteLine(ex.ReasonPhrase); // Too Many Requests\nConsole.WriteLine(ex.Message); // The allowed number of requests has been exceeded.\n\n// Create with a custom message\nvar custom = new TooManyRequestsException(\"Rate limit: maximum 100 requests per minute.\");\nConsole.WriteLine(custom.Message);\n\n// Create with inner exception\nvar inner = new InvalidOperationException(\"Request quota exceeded.\");\nvar withInner = new TooManyRequestsException(\"API rate limit reached.\", inner);\nConsole.WriteLine(withInner.InnerException?.Message); // Request quota exceeded.\n\n// Use TryParse from the base class to resolve by status code\nif (HttpStatusCodeException.TryParse(429, \"Slow down!\", out var parsed))\n{\n Console.WriteLine(parsed.Message); // Slow down!\n Console.WriteLine(parsed.StatusCode); // 429\n}\n\n// Simulate a rate-limit check using the RetryAfter header\nvar requestCount = 101;\nvar maxRequests = 100;\nif (requestCount > maxRequests)\n{\n var rateLimited = new TooManyRequestsException(\n $\"Request #{requestCount} exceeds the limit of {maxRequests} requests per minute.\");\n rateLimited.Headers[\"Retry-After\"] = \"60\";\n Console.WriteLine(rateLimited.Message); // Request #101 exceeds the limit...\n Console.WriteLine(rateLimited.Headers[\"Retry-After\"]); // 60\n\n}" + } + }, + { + "id": "4a4e45791b3d4022e1c1967e", + "exampleId": "Cuemon.ConvertibleOptions#1", + "uid": "Cuemon.ConvertibleOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing MyApp.Examples;\n\nnew ConvertibleOptionsExample().Demonstrate();\n\nnamespace MyApp.Examples\n{\n public class ConvertibleOptionsExample\n {\n public void Demonstrate()\n {\n var options = new ConvertibleOptions();\n Console.WriteLine($\"Default byte order: {options.ByteOrder}\");\n\n options.ByteOrder = Endianness.BigEndian;\n Console.WriteLine($\"Byte order: {options.ByteOrder}\");\n\n MyValue myValue = new MyValue { Amount = 12345 };\n byte[] result = Convertible.GetBytes(myValue, o =>\n {\n o.ByteOrder = Endianness.BigEndian;\n o.Converters.Add(value =>\n {\n byte[] bytes = BitConverter.GetBytes(value.Amount);\n if (o.ByteOrder == Endianness.BigEndian && BitConverter.IsLittleEndian)\n {\n Array.Reverse(bytes);\n }\n return bytes;\n });\n });\n\n Console.WriteLine($\"Converted bytes: {BitConverter.ToString(result)}\");\n }\n }\n public struct MyValue : IConvertible\n {\n public int Amount { get; set; }\n\n public TypeCode GetTypeCode() => TypeCode.Object;\n public bool ToBoolean(IFormatProvider provider) => Convert.ToBoolean(Amount);\n public byte ToByte(IFormatProvider provider) => Convert.ToByte(Amount);\n public char ToChar(IFormatProvider provider) => Convert.ToChar(Amount);\n public DateTime ToDateTime(IFormatProvider provider) => Convert.ToDateTime(Amount);\n public decimal ToDecimal(IFormatProvider provider) => Amount;\n public double ToDouble(IFormatProvider provider) => Amount;\n public short ToInt16(IFormatProvider provider) => Convert.ToInt16(Amount);\n public int ToInt32(IFormatProvider provider) => Amount;\n public long ToInt64(IFormatProvider provider) => Amount;\n public sbyte ToSByte(IFormatProvider provider) => Convert.ToSByte(Amount);\n public float ToSingle(IFormatProvider provider) => Amount;\n public string ToString(IFormatProvider provider) => Amount.ToString(provider);\n public object ToType(Type conversionType, IFormatProvider provider) => Convert.ChangeType(Amount, conversionType, provider);\n public ushort ToUInt16(IFormatProvider provider) => Convert.ToUInt16(Amount, provider);\n public uint ToUInt32(IFormatProvider provider) => Convert.ToUInt32(Amount, provider);\n public ulong ToUInt64(IFormatProvider provider) => Convert.ToUInt64(Amount, provider);\n }\n}" + } + }, + { + "id": "4ada39afb45c843c74ab5544", + "exampleId": "Cuemon.Extensions.Xml.XmlWriterExtensions#1", + "uid": "Cuemon.Extensions.Xml.XmlWriterExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Xml;\nusing Cuemon.Extensions.Xml;\nusing Cuemon.Xml.Serialization;\nusing DocExamples;\n\nXmlWriterExtensionsExample.Demonstrate();\n\nnamespace DocExamples\n{\n public static class XmlWriterExtensionsExample\n {\n public static void Demonstrate()\n {\n Console.WriteLine(WriteException());\n Console.WriteLine(WriteStandaloneElement());\n Console.WriteLine(WriteWrappedException());\n Console.WriteLine(WriteRootElement());\n }\n\n private static string WriteException()\n {\n var output = new StringWriter();\n using var writer = XmlWriter.Create(output, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true });\n writer.WriteObject(new InvalidOperationException());\n writer.Flush();\n return output.ToString();\n }\n\n private static string WriteStandaloneElement()\n {\n var output = new StringWriter();\n using var writer = XmlWriter.Create(output, new XmlWriterSettings { OmitXmlDeclaration = true });\n writer.WriteStartElement(new XmlQualifiedEntity(\"Cuemon\"));\n writer.WriteEndElement();\n writer.Flush();\n return output.ToString();\n }\n\n private static string WriteWrappedException()\n {\n var output = new StringWriter();\n using var writer = XmlWriter.Create(output, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true });\n writer.WriteEncapsulatingElementWhenNotNull(new InvalidOperationException(), new XmlQualifiedEntity(\"MyWrappedElement\"), (nestedWriter, exception) =>\n {\n nestedWriter.WriteObject(exception);\n });\n writer.Flush();\n return output.ToString();\n }\n\n private static string WriteRootElement()\n {\n var output = new StringWriter();\n using var writer = XmlWriter.Create(output, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true });\n writer.WriteXmlRootElement(new InvalidOperationException(), (nestedWriter, exception, rootEntity) =>\n {\n nestedWriter.WriteObject(exception);\n }, new XmlQualifiedEntity(\"Root\", \"cuemon\"));\n writer.Flush();\n return output.ToString();\n }\n }\n}" + } + }, + { + "id": "4b4ad5cd1d2d7bba0ef8c5c7", + "exampleId": "Cuemon.TimeRange#1", + "uid": "Cuemon.TimeRange", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon; // for TimeRange\n\n// Define working hours (09:00 to 17:30)\nvar workDay = new TimeRange(\n TimeSpan.FromHours(9),\n TimeSpan.FromHours(17.5));\n\nConsole.WriteLine($\"Start: {workDay.Start}\"); // 09:00:00\nConsole.WriteLine($\"End: {workDay.End}\"); // 17:30:00\nConsole.WriteLine($\"Duration: {workDay.Duration}\"); // 08:30:00\n\n// Use inherited formatting\nConsole.WriteLine(workDay.ToString(\"g\", null));\n// Output: A duration of 00.08:30:00 between 09:00:00 and 17:30:00.\n\n// Create a short break range\nvar lunchBreak = new TimeRange(\n TimeSpan.FromHours(12),\n TimeSpan.FromHours(13));\nConsole.WriteLine(lunchBreak.Duration); // 01:00:00" + } + }, + { + "id": "4b4beaed17f46a65b7501910", + "exampleId": "Cuemon.Security.Cryptography.UnkeyedCryptoAlgorithm#1", + "uid": "Cuemon.Security.Cryptography.UnkeyedCryptoAlgorithm", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Cryptography;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\n\n// UnkeyedCryptoAlgorithm specifies the hash algorithm to use.\n// Md5 = -2 (MD5, 128 bits)\n// Sha1 = -1 (SHA-1, 160 bits)\n// Sha256 = 0 (SHA-256, 256 bits)\n// Sha384 = 1 (SHA-384, 384 bits)\n// Sha512 = 2 (SHA-512, 512 bits)\n// Sha512Slash256 = 3 (SHA-512/256, 256 bits)\n\nbyte[] data = Encoding.UTF8.GetBytes(\"The quick brown fox jumps over the lazy dog\");\n\n// SHA-256 (default/recommended)\nusing var sha256 = SHA256.Create();\nbyte[] hash256 = sha256.ComputeHash(data);\nConsole.WriteLine($\"Sha256: {BitConverter.ToString(hash256).Replace(\"-\", \"\").ToLowerInvariant()}\");\n\n// SHA-384\nusing var sha384 = SHA384.Create();\nbyte[] hash384 = sha384.ComputeHash(data);\nConsole.WriteLine($\"Sha384: {BitConverter.ToString(hash384).Replace(\"-\", \"\").ToLowerInvariant()}\");\n\n// SHA-512\nusing var sha512 = SHA512.Create();\nbyte[] hash512 = sha512.ComputeHash(data);\nConsole.WriteLine($\"Sha512: {BitConverter.ToString(hash512).Replace(\"-\", \"\").ToLowerInvariant()}\");\n\n// SHA-1\nusing var sha1 = SHA1.Create();\nbyte[] hashSha1 = sha1.ComputeHash(data);\nConsole.WriteLine($\"Sha1: {BitConverter.ToString(hashSha1).Replace(\"-\", \"\").ToLowerInvariant()}\");\n\n// Using UnkeyedCryptoAlgorithm to select algorithm dynamically\nUnkeyedCryptoAlgorithm algorithm = UnkeyedCryptoAlgorithm.Sha512;\nConsole.WriteLine($\"Selected algorithm: {algorithm}\"); // Sha512\n\n// Enum value comparison\nConsole.WriteLine($\"Sha256 == 0: {UnkeyedCryptoAlgorithm.Sha256 == (UnkeyedCryptoAlgorithm)0}\"); // True\nConsole.WriteLine($\"Bit size of Sha512: 512 bits\");" + } + }, + { + "id": "4bd44e098b76a82d7e9a84f6", + "exampleId": "Cuemon.Extensions.DependencyInjection.ServiceProviderExtensions#1", + "uid": "Cuemon.Extensions.DependencyInjection.ServiceProviderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.DependencyInjection@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.Extensions.DependencyInjection;\nusing Microsoft.Extensions.DependencyInjection;\nusing Cuemon.Docs.Samples.DependencyInjection;\n\nServiceProviderExtensionsExample.Demonstrate();\n\nnamespace Cuemon.Docs.Samples.DependencyInjection\n{\n public static class ServiceProviderExtensionsExample\n {\n public static void Demonstrate()\n {\n var services = new ServiceCollection();\n services.AddSingleton();\n services.AddScoped();\n\n using var provider = services.BuildServiceProvider();\n var wrappedProvider = new DelegatingServiceProvider(provider);\n\n var descriptors = wrappedProvider.GetServiceDescriptors().ToList();\n\n Console.WriteLine(descriptors.Any(descriptor => descriptor.ServiceType == typeof(IClock)));\n Console.WriteLine(descriptors.Any(descriptor => descriptor.ServiceType == typeof(IJobRepository)));\n }\n\n public interface IClock\n {\n }\n\n public sealed class SystemClock : IClock\n {\n }\n\n public interface IJobRepository\n {\n }\n\n public sealed class InMemoryJobRepository : IJobRepository\n {\n }\n\n private sealed class DelegatingServiceProvider : IServiceProvider\n {\n private readonly IServiceProvider _provider;\n\n public DelegatingServiceProvider(IServiceProvider provider)\n {\n _provider = provider;\n }\n\n public object GetService(Type serviceType)\n {\n return _provider.GetService(serviceType);\n }\n }\n }\n}" + } + }, + { + "id": "4ccbaf005cae866a5640e9a9", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpCacheableFilter#1", + "uid": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpCacheableFilter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Mvc.Filters.Cacheable;\nusing Microsoft.Extensions.Options;\n\nvar options = new HttpCacheableOptions();\noptions.Filters.Add(new HttpEntityTagHeaderFilter(io => io.UseEntityTagResponseParser = true));\noptions.Filters.Add(new HttpLastModifiedHeaderFilter());\n\nvar filter = new HttpCacheableFilter(Options.Create(options));\n\nConsole.WriteLine(filter.Options.Filters.Count);\nConsole.WriteLine(filter.Options.UseCacheControl);" + } + }, + { + "id": "4ce00f82f63c1f0788e350da", + "exampleId": "Cuemon.Xml.Serialization.XmlSerializerOptions#1", + "uid": "Cuemon.Xml.Serialization.XmlSerializerOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Xml;\nusing Cuemon.Xml.Serialization;\n\nvar options = new XmlSerializerOptions\n{\n RootName = new XmlQualifiedEntity(\"Invoice\"),\n FlattenCollectionItems = true,\n Reader = new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore },\n Writer = new XmlWriterSettings { Indent = true }\n};\n\nConsole.WriteLine(options.RootName.LocalName);\nConsole.WriteLine(options.FlattenCollectionItems);\nConsole.WriteLine(options.Writer.Indent);\nConsole.WriteLine(options.Converters.Count);" + } + }, + { + "id": "4ce6c9aa63569288398737f8", + "exampleId": "Cuemon.AspNetCore.Diagnostics.PreferredFaultDescriptor#1", + "uid": "Cuemon.AspNetCore.Diagnostics.PreferredFaultDescriptor", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Diagnostics;\n\n var preferredFormat = PreferredFaultDescriptor.ProblemDetails;\nConsole.WriteLine(preferredFormat);" + } + }, + { + "id": "4d6879e5532e04fd034ba23e", + "exampleId": "Cuemon.Globalization.StatisticalRegionKind#1", + "uid": "Cuemon.Globalization.StatisticalRegionKind", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Globalization;\n\nvar regionKind = StatisticalRegionKind.CountryOrTerritory;\n\nswitch (regionKind)\n{\n case StatisticalRegionKind.World:\n Console.WriteLine(\"The entire world (code 001).\");\n break;\n case StatisticalRegionKind.Region:\n Console.WriteLine(\"A major geographic region or continent.\");\n break;\n case StatisticalRegionKind.Subregion:\n Console.WriteLine(\"A subdivision of a region (e.g., Western Europe).\");\n break;\n case StatisticalRegionKind.IntermediateRegion:\n Console.WriteLine(\"An intermediate grouping of subregions.\");\n break;\n case StatisticalRegionKind.CountryOrTerritory:\n Console.WriteLine(\"An individual country or territory (leaf node).\");\n break;\n\n}" + } + }, + { + "id": "4ea5b38c92ab43d16760e3a2", + "exampleId": "Cuemon.Extensions.Net.Http.HttpManagerFactory#1", + "uid": "Cuemon.Extensions.Net.Http.HttpManagerFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing System.Threading.Tasks;\nusing Cuemon.Extensions.Net.Http;\n\nawait new HttpManagerFactoryExample().DemonstrateAsync();\n\nnamespace Cuemon.Extensions.Net.Http\n{\n public class HttpManagerFactoryExample\n {\n public async Task DemonstrateAsync()\n {\n var clientFactory = new HttpClientFactoryStub();\n\n var manager = HttpManagerFactory.CreateManager(clientFactory, \"github\");\n var response = await manager.HttpGetAsync(new Uri(\"https://api.github.com\"));\n Console.WriteLine(await response.Content.ReadAsStringAsync());\n }\n\n private class HttpClientFactoryStub : IHttpClientFactory\n {\n public HttpClient CreateClient(string name)\n {\n var client = new HttpClient();\n client.DefaultRequestHeaders.UserAgent.ParseAdd(\"HttpManagerFactoryExample\");\n return client;\n }\n }\n }\n}" + } + }, + { + "id": "4ec088491a5fbb3c8b47249d", + "exampleId": "Cuemon.Resilience.AsyncTransientOperationOptions#1", + "uid": "Cuemon.Resilience.AsyncTransientOperationOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Resilience@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading.Tasks;\nusing Cuemon.Resilience;\nusing Examples;\n\nawait new AsyncTransientOperationExample().ExecuteWithRetryAsync();\n\nnamespace Examples\n{\n public class AsyncTransientOperationExample\n {\n public async Task ExecuteWithRetryAsync()\n {\n // Direct instantiation of AsyncTransientOperationOptions\n var transientOptions = new AsyncTransientOperationOptions\n {\n RetryAttempts = 3,\n MaximumAllowedLatency = TimeSpan.FromSeconds(30)\n };\n transientOptions.RetryStrategy = currentAttempt => TimeSpan.FromSeconds(Math.Pow(2, currentAttempt));\n transientOptions.DetectionStrategy = exception => exception is TimeoutException;\n\n var result = await TransientOperation.WithFuncAsync(async ct =>\n {\n return await Task.FromResult(42);\n }, o =>\n {\n o.RetryAttempts = 3;\n o.RetryStrategy = currentAttempt => TimeSpan.FromSeconds(Math.Pow(2, currentAttempt));\n o.MaximumAllowedLatency = TimeSpan.FromSeconds(30);\n o.DetectionStrategy = exception => exception is TimeoutException;\n });\n // result == 42 after up to 3 retries with exponential backoff\n Console.WriteLine(result);\n\n }\n }\n}" + } + }, + { + "id": "4f305536e3671135d7db80d5", + "exampleId": "Cuemon.Xml.Linq.StringDecoratorExtensions#1", + "uid": "Cuemon.Xml.Linq.StringDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Xml.Linq;\nusing Cuemon;\nusing Cuemon.Xml.Linq;\n\n // Valid XML string\n var validXml = \"value\";\n\n // Check if the string is valid XML\n var isValid = Decorator.Enclose(validXml).IsXmlString();\n Console.WriteLine($\"Is valid XML: {isValid}\"); // True\n\n // Try to parse the XML string into an XElement\n if (Decorator.Enclose(validXml).TryParseXElement(out var element))\n {\n Console.WriteLine($\"Root element: {element.Name}\");\n Console.WriteLine($\"Inner XML: {element}\");\n\n // Navigate the parsed XElement\n var item = element.Element(\"item\");\n Console.WriteLine($\"Item id attribute: {item?.Attribute(\"id\")?.Value}\");\n Console.WriteLine($\"Item value: {item?.Value}\");\n\n // Invalid XML string\n var invalidXml = \"not xml at all\";\n var isInvalid = Decorator.Enclose(invalidXml).IsXmlString();\n Console.WriteLine($\"Is valid XML: {isInvalid}\"); // False\n\n // TryParse will return false for invalid XML\n if (!Decorator.Enclose(invalidXml).TryParseXElement(out var badElement))\n {\n Console.WriteLine(\"Could not parse invalid XML.\");\n Console.WriteLine($\"Result is null: {badElement == null}\"); // True\n\n // TryParse with load options\n var xmlWithWhitespace = \" value \";\n if (Decorator.Enclose(xmlWithWhitespace)\n .TryParseXElement(LoadOptions.PreserveWhitespace, out var preserveElement))\n {\n Console.WriteLine($\"Preserved whitespace element: '{preserveElement}'\");\n\n}}}" + } + }, + { + "id": "4f705d0afd3e55d53a10bfa5", + "exampleId": "Cuemon.Extensions.AspNetCore.Authentication.AuthorizationResponseHandlerOptions#1", + "uid": "Cuemon.Extensions.AspNetCore.Authentication.AuthorizationResponseHandlerOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Authentication@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Diagnostics;\nusing Cuemon.Extensions.AspNetCore.Authentication;\nusing Microsoft.AspNetCore.Authorization.Policy;\n\nvar options = new AuthorizationResponseHandlerOptions\n{\n SensitivityDetails = FaultSensitivityDetails.All,\n FallbackResponseHandler = new AuthorizationMiddlewareResultHandler()\n};\n\nConsole.WriteLine(options.SensitivityDetails);\nConsole.WriteLine(options.FallbackResponseHandler != null);" + } + }, + { + "id": "4fc0d41824ba823ed0d833af", + "exampleId": "Cuemon.Reflection.ActivatorOptions#1", + "uid": "Cuemon.Reflection.ActivatorOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Reflection;\nusing Cuemon.Reflection;\n\n// Direct instantiation of ActivatorOptions\nvar options = new ActivatorOptions\n{\n Flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance\n};\n\n// Create a Uri instance using a factory with explicit binding flags\nvar uri = ActivatorFactory.CreateInstance(\"http://example.com\", o =>\n{\n o.Flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance;\n});\n\nConsole.WriteLine(uri.Host);" + } + }, + { + "id": "514de72b008a7b03fd3c502f", + "exampleId": "Cuemon.Calculator#1", + "uid": "Cuemon.Calculator", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\nint sum = Calculator.Add(10, 20);\nConsole.WriteLine(sum); // 30\n\nint difference = Calculator.Subtract(20, 5);\nConsole.WriteLine(difference); // 15\n\nint product = Calculator.Multiply(4, 5);\nConsole.WriteLine(product); // 20\n\nint quotient = Calculator.Divide(20, 4);\nConsole.WriteLine(quotient); // 5\n\nint remainder = Calculator.Remainder(10, 3);\nConsole.WriteLine(remainder); // 1\n\nint bitwiseAnd = Calculator.And(0b1100, 0b1010);\nConsole.WriteLine(bitwiseAnd); // 8 (0b1000)" + } + }, + { + "id": "518c1f9c16336835d4a1b1db", + "exampleId": "Cuemon.DataPair`1#1", + "uid": "Cuemon.DataPair`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon;\n\n // Create a strongly typed DataPair for an integer value\n var age = new DataPair(\"Age\", 30);\n Console.WriteLine(age.HasValue); // True\n Console.WriteLine(age.Name); // Age\n Console.WriteLine(age.Value); // 30\n Console.WriteLine(age.Type); // System.Int32\n\n // Create a DataPair with a null value\n var middleName = new DataPair(\"MiddleName\", null);\n Console.WriteLine(middleName.HasValue); // False\n Console.WriteLine(middleName); // Name: MiddleName, Value: , Type: String\n\n // Override the type metadata (e.g., for a derived type)\n var now = new DataPair(\"Created\", DateTime.UtcNow, typeof(DateTimeOffset));\n Console.WriteLine(now.Type); // System.DateTimeOffset\n\n // Use DataPair in a collection\n var pairs = new List>\n {\n new(\"Id\", Guid.NewGuid()),\n new(\"Timestamp\", DateTime.UtcNow),\n new(\"Active\", true)\n };\n\n foreach (var pair in pairs)\n {\n Console.WriteLine(pair);\n\n}" + } + }, + { + "id": "51ca3e552f55134e9006c7e7", + "exampleId": "Cuemon.Security.FowlerNollVo1024#1", + "uid": "Cuemon.Security.FowlerNollVo1024", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon;\nusing Cuemon.Security;\n\nvar hasher = new FowlerNollVo1024(options =>\n{\n options.Algorithm = FowlerNollVoAlgorithm.Fnv1a;\n options.ByteOrder = Endianness.BigEndian;\n});\n\nHashResult orderHash = hasher.ComputeHash(Encoding.UTF8.GetBytes(\"order-42\"));\n\nConsole.WriteLine(hasher.Bits);\nConsole.WriteLine(orderHash.GetBytes().Length);\nConsole.WriteLine(orderHash.ToHexadecimalString());\n\nvar legacyHasher = new FowlerNollVo1024(options => options.Algorithm = FowlerNollVoAlgorithm.Fnv1);\nConsole.WriteLine(legacyHasher.ComputeHash(\"order-42\").ToHexadecimalString());" + } + }, + { + "id": "52102929cfa14d7ce0300f90", + "exampleId": "Cuemon.Net.Http.HttpManager#1", + "uid": "Cuemon.Net.Http.HttpManager", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net;\nusing System.Net.Http;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Cuemon.Net.Http;\nusing MyApp.Examples;\n\nawait HttpManagerExample.DemonstrateAsync();\n\nnamespace MyApp.Examples\n{\n public static class HttpManagerExample\n {\n public static async Task DemonstrateAsync()\n {\n using var manager = new HttpManager(() => new HttpClient(new EchoHandler(), false));\n using var response = await manager.HttpGetAsync(new Uri(\"https://example.com/health\"));\n\n Console.WriteLine(response.StatusCode);\n Console.WriteLine(manager.Timeout > TimeSpan.Zero);\n }\n\n private sealed class EchoHandler : HttpMessageHandler\n {\n protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\n {\n return Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)\n {\n RequestMessage = request,\n Content = new StringContent(\"OK\")\n });\n }\n }\n }\n}" + } + }, + { + "id": "5258947071bf30c7cd5277c4", + "exampleId": "Cuemon.Patterns#1", + "uid": "Cuemon.Patterns", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading;\nusing Cuemon;\nusing Cuemon.Threading;\nusing Contoso.Infrastructure;\n\nPatternsExample.Run();\n\nnamespace Contoso.Infrastructure\n{\n public sealed class PatternsExample\n {\n public static void Run()\n {\n var options = Patterns.Configure(setup =>\n {\n setup.CancellationToken = CancellationToken.None;\n });\n\n var profile = Patterns.CreateInstance(instance =>\n {\n instance.Name = \"health\";\n });\n\n bool wroteMessage = Patterns.TryInvoke(() => Console.WriteLine(profile.Name));\n int fallbackPort = Patterns.InvokeOrDefault(() => int.Parse(\"not-a-number\"), -1);\n bool recoverable = Patterns.IsRecoverableException(new InvalidOperationException(\"Transient.\"));\n\n Console.WriteLine($\"Token can cancel: {options.CancellationToken.CanBeCanceled}\");\n Console.WriteLine($\"TryInvoke succeeded: {wroteMessage}\");\n Console.WriteLine($\"Fallback port: {fallbackPort}\");\n Console.WriteLine($\"Recoverable: {recoverable}\");\n }\n\n private sealed class EndpointProfile\n {\n public string Name { get; set; }\n }\n }\n}" + } + }, + { + "id": "531c943d7d54e5591617bcd3", + "exampleId": "Cuemon.Generate#1", + "uid": "Cuemon.Generate", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon;\n\n// Generate a range of values using a generator function\nIEnumerable numbers = Generate.RangeOf(5, i => i * 10);\nConsole.WriteLine(string.Join(\", \", numbers)); // 0, 10, 20, 30, 40\n\n// Generate a random integer in a specific range\nint randomValue = Generate.RandomNumber(1, 101);\nConsole.WriteLine($\"Random between 1 and 100: {randomValue}\");\n\n// Generate a random alphanumeric string\nstring randomStr = Generate.RandomString(12);\nConsole.WriteLine($\"Random 12-char string: {randomStr}\");\n\n// Generate a random string from custom character buckets\nstring customRandom = Generate.RandomString(8, \"ABCDEF\", \"123456\");\nConsole.WriteLine($\"Custom random string: {customRandom}\");\n\n// Generate a fixed string of repeated characters\nstring separator = Generate.FixedString('-', 20);\nConsole.WriteLine(separator); // --------------------\n\n// Compute hash codes from convertible values\nint hash32 = Generate.HashCode32(42, \"hello\", true);\nlong hash64 = Generate.HashCode64(42, \"hello\", true);\nConsole.WriteLine($\"32-bit hash: {hash32}, 64-bit hash: {hash64}\");\n\n// Generate a structured portrayal of an object\nvar person = new { Name = \"Alice\", Age = 30 };\nstring portrayal = Generate.ObjectPortrayal(person);\nConsole.WriteLine(portrayal); // shows property names and values" + } + }, + { + "id": "533bfcfd8a930e86659d8797", + "exampleId": "Cuemon.AspNetCore.Http.Headers.UserAgentSentinelOptions#1", + "uid": "Cuemon.AspNetCore.Http.Headers.UserAgentSentinelOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon.AspNetCore.Http.Headers;\n\n var options = new UserAgentSentinelOptions\n{\n RequireUserAgentHeader = true,\n ValidateUserAgentHeader = true,\n AllowedUserAgents = new List { \"Cuemon-Agent\" }\n};\n\noptions.ValidateOptions();\nusing var response = options.ResponseHandler(\"Unknown-Agent\");\nvar message = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();\nConsole.WriteLine(message);" + } + }, + { + "id": "53bc4ea38c1998917f80697d", + "exampleId": "Cuemon.Threading.AsyncFuncFactory`2#1", + "uid": "Cuemon.Threading.AsyncFuncFactory`2", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Cuemon;\nusing Cuemon.Threading;\nusing MyApp.Examples;\n\nawait new AsyncFuncFactoryExample().DemonstrateAsync();\n\nnamespace MyApp.Examples\n{\n public class AsyncFuncFactoryExample\n {\n public async Task DemonstrateAsync()\n {\n // Create an AsyncFuncFactory that encapsulates a function taking\n // two string arguments and returning an int.\n var factory = AsyncFuncFactory.Create(\n (string a, string b, CancellationToken ct) =>\n {\n ct.ThrowIfCancellationRequested();\n return Task.FromResult(a.Length + b.Length);\n },\n \"Hello\",\n \"World\"\n );\n\n Console.WriteLine($\"Has delegate: {factory.HasDelegate}\"); // True\n Console.WriteLine($\"Delegate info: {factory.DelegateInfo?.Name}\"); //
b__0_0 or similar\n\n // Execute the wrapped function asynchronously.\n var result = await factory.ExecuteMethodAsync(CancellationToken.None);\n Console.WriteLine($\"Total length: {result}\"); // 10\n\n // Clone the factory for safe concurrent use.\n var clone = (AsyncFuncFactory, int>)factory.Clone();\n var clonedResult = await clone.ExecuteMethodAsync(CancellationToken.None);\n Console.WriteLine($\"Cloned result: {clonedResult}\"); // 10\n\n}}\n}" + } + }, + { + "id": "53df3969759a1b7a356b53f4", + "exampleId": "Cuemon.Extensions.DoubleExtensions#1", + "uid": "Cuemon.Extensions.DoubleExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Extensions;\n\ndouble unixTimestamp = 1617738277d;\nDateTime fromUnix = unixTimestamp.FromUnixEpochTime().ToLocalTime();\n\nTimeSpan fromSeconds = 3661d.ToTimeSpan(TimeUnit.Seconds);\ndouble factorial = 5d.Factorial();\n\ndouble value = 123456789.987654321d;\ndouble nearestThousand = value.RoundOff(RoundOffAccuracy.NearestThousandth);\ndouble nearestMillion = value.RoundOff(RoundOffAccuracy.NearestMillion);\n\nConsole.WriteLine(fromUnix.ToString(\"O\"));\nConsole.WriteLine(fromSeconds);\nConsole.WriteLine(factorial);\nConsole.WriteLine(nearestThousand);\nConsole.WriteLine(nearestMillion);" + } + }, + { + "id": "541c2c4d3bdaff9727d5bc18", + "exampleId": "Cuemon.Net.Http.HttpWatcherOptions#1", + "uid": "Cuemon.Net.Http.HttpWatcherOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing Cuemon.Net.Http;\nusing Cuemon.Security;\n\nvar options = new HttpWatcherOptions\n{\n ClientFactory = () => new HttpClient(new HttpClientHandler(), false),\n HashFactory = () => new CyclicRedundancyCheck64(),\n ReadResponseBody = true,\n Period = TimeSpan.FromSeconds(5)\n};\n\noptions.ValidateOptions();\n\nConsole.WriteLine(options.ReadResponseBody);\nConsole.WriteLine(options.Period.TotalSeconds);\nConsole.WriteLine($\"HTTP client factory configured: {options.ClientFactory is not null}\");" + } + }, + { + "id": "55caa3a8e55dc0ce4742f425", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Headers.ApiKeySentinelFilter#1", + "uid": "Cuemon.AspNetCore.Mvc.Filters.Headers.ApiKeySentinelFilter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Mvc@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net;\nusing Cuemon.AspNetCore.Http.Headers;\nusing Cuemon.AspNetCore.Mvc.Filters.Headers;\nusing Microsoft.Extensions.Options;\n\nvar options = Options.Create(new ApiKeySentinelOptions\n{\n UseGenericResponse = true,\n GenericClientStatusCode = HttpStatusCode.NotFound,\n GenericClientMessage = \"Resource not found.\"\n});\noptions.Value.AllowedKeys.Add(\"Cuemon-Key\");\n\nvar filter = new ApiKeySentinelFilter(options);\n\nConsole.WriteLine(filter.Options.HeaderName);\nConsole.WriteLine(filter.Options.AllowedKeys.Count);" + } + }, + { + "id": "55d19b03dfe9fd6016b62ad0", + "exampleId": "Cuemon.Globalization.StatisticalRegionInfo#1", + "uid": "Cuemon.Globalization.StatisticalRegionInfo", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.Globalization;\n\n// Get United States by its UN M.49 code\nStatisticalRegionInfo usa = World.GetCountry(\"840\");\n\nif (usa != null)\n{\n Console.WriteLine($\"Name: {usa.Name}\");\n Console.WriteLine($\"Code: {usa.Code}\");\n Console.WriteLine($\"ISO Alpha-2: {usa.IsoAlpha2}\");\n Console.WriteLine($\"ISO Alpha-3: {usa.IsoAlpha3}\");\n Console.WriteLine($\"Kind: {usa.Kind}\");\n Console.WriteLine($\"Parent: {usa.Parent?.Name}\");\n\n// List all European countries\nvar europe = World.GetStatisticalRegion(\"150\");\nif (europe != null)\n{\n Console.WriteLine($\"\\nCountries in {europe.Name}:\");\n foreach (var country in europe.Countries.Take(5))\n {\n Console.WriteLine($\" - {country.Name} ({country.IsoAlpha2})\");\n\n}}}" + } + }, + { + "id": "57b87d3a247429bade8c6308", + "exampleId": "Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelOptions#1", + "uid": "Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http.Headers;\nusing Cuemon.AspNetCore.Http.Throttling;\nusing Microsoft.AspNetCore.Http;\nusing MyApp.Http.Throttling;\n\nConsole.WriteLine(new ThrottlingSentinelOptionsExample().CreateDefault());\n\nnamespace MyApp.Http.Throttling\n{\n public class ThrottlingSentinelOptionsExample\n {\n public ThrottlingSentinelOptions CreateDefault()\n {\n // Default: RateLimit-Limit header, 429 response with Retry-After\n var options = new ThrottlingSentinelOptions();\n return options;\n }\n\n public ThrottlingSentinelOptions CreateCustom()\n {\n var options = new ThrottlingSentinelOptions\n {\n // Allow 60 requests per 1 minute window per client\n Quota = new ThrottleQuota(60, TimeSpan.FromMinutes(1)),\n // Resolve context by client IP address\n ContextResolver = ctx =>\n ctx.Connection.RemoteIpAddress?.ToString() ?? \"unknown\",\n // Custom header names\n RateLimitHeaderName = \"X-Rate-Limit-Limit\",\n RateLimitRemainingHeaderName = \"X-Rate-Limit-Remaining\",\n RateLimitResetHeaderName = \"X-Rate-Limit-Reset\",\n // Use delta-seconds for Retry-After\n RateLimitResetScope = RetryConditionScope.DeltaSeconds,\n UseRetryAfterHeader = true,\n RetryAfterScope = RetryConditionScope.DeltaSeconds,\n // Custom response message\n TooManyRequestsMessage = \"Rate limit exceeded. Please slow down.\"\n };\n\n // Validate the configuration\n options.ValidateOptions();\n\n Console.WriteLine($\"Quota: {options.Quota.RateLimit} req / {options.Quota.Window.TotalMinutes} min\");\n Console.WriteLine($\"RateLimitHeader: {options.RateLimitHeaderName}\");\n Console.WriteLine($\"RetryAfterScope: {options.RetryAfterScope}\");\n\n return options;\n }\n }\n}" + } + }, + { + "id": "589bb17f8b48f3520f6695b5", + "exampleId": "Cuemon.Extensions.AspNetCore.Diagnostics.ServiceProviderExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Diagnostics.ServiceProviderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Net.Http.Headers;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.Diagnostics;\nusing Cuemon.Extensions.AspNetCore.Diagnostics;\nusing Cuemon.Net.Http;\nusing Microsoft.Extensions.DependencyInjection;\n\nvar services = new ServiceCollection();\nvar formatter = new HttpExceptionDescriptorResponseFormatter(new ExampleFormatterOptions());\nservices.AddSingleton(formatter.GetType(), formatter);\n\nusing var provider = services.BuildServiceProvider();\nvar formatters = provider.GetExceptionResponseFormatters().ToList();\n\nConsole.WriteLine(formatters.Count);\nConsole.WriteLine(formatters[0].GetType().GenericTypeArguments[0].Name);\n\npublic sealed class ExampleFormatterOptions : IContentNegotiation, IExceptionDescriptorOptions\n{\n public IReadOnlyCollection SupportedMediaTypes { get; } =\n new[] { new MediaTypeHeaderValue(\"application/json\") };\n\n public FaultSensitivityDetails SensitivityDetails { get; set; }\n}" + } + }, + { + "id": "5909ec077e6424ca5387ea47", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpLastModifiedHeaderOptions#1", + "uid": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpLastModifiedHeaderOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Mvc.Filters.Cacheable;\nusing Cuemon.Data.Integrity;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Net.Http.Headers;\nusing MyApp.Examples;\n\nHttpLastModifiedHeaderOptionsExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class HttpLastModifiedHeaderOptionsExample\n {\n public static void Demonstrate()\n {\n var options = new HttpLastModifiedHeaderOptions();\n var context = new DefaultHttpContext();\n context.Request.Method = HttpMethods.Get;\n\n var timestamp = new SampleEntityDataTimestamp(\n DateTime.Parse(\"2024-01-01T00:00:00Z\"),\n DateTime.Parse(\"2024-01-02T00:00:00Z\"));\n\n options.LastModifiedProvider(timestamp, context);\n\n Console.WriteLine(options.HasLastModifiedProvider);\n Console.WriteLine(context.Response.Headers[HeaderNames.LastModified].ToString());\n }\n\n private sealed class SampleEntityDataTimestamp : IEntityDataTimestamp\n {\n public SampleEntityDataTimestamp(DateTime created, DateTime? modified)\n {\n Created = created;\n Modified = modified;\n }\n\n public DateTime Created { get; }\n\n public DateTime? Modified { get; }\n }\n }\n}" + } + }, + { + "id": "5915f50f3d2e11fae6a4aeea", + "exampleId": "Cuemon.Data.DatabaseDependency#1", + "uid": "Cuemon.Data.DatabaseDependency", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Data;\nusing System.Threading.Tasks;\nusing Cuemon.Data;\nusing Cuemon.Runtime;\nusing MyApp.Examples;\n\nawait new DatabaseDependencyExample().DemonstrateAsync();\n\nnamespace MyApp.Examples\n{\n public class DatabaseDependencyExample\n {\n public async Task DemonstrateAsync()\n {\n var lazyWatcher = new Lazy(() =>\n {\n var connection = new StubConnection();\n return new DatabaseWatcher(\n connection,\n conn =>\n {\n var command = conn.CreateCommand();\n command.CommandText = \"SELECT COUNT(*) FROM Products\";\n return command.ExecuteReader();\n });\n });\n\n var dependency = new DatabaseDependency(lazyWatcher, breakTieOnChanged: true);\n\n dependency.DependencyChanged += (sender, args) =>\n {\n Console.WriteLine(\"Database data has changed!\");\n };\n\n await dependency.StartAsync();\n Console.WriteLine(\"Database dependency started.\");\n }\n\n private sealed class StubConnection : IDbConnection\n {\n public string ConnectionString { get; set; }\n public int ConnectionTimeout => 30;\n public string Database => \"MyDb\";\n public ConnectionState State => ConnectionState.Closed;\n public IDbTransaction BeginTransaction() => null;\n public IDbTransaction BeginTransaction(IsolationLevel il) => null;\n public void ChangeDatabase(string databaseName) { }\n public void Close() { }\n public IDbCommand CreateCommand() => new StubCommand();\n public void Open() { }\n public void Dispose() { }\n }\n\n private sealed class StubCommand : IDbCommand\n {\n public string CommandText { get; set; }\n public int CommandTimeout { get; set; }\n public CommandType CommandType { get; set; }\n public IDbConnection Connection { get; set; }\n public IDataParameterCollection Parameters => null;\n public IDbTransaction Transaction { get; set; }\n public UpdateRowSource UpdatedRowSource { get; set; }\n public bool DesignTimeVisible { get; set; }\n public void Cancel() { }\n public IDbDataParameter CreateParameter() => null;\n public int ExecuteNonQuery() => 0;\n public IDataReader ExecuteReader() => null;\n public IDataReader ExecuteReader(CommandBehavior behavior) => null;\n public object ExecuteScalar() => 0;\n public void Prepare() { }\n public void Dispose() { }\n }\n }\n}" + } + }, + { + "id": "591cbb6bb8193856480e8739", + "exampleId": "Cuemon.FormattingOptions#1", + "uid": "Cuemon.FormattingOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Globalization;\nusing Cuemon;\n\nvar options = new FormattingOptions\n{\n FormatProvider = new CultureInfo(\"da-DK\")\n};\n\nvar value = 1234.56;\nvar formatted = value.ToString(\"N2\", options.FormatProvider);\n\nConsole.WriteLine(formatted); // Output depends on the culture (e.g., \"1.234,56\" for da-DK)" + } + }, + { + "id": "59df8043753b9d5b15f12cfd", + "exampleId": "Cuemon.Resilience.TransientOperationOptions#1", + "uid": "Cuemon.Resilience.TransientOperationOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Resilience@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing Cuemon.Resilience;\n\nvar options = new TransientOperationOptions\n{\n RetryAttempts = 3,\n RetryStrategy = attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)),\n DetectionStrategy = exception => exception is HttpRequestException,\n MaximumAllowedLatency = TimeSpan.FromSeconds(30)\n};\n\noptions.ValidateOptions();\n\nConsole.WriteLine(options.RetryAttempts);\nConsole.WriteLine(options.EnableRecovery);\nConsole.WriteLine(options.MaximumAllowedLatency);\nConsole.WriteLine(options.DetectionStrategy(new HttpRequestException(\"Network timeout simulated.\")));" + } + }, + { + "id": "5a89a4022884f3554e64af50", + "exampleId": "Cuemon.AspNetCore.Authentication.AuthorizationHeaderOptions#1", + "uid": "Cuemon.AspNetCore.Authentication.AuthorizationHeaderOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Authentication;\n\nvar options = new AuthorizationHeaderOptions\n{\n CredentialsDelimiter = \", \",\n CredentialsKeyValueDelimiter = \"=\"\n};\n\noptions.ValidateOptions();\n\nConsole.WriteLine(options.CredentialsDelimiter);\nConsole.WriteLine(options.CredentialsKeyValueDelimiter);" + } + }, + { + "id": "5abbe52bdee71d13d9595e91", + "exampleId": "Cuemon.Extensions.RoundOffAccuracy#1", + "uid": "Cuemon.Extensions.RoundOffAccuracy", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions;\n\ndouble value = 123456789.987654321d;\n\nConsole.WriteLine(value.RoundOff(RoundOffAccuracy.NearestTenth));\nConsole.WriteLine(value.RoundOff(RoundOffAccuracy.NearestHundredth));\nConsole.WriteLine(value.RoundOff(RoundOffAccuracy.NearestThousandth));\nConsole.WriteLine(value.RoundOff(RoundOffAccuracy.NearestMillion));" + } + }, + { + "id": "5acec4474b4e95e2fbcef7c9", + "exampleId": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationHandler#1", + "uid": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationHandler", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Claims;\nusing Cuemon.AspNetCore.Authentication.Basic;\nusing Microsoft.AspNetCore.Authentication;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\nusing MyApp.Examples;\n\nBasicAuthenticationHandlerExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class BasicAuthenticationHandlerExample\n {\n public static void Demonstrate()\n {\n var services = new ServiceCollection();\n\n services.AddLogging();\n services.AddAuthentication(BasicAuthorizationHeader.Scheme)\n .AddScheme(BasicAuthorizationHeader.Scheme, options =>\n {\n options.Realm = \"docs-example\";\n options.RequireSecureConnection = false;\n options.Authenticator = (username, password) =>\n {\n if (username == \"Agent\" && password == \"Test\")\n {\n return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, BasicAuthorizationHeader.Scheme));\n }\n\n return null;\n };\n });\n\n using var provider = services.BuildServiceProvider();\n var options = provider.GetRequiredService>().Get(BasicAuthorizationHeader.Scheme);\n\n Console.WriteLine($\"Authentication realm: {options.Realm}\");\n }\n }\n}" + } + }, + { + "id": "5b36042b10dd61f92560cda7", + "exampleId": "Cuemon.AspNetCore.Authentication.Authenticator#1", + "uid": "Cuemon.AspNetCore.Authentication.Authenticator", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Claims;\nusing Cuemon;\nusing Cuemon.AspNetCore.Authentication;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Net.Http.Headers;\n\nvar context = new DefaultHttpContext()\n{\n Request = { IsHttps = true }\n};\ncontext.Request.Headers.Append(HeaderNames.Authorization, \"Basic YWxpY2U6cGFzc3dvcmQ=\");\n\nvar result = Authenticator.Authenticate(context, false,\n (HttpContext _, string authorizationHeader) => authorizationHeader,\n (HttpContext _, string credentials, out ConditionalValue principal) =>\n {\n principal = new SuccessfulValue(\n new ClaimsPrincipal(new ClaimsIdentity(\n new[] { new Claim(ClaimTypes.Name, \"alice\") }, \"Basic\")));\n return true;\n });\n\nConsole.WriteLine(\"Succeeded: \" + result.Succeeded);\nConsole.WriteLine(\"User: \" + result.Result?.Identity?.Name);" + } + }, + { + "id": "5b8b29f35dafdc718e28b156", + "exampleId": "Cuemon.Threading.AsyncFuncFactory#1", + "uid": "Cuemon.Threading.AsyncFuncFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Cuemon.Threading;\n\nawait new AsyncFuncFactoryExample().DemonstrateAsync();\n\nnamespace Cuemon.Threading\n{\n public class AsyncFuncFactoryExample\n {\n public async Task DemonstrateAsync()\n {\n var factory = AsyncFuncFactory.Create(ct =>\n {\n return Task.FromResult(42);\n });\n var result = await factory.ExecuteMethodAsync(CancellationToken.None);\n Console.WriteLine($\"Result: {result}\");\n\n var factoryWithArg = AsyncFuncFactory.Create(async (int a, int b, CancellationToken ct) =>\n {\n await Task.Delay(10, ct);\n return a + b;\n }, 3, 4);\n var sum = await factoryWithArg.ExecuteMethodAsync(CancellationToken.None);\n Console.WriteLine($\"Sum: {sum}\");\n }\n }\n}" + } + }, + { + "id": "5bfeeb175e4542b6d7995ded", + "exampleId": "Cuemon.AspNetCore.Http.Headers.ApiKeyException#1", + "uid": "Cuemon.AspNetCore.Http.Headers.ApiKeyException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Microsoft.AspNetCore.Http;\nusing Cuemon.AspNetCore.Http.Headers;\n\n var exception = new ApiKeyException(StatusCodes.Status403Forbidden, \"The API key was rejected.\");\nConsole.WriteLine($\"{exception.StatusCode} {exception.ReasonPhrase}\");" + } + }, + { + "id": "5c2d665e0a7c6e7ced10395f", + "exampleId": "Cuemon.Runtime.FileDependency#1", + "uid": "Cuemon.Runtime.FileDependency", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Threading.Tasks;\nusing Cuemon.Runtime;\n\nstring directory = Path.Combine(Path.GetTempPath(), \"cuemon-docs\");\nDirectory.CreateDirectory(directory);\nstring filePath = Path.Combine(directory, \"settings.json\");\nFile.WriteAllText(filePath, \"{ }\");\n\nvar lazyWatcher = new Lazy(() => new FileWatcher(filePath, false, options =>\n{\n options.Period = TimeSpan.FromMilliseconds(500);\n}));\n\nvar dependency = new FileDependency(lazyWatcher, breakTieOnChanged: true);\ndependency.DependencyChanged += static (_, e) => Console.WriteLine(e.UtcLastModified.ToString(\"O\"));\n\nConsole.WriteLine(lazyWatcher.IsValueCreated);\nConsole.WriteLine(dependency.BreakTieOnChanged);\n\nawait dependency.StartAsync();\n\nConsole.WriteLine(lazyWatcher.IsValueCreated);\nConsole.WriteLine(dependency.HasChanged);" + } + }, + { + "id": "5ccff5f21ef3200384d0f12a", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.HttpExceptionDescriptorResponseFormatterExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Http.HttpExceptionDescriptorResponseFormatterExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Net;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.Extensions.AspNetCore.Http;\n\nvar formatters = new List\n{\n new ExampleFormatter()\n};\n\nvar handlers = formatters.SelectExceptionDescriptorHandlers().ToList();\nConsole.WriteLine(handlers.Count);\nConsole.WriteLine(handlers[0].ContentType.MediaType);\n\npublic sealed class ExampleFormatter : IHttpExceptionDescriptorResponseFormatter\n{\n public ICollection ExceptionDescriptorHandlers { get; } =\n new List\n {\n new HttpExceptionDescriptorResponseHandler(\n new MediaTypeHeaderValue(\"application/json\"),\n descriptor => new HttpResponseMessage(HttpStatusCode.InternalServerError)\n {\n Content = new StringContent(descriptor.Message)\n })\n };\n}" + } + }, + { + "id": "5dc2c00ccc40784abaa58662", + "exampleId": "Cuemon.Text.ByteOrderMark#1", + "uid": "Cuemon.Text.ByteOrderMark", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing Cuemon.Text;\n\nvar utf8Bytes = new byte[] { 0xEF, 0xBB, 0xBF, 0x48, 0x65, 0x6C, 0x6C, 0x6F };\nvar encoding = ByteOrderMark.Decode(utf8Bytes);\nConsole.WriteLine($\"Detected encoding: {encoding.EncodingName}\");\n\nvar bytes = ByteOrderMark.Remove(utf8Bytes, Encoding.UTF8);\nConsole.WriteLine($\"BOM removed, remaining length: {bytes.Length}\");\n\nusing var stream = new MemoryStream(utf8Bytes);\nif (ByteOrderMark.TryDetectEncoding(stream, out var detected))\n{\n Console.WriteLine($\"Stream encoding: {detected.EncodingName}\");\n}" + } + }, + { + "id": "5df55e61c12b1592c4725f96", + "exampleId": "Cuemon.Extensions.Data.Integrity.DateTimeExtensions#1", + "uid": "Cuemon.Extensions.Data.Integrity.DateTimeExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Data.Integrity@11.0.0" + ], + "source": "using System;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Extensions.Data.Integrity;\nusing Cuemon.Security;\n\nnamespace MyApp.Examples;\n\npublic class DateTimeExtensionsExample\n{\n public static void Main()\n {\n // Define timestamps for when data was created and last modified\n DateTime created = new DateTime(2025, 1, 15, 10, 0, 0, DateTimeKind.Utc);\n DateTime modified = new DateTime(2025, 6, 10, 14, 30, 0, DateTimeKind.Utc);\n\n // Basic timestamp-only validator (weak integrity based on timestamps)\n CacheValidator timestampValidator = created.GetCacheValidator(modified);\n Console.WriteLine($\"Created (UTC): {timestampValidator.Created:O}\");\n Console.WriteLine($\"Modified (UTC): {timestampValidator.Modified:O}\");\n Console.WriteLine($\"Checksum (hex): {timestampValidator.Checksum.ToHexadecimalString()}\");\n\n // Create a validator using the Timestamp method\n // (checksum is derived purely from timestamps)\n CacheValidator timeBasedValidator = created.GetCacheValidator(modified,\n hashFactory: () => HashFactory.CreateFnv128(),\n method: EntityDataIntegrityMethod.Timestamp);\n Console.WriteLine($\"Time-based method checksum: {timeBasedValidator.Checksum.ToHexadecimalString()}\");\n\n // Create a validator with both timestamps and a content checksum\n byte[] contentChecksum = HashFactory.CreateFnv128().ComputeHash(\"content-data\").GetBytes();\n CacheValidator strongValidator = created.GetCacheValidator(modified, contentChecksum,\n validation: EntityDataIntegrityValidation.Strong);\n Console.WriteLine($\"Strong validator checksum: {strongValidator.Checksum.ToHexadecimalString()}\");\n Console.WriteLine($\"Validation level: {strongValidator.Validation}\");\n\n // Create a validator with only the created timestamp (no modified date)\n CacheValidator createdOnly = created.GetCacheValidator();\n Console.WriteLine($\"Created-only checksum: {createdOnly.Checksum.ToHexadecimalString()}\");\n\n}\n}" + } + }, + { + "id": "5e1f7107dc052f623f6698b8", + "exampleId": "Cuemon.ExceptionInvoker`2#1", + "uid": "Cuemon.ExceptionInvoker`2", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing MyApp.Examples;\n\nnew ExceptionInvokerOfT2Example().Demonstrate();\n\nnamespace MyApp.Examples\n{\n public class ExceptionInvokerOfT2Example\n {\n public void Demonstrate()\n {\n // Create a tester that extracts a value from a configuration string\n // TesterFunc is: bool (out int result)\n TesterFunc tryGetPort = (out int port) =>\n {\n string configValue = Environment.GetEnvironmentVariable(\"APP_PORT\") ?? \"8080\";\n return int.TryParse(configValue, out port);\n };\n\n // Build the full fluent chain\n // The Create method returns an ExceptionInvoker\n ExceptionInvoker invoker = new ExceptionCondition()\n .IsFalse(tryGetPort)\n .Create(port => new InvalidOperationException(\n $\"Invalid port number ({port}) configured in APP_PORT environment variable.\"));\n\n // TryThrow evaluates tryGetPort; if it returns false (matching IsFalse),\n // the exception is thrown with the out value (0) passed to the handler.\n // If the environment variable is valid, no exception is thrown.\n invoker.TryThrow();\n Console.WriteLine(\"APP_PORT validation passed.\");\n\n // You can also create multiple invokers from tester conditions\n TesterFunc tryGetName = (out string name) =>\n {\n name = Environment.GetEnvironmentVariable(\"APP_NAME\") ?? \"MyApp\";\n return !string.IsNullOrEmpty(name);\n };\n\n var nameInvoker = new ExceptionCondition()\n .IsFalse(tryGetName)\n .Create(name => new ArgumentNullException(nameof(name),\n $\"APP_NAME resolved to '{name}' which is not a valid application name.\"));\n\n nameInvoker.TryThrow();\n Console.WriteLine(\"APP_NAME validation passed.\");\n\n }\n }\n}" + } + }, + { + "id": "5ea41b079f807f48372f84a7", + "exampleId": "Cuemon.Extensions.CharExtensions#1", + "uid": "Cuemon.Extensions.CharExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon.Extensions;\n\nchar[] chars = \"Hello World\".ToCharArray();\nstring text = chars.FromChars();\nIEnumerable strings = chars.ToEnumerable();\nstring alphabet = Enumerable.Range('A', 26).Select(c => (char)c).FromChars();\n\nConsole.WriteLine(text);\nConsole.WriteLine(strings.Count());\nConsole.WriteLine(alphabet);" + } + }, + { + "id": "5f5f38da9c2c716d9af656df", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcCoreBuilderExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcCoreBuilderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml;\nusing Microsoft.Extensions.DependencyInjection;\n\nvar services = new ServiceCollection();\nservices.AddLogging();\nvar builder = services.AddMvcCore();\n\nbuilder.AddXmlFormatters(options =>\n{\n options.SynchronizeWithXmlConvert = true;\n});\n\nbuilder.AddXmlFormattersOptions(options =>\n{\n options.SynchronizeWithXmlConvert = true;\n});\n\nusing var provider = services.BuildServiceProvider();\nConsole.WriteLine(\"MVC Core XML formatters configured.\");" + } + }, + { + "id": "5fccb59e120c32b707d3e338", + "exampleId": "Cuemon.Security.Cryptography.AesCryptorOptions#1", + "uid": "Cuemon.Security.Cryptography.AesCryptorOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Cryptography;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\n\n// Generate a key and initialization vector\nbyte[] key = AesCryptor.GenerateKey();\nbyte[] iv = AesCryptor.GenerateInitializationVector();\n\n// Create an AES cryptor with the key and IV\nvar cryptor = new AesCryptor(key, iv);\n\n// Encrypt data using default options (CBC mode, PKCS7 padding)\nbyte[] plaintext = Encoding.UTF8.GetBytes(\"Secret message.\");\nbyte[] encrypted = cryptor.Encrypt(plaintext);\nConsole.WriteLine($\"Encrypted ({encrypted.Length} bytes): {Convert.ToBase64String(encrypted)}\");\n\n// Decrypt with default options\nbyte[] decrypted = cryptor.Decrypt(encrypted);\nConsole.WriteLine($\"Decrypted: {Encoding.UTF8.GetString(decrypted)}\"); // Secret message.\n\n// Create options explicitly and copy settings via delegate\nvar defaultOptions = new AesCryptorOptions();\ndefaultOptions.Mode = CipherMode.CBC;\ndefaultOptions.Padding = PaddingMode.PKCS7;\n\n// Encrypt with explicit cipher mode and padding via delegate from AesCryptorOptions\nbyte[] plaintext2 = Encoding.UTF8.GetBytes(\"Configured encryption.\");\nbyte[] encrypted2 = cryptor.Encrypt(plaintext2, o =>\n{\n o.Mode = defaultOptions.Mode;\n o.Padding = defaultOptions.Padding;\n});\n\n// Decrypt using the same options\nbyte[] decrypted2 = cryptor.Decrypt(encrypted2, o =>\n{\n o.Mode = defaultOptions.Mode;\n o.Padding = defaultOptions.Padding;\n});\nConsole.WriteLine($\"Decrypted: {Encoding.UTF8.GetString(decrypted2)}\"); // Configured encryption.\n\n// Using ECB mode with Zeros padding (not recommended for production)\ndefaultOptions.Mode = CipherMode.ECB;\ndefaultOptions.Padding = PaddingMode.Zeros;\nbyte[] plaintext3 = Encoding.UTF8.GetBytes(\"Alternative mode.\");\nbyte[] encrypted3 = cryptor.Encrypt(plaintext3, o =>\n{\n o.Mode = defaultOptions.Mode;\n o.Padding = defaultOptions.Padding;\n});\nbyte[] decrypted3 = cryptor.Decrypt(encrypted3, o =>\n{\n o.Mode = defaultOptions.Mode;\n o.Padding = defaultOptions.Padding;\n});\nConsole.WriteLine($\"Decrypted: {Encoding.UTF8.GetString(decrypted3)}\"); // Alternative mode." + } + }, + { + "id": "609e05086b94fbf6be279a98", + "exampleId": "Cuemon.Extensions.Wrapper`1#1", + "uid": "Cuemon.Extensions.Wrapper`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Reflection;\nusing Cuemon.Extensions;\nusing MyApp.Examples;\n\nWrapperExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class WrapperExample\n {\n private sealed class WrapperExampleModel\n {\n public string Name { get; set; } = string.Empty;\n }\n\n public static void Demonstrate()\n {\n PropertyInfo nameProperty = typeof(WrapperExampleModel).GetProperty(nameof(WrapperExampleModel.Name), BindingFlags.Public | BindingFlags.Instance);\n var answer = new Wrapper(42, nameProperty);\n answer.Data[\"category\"] = \"number\";\n\n var fromText = new Wrapper(\"42\");\n var bytes = new Wrapper(new byte[] { 1, 2, 3, 4 });\n var type = new Wrapper(typeof(Dictionary));\n\n Console.WriteLine(answer.Instance);\n Console.WriteLine(answer.MemberReference?.Name);\n Console.WriteLine(answer.InstanceAs(CultureInfo.InvariantCulture));\n Console.WriteLine(fromText.InstanceAs());\n Console.WriteLine(answer.Data[\"category\"]);\n Console.WriteLine(Wrapper.ParseInstance(bytes));\n Console.WriteLine(type.ToString());\n }\n }\n}" + } + }, + { + "id": "617841890b44fc101e61a831", + "exampleId": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationOptions#1", + "uid": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Claims;\nusing Cuemon.AspNetCore.Authentication.Basic;\n\nvar options = new BasicAuthenticationOptions\n{\n Realm = \"docs-example\",\n RequireSecureConnection = false,\n Authenticator = (username, password) =>\n {\n if (username == \"Agent\" && password == \"Test\")\n {\n return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, BasicAuthorizationHeader.Scheme));\n }\n\n return null;\n }\n};\n\noptions.ValidateOptions();\n\nConsole.WriteLine(options.Realm);" + } + }, + { + "id": "61a5acfbdf7181ef2fad373b", + "exampleId": "Cuemon.Extensions.Xml.ByteArrayExtensions#1", + "uid": "Cuemon.Extensions.Xml.ByteArrayExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing System.Xml;\nusing Cuemon.Extensions.Xml;\n\nbyte[] xmlData = Encoding.UTF8.GetBytes(\"Value\");\n\n// Convert the byte array to an XmlReader\nusing (XmlReader reader = xmlData.ToXmlReader())\n{\n while (reader.Read())\n {\n if (reader.NodeType == XmlNodeType.Element)\n {\n Console.WriteLine(reader.Name);\n\n}}}" + } + }, + { + "id": "61e2178dda82cae907fc131d", + "exampleId": "Cuemon.AspNetCore.Http.ConflictException#1", + "uid": "Cuemon.AspNetCore.Http.ConflictException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http;\n\n// Create a ConflictException with default message\nvar ex = new ConflictException();\nConsole.WriteLine(ex.StatusCode); // 409\nConsole.WriteLine(ex.ReasonPhrase); // Conflict\nConsole.WriteLine(ex.Message); // The request could not be completed due to a conflict...\n\n// Create with a custom message\nvar custom = new ConflictException(\"A record with the same email address already exists.\");\nConsole.WriteLine(custom.Message);\n\n// Create with inner exception\nvar inner = new InvalidOperationException(\"Duplicate key violation.\");\nvar withInner = new ConflictException(\"Resource update conflict.\", inner);\nConsole.WriteLine(withInner.InnerException?.Message); // Duplicate key violation.\n\n// Use TryParse from the base class to resolve by status code\nif (HttpStatusCodeException.TryParse(409, out var parsed))\n{\n Console.WriteLine(parsed.Message); // The request could not be completed due to a conflict.\n Console.WriteLine(parsed.StatusCode); // 409\n}\n\n// Simulate a conflict check without throwing\nvar dbTimestamp = DateTime.UtcNow;\nvar clientTimestamp = dbTimestamp.AddHours(-1);\nif (clientTimestamp < dbTimestamp)\n{\n var conflict = new ConflictException(\n \"The resource was modified by another user. Please refresh and retry.\");\n Console.WriteLine(conflict.Message); // The resource was modified by another user...\n\n}" + } + }, + { + "id": "626bc27d58574044529a1e6f", + "exampleId": "Cuemon.Diagnostics.ExceptionDescriptor#1", + "uid": "Cuemon.Diagnostics.ExceptionDescriptor", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Diagnostics;\n\nvar descriptor = new ExceptionDescriptor(\n new InvalidOperationException(\"Order 12345 has already been processed.\"),\n code: \"OrderAlreadyProcessed\",\n message: \"The order cannot be modified because it has already been processed.\",\n helpLink: new Uri(\"https://docs.example.com/errors/order-already-processed\"));\n\ndescriptor.AddEvidence(\"OrderId\", 12345, value => value);\ndescriptor.AddEvidence(\"UserId\", \"alice@example.com\", value => value);\n\nConsole.WriteLine(descriptor.Code);\nConsole.WriteLine(descriptor.Message);\nConsole.WriteLine(descriptor.Evidence.Count);" + } + }, + { + "id": "628af8ccafe8f2da19ee2fc0", + "exampleId": "Cuemon.Extensions.Xml.StringExtensions#1", + "uid": "Cuemon.Extensions.Xml.StringExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.Xml;\n\n// Escape XML special characters\nvar unsafeText = \"Use & < > \\\" ' in XML\";\nvar escaped = unsafeText.EscapeXml();\nConsole.WriteLine(escaped); // \"Use & < > " ' in XML\"\n\n// Unescape XML back to original text\nvar unescaped = escaped.UnescapeXml();\nConsole.WriteLine(unescaped); // \"Use & < > \\\" ' in XML\"\n\n// Sanitize a string for use as an XML element name\nvar invalidName = \"1st Element Name!\";\nvar sanitizedName = invalidName.SanitizeXmlElementName();\nConsole.WriteLine(sanitizedName); // \"_st_Element_Name_\"\n\n// Sanitize XML element text (remove control characters except \\t, \\n, \\r)\nvar invalidText = \"Valid text \\x00 with \\x01 control chars\";\nvar sanitizedText = invalidText.SanitizeXmlElementText();\nConsole.WriteLine(sanitizedText); // \"Valid text with control chars\"\n\n// Sanitize XML element text with CDATA section rules (discourages \"]]>\" sequence)\nvar cdataText = \"text with ]]> inside\";\nvar sanitizedCdata = cdataText.SanitizeXmlElementText(cdataSection: true);\nConsole.WriteLine(sanitizedCdata); // \"text with ]] inside\"" + } + }, + { + "id": "62fb3bdecb7b61910d959626", + "exampleId": "Cuemon.Extensions.Collections.Generic.CollectionExtensions#1", + "uid": "Cuemon.Extensions.Collections.Generic.CollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Collections.Generic@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon.Extensions.Collections.Generic;\n\nICollection values = new List();\nvalues.AddRange(1, 2, 3, 4);\n\nvar partitioner = values.ToPartitioner(2);\n\nConsole.WriteLine(values.Count);\nConsole.WriteLine(partitioner.Count());" + } + }, + { + "id": "63bfda4be52013e253f299c7", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationInputFormatter#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationInputFormatter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml;\nusing Cuemon.Xml.Serialization.Formatters;\n\nvar options = new XmlFormatterOptions();\nvar formatter = new XmlSerializationInputFormatter(options);\n\nConsole.WriteLine($\"Supported media types: {string.Join(\", \", formatter.SupportedMediaTypes)}\");\nConsole.WriteLine($\"Supported encodings: {string.Join(\", \", formatter.SupportedEncodings.Select(e => e.WebName))}\");" + } + }, + { + "id": "640e025c7e4424e39f1b7268", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Headers.UserAgentSentinelFilter#1", + "uid": "Cuemon.AspNetCore.Mvc.Filters.Headers.UserAgentSentinelFilter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http.Headers;\nusing Cuemon.AspNetCore.Mvc.Filters.Headers;\nusing Microsoft.Extensions.Options;\n\nvar options = Options.Create(new UserAgentSentinelOptions\n{\n RequireUserAgentHeader = true,\n ValidateUserAgentHeader = true\n});\noptions.Value.AllowedUserAgents.Add(\"Cuemon-Agent\");\n\nvar filter = new UserAgentSentinelFilter(options);\n\nConsole.WriteLine(filter.Options.RequireUserAgentHeader);\nConsole.WriteLine(filter.Options.AllowedUserAgents.Count);" + } + }, + { + "id": "641e3314607e0efbe1f4c1d7", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptor#1", + "uid": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptor", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http;\nusing Cuemon.AspNetCore.Diagnostics;\n\n var descriptor = new HttpExceptionDescriptor(new BadRequestException())\n{\n Instance = new Uri(\"urn:request:42\"),\n RequestId = \"req-42\",\n CorrelationId = \"corr-42\"\n};\n\nConsole.WriteLine($\"{descriptor.StatusCode} {descriptor.Message}\");" + } + }, + { + "id": "64b6f8c3b5489af0abce2e5d", + "exampleId": "Cuemon.Data.SqlClient.SqlQueryBuilder#1", + "uid": "Cuemon.Data.SqlClient.SqlQueryBuilder", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0", + "Cuemon.Data.SqlClient@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon.Data;\nusing Cuemon.Data.SqlClient;\n\n// Build a SELECT query with key columns and optional columns\nvar selectBuilder = new SqlQueryBuilder(\n \"Employees\",\n new Dictionary { { \"EmployeeId\", \"@EmployeeId\" } },\n new Dictionary\n {\n { \"FirstName\", \"@FirstName\" },\n { \"LastName\", \"@LastName\" },\n { \"Email\", \"@Email\" }\n })\n{\n EnableTableAndColumnEncapsulation = true,\n EnableDirtyReads = true,\n EnableReadLimit = true,\n ReadLimit = 50\n};\n\nstring selectQuery = selectBuilder.GetQuery(QueryType.Select);\nConsole.WriteLine(selectQuery);\n// SELECT TOP 50 [EmployeeId],[FirstName],[LastName],[Email] FROM [Employees] WITH(NOLOCK) WHERE [EmployeeId]=@EmployeeId\n\n// Build an INSERT query\nvar insertBuilder = new SqlQueryBuilder(\n \"Employees\",\n new Dictionary(),\n new Dictionary\n {\n { \"FirstName\", \"@FirstName\" },\n { \"LastName\", \"@LastName\" },\n { \"Email\", \"@Email\" }\n })\n{\n EnableTableAndColumnEncapsulation = true\n};\n\nstring insertQuery = insertBuilder.GetQuery(QueryType.Insert);\nConsole.WriteLine(insertQuery);\n// INSERT INTO [Employees] ([FirstName],[LastName],[Email]) VALUES (@FirstName,@LastName,@Email)\n\n// Build an UPDATE query\nvar updateBuilder = new SqlQueryBuilder(\n \"Employees\",\n new Dictionary { { \"EmployeeId\", \"@EmployeeId\" } },\n new Dictionary\n {\n { \"FirstName\", \"@FirstName\" },\n { \"LastName\", \"@LastName\" }\n })\n{\n EnableTableAndColumnEncapsulation = true\n};\n\nstring updateQuery = updateBuilder.GetQuery(QueryType.Update);\nConsole.WriteLine(updateQuery);\n// UPDATE [Employees] SET [FirstName]=@FirstName,[LastName]=@LastName WHERE [EmployeeId]=@EmployeeId\n\n// Build a DELETE query\nvar deleteBuilder = new SqlQueryBuilder(\n \"Employees\",\n new Dictionary { { \"EmployeeId\", \"@EmployeeId\" } },\n new Dictionary())\n{\n EnableTableAndColumnEncapsulation = true\n};\n\nstring deleteQuery = deleteBuilder.GetQuery(QueryType.Delete);\nConsole.WriteLine(deleteQuery);\n// DELETE FROM [Employees] WHERE [EmployeeId]=@EmployeeId\n\n// Build an EXISTS query\nstring existsQuery = deleteBuilder.GetQuery(QueryType.Exists);\nConsole.WriteLine(existsQuery);" + } + }, + { + "id": "64c3e2821ec0270032fb6fde", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpLastModifiedHeaderFilter#1", + "uid": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpLastModifiedHeaderFilter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Mvc.Filters.Cacheable;\n\nvar filter = new HttpLastModifiedHeaderFilter();\nvar options = new HttpCacheableOptions();\noptions.Filters.Add(filter);\n\nConsole.WriteLine(filter.Options.HasLastModifiedProvider);\nConsole.WriteLine(options.Filters.Count);" + } + }, + { + "id": "6547eedabe61adc152ed0363", + "exampleId": "Cuemon.Extensions.Reflection.MemberInfoExtensions#1", + "uid": "Cuemon.Extensions.Reflection.MemberInfoExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Reflection@11.0.0" + ], + "source": "using System;\nusing System.ComponentModel;\nusing System.Reflection;\nusing Cuemon.Extensions.Reflection;\n\nnamespace MyApp.Examples;\n\npublic class MemberInfoExtensionsExample\n{\n [Description(\"Sample property with a DescriptionAttribute\")]\n public string AnnotatedProperty { get; set; }\n\n [Obsolete(\"This field is obsolete.\")]\n public string ObsoleteField;\n\n public string RegularProperty { get; set; }\n\n public static void Main()\n {\n var example = new MemberInfoExtensionsExample();\n var members = typeof(MemberInfoExtensionsExample).GetMembers(BindingFlags.Instance | BindingFlags.Public);\n\n foreach (MemberInfo member in members)\n {\n bool hasAttributes = member.HasAttributes(typeof(DescriptionAttribute), typeof(ObsoleteAttribute));\n Console.WriteLine($\"{member.Name} ({member.MemberType}): has target attributes = {hasAttributes}\");\n\n}}\n}" + } + }, + { + "id": "65c970f33a78e792f4f779c9", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcBuilderExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcBuilderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml;\nusing Microsoft.Extensions.DependencyInjection;\n\nvar services = new ServiceCollection();\nservices.AddLogging();\nvar builder = services.AddControllers();\n\nbuilder.AddXmlFormatters(options =>\n{\n options.Settings.Writer.Indent = true;\n});\n\nbuilder.AddXmlFormattersOptions(options =>\n{\n options.Settings.Writer.Indent = false;\n});\n\nusing var provider = services.BuildServiceProvider();\nConsole.WriteLine(\"MVC XML formatters configured.\");" + } + }, + { + "id": "65d6560bf8c29efc2c046ccc", + "exampleId": "Cuemon.Text.PreambleSequence#1", + "uid": "Cuemon.Text.PreambleSequence", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Text;\n\nvar options = new EncodingOptions\n{\n Encoding = Encoding.UTF8,\n Preamble = PreambleSequence.Keep\n};\n\nvar preambleAction = options.Preamble;\nvar encoding = options.Encoding;\n\nConsole.WriteLine(preambleAction); // outputs: Keep" + } + }, + { + "id": "6636f10992cec8203b8df199", + "exampleId": "Cuemon.Net.QueryStringCollection#1", + "uid": "Cuemon.Net.QueryStringCollection", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.Net;\n\n // Create an empty query string collection and add parameters.\n var qsc = new QueryStringCollection();\n qsc.Add(\"search\", \"dotnet\");\n qsc.Add(\"page\", \"2\");\n qsc.Add(\"sort\", \"name\");\n Console.WriteLine(\"Query string: {0}\", qsc); // search=dotnet&page=2&sort=name\n\n // Create from an existing URI query string.\n var fromUrl = new QueryStringCollection(\"?category=books&author=tolkien\");\n Console.WriteLine(\"Parsed query: {0}\", fromUrl); // category=books&author=tolkien\n\n // Create with URL decoding enabled.\n var encoded = new QueryStringCollection(\"q=hello%20world&lang=en\", urlDecode: true);\n Console.WriteLine(\"Decoded 'q': {0}\", encoded[\"q\"]); // hello world\n\n // Iterate over key-value pairs.\n Console.WriteLine(\"Parameters:\");\n foreach (var pair in fromUrl)\n {\n Console.WriteLine(\" {0} = {1}\", pair.Key, pair.Value);\n\n // Use AllKeys from the base NameValueCollection.\n Console.WriteLine(\"Keys: {0}\", string.Join(\", \", qsc.AllKeys));\n\n // Clone a QueryStringCollection.\n var clone = new QueryStringCollection(qsc);\n clone[\"page\"] = \"3\";\n Console.WriteLine(\"Original page: {0}\", qsc[\"page\"]); // 2\n Console.WriteLine(\"Cloned page: {0}\", clone[\"page\"]); // 3\n\n // Count entries.\n Console.WriteLine(\"Count: {0}\", qsc.Count);\n\n}" + } + }, + { + "id": "666a8d716451feb4d647a1ea", + "exampleId": "Cuemon.Xml.StringDecoratorExtensions#1", + "uid": "Cuemon.Xml.StringDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Xml;\n\n// Escape XML characters in a string\nvar raw = \"\";\nvar escaped = Decorator.Enclose(raw).EscapeXml();\nConsole.WriteLine($\"Escaped: {escaped}\");\n// Output: <hello & 'world' "test">\n\n// Unescape back to original\nvar unescaped = Decorator.Enclose(escaped).UnescapeXml();\nConsole.WriteLine($\"Unescaped: {unescaped}\");\n// Output: \n\n// Sanitize a string to be a valid XML element name\nvar invalidName = \"123order-details!.xml\";\nvar sanitizedName = Decorator.Enclose(invalidName).SanitizeXmlElementName();\nConsole.WriteLine($\"Sanitized element name: {sanitizedName}\");\n// Output: order-details.xml\n\n// Sanitize XML element text (remove control characters)\nvar textWithControlChars = \"Hello\\x0001\\x0002World\";\nvar cleanText = Decorator.Enclose(textWithControlChars).SanitizeXmlElementText();\nConsole.WriteLine($\"Clean text: {cleanText}\");\n// Output: HelloWorld\n\n// Sanitize with CDATA section rules (removes ]]> sequences)\nvar cdataText = \"Some data with ]]> embedded\";\nvar safeCdata = Decorator.Enclose(cdataText).SanitizeXmlElementText(cdataSection: true);\nConsole.WriteLine($\"Safe CDATA: {safeCdata}\");\n// Output: Some data with embedded" + } + }, + { + "id": "667b2f2a616981c05ac90547", + "exampleId": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationOptions#1", + "uid": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Claims;\nusing Cuemon.AspNetCore.Authentication.Hmac;\nusing Cuemon.Security.Cryptography;\n\nvar options = new HmacAuthenticationOptions\n{\n AuthenticationScheme = \"hmac-docs\",\n Algorithm = KeyedCryptoAlgorithm.HmacSha256,\n RequireSecureConnection = false,\n Authenticator = (string clientId, out string clientSecret) =>\n {\n clientSecret = clientId == \"Agent-Api\" ? \"Test\" : null;\n return clientSecret == null\n ? null\n : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, clientId) }, \"hmac-docs\"));\n }\n};\n\noptions.ValidateOptions();\n\nConsole.WriteLine(options.AuthenticationScheme);" + } + }, + { + "id": "6699d0446f0322e7594501f1", + "exampleId": "Cuemon.DelimitedStringOptions#1", + "uid": "Cuemon.DelimitedStringOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon; // for DelimitedStringOptions, DelimitedString\n\n// Default options: comma delimiter, double-quote qualifier\nvar defaultOptions = new DelimitedStringOptions();\nConsole.WriteLine($\"Delimiter: '{defaultOptions.Delimiter}'\"); // ','\nConsole.WriteLine($\"Qualifier: '{defaultOptions.Qualifier}'\"); // '\"'\n\n// Custom tab-delimited options\nvar tabOptions = new DelimitedStringOptions\n{\n Delimiter = \"\\t\",\n Qualifier = \"'\"\n};\n\n// Parse a tab-delimited line using the setup action\nstring tabLine = \"Alice\\t30\\tNew York\";\nstring[] fields = DelimitedString.Split(tabLine, o =>\n{\n o.Delimiter = tabOptions.Delimiter;\n o.Qualifier = tabOptions.Qualifier;\n});\nConsole.WriteLine($\"Fields: {string.Join(\", \", fields)}\"); // Alice, 30, New York\n\n// Parse a pipe-delimited line\nstring pipeLine = \"'Bob'|'25'|'London'\";\nfields = DelimitedString.Split(pipeLine, o =>\n{\n o.Delimiter = \"|\";\n o.Qualifier = \"'\";\n});\nConsole.WriteLine($\"Fields: {string.Join(\", \", fields)}\"); // Bob, 25, London" + } + }, + { + "id": "66b4b87c418aa393b7809e88", + "exampleId": "Cuemon.Xml.Serialization.XmlConvert#1", + "uid": "Cuemon.Xml.Serialization.XmlConvert", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Xml;\nusing System.Text;\nusing Cuemon.Xml.Serialization;\nusing XmlConvert = Cuemon.Xml.Serialization.XmlConvert;\n\nXmlConvert.DefaultSettings = () => new XmlSerializerOptions\n{\n Writer = new XmlWriterSettings { Encoding = Encoding.UTF8, IndentChars = \" \" }\n};\n\nvar settings = XmlConvert.DefaultSettings();\nConsole.WriteLine($\"Default encoding: {settings.Writer.Encoding.EncodingName}\");" + } + }, + { + "id": "66e0c4af6acff27a11743ffb", + "exampleId": "Cuemon.Data.Xml.XmlDataReader#1", + "uid": "Cuemon.Data.Xml.XmlDataReader", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Xml;\nusing Cuemon.Data.Xml;\n\n// Create XML data to read\nvar xml = @\"\n 1Alice95.5\n 2Bob87.0\n 3Charlie92.3\n\";\n\nusing var stringReader = new StringReader(xml);\nusing var xmlReader = XmlReader.Create(stringReader);\n\n// Create the XmlDataReader\nusing var dataReader = new XmlDataReader(xmlReader);\n\n// Read through the records like a database result set\nwhile (dataReader.Read())\n{\n Console.WriteLine($\"Row {dataReader.RowCount}:\");\n Console.WriteLine($\" Id: {dataReader[\"id\"]}\");\n Console.WriteLine($\" Name: {dataReader[\"name\"]}\");\n Console.WriteLine($\" Score: {dataReader[\"score\"]}\");\n Console.WriteLine($\" Depth: {dataReader.Depth}\");\n}\n\nConsole.WriteLine($\"Total rows read: {dataReader.RowCount}\");\n\n// Verify field count\nConsole.WriteLine($\"Fields per row: {dataReader.FieldCount}\");" + } + }, + { + "id": "67477e6fd1fe98e8658f376f", + "exampleId": "Cuemon.Text.EncodingOptions#1", + "uid": "Cuemon.Text.EncodingOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Text; // for EncodingOptions, PreambleSequence\n\n// Create options with UTF-8 encoding, removing the BOM preamble\nvar options = new EncodingOptions\n{\n Encoding = Encoding.UTF8,\n Preamble = PreambleSequence.Remove\n};\nConsole.WriteLine(options.Encoding.EncodingName); // Unicode (UTF-8)\nConsole.WriteLine(options.Preamble); // Remove\n\n// Create options that keep the preamble\nvar preserveOptions = new EncodingOptions\n{\n Encoding = Encoding.Unicode,\n Preamble = PreambleSequence.Keep\n};\nConsole.WriteLine(preserveOptions.Preamble); // Keep\n\n// Encoding property validates for null\n// options.Encoding = null; // throws ArgumentNullException" + } + }, + { + "id": "675e91b79ea3b606b7055877", + "exampleId": "Cuemon.Security.Cryptography.SHA512256#1", + "uid": "Cuemon.Security.Cryptography.SHA512256", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\n\nusing var algorithm = new SHA512256();\n\nvar digest = algorithm.ComputeHash(Encoding.UTF8.GetBytes(\"Hello, world!\"));\nalgorithm.Initialize();\nvar secondDigest = algorithm.ComputeHash(Encoding.UTF8.GetBytes(\"Hello, world!\"));\n\nConsole.WriteLine(digest.Length);\nConsole.WriteLine(digest.Length == secondDigest.Length);" + } + }, + { + "id": "67b4a4ec7dd8864f385beb2a", + "exampleId": "Cuemon.AspNetCore.Http.Headers.ChecksumBuilderDecoratorExtensions#1", + "uid": "Cuemon.AspNetCore.Http.Headers.ChecksumBuilderDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Security;\nusing Cuemon.AspNetCore.Http.Headers;\n\n var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128());\nvar entityTag = Decorator.Enclose(builder).ToEntityTagHeaderValue(isWeak: true);\n\nConsole.WriteLine(entityTag.ToString());" + } + }, + { + "id": "67d4fc15a7a4ec439a4f68cf", + "exampleId": "Cuemon.AspNetCore.Authentication.AuthenticationHandlerFeature#1", + "uid": "Cuemon.AspNetCore.Authentication.AuthenticationHandlerFeature", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Claims;\nusing Cuemon.AspNetCore.Authentication;\nusing Microsoft.AspNetCore.Authentication;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.Http.Features.Authentication;\n\nvar principal = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, \"Agent\") }, \"Basic\"));\nvar result = AuthenticateResult.Success(new AuthenticationTicket(principal, \"Basic\"));\nvar context = new DefaultHttpContext();\n\nAuthenticationHandlerFeature.Set(result, context);\n\nvar authenticateFeature = (AuthenticationHandlerFeature)context.Features.Get()!;\nvar httpAuthenticationFeature = (AuthenticationHandlerFeature)context.Features.Get()!;\n\nConsole.WriteLine(authenticateFeature.AuthenticateResult == result);\nConsole.WriteLine(httpAuthenticationFeature.User.Identity?.Name);" + } + }, + { + "id": "67e4a45fc99112034de3a0b0", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.Headers.ServiceCollectionExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Http.Headers.ServiceCollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http.Headers;\nusing Cuemon.Extensions.AspNetCore.Http.Headers;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\n\nvar services = new ServiceCollection();\nservices.AddOptions();\nservices.AddApiKeySentinelOptions(options =>\n{\n options.AllowedKeys.Add(\"known-key\");\n options.HeaderName = \"X-Test-Key\";\n options.UseGenericResponse = true;\n});\nservices.AddUserAgentSentinelOptions(options =>\n{\n options.AllowedUserAgents.Add(\"Cuemon-Agent\");\n options.RequireUserAgentHeader = true;\n options.ValidateUserAgentHeader = true;\n});\n\nusing var provider = services.BuildServiceProvider();\nvar apiKeyOptions = provider.GetRequiredService>().Value;\nvar userAgentOptions = provider.GetRequiredService>().Value;\n\nConsole.WriteLine($\"{apiKeyOptions.HeaderName}:{apiKeyOptions.AllowedKeys.Count}\");\nConsole.WriteLine($\"{userAgentOptions.RequireUserAgentHeader}:{userAgentOptions.AllowedUserAgents.Count}\");" + } + }, + { + "id": "67e6bd023fe0ad147f18a025", + "exampleId": "Cuemon.Data.Integrity.EntityDataIntegrityValidation#1", + "uid": "Cuemon.Data.Integrity.EntityDataIntegrityValidation", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Security;\n\nvar created = new DateTime(2024, 1, 2, 3, 4, 5, DateTimeKind.Utc);\nvar modified = created.AddHours(1);\nvar entity = new EntityInfo(\n created,\n modified,\n Encoding.UTF8.GetBytes(\"order-42\"),\n EntityDataIntegrityValidation.Strong);\n\nvar validator = new CacheValidator(entity, () => HashFactory.CreateFnv128());\n\nswitch (validator.Validation)\n{\n case EntityDataIntegrityValidation.Unspecified:\n Console.WriteLine(\"No checksum strength was supplied.\");\n break;\n case EntityDataIntegrityValidation.Weak:\n Console.WriteLine(\"The checksum is semantically valid.\");\n break;\n case EntityDataIntegrityValidation.Strong:\n Console.WriteLine(\"The checksum is byte-for-byte strong.\");\n break;\n}\n\nConsole.WriteLine($\"Validation: {validator.Validation}\");\nConsole.WriteLine($\"Checksum: {validator.Checksum.ToHexadecimalString()}\");" + } + }, + { + "id": "6854edc9b54f736179defc6e", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Filters.MvcBuilderExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Filters.MvcBuilderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.AspNetCore.Http;\nusing Cuemon.AspNetCore.Http.Throttling;\nusing Cuemon.Diagnostics;\nusing Cuemon.Extensions.AspNetCore.Mvc.Filters;\nusing Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable;\nusing Cuemon.Extensions.AspNetCore.Mvc.Filters.Diagnostics;\nusing Microsoft.Extensions.DependencyInjection;\nusing Cuemon.Extensions.AspNetCore.Mvc.Filters.DocExamples;\n\nConsole.WriteLine(new MvcBuilderExtensionsExample().ConfigureServices());\n\nnamespace Cuemon.Extensions.AspNetCore.Mvc.Filters.DocExamples\n{\n public sealed class MvcBuilderExtensionsExample\n {\n public IServiceCollection ConfigureServices()\n {\n var services = new ServiceCollection();\n\n var builder = services\n .AddMvc()\n .AddApiKeySentinelOptions(options =>\n {\n options.AllowedKeys.Add(\"demo-key\");\n options.UseGenericResponse = true;\n })\n .AddThrottlingSentinelOptions(options =>\n {\n options.ContextResolver = context => context.Connection.RemoteIpAddress?.ToString() ?? \"anonymous\";\n options.Quota = new ThrottleQuota(100, 1, TimeUnit.Minutes);\n options.TooManyRequestsMessage = \"Rate limit exceeded.\";\n })\n .AddUserAgentSentinelOptions(options =>\n {\n options.RequireUserAgentHeader = true;\n options.ValidateUserAgentHeader = true;\n options.AllowedUserAgents.Add(\"DocsSample/1.0\");\n })\n .AddFaultDescriptorOptions(options =>\n {\n options.MarkExceptionHandled = true;\n options.SensitivityDetails = FaultSensitivityDetails.All;\n options.HttpFaultResolvers.AddHttpFaultResolver();\n })\n .AddHttpCacheableOptions(options =>\n {\n options.CacheControl.MaxAge = TimeSpan.FromMinutes(5);\n options.Filters.AddLastModifiedHeader();\n options.Filters.AddEntityTagHeader(entityTag =>\n {\n entityTag.UseEntityTagResponseParser = true;\n });\n });\n\n Console.WriteLine(builder.Services.Count);\n return builder.Services;\n }\n }\n}" + } + }, + { + "id": "689097df401157b541058acb", + "exampleId": "Cuemon.Security.Cryptography.SecureHashAlgorithm384#1", + "uid": "Cuemon.Security.Cryptography.SecureHashAlgorithm384", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\n\nvar algorithm = new SecureHashAlgorithm384();\nvar result = algorithm.ComputeHash(Encoding.UTF8.GetBytes(\"Payload for SHA-384\"));\n\nConsole.WriteLine(SecureHashAlgorithm384.BitSize);\nConsole.WriteLine(result.GetBytes().Length);" + } + }, + { + "id": "68a5a54a36e76851c9832e5a", + "exampleId": "Cuemon.Extensions.Collections.Generic.QueueExtensions#1", + "uid": "Cuemon.Extensions.Collections.Generic.QueueExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Collections.Generic@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon.Extensions.Collections.Generic;\n\nvar queue = new Queue();\nqueue.Enqueue(\"first\");\nqueue.Enqueue(\"second\");\n\nif (queue.TryPeek(out string result))\n{\n Console.WriteLine($\"Peeked: {result}\");\n}\n\nqueue.TryPeek(out string same);\nConsole.WriteLine(same);" + } + }, + { + "id": "68fbb102f914b7bee45cda4b", + "exampleId": "Cuemon.AspNetCore.Http.Headers.RequestIdentifierMiddleware#1", + "uid": "Cuemon.AspNetCore.Http.Headers.RequestIdentifierMiddleware", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading.Tasks;\nusing Cuemon.AspNetCore.Http.Headers;\nusing Cuemon.Messaging;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.Options;\n\nvar context = new DefaultHttpContext();\nvar options = Options.Create(new RequestIdentifierOptions\n{\n Token = new RequestToken(\"req-42\")\n});\n\nvar middleware = new RequestIdentifierMiddleware(\n httpContext => httpContext.Response.WriteAsync(\"Hello\"),\n options);\n\nawait middleware.InvokeAsync(context);\n\n// The middleware writes this header when the response starts.\nConsole.WriteLine($\"{options.Value.HeaderName}: {options.Value.Token.RequestId}\");" + } + }, + { + "id": "697c8a8eded4b7a351a6d40c", + "exampleId": "Cuemon.Extensions.AspNetCore.Xml.Converters.XmlConverterExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Xml.Converters.XmlConverterExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Xml@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon.Diagnostics;\nusing Cuemon.Extensions.AspNetCore.Xml.Converters;\nusing Cuemon.Xml.Serialization.Converters;\nusing Cuemon.Xml.Serialization;\n\nvar converters = new List();\nconverters.AddProblemDetailsConverter();\nconverters.AddHttpExceptionDescriptorConverter(options =>\n{\n options.SensitivityDetails = FaultSensitivityDetails.All;\n});\nconverters.AddStringValuesConverter();\nconverters.AddHeaderDictionaryConverter();\nconverters.AddQueryCollectionConverter();\nconverters.AddFormCollectionConverter();\nconverters.AddCookieCollectionConverter();\n\nvar serializerOptions = new XmlSerializerOptions();\nforeach (var converter in converters)\n{\n serializerOptions.Converters.Add(converter);\n}\n\nConsole.WriteLine(serializerOptions.Converters.Count);\nConsole.WriteLine(serializerOptions.Converters[0].CanConvert(typeof(object)));" + } + }, + { + "id": "6a2510c253e8a562ea66e53c", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.AppImageTagHelper#1", + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.AppImageTagHelper", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Razor.TagHelpers;\nusing Microsoft.Extensions.Options;\nusing MyApp.Examples;\n\nAppImageTagHelperExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class AppImageTagHelperExample\n {\n public static void Demonstrate()\n {\n var options = Options.Create(CreateOptions());\n\n var tagHelper = new AppImageTagHelper(options)\n {\n Src = \"images/logo.svg\",\n Alt = \"Codebelt logo\"\n };\n\n Console.WriteLine(FormatAssetUrl(tagHelper.Options, tagHelper.Src));\n }\n\n private static AppTagHelperOptions CreateOptions() => new()\n {\n Scheme = ProtocolUriScheme.Relative,\n BaseUrl = \"static.cuemon.net\"\n };\n\n private static string FormatAssetUrl(AppTagHelperOptions options, string asset)\n {\n return options.GetFormattedBaseUrl() + asset;\n }\n }\n}" + } + }, + { + "id": "6ad5e1d298f529d0ac598bc7", + "exampleId": "Cuemon.Extensions.Xml.Serialization.XmlSerializerOptionsExtensions#1", + "uid": "Cuemon.Extensions.Xml.Serialization.XmlSerializerOptionsExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing System.Xml;\nusing Cuemon.Extensions.Xml.Serialization;\nusing Cuemon.Xml.Serialization;\n\n// Configure XmlSerializerOptions\nvar options = new XmlSerializerOptions\n{\n Reader = new XmlReaderSettings { IgnoreWhitespace = true },\n Writer = new XmlWriterSettings { Indent = true, Encoding = Encoding.UTF8 }\n};\n\n// Apply to default XmlConvert settings\noptions.ApplyToDefaultSettings();\n\n// After this call, XmlConvert.DefaultSettings will reflect the options\nConsole.WriteLine(options.Writer.Indent);\nConsole.WriteLine(options.Reader.IgnoreWhitespace);" + } + }, + { + "id": "6ae3c029a56668c172933d01", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Rendering.HtmlHelperExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Rendering.HtmlHelperExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Mvc@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text.Encodings.Web;\nusing System.Threading.Tasks;\nusing Cuemon.Extensions.AspNetCore.Mvc.Rendering;\nusing Microsoft.AspNetCore.Html;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.Mvc.ModelBinding;\nusing Microsoft.AspNetCore.Mvc.Rendering;\nusing Microsoft.AspNetCore.Mvc.ViewFeatures;\nusing Microsoft.AspNetCore.Routing;\n\nvar routeData = new RouteData();\nrouteData.Values[\"controller\"] = \"Home\";\nrouteData.Values[\"action\"] = \"Index\";\nrouteData.Values[\"page\"] = \"Contact\";\n\nvar helper = new HtmlHelperStub\n{\n ViewContext = new ViewContext\n {\n HttpContext = new DefaultHttpContext(),\n RouteData = routeData,\n ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary()),\n Writer = TextWriter.Null\n }\n};\n\nConsole.WriteLine(helper.UseWhenView(\"Index\", \"Home\", () => \"
Welcome to the Home Page
\"));\nConsole.WriteLine(helper.UseWhenPage(\"Contact\", () => \"Contact Us\"));\n\npublic sealed class HtmlHelperStub : IHtmlHelper\n{\n public ViewContext ViewContext { get; set; } = null!;\n public ViewDataDictionary ViewData { get; } = new(new EmptyModelMetadataProvider(), new ModelStateDictionary());\n public Html5DateRenderingMode Html5DateRenderingMode { get; set; }\n public string IdAttributeDotReplacement => \".\";\n public IModelMetadataProvider MetadataProvider { get; } = new EmptyModelMetadataProvider();\n public ITempDataDictionary TempData => throw new NotSupportedException();\n public UrlEncoder UrlEncoder { get; } = UrlEncoder.Default;\n public object ViewBag => throw new NotSupportedException();\n public IHtmlContent ActionLink(string linkText, string actionName, string controllerName, string protocol, string hostname, string fragment, object routeValues, object htmlAttributes) => throw new NotSupportedException();\n public IHtmlContent AntiForgeryToken() => throw new NotSupportedException();\n public MvcForm BeginForm(string actionName, string controllerName, object routeValues, FormMethod method, bool? antiforgery, object htmlAttributes) => throw new NotSupportedException();\n public MvcForm BeginRouteForm(string routeName, object routeValues, FormMethod method, bool? antiforgery, object htmlAttributes) => throw new NotSupportedException();\n public IHtmlContent CheckBox(string expression, bool? isChecked, object htmlAttributes) => throw new NotSupportedException();\n public IHtmlContent Display(string expression, string templateName, string htmlFieldName, object additionalViewData) => throw new NotSupportedException();\n public string DisplayName(string expression) => throw new NotSupportedException();\n public string DisplayText(string expression) => throw new NotSupportedException();\n public IHtmlContent DropDownList(string expression, IEnumerable selectList, string optionLabel, object htmlAttributes) => throw new NotSupportedException();\n public IHtmlContent Editor(string expression, string templateName, string htmlFieldName, object additionalViewData) => throw new NotSupportedException();\n public string Encode(object value) => throw new NotSupportedException();\n public string Encode(string value) => throw new NotSupportedException();\n public void EndForm() => throw new NotSupportedException();\n public string FormatValue(object value, string format) => throw new NotSupportedException();\n public string GenerateIdFromName(string fullName) => throw new NotSupportedException();\n public IEnumerable GetEnumSelectList() => throw new NotSupportedException();\n public IEnumerable GetEnumSelectList() where TEnum : struct => throw new NotSupportedException();\n public IEnumerable GetEnumSelectList(Type enumType) => throw new NotSupportedException();\n public IHtmlContent Hidden(string expression, object value, object htmlAttributes) => throw new NotSupportedException();\n public string Id(string expression) => throw new NotSupportedException();\n public IHtmlContent Label(string expression, string labelText, object htmlAttributes) => throw new NotSupportedException();\n public IHtmlContent ListBox(string expression, IEnumerable selectList, object htmlAttributes) => throw new NotSupportedException();\n public string Name(string expression) => throw new NotSupportedException();\n public Task PartialAsync(string partialViewName, object model, ViewDataDictionary viewData) => throw new NotSupportedException();\n public IHtmlContent Password(string expression, object value, object htmlAttributes) => throw new NotSupportedException();\n public IHtmlContent RadioButton(string expression, object value, bool? isChecked, object htmlAttributes) => throw new NotSupportedException();\n public IHtmlContent Raw(string value) => throw new NotSupportedException();\n public IHtmlContent Raw(object value) => throw new NotSupportedException();\n public Task RenderPartialAsync(string partialViewName, object model, ViewDataDictionary viewData) => throw new NotSupportedException();\n public IHtmlContent RouteLink(string linkText, string routeName, string protocol, string hostName, string fragment, object routeValues, object htmlAttributes) => throw new NotSupportedException();\n public IHtmlContent TextArea(string expression, string value, int rows, int columns, object htmlAttributes) => throw new NotSupportedException();\n public IHtmlContent TextBox(string expression, object value, string format, object htmlAttributes) => throw new NotSupportedException();\n public IHtmlContent ValidationMessage(string expression, string message, object htmlAttributes, string tag) => throw new NotSupportedException();\n public IHtmlContent ValidationSummary(bool excludePropertyErrors, string message, object htmlAttributes, string tag) => throw new NotSupportedException();\n public string Value(string expression, string format) => throw new NotSupportedException();\n}" + } + }, + { + "id": "6bb00540d68803f2dd399d85", + "exampleId": "Cuemon.Text.Stem#1", + "uid": "Cuemon.Text.Stem", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Text;\n\nvar path = new Stem(\"api\")\n .AttachPrefix(\"/\")\n .AttachSuffix(\"/\")\n .AttachSuffix(\"v1\")\n .AttachSuffix(\"/\")\n .AttachSuffix(\"users\");\n\nvar result = path.ToString();\n// result == \"/api/v1/users\"\nConsole.WriteLine(result);" + } + }, + { + "id": "6bb670bc4ca395540305a6b5", + "exampleId": "Cuemon.Threading.Awaiter#1", + "uid": "Cuemon.Threading.Awaiter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Cuemon.Threading;\n\nawait new AwaiterExample().DemonstrateAsync();\n\nnamespace Cuemon.Threading\n{\n public class AwaiterExample\n {\n public async Task DemonstrateAsync()\n {\n var attempt = 0;\n var cancellationSource = new CancellationTokenSource(TimeSpan.FromSeconds(10));\n\n var result = await Awaiter.RunUntilSuccessfulOrTimeoutAsync(async () =>\n {\n attempt++;\n if (attempt < 3)\n {\n await Task.Delay(50);\n return new UnsuccessfulValue();\n }\n return new SuccessfulValue();\n }, options =>\n {\n options.Timeout = TimeSpan.FromSeconds(5);\n options.Delay = TimeSpan.FromMilliseconds(100);\n options.CancellationToken = cancellationSource.Token;\n });\n\n Console.WriteLine($\"Succeeded after {attempt} attempts: {result.Succeeded}\");\n }\n }\n}" + } + }, + { + "id": "6c2cadee8a34aaa5ccbab5ff", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingAttribute#1", + "uid": "Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingAttribute", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading.Tasks;\nusing Cuemon;\nusing Cuemon.AspNetCore.Mvc.Filters.Diagnostics;\nusing Microsoft.AspNetCore.Mvc;\nusing Microsoft.AspNetCore.Mvc.Filters;\nusing Microsoft.Extensions.Logging;\nusing MyApp.Examples;\n\nServerTimingAttributeExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class ServerTimingAttributeExample\n {\n public static void Demonstrate()\n {\n var attribute = new ServerTimingAttribute\n {\n Name = \"weatherApi\",\n Description = \"Weather API endpoint\",\n Threshold = 500,\n ThresholdTimeUnit = TimeUnit.Milliseconds,\n DesiredLogLevel = LogLevel.Warning,\n EnvironmentName = string.Empty\n };\n\n Console.WriteLine(attribute.Name);\n Console.WriteLine(attribute is IFilterFactory);\n Console.WriteLine(attribute.IsReusable);\n }\n }\n [ApiController]\n [Route(\"weather\")]\n public sealed class WeatherController : ControllerBase\n {\n [HttpGet]\n [ServerTiming(\n Name = \"weatherApi\",\n Description = \"Weather API endpoint\",\n Threshold = 500,\n ThresholdTimeUnit = TimeUnit.Milliseconds,\n DesiredLogLevel = LogLevel.Warning)]\n public async Task GetWeatherAsync()\n {\n await Task.Delay(300);\n return Ok(new { Temperature = 22, Condition = \"Sunny\" });\n }\n }\n}" + } + }, + { + "id": "6c876f55ceffe837e622bff8", + "exampleId": "Cuemon.Extensions.Text.Json.Utf8JsonWriterAction`1#1", + "uid": "Cuemon.Extensions.Text.Json.Utf8JsonWriterAction`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\nusing Cuemon.Extensions.Text.Json;\n\nUtf8JsonWriterAction writer = (jsonWriter, value, _) =>\n jsonWriter.WriteStringValue(value.ToString(\"D\"));\n\nvar converter = DynamicJsonConverter.Create(writer: writer);\nvar json = JsonSerializer.Serialize(Guid.Parse(\"11111111-2222-3333-4444-555555555555\"), new JsonSerializerOptions\n{\n TypeInfoResolver = new DefaultJsonTypeInfoResolver(),\n Converters = { converter }\n});\n\nConsole.WriteLine(json);" + } + }, + { + "id": "6d563c7b526d50ef118efa66", + "exampleId": "Cuemon.Security.Cryptography.AesKeyOptions#1", + "uid": "Cuemon.Security.Cryptography.AesKeyOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Security.Cryptography;\nusing MyApp.Security.Cryptography;\n\nAesKeyOptionsExamples.ConfigureKeySize();\n\nnamespace MyApp.Security.Cryptography\n{\n public class AesKeyOptionsExamples\n {\n public static void ConfigureKeySize()\n {\n // Default is AesSize.Aes256 (32 bytes).\n var defaultOptions = new AesKeyOptions();\n Console.WriteLine(\"Default key size: {0}\", defaultOptions.Size); // Aes256\n\n // Generate a 128-bit key with AesKeyOptions.\n byte[] key128 = AesCryptor.GenerateKey(o =>\n {\n o.Size = AesSize.Aes128;\n });\n Console.WriteLine(\"128-bit key length: {0} bytes\", key128.Length); // 16\n\n // Generate a 192-bit key.\n byte[] key192 = AesCryptor.GenerateKey(o =>\n {\n o.Size = AesSize.Aes192;\n });\n Console.WriteLine(\"192-bit key length: {0} bytes\", key192.Length); // 24\n\n // Generate a 256-bit key explicitly.\n byte[] key256 = AesCryptor.GenerateKey(o =>\n {\n o.Size = AesSize.Aes256;\n });\n Console.WriteLine(\"256-bit key length: {0} bytes\", key256.Length); // 32\n }\n\n public static void CustomRandomStringProvider()\n {\n // Replace the default random string provider with a custom one.\n // The provider is used internally when generating passphrase-based keys.\n byte[] key = AesCryptor.GenerateKey(o =>\n {\n o.Size = AesSize.Aes128;\n o.RandomStringProvider = size => new string('X', size == AesSize.Aes128 ? 16 : size == AesSize.Aes192 ? 24 : 32);\n });\n\n Console.WriteLine(\"Custom provider key length: {0} bytes\", key.Length); // 16\n }\n\n public static void InspectDefaultProperties()\n {\n var options = new AesKeyOptions();\n Console.WriteLine(\"Default size: {0}\", options.Size); // Aes256\n Console.WriteLine(\"RandomStringProvider != null: {0}\", options.RandomStringProvider != null); // true\n }\n }\n}" + } + }, + { + "id": "6d716aca3cabc9f82f9b315b", + "exampleId": "Cuemon.Security.Cryptography.HmacSecureHashAlgorithm1#1", + "uid": "Cuemon.Security.Cryptography.HmacSecureHashAlgorithm1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\nusing MyApp.Examples;\n\nHmacSecureHashAlgorithm1Example.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class HmacSecureHashAlgorithm1Example\n {\n public static void Demonstrate()\n {\n var algorithm = new HmacSecureHashAlgorithm1(CreateSecret(), null);\n var result = algorithm.ComputeHash(Encoding.UTF8.GetBytes(\"Authenticate this message\"));\n\n Console.WriteLine(result.GetBytes().Length);\n Console.WriteLine(result.ToBase64String());\n }\n\n private static byte[] CreateSecret() => Encoding.UTF8.GetBytes(\"docs-secret-sha1\");\n }\n}" + } + }, + { + "id": "6dee641f323f5722009b2fd5", + "exampleId": "Cuemon.Extensions.ByteExtensions#1", + "uid": "Cuemon.Extensions.ByteExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Extensions;\n\nbyte[] data = { 0xEF, 0xBB, 0xBF, 0x48, 0x65, 0x6C, 0x6C, 0x6F };\nstring text = data.ToEncodedString();\nstring hex = data.ToHexadecimalString();\nstring binary = data.ToBinaryString();\nstring base64 = data.ToBase64String();\nstring urlBase64 = data.ToUrlEncodedBase64String();\n\ndata.TryDetectUnicodeEncoding(out Encoding detectedEncoding);\n\nConsole.WriteLine(text);\nConsole.WriteLine(hex);\nConsole.WriteLine(binary);\nConsole.WriteLine(base64);\nConsole.WriteLine(urlBase64);\nConsole.WriteLine(detectedEncoding?.WebName ?? \"unknown\");" + } + }, + { + "id": "6e08c27cb35d6fd2dace578a", + "exampleId": "Cuemon.Xml.HierarchyDecoratorExtensions#1", + "uid": "Cuemon.Xml.HierarchyDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0", + "Cuemon.Kernel@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Extensions.Runtime;\nusing Cuemon.Xml;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Xml.Serialization;\nusing MyApp.Examples;\n\nHierarchyDecoratorExtensionsExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class HierarchyDecoratorExtensionsExample\n {\n public static void Demonstrate()\n {\n var hierarchy = new Hierarchy();\n var root = hierarchy.Add(new Person { Name = \"Alice\" });\n var child = root.Add(new Address { City = \"Paris\" });\n\n var decorator = Decorator.Enclose((IHierarchy)child);\n var rootDecorator = Decorator.Enclose((IHierarchy)root);\n var qualifiedEntity = decorator.GetXmlQualifiedEntity();\n var hasRoot = rootDecorator.TryGetXmlRootAttribute(out _);\n var hasElement = decorator.TryGetXmlElementAttribute(out _);\n var hasText = decorator.TryGetXmlTextAttribute(out _);\n var hasAttribute = decorator.TryGetXmlAttributeAttribute(out _);\n var ordered = Decorator.Enclose((IEnumerable>)new[] { root, child }).OrderByXmlAttributes().ToList();\n\n Console.WriteLine(qualifiedEntity.LocalName);\n Console.WriteLine(hasRoot);\n Console.WriteLine(hasElement || hasText || hasAttribute);\n Console.WriteLine(decorator.IsNodeEnumerable());\n Console.WriteLine(decorator.HasXmlIgnoreAttribute());\n Console.WriteLine(ordered.Count);\n }\n\n [XmlRoot(\"person\")]\n private sealed class Person\n {\n public string Name { get; set; }\n }\n\n private sealed class Address\n {\n public string City { get; set; }\n }\n }\n}" + } + }, + { + "id": "6ea81c9383c4ffb995fb0bfb", + "exampleId": "Cuemon.Extensions.MutableTupleFactory#1", + "uid": "Cuemon.Extensions.MutableTupleFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Extensions;\n\nvar zero = MutableTupleFactory.CreateZero();\n\nvar one = MutableTupleFactory.CreateOne(42);\nConsole.WriteLine(one.Arg1);\n\nvar two = MutableTupleFactory.CreateTwo(\"Alice\", 30);\nConsole.WriteLine($\"{two.Arg1} is {two.Arg2} years old\");\n\nvar three = MutableTupleFactory.CreateThree(1, 2, 3);\n\nvar five = MutableTupleFactory.CreateFive('a', 'b', 'c', 'd', 'e');" + } + }, + { + "id": "6f3f7044c385dcea6327b1b7", + "exampleId": "Cuemon.Extensions.Net.Security.UriExtensions#1", + "uid": "Cuemon.Extensions.Net.Security.UriExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Extensions.Net.Security;\n\nvar secret = Encoding.UTF8.GetBytes(\"1234\");\nvar location = new Uri(\"https://example.com/search?q=cuemon\");\nvar signed = location.ToSignedUri(secret, DateTime.UtcNow.AddMinutes(-1), DateTime.UtcNow.AddMinutes(1));\n\nsigned.ValidateSignedUri(secret);\n\nConsole.WriteLine(signed != location);\nConsole.WriteLine(signed.AbsoluteUri);" + } + }, + { + "id": "6fe1e0a8193d7c030b87ca21", + "exampleId": "Cuemon.Globalization.World#1", + "uid": "Cuemon.Globalization.World", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Globalization;\nusing System.Linq;\nusing Cuemon.Globalization;\n\nvar regions = World.Regions.ToList();\nConsole.WriteLine($\"Number of regions: {regions.Count}\");\n\nvar statisticalRegions = World.StatisticalRegions.ToList();\nConsole.WriteLine($\"Statistical regions: {statisticalRegions.Count}\");\n\nvar country = World.GetStatisticalRegion(\"840\");\nConsole.WriteLine($\"United States M.49: {country?.Name}\");\n\nvar cultures = World.GetCultures(new RegionInfo(\"US\"));\nforeach (var culture in cultures)\n{\n Console.WriteLine($\"Culture: {culture.DisplayName}\");\n}" + } + }, + { + "id": "6fe6f772f176efcecb3061cb", + "exampleId": "Cuemon.AspNetCore.Mvc.TooManyRequestsResult#1", + "uid": "Cuemon.AspNetCore.Mvc.TooManyRequestsResult", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Mvc;\nusing Microsoft.AspNetCore.Mvc;\nusing MyApp.Examples;\n\nConsole.WriteLine(new RateLimitController().GetData());\n\nnamespace MyApp.Examples\n{\n public class RateLimitController : Controller\n {\n [HttpGet(\"/api/rate-limited\")]\n public IActionResult GetData()\n {\n var result = new TooManyRequestsResult();\n Console.WriteLine(result.StatusCode); // 429\n return result;\n\n }\n }\n}" + } + }, + { + "id": "6faa4e81d231e4605cdd95e8", + "exampleId": "Cuemon.Extensions.AspNetCore.Authentication.AuthenticationBuilderExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Authentication.AuthenticationBuilderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Extensions.AspNetCore.Authentication@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Claims;\nusing Cuemon.AspNetCore.Authentication.Basic;\nusing Cuemon.AspNetCore.Authentication.Digest;\nusing Cuemon.AspNetCore.Authentication.Hmac;\nusing Cuemon.Extensions.AspNetCore.Authentication;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\nusing MyApp.Examples;\n\nAuthenticationBuilderExtensionsExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class AuthenticationBuilderExtensionsExample\n {\n public static void Demonstrate()\n {\n var services = new ServiceCollection();\n\n services.AddLogging();\n services.AddInMemoryDigestAuthenticationNonceTracker();\n services.AddAuthentication(BasicAuthorizationHeader.Scheme)\n .AddBasic(o =>\n {\n o.Authenticator = (username, password) => new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, BasicAuthorizationHeader.Scheme));\n o.RequireSecureConnection = false;\n })\n .AddDigestAccess(o =>\n {\n o.Authenticator = (string username, out string password) =>\n {\n password = \"Test\";\n return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, DigestAuthorizationHeader.Scheme));\n };\n o.RequireSecureConnection = false;\n })\n .AddHmac(o =>\n {\n o.AuthenticationScheme = \"hmac-docs\";\n o.Authenticator = (string clientId, out string clientSecret) =>\n {\n clientSecret = \"Test\";\n return new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, clientId) }, o.AuthenticationScheme));\n };\n o.RequireSecureConnection = false;\n });\n\n using var provider = services.BuildServiceProvider();\n\n var basicOptions = provider.GetRequiredService>().Get(BasicAuthorizationHeader.Scheme);\n var digestOptions = provider.GetRequiredService>().Get(DigestAuthorizationHeader.Scheme);\n var hmacOptions = provider.GetRequiredService>().Get(\"hmac-docs\");\n\n Console.WriteLine($\"Basic authentication requires HTTPS: {basicOptions.RequireSecureConnection}\");\n Console.WriteLine($\"Digest authentication requires HTTPS: {digestOptions.RequireSecureConnection}\");\n Console.WriteLine($\"HMAC authentication scheme: {hmacOptions.AuthenticationScheme}\");\n }\n }\n}" + } + }, + { + "id": "702134276e4ae08d2a5b0aa6", + "exampleId": "Cuemon.Data.DataTransferColumnCollection#1", + "uid": "Cuemon.Data.DataTransferColumnCollection", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Data;\nusing Cuemon.Data;\n\nvar table = new DataTable();\ntable.Columns.Add(\"Id\", typeof(int));\ntable.Columns.Add(\"Name\", typeof(string));\ntable.Columns.Add(\"Created\", typeof(DateTime));\ntable.Rows.Add(1, \"Alice\", new DateTime(2024, 1, 2, 3, 4, 5, DateTimeKind.Utc));\n\nusing var reader = table.CreateDataReader();\nreader.Read();\n\nDataTransferColumnCollection columns = DataTransfer.GetColumns(reader);\n\nConsole.WriteLine($\"Column count: {columns.Count}\");\nConsole.WriteLine($\"First column: {columns[0].Name} ({columns[0].DataType.Name})\");\nConsole.WriteLine($\"Name column ordinal: {columns[\"Name\"].Ordinal}\");\nConsole.WriteLine($\"Missing column found: {columns[\"Missing\"] != null}\");" + } + }, + { + "id": "705b005f353c871e56681e44", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpRequestEvidence#1", + "uid": "Cuemon.AspNetCore.Diagnostics.HttpRequestEvidence", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Text;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Microsoft.Extensions.Primitives;\nusing Microsoft.AspNetCore.Http;\n\nvar context = new DefaultHttpContext();\ncontext.Request.Scheme = \"https\";\ncontext.Request.Host = new HostString(\"api.example.com\");\ncontext.Request.Path = \"/orders\";\ncontext.Request.QueryString = new QueryString(\"?status=pending\");\ncontext.Request.Method = HttpMethods.Post;\ncontext.Request.ContentType = \"application/x-www-form-urlencoded\";\ncontext.Request.Headers[\"Authorization\"] = \"Bearer eyJhbGci...\";\ncontext.Request.Headers[\"X-Trace-Id\"] = \"abc-123\";\ncontext.Request.Form = new FormCollection(\n new Dictionary\n {\n { \"customerId\", \"42\" }\n });\n\n// Capture the request body so HttpRequestEvidence can retrieve it\nvar bodyBytes = Encoding.UTF8.GetBytes(\"customerId=42\");\ncontext.Items[HttpRequestEvidence.HttpContextItemsKeyForCapturedRequestBody] =\n new MemoryStream(bodyBytes);\n\nvar evidence = new HttpRequestEvidence(context.Request);\n\nConsole.WriteLine($\"Location: {evidence.Location}\");\nConsole.WriteLine($\"Method: {evidence.Method}\");\nConsole.WriteLine($\"Auth Header: {evidence.Headers[\"Authorization\"]}\");\nConsole.WriteLine($\"Query: status={evidence.Query[\"status\"]}\");\nConsole.WriteLine($\"Form: customerId={evidence.Form[\"customerId\"]}\");\nConsole.WriteLine($\"Body: {evidence.Body}\");" + } + }, + { + "id": "7083124b13769a25e3631a5d", + "exampleId": "Cuemon.Extensions.AspNetCore.Configuration.ServiceCollectionExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Configuration.ServiceCollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Cuemon.Security.Cryptography@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.AspNetCore.Configuration;\nusing Cuemon.Extensions.AspNetCore.Configuration;\nusing Cuemon.Security.Cryptography;\nusing Microsoft.Extensions.DependencyInjection;\n\nvar services = new ServiceCollection();\nservices.AddOptions();\nservices.Configure(options =>\n{\n options.Assembly = typeof(ReleaseCacheBusting).Assembly;\n options.Algorithm = UnkeyedCryptoAlgorithm.Sha256;\n options.ReadByteForByteChecksum = true;\n});\n\nservices.AddAssemblyCacheBusting();\nservices.AddDynamicCacheBusting();\nservices.AddCacheBusting();\n\nusing var provider = services.BuildServiceProvider();\nvar versions = provider.GetServices().Select(cache => cache.Version).ToList();\n\nConsole.WriteLine(versions.Count);\nConsole.WriteLine(string.Join(\", \", versions));\n\npublic sealed class ReleaseCacheBusting : ICacheBusting\n{\n public string Version => \"20260618\";\n}" + } + }, + { + "id": "70fca55c7c1fa818b79defb9", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.CdnLinkTagHelper#1", + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.CdnLinkTagHelper", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Razor.TagHelpers;\nusing Microsoft.Extensions.Options;\nusing MyApp.Examples;\n\nCdnLinkTagHelperExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class CdnLinkTagHelperExample\n {\n public static void Demonstrate()\n {\n var options = Options.Create(CreateStylesheetOptions(\"nblcdn.net\"));\n\n var tagHelper = new CdnLinkTagHelper(options)\n {\n Href = \"packages/fontawesome/5.15.3/css/all.css\"\n };\n var stylesheetHref = tagHelper.Options.GetFormattedBaseUrl() + tagHelper.Href;\n\n Console.WriteLine(stylesheetHref);\n }\n\n private static CdnTagHelperOptions CreateStylesheetOptions(string baseUrl)\n {\n return new CdnTagHelperOptions\n {\n Scheme = ProtocolUriScheme.Https,\n BaseUrl = baseUrl\n };\n }\n }\n}" + } + }, + { + "id": "7137e1b3c53277027819065b", + "exampleId": "Cuemon.Runtime.Caching.CachingManager#1", + "uid": "Cuemon.Runtime.Caching.CachingManager", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Runtime.Caching@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Runtime.Caching;\n\nvar cache = CachingManager.Cache;\nvar key = \"myKey\";\nvar value = cache.Get(key);\nif (value == null)\n{\n cache.Add(key, DateTime.UtcNow, TimeSpan.FromMinutes(5));\n}\nvalue = cache.Get(key);\nConsole.WriteLine($\"Cached value: {value}\");\n\nvar sameValue = cache.Get(key);\nConsole.WriteLine($\"Same instance? {value == sameValue}\");" + } + }, + { + "id": "71b4339e023d93125f75d02a", + "exampleId": "Cuemon.ObjectFormattingOptions#1", + "uid": "Cuemon.ObjectFormattingOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Globalization;\nusing Cuemon;\n\n// Direct instantiation of ObjectFormattingOptions\nvar options = new ObjectFormattingOptions\n{\n FormatProvider = new CultureInfo(\"da-DK\")\n};\n\nvar value = \"1234.56\";\n\n// Convert the string to a double using Danish formatting\nvar result = Decorator.Enclose((object)value)\n .ChangeType(o =>\n {\n o.FormatProvider = new CultureInfo(\"da-DK\");\n });\n\nConsole.WriteLine(result); // Output: 1234.56" + } + }, + { + "id": "72a5aef61df037dcf47c696a", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.AppScriptTagHelper#1", + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.AppScriptTagHelper", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Razor.TagHelpers;\nusing Microsoft.Extensions.Options;\n\nvar options = Options.Create(new AppTagHelperOptions\n{\n Scheme = ProtocolUriScheme.Relative,\n BaseUrl = \"static.cuemon.net\"\n});\n\nvar tagHelper = new AppScriptTagHelper(options)\n{\n Src = \"js/app.js\",\n Defer = true\n};\n\nConsole.WriteLine(string.Concat(tagHelper.Options.GetFormattedBaseUrl(), tagHelper.Src));" + } + }, + { + "id": "72a8627aec108def85fa2cc3", + "exampleId": "Cuemon.Extensions.FileProviders.PortablePhysicalFileProvider#1", + "uid": "Cuemon.Extensions.FileProviders.PortablePhysicalFileProvider", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.FileProviders.Physical@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing Cuemon.Extensions.FileProviders;\n\nvar contentRoot = Path.Combine(Path.GetTempPath(), \"cuemon-docs\", \"wwwroot\");\nvar imageDirectory = Path.Combine(contentRoot, \"assets\", \"images\");\nDirectory.CreateDirectory(imageDirectory);\nFile.WriteAllText(Path.Combine(imageDirectory, \"logo.svg\"), \"\");\n\nusing var files = new PortablePhysicalFileProvider(contentRoot);\n\nvar logo = files.GetFileInfo(\"assets/images/logo.svg\");\nif (logo.Exists)\n{\n Console.WriteLine($\"Resolved file: {logo.Name}\");\n Console.WriteLine($\"Physical path: {logo.PhysicalPath}\");\n}\n\nvar images = files.GetDirectoryContents(\"ASSETS/IMAGES\");\nConsole.WriteLine($\"Image directory found: {images.Exists}\");\n\nvar changeToken = files.Watch(\"assets/images/logo.svg\");\nConsole.WriteLine($\"Change callbacks active: {changeToken.ActiveChangeCallbacks}\");" + } + }, + { + "id": "72b9f0dfc2cca1c4ae936381", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerOptions#1", + "uid": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing Cuemon.AspNetCore.Diagnostics;\n\n var options = new HttpExceptionDescriptorResponseHandlerOptions\n{\n ContentType = new MediaTypeHeaderValue(\"text/plain\"),\n ContentFactory = exceptionDescriptor => new StringContent(exceptionDescriptor.Message),\n StatusCodeFactory = exceptionDescriptor => (HttpStatusCode)exceptionDescriptor.StatusCode\n};\n\noptions.ValidateOptions();\n\nConsole.WriteLine(options.ContentType);" + } + }, + { + "id": "72d7ace2963ab100fc7c4da1", + "exampleId": "Cuemon.Reflection.TypeNameOptions#1", + "uid": "Cuemon.Reflection.TypeNameOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Reflection;\n\n// Direct instantiation of TypeNameOptions\nvar options = new TypeNameOptions\n{\n FullName = true,\n ExcludeGenericArguments = false\n};\n\nType type = typeof(Console);\n\nstring friendlyName = Decorator.Enclose(type).ToFriendlyName(o =>\n{\n o.FullName = true;\n o.ExcludeGenericArguments = false;\n});\n// friendlyName == \"System.Console\"\nConsole.WriteLine(friendlyName);\n\nfriendlyName = Decorator.Enclose(type).ToFriendlyName(o =>\n{\n o.FullName = false;\n});\n// friendlyName == \"Console\"\nConsole.WriteLine(friendlyName);" + } + }, + { + "id": "72e8f97ae4d6693ccecee6c5", + "exampleId": "Cuemon.Extensions.AspNetCore.Diagnostics.ApplicationBuilderExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Diagnostics.ApplicationBuilderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.Extensions.AspNetCore.Diagnostics;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.Extensions.DependencyInjection;\n\nvar services = new ServiceCollection();\nservices.AddLogging();\nservices.AddServerTiming();\nservices.AddFaultDescriptorOptions();\nusing var provider = services.BuildServiceProvider();\n\nvar app = new ApplicationBuilder(provider);\napp.UseServerTiming();\napp.UseFaultDescriptorExceptionHandler();\n\nConsole.WriteLine(\"Server-Timing and fault descriptor middleware configured.\");" + } + }, + { + "id": "74147b4a00b44e13eb7cfba8", + "exampleId": "Cuemon.Data.Integrity.DataIntegrityFactory#1", + "uid": "Cuemon.Data.Integrity.DataIntegrityFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Security;\nusing MyApp.Data;\n\nnew DataIntegrityFactoryExample().Demonstrate();\n\nnamespace MyApp.Data\n{\n public sealed class DataIntegrityFactoryExample\n {\n public void Demonstrate()\n {\n var file = new FileInfo(Path.GetTempFileName());\n try\n {\n File.WriteAllText(file.FullName, \"Sample data for integrity check.\");\n\n IDataIntegrity integrity = DataIntegrityFactory.CreateIntegrity(file, options =>\n {\n options.BytesToRead = 1024;\n options.IntegrityConverter = (fi, checksumBytes) =>\n {\n var hash = HashFactory.CreateCrc64().ComputeHash(checksumBytes);\n return new DataIntegrity(fi, hash);\n };\n });\n\n Console.WriteLine($\"Integrity: {integrity}\");\n }\n finally\n {\n file.Delete();\n }\n }\n }\n // Minimal IDataIntegrity implementation for demonstration\n public class DataIntegrity(FileInfo file, HashResult checksum) : IDataIntegrity\n {\n public FileInfo File { get; } = file;\n\n public HashResult Checksum { get; } = checksum;\n\n public override string ToString() => $\"{File.Name}: {Checksum.ToHexadecimalString()}\";\n }\n}" + } + }, + { + "id": "74c56cb40ddb896e973df09b", + "exampleId": "Cuemon.CharDecoratorExtensions#1", + "uid": "Cuemon.CharDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon;\n\n// Convert a sequence of characters to a sequence of single-character strings\nIEnumerable characters = \"Hello\".AsEnumerable();\n\nIEnumerable strings = Decorator.Enclose(characters).ToEnumerable();\nConsole.WriteLine(string.Join(\", \", strings)); // \"H, e, l, l, o\"\n\n// Convert a sequence of characters back to a single string\nstring result = Decorator.Enclose(characters).ToStringEquivalent();\nConsole.WriteLine(result); // \"Hello\"\n\n// Works with any IEnumerable including char arrays\nchar[] charArray = { 'A', 'B', 'C' };\nstring joined = Decorator.Enclose(charArray.AsEnumerable()).ToStringEquivalent();\nConsole.WriteLine(joined); // \"ABC\"" + } + }, + { + "id": "74eb5de683d654a7ac988607", + "exampleId": "Cuemon.IO.AsyncStreamCopyOptions#1", + "uid": "Cuemon.IO.AsyncStreamCopyOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Cuemon;\nusing Cuemon.IO;\n\nvar options = new AsyncStreamCopyOptions\n{\n BufferSize = 4096,\n LeaveOpen = true\n};\n\nusing var source = new MemoryStream(Encoding.UTF8.GetBytes(\"Copy me asynchronously.\"));\nusing var destination = new MemoryStream();\n\nawait Decorator.Enclose(source).CopyStreamAsync(destination, options.BufferSize, changePosition: true, ct: CancellationToken.None);\n\nbyte[] copied = await Decorator.Enclose(destination).ToByteArrayAsync(setup =>\n{\n setup.BufferSize = options.BufferSize;\n setup.LeaveOpen = options.LeaveOpen;\n});\n\nConsole.WriteLine(Encoding.UTF8.GetString(copied));" + } + }, + { + "id": "7548b33e2c766577b35482b3", + "exampleId": "Cuemon.ExceptionInvoker`1#1", + "uid": "Cuemon.ExceptionInvoker`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon;\n\nvar settings = new Dictionary(StringComparer.OrdinalIgnoreCase);\n\nExceptionInvoker invoker =\n new ExceptionCondition()\n .IsTrue(() => !settings.ContainsKey(\"ConnectionString\"))\n .Create(() => new InvalidOperationException(\"A ConnectionString setting is required before the data pipeline can start.\"));\n\nbool threw = false;\n\ntry\n{\n invoker.TryThrow();\n}\ncatch (InvalidOperationException ex)\n{\n threw = true;\n Console.WriteLine(ex.Message);\n}\n\nConsole.WriteLine($\"Threw: {threw}\");" + } + }, + { + "id": "75a0528e37206a742b4f3ff2", + "exampleId": "Cuemon.Extensions.DependencyInjection.ServiceCollectionExtensions#1", + "uid": "Cuemon.Extensions.DependencyInjection.ServiceCollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.DependencyInjection@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.DependencyInjection;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\nusing Cuemon.Docs.Samples.DependencyInjection;\n\nServiceCollectionExtensionsExample.Demonstrate();\n\nnamespace Cuemon.Docs.Samples.DependencyInjection\n{\n public static class ServiceCollectionExtensionsExample\n {\n public static void Demonstrate()\n {\n var services = new ServiceCollection();\n\n services.Add(options =>\n {\n options.Lifetime = ServiceLifetime.Scoped;\n });\n services.TryAdd(options =>\n {\n options.Lifetime = ServiceLifetime.Scoped;\n });\n services.TryAdd, OrdersMessageHandler>(options =>\n {\n options.Lifetime = ServiceLifetime.Singleton;\n });\n services.TryAdd(typeof(IMessageHandler), typeof(OrdersMessageHandler), options =>\n {\n options.Lifetime = ServiceLifetime.Singleton;\n });\n services.TryAdd(typeof(IMessageHandler), typeof(OrdersMessageHandler), ServiceLifetime.Scoped, options =>\n {\n options.Label = \"typed\";\n });\n services.TryAdd, OrdersMessageHandler, HandlerOptions>(ServiceLifetime.Scoped, options =>\n {\n options.Enabled = true;\n });\n services.TryConfigure(options =>\n {\n options.Label = \"configured\";\n });\n services.PostConfigureAllOf(options =>\n {\n options.Label = \"post-configured\";\n });\n\n using var provider = services.BuildServiceProvider();\n using var scope = provider.CreateScope();\n\n var concrete = scope.ServiceProvider.GetRequiredService();\n var typedContract = scope.ServiceProvider.GetRequiredService>();\n var marker = scope.ServiceProvider.GetRequiredService>();\n var handlerOptions = scope.ServiceProvider.GetRequiredService>().Value;\n\n Console.WriteLine(object.ReferenceEquals(concrete, typedContract));\n Console.WriteLine(object.ReferenceEquals(concrete, marker));\n Console.WriteLine(typedContract.Name);\n Console.WriteLine(handlerOptions.Label);\n }\n\n public sealed class OrdersChannel\n {\n }\n\n public interface IMessageHandler\n {\n string Name { get; }\n }\n\n public interface IMessageHandler : IMessageHandler, IDependencyInjectionMarker\n {\n }\n\n public sealed class HandlerOptions\n {\n public bool Enabled { get; set; }\n\n public string Label { get; set; } = string.Empty;\n }\n\n public sealed class OrdersMessageHandler : IMessageHandler\n {\n public string Name => nameof(OrdersMessageHandler);\n }\n }\n}" + } + }, + { + "id": "768b58f04bd295b15238ff68", + "exampleId": "Cuemon.IO.StreamFactory#1", + "uid": "Cuemon.IO.StreamFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing Cuemon.IO;\nusing Cuemon.Text;\n\n// Create a stream by writing to a StreamWriter\nStream stream = StreamFactory.Create(writer =>\n{\n writer.Write(\"Hello, StreamFactory!\");\n});\n\nConsole.WriteLine($\"Stream length: {stream.Length}\");\nConsole.WriteLine($\"Stream position: {stream.Position}\");\n\nusing var reader = new StreamReader(stream);\nstring content = reader.ReadToEnd();\nConsole.WriteLine(content);\n\n// Create a stream with encoding options\nStream utf32Stream = StreamFactory.Create(writer =>\n{\n writer.Write(\"UTF-32 encoded content\");\n}, options =>\n{\n options.Encoding = Encoding.UTF32;\n options.Preamble = PreambleSequence.Remove;\n});\n\nusing var utf32Reader = new StreamReader(utf32Stream, Encoding.UTF32);\nConsole.WriteLine(utf32Reader.ReadToEnd());" + } + }, + { + "id": "76c72a695fb0fd1607163e3d", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Filters.FilterCollectionExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Filters.FilterCollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Mvc@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.AspNetCore.Mvc.Filters;\nusing Microsoft.AspNetCore.Mvc;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\n\nvar services = new ServiceCollection();\nservices.AddLogging();\nservices.AddControllers(options =>\n{\n options.Filters.AddHttpCacheable();\n options.Filters.AddFaultDescriptor();\n options.Filters.AddServerTiming();\n options.Filters.AddUserAgentSentinel();\n options.Filters.AddThrottlingSentinel();\n options.Filters.AddApiKeySentinel();\n});\n\nusing var provider = services.BuildServiceProvider();\nvar options = provider.GetRequiredService>().Value;\nConsole.WriteLine(options.Filters.Count);" + } + }, + { + "id": "76e1464c0ea7a7e769d7b323", + "exampleId": "Cuemon.AspNetCore.Http.Headers.ExpiresHeaderValue#1", + "uid": "Cuemon.AspNetCore.Http.Headers.ExpiresHeaderValue", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http.Headers;\n\n// Create an Expires header value that makes the response stale after 1 hour\nvar expires = new ExpiresHeaderValue(TimeSpan.FromHours(1));\n\n// The ToString() method produces the RFC 1123 format\nstring headerValue = expires.ToString();\nConsole.WriteLine($\"Expires: {headerValue}\");\n\n// Output example: \"Expires: Thu, 17 Jun 2026 12:00:00 GMT\"" + } + }, + { + "id": "775488ac5d1d6e0f07b6fd4f", + "exampleId": "Cuemon.Extensions.Runtime.HierarchyDecoratorExtensions#1", + "uid": "Cuemon.Extensions.Runtime.HierarchyDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon;\nusing Cuemon.Extensions.Runtime;\nusing MyApp.Examples;\n\nHierarchyDecoratorExtensionsExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class HierarchyDecoratorExtensionsExample\n {\n public static void Demonstrate()\n {\n var root = BuildStringHierarchy(out var childOne, out var grandchild, out _);\n\n var rootNode = Decorator.Enclose(grandchild).Root();\n var ancestors = Decorator.Enclose(grandchild).AncestorsAndSelf().Select(node => node.Instance).ToArray();\n var descendants = Decorator.Enclose(root).DescendantsAndSelf().Select(node => node.Instance).ToArray();\n var siblings = Decorator.Enclose(childOne).SiblingsAndSelf().Select(node => node.Instance).ToArray();\n var nodesAtDepth = Decorator.Enclose(grandchild).SiblingsAndSelfAt(1).Select(node => node.Instance).ToArray();\n var flattened = Decorator.Enclose(childOne).FlattenAll().Select(node => node.Instance).ToArray();\n var firstChildName = Decorator.Enclose(root).FindFirstInstance(node => node.Instance.StartsWith(\"child\", StringComparison.Ordinal));\n var grandchildName = Decorator.Enclose(root).FindSingleInstance(node => node.Instance == \"grandchild\");\n var firstChildNode = Decorator.Enclose(root).FindFirst(node => node.Depth == 1);\n var grandchildNode = Decorator.Enclose(root).FindSingle(node => node.Instance == \"grandchild\");\n var childNames = Decorator.Enclose(root).FindInstance(node => node.Depth == 1).OrderBy(name => name).ToArray();\n var childNodes = Decorator.Enclose(root).Find(node => node.Depth == 1).ToArray();\n var indexedNode = Decorator.Enclose(root).NodeAt(2);\n\n Decorator.Enclose(grandchild).Replace((node, value) => node.Replace(value.ToUpperInvariant()));\n Decorator.Enclose(Decorator.Enclose(root).Find(node => node.Depth == 1)).ReplaceAll((node, value) => node.Replace(value.ToUpperInvariant()));\n\n var integerNode = BuildDataPairHierarchy(new DataPair(typeof(int).Name, \"42\", typeof(string)));\n var timestamp = new DateTime(2024, 1, 2, 3, 4, 5, DateTimeKind.Utc);\n var dateTimeNode = BuildDataPairHierarchy(new DataPair(\"When\", timestamp, typeof(DateTime)));\n var guid = Guid.Parse(\"11111111-2222-3333-4444-555555555555\");\n var guidNode = BuildDataPairHierarchy(new DataPair(\"Value\", guid.ToString(\"D\"), typeof(string)));\n var stringNode = BuildDataPairHierarchy(new DataPair(\"Text\", \"hello\", typeof(string)));\n var decimalNode = BuildDataPairHierarchy(new DataPair(\"Amount\", \"42.5\", typeof(string)));\n var uri = new Uri(\"https://example.com/path?value=42\", UriKind.Absolute);\n var uriNode = BuildDataPairHierarchy(new DataPair(\"OriginalString\", uri.OriginalString, typeof(string)));\n\n var typedValues = new object[]\n {\n Decorator.Enclose(integerNode).UseConvertibleFormatter(),\n Decorator.Enclose(dateTimeNode).UseDateTimeFormatter(),\n Decorator.Enclose(guidNode).UseGuidFormatter(),\n Decorator.Enclose(stringNode).UseStringFormatter(),\n Decorator.Enclose(decimalNode).UseDecimalFormatter(),\n Decorator.Enclose(uriNode).UseUriFormatter()\n };\n\n ICollection prices = Decorator.Enclose(BuildCollectionHierarchy(typeof(decimal), \"42.5\", \"84.0\")).UseCollection(typeof(decimal));\n IDictionary milestones = Decorator.Enclose(BuildDictionaryHierarchy(\n typeof(DateTime),\n new KeyValuePair(\"created\", timestamp),\n new KeyValuePair(\"updated\", timestamp.AddHours(2))))\n .UseDictionary(new[] { typeof(string), typeof(DateTime) });\n\n Console.WriteLine(rootNode.Instance);\n Console.WriteLine(string.Join(\" > \", ancestors));\n Console.WriteLine(string.Join(\", \", descendants));\n Console.WriteLine(string.Join(\", \", siblings));\n Console.WriteLine(string.Join(\", \", nodesAtDepth));\n Console.WriteLine(string.Join(\", \", flattened));\n Console.WriteLine(firstChildName);\n Console.WriteLine(grandchildName);\n Console.WriteLine(firstChildNode.Instance);\n Console.WriteLine(grandchildNode.Instance);\n Console.WriteLine(string.Join(\", \", childNames));\n Console.WriteLine(childNodes.Length);\n Console.WriteLine(indexedNode.Instance);\n Console.WriteLine(grandchild.Instance);\n Console.WriteLine(string.Join(\", \", root.GetChildren().Select(node => node.Instance)));\n Console.WriteLine(string.Join(\", \", typedValues));\n Console.WriteLine(string.Join(\", \", prices.Cast()));\n Console.WriteLine(string.Join(\", \", milestones.Keys.Cast()));\n }\n\n private static Hierarchy BuildStringHierarchy(out IHierarchy childOne, out IHierarchy grandchild, out IHierarchy childTwo)\n {\n var root = new Hierarchy();\n root.Add(\"root\");\n childOne = root.Add(\"child-one\");\n grandchild = childOne.Add(\"grandchild\");\n childTwo = root.Add(\"child-two\");\n return root;\n }\n\n private static IHierarchy BuildDataPairHierarchy(DataPair pair)\n {\n var hierarchy = new Hierarchy();\n hierarchy.Add(pair);\n return hierarchy;\n }\n\n private static IHierarchy BuildCollectionHierarchy(Type valueType, params object[] values)\n {\n var hierarchy = new Hierarchy();\n hierarchy.Add(new DataPair(\"Items\", null, typeof(List)));\n foreach (var value in values)\n {\n hierarchy.Add(CreateValuePair(valueType, value));\n }\n\n return hierarchy;\n }\n\n private static IHierarchy BuildDictionaryHierarchy(Type valueType, params KeyValuePair[] values)\n {\n var hierarchy = new Hierarchy();\n hierarchy.Add(new DataPair(\"Entries\", null, typeof(Dictionary)));\n foreach (var value in values)\n {\n var keyNode = hierarchy.Add(new DataPair(\"Key\", value.Key, typeof(string)));\n keyNode.Add(CreateValuePair(valueType, value.Value));\n }\n\n return hierarchy;\n }\n\n private static DataPair CreateValuePair(Type valueType, object value)\n {\n if (valueType.IsPrimitive)\n {\n return new DataPair(valueType.Name, value, value.GetType());\n }\n\n if (valueType == typeof(Uri))\n {\n return new DataPair(\"OriginalString\", value, typeof(string));\n }\n\n if (valueType == typeof(DateTime))\n {\n return new DataPair(\"When\", value, typeof(DateTime));\n }\n\n return new DataPair(\"Value\", value, value?.GetType() ?? typeof(object));\n }\n }\n}" + } + }, + { + "id": "77cfc4d2b1b9055ef3b01218", + "exampleId": "Cuemon.CasingMethod#1", + "uid": "Cuemon.CasingMethod", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing Cuemon;\nusing System;\n\nvar lower = CasingMethod.LowerCase;\nvar upper = CasingMethod.UpperCase;\nvar title = CasingMethod.TitleCase;\n\nConsole.WriteLine(lower); // outputs: LowerCase\nConsole.WriteLine(upper); // outputs: UpperCase\nConsole.WriteLine(title); // outputs: TitleCase" + } + }, + { + "id": "7842d58b92f3cbdc3abfd2a0", + "exampleId": "Cuemon.Xml.Serialization.XmlSerializerOptionsDecoratorExtensions#1", + "uid": "Cuemon.Xml.Serialization.XmlSerializerOptionsDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ], + "source": "using System;\nusing System.Xml;\nusing Cuemon;\nusing Cuemon.Xml.Serialization;\n\nnamespace MyApp.Examples;\n\npublic class XmlSerializerOptionsDecoratorExtensionsExample\n{\n public static void Main()\n {\n var options = new XmlSerializerOptions\n {\n Writer = new XmlWriterSettings { Indent = true, IndentChars = \" \" },\n RootName = new XmlQualifiedEntity(\"CustomRoot\")\n };\n\n // Apply the options as the default XmlWriterSettings globally.\n Decorator.Enclose(options).ApplyToDefaultSettings();\n\n // When running XmlConvert.EncodeName or similar, the default settings apply.\n Console.WriteLine(\"Default settings applied successfully.\");\n\n}\n}" + } + }, + { + "id": "7846bb1a7af981bd6eb55464", + "exampleId": "Cuemon.Extensions.Net.Http.SlimHttpClientFactory#1", + "uid": "Cuemon.Extensions.Net.Http.SlimHttpClientFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing Cuemon.Extensions.Net.Http;\n\n// Create a factory that reuses HttpClientHandler instances per name\nvar factory = new SlimHttpClientFactory(\n () => new HttpClientHandler\n {\n AllowAutoRedirect = false,\n MaxAutomaticRedirections = 5\n });\n\n// Create two named clients - they share the same handler pool\nusing var clientA = factory.CreateClient(\"ServiceA\");\nusing var clientB = factory.CreateClient(\"ServiceB\");\n\nclientA.BaseAddress = new Uri(\"https://service-a.example.com\");\nclientB.BaseAddress = new Uri(\"https://service-b.example.com\");\n\nConsole.WriteLine($\"ClientA base: {clientA.BaseAddress}\");\nConsole.WriteLine($\"ClientB base: {clientB.BaseAddress}\");" + } + }, + { + "id": "784b084d0280247b5d1f6a6f", + "exampleId": "Cuemon.AspNetCore.Authentication.Basic.BasicFields#1", + "uid": "Cuemon.AspNetCore.Authentication.Basic.BasicFields", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Authentication.Basic;\n\nvar builder = new BasicAuthorizationHeaderBuilder();\nbuilder.AddUserName(\"alice\");\nbuilder.AddPassword(\"s3cret\");\nvar header = builder.Build();\n\nConsole.WriteLine(BasicAuthorizationHeader.Scheme);\nConsole.WriteLine(BasicFields.Realm);\nConsole.WriteLine(BasicFields.Credentials);" + } + }, + { + "id": "78e348c26cd3eefc562ee250", + "exampleId": "Cuemon.Text.FallbackEncodingOptions#1", + "uid": "Cuemon.Text.FallbackEncodingOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Text;\n\nvar options = new FallbackEncodingOptions\n{\n TargetEncoding = Encoding.ASCII,\n EncoderFallback = EncoderFallback.ExceptionFallback,\n DecoderFallback = DecoderFallback.ExceptionFallback,\n Encoding = Encoding.UTF8,\n Preamble = PreambleSequence.Remove\n};\n\n// The options are ready to be used with encoding operations\n// that respect FallbackEncodingOptions. When an unsupported\n// character is encountered, an EncoderFallbackException will be thrown.\nConsole.WriteLine(options.TargetEncoding.WebName);\nConsole.WriteLine(options.Preamble);\nConsole.WriteLine(options.EncoderFallback.MaxCharCount);\nConsole.WriteLine(options.DecoderFallback.MaxCharCount);" + } + }, + { + "id": "7a1b28e27816b6b7872c8374", + "exampleId": "Cuemon.Extensions.Xml.Serialization.Converters.XmlConverterExtensions#1", + "uid": "Cuemon.Extensions.Xml.Serialization.Converters.XmlConverterExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Xml@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Xml;\nusing Cuemon.Diagnostics;\nusing Cuemon.Extensions.Xml.Serialization.Converters;\nusing Cuemon.Xml.Serialization;\nusing Cuemon.Xml.Serialization.Converters;\n\nIList converters = new List();\n\nconverters.InsertXmlConverter(\n 0,\n (writer, value, entity) => writer.WriteElementString(entity?.LocalName ?? \"Value\", value),\n (reader, objectType) => reader.ReadElementContentAsString(),\n objectType => objectType == typeof(string),\n new XmlQualifiedEntity(\"String\"));\n\nconverters.AddXmlConverter(\n (writer, value, entity) => writer.WriteElementString(entity?.LocalName ?? \"Value\", value.ToString()),\n (reader, objectType) => reader.ReadElementContentAsInt(),\n objectType => objectType == typeof(int),\n new XmlQualifiedEntity(\"Int32\"));\n\nconverters.AddEnumerableConverter();\nconverters.AddExceptionDescriptorConverter(options => options.SensitivityDetails = FaultSensitivityDetails.All);\nconverters.AddUriConverter();\nconverters.AddDateTimeConverter();\nconverters.AddTimeSpanConverter();\nconverters.AddStringConverter();\nconverters.AddExceptionConverter(includeStackTrace: true, includeData: true);\nconverters.AddFailureConverter();\n\nvar writerConverter = converters.FirstOrDefaultWriterConverter(typeof(Uri));\nvar readerConverter = converters.FirstOrDefaultReaderConverter(typeof(string));\n\nvar serializerOptions = new XmlSerializerOptions();\nserializerOptions.Converters.Clear();\nforeach (var converter in converters)\n{\n serializerOptions.Converters.Add(converter);\n}\n\nvar serializer = XmlSerializer.Create(serializerOptions);\nusing var stream = serializer.Serialize(new Uri(\"https://example.com/feed.xml\"), typeof(Uri));\nusing var xml = new StreamReader(stream);\n\nConsole.WriteLine(writerConverter is not null && readerConverter is not null);\nConsole.WriteLine(xml.ReadToEnd());" + } + }, + { + "id": "7bf1e6aaa5809ee1009e5d94", + "exampleId": "Cuemon.Extensions.AspNetCore.Text.Json.Formatters.ServiceCollectionExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Text.Json.Formatters.ServiceCollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Text.Json@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.Diagnostics;\nusing Cuemon.Extensions.AspNetCore.Text.Json.Formatters;\nusing Cuemon.Extensions.Text.Json.Formatters;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\n\nvar services = new ServiceCollection();\nservices.AddJsonFormatterOptions(options =>\n{\n options.SensitivityDetails = FaultSensitivityDetails.All;\n});\nservices.AddJsonExceptionResponseFormatter();\n\nusing var provider = services.BuildServiceProvider();\nvar options = provider.GetRequiredService>().Value;\nvar formatters = provider.GetServices().ToList();\n\nConsole.WriteLine(options.SensitivityDetails);\nConsole.WriteLine(formatters.Count);" + } + }, + { + "id": "7cf0d489e4dae6981802f960", + "exampleId": "Cuemon.Extensions.Reflection.AssemblyExtensions#1", + "uid": "Cuemon.Extensions.Reflection.AssemblyExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Reflection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Assembly = System.Reflection.Assembly;\nusing Cuemon.Extensions.Reflection;\n\nvar assembly = typeof(AssemblyExtensions).Assembly;\n\n// Get the assembly version (from AssemblyVersionAttribute)\nvar assemblyVersion = assembly.GetAssemblyVersion();\nConsole.WriteLine($\"Assembly version: {assemblyVersion}\"); // e.g., \"1.0.0.0\"\nConsole.WriteLine($\"Has alphanumeric version: {assemblyVersion.HasAlphanumericVersion}\"); // False\nConsole.WriteLine($\"Is semantic version: {assemblyVersion.IsSemanticVersion()}\"); // False\n\n// Get the file version (from AssemblyFileVersionAttribute)\nvar fileVersion = assembly.GetFileVersion();\nConsole.WriteLine($\"File version: {fileVersion}\"); // e.g., \"1.0.0.0\"\n\n// Get the product version (from AssemblyInformationalVersionAttribute)\nvar productVersion = assembly.GetProductVersion();\nConsole.WriteLine($\"Product version: {productVersion}\"); // e.g., \"1.0.0\"\nConsole.WriteLine($\"Has alphanumeric version: {productVersion.HasAlphanumericVersion}\"); // True (usually)\nConsole.WriteLine($\"Is semantic version: {productVersion.IsSemanticVersion()}\"); // True\n\n// Check if the assembly is a debug build\nvar isDebug = assembly.IsDebugBuild();\nConsole.WriteLine($\"Is debug build: {isDebug}\"); // True in Debug, False in Release" + } + }, + { + "id": "7d6c0122aad2dd26533ce63e", + "exampleId": "Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierMiddleware#1", + "uid": "Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierMiddleware", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http.Headers;\nusing Cuemon.Messaging;\nusing Cuemon.Net.Http;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\n\nvar services = new ServiceCollection();\nservices.AddLogging();\nservices.Configure(options =>\n{\n options.HeaderName = HttpHeaderNames.XCorrelationId;\n options.Token = new CorrelationToken();\n});\n\nusing var provider = services.BuildServiceProvider();\nvar app = new ApplicationBuilder(provider);\napp.UseMiddleware();\napp.Run(async context =>\n{\n var correlationId = context.Items[CorrelationIdentifierMiddleware.HttpContextItemsKey];\n await context.Response.WriteAsync($\"Correlation ID: {correlationId}\");\n});\n\nvar pipeline = app.Build();\nvar httpContext = new DefaultHttpContext { RequestServices = provider };\nawait pipeline(httpContext);\n\nConsole.WriteLine(httpContext.Items[CorrelationIdentifierMiddleware.HttpContextItemsKey]);" + } + }, + { + "id": "7d9d9f5c189b68b724135790", + "exampleId": "Cuemon.Net.Http.HttpHeaderNames#1", + "uid": "Cuemon.Net.Http.HttpHeaderNames", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing System.Threading.Tasks;\nusing Cuemon.Net.Http;\n\nusing var client = new HttpClient();\nusing var request = new HttpRequestMessage(HttpMethod.Get, \"https://example.com\");\n\n// Set request headers using the constants\nrequest.Headers.Add(HttpHeaderNames.Accept, \"application/json\");\nrequest.Headers.Add(HttpHeaderNames.Authorization, \"Bearer token123\");\nrequest.Headers.Add(HttpHeaderNames.UserAgent, \"MyApp/1.0\");\nrequest.Headers.Add(HttpHeaderNames.AcceptEncoding, \"gzip\");\n\nConsole.WriteLine(\"Request headers configured:\");\nforeach (var header in request.Headers)\n{\n Console.WriteLine($\" {header.Key}: {string.Join(\", \", header.Value)}\");\n}" + } + }, + { + "id": "7dac037ec19dadac590338ee", + "exampleId": "Cuemon.Text.AsyncEncodingOptions#1", + "uid": "Cuemon.Text.AsyncEncodingOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading.Tasks;\nusing System.Text;\nusing System.Threading;\nusing Cuemon.Text;\n\nusing var cts = new CancellationTokenSource();\nvar options = new AsyncEncodingOptions\n{\n Encoding = Encoding.UTF8,\n Preamble = PreambleSequence.Remove,\n CancellationToken = cts.Token\n};\n\n// The options can be passed to async encoding methods\n// that accept AsyncEncodingOptions. If cancellation is\n// requested, the operation will be cancelled gracefully.\nConsole.WriteLine(options.Encoding.WebName);\nConsole.WriteLine(options.Preamble);\nConsole.WriteLine(options.CancellationToken.CanBeCanceled);" + } + }, + { + "id": "7dd44f9075c0ee4520590b2e", + "exampleId": "Cuemon.Extensions.Xml.XmlCopyOptions#1", + "uid": "Cuemon.Extensions.Xml.XmlCopyOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Xml;\nusing Cuemon.Extensions.Xml;\nusing MyApp.Examples;\n\nnew XmlCopyOptionsExample().CopyXmlWithCustomSettings();\n\nnamespace MyApp.Examples\n{\n public class XmlCopyOptionsExample\n {\n public void CopyXmlWithCustomSettings()\n {\n // Configure writer settings for indentation and encoding\n var copyOptions = new XmlCopyOptions\n {\n WriterSettings = settings =>\n {\n settings.Indent = true;\n settings.IndentChars = \" \";\n settings.OmitXmlDeclaration = false;\n settings.NewLineOnAttributes = false;\n }\n };\n\n // Use the options to configure an XmlWriter during a copy operation\n string input = @\"text\";\n\n using (var reader = XmlReader.Create(new StringReader(input)))\n using (var writer = XmlWriter.Create(Console.Out, ConfigureWriter(copyOptions)))\n {\n writer.WriteNode(reader, false);\n }\n // Output:\n // \n // \n // text\n // \n }\n\n private static XmlWriterSettings ConfigureWriter(XmlCopyOptions options)\n {\n var settings = new XmlWriterSettings();\n options.WriterSettings?.Invoke(settings);\n return settings;\n }\n\n public void UseDefaults()\n {\n // Default options have null WriterSettings (no custom configuration)\n var options = new XmlCopyOptions();\n Console.WriteLine($\"WriterSettings: {(options.WriterSettings == null ? \"null (no customization)\" : \"configured\")}\");\n }\n }\n}" + } + }, + { + "id": "7e3ace94e70bcafa5eaa891d", + "exampleId": "Cuemon.Xml.Serialization.XmlQualifiedEntity#1", + "uid": "Cuemon.Xml.Serialization.XmlQualifiedEntity", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Xml.Serialization;\nusing Cuemon.Xml.Serialization;\n\n// Create an entity from local name only\nvar entity1 = new XmlQualifiedEntity(\"Order\");\nConsole.WriteLine($\"LocalName: {entity1.LocalName}\"); // Order\nConsole.WriteLine($\"Namespace: {entity1.Namespace}\"); // (null)\nConsole.WriteLine($\"Prefix: {entity1.Prefix}\"); // (null)\n\n// Create an entity with local name and namespace\nvar entity2 = new XmlQualifiedEntity(\"Order\", \"http://example.com/orders\");\nConsole.WriteLine($\"LocalName: {entity2.LocalName}, Namespace: {entity2.Namespace}\");\n\n// Create an entity with prefix, local name, and namespace\nvar entity3 = new XmlQualifiedEntity(\"o\", \"Order\", \"http://example.com/orders\");\nConsole.WriteLine($\"Prefix: {entity3.Prefix}, LocalName: {entity3.LocalName}, Namespace: {entity3.Namespace}\");\n\n// Create from XmlRootAttribute\nvar rootAttr = new XmlRootAttribute(\"PurchaseOrder\");\nvar fromRoot = new XmlQualifiedEntity(rootAttr);\nConsole.WriteLine($\"From XmlRoot: {fromRoot.LocalName} (Namespace: {fromRoot.Namespace})\");\nConsole.WriteLine($\"HasXmlRootDecoration: {fromRoot.HasXmlRootDecoration}\"); // True\n\n// Create from XmlElementAttribute\nvar elemAttr = new XmlElementAttribute(\"LineItem\");\nvar fromElement = new XmlQualifiedEntity(elemAttr);\nConsole.WriteLine($\"From XmlElement: {fromElement.LocalName}\");\nConsole.WriteLine($\"HasXmlElementDecoration: {fromElement.HasXmlElementDecoration}\"); // True\n\n// Create from XmlAttributeAttribute\nvar attr = new XmlAttributeAttribute(\"Quantity\");\nvar fromAttribute = new XmlQualifiedEntity(attr);\nConsole.WriteLine($\"From XmlAttribute: {fromAttribute.LocalName}\");\nConsole.WriteLine($\"HasXmlAttributeDecoration: {fromAttribute.HasXmlAttributeDecoration}\"); // True\n\n// Use with XmlSerializerOptions to set a custom root name\nvar options = new XmlSerializerOptions\n{\n RootName = new XmlQualifiedEntity(\"CustomRoot\", \"http://example.com/schema\")\n};\nConsole.WriteLine($\"Options root name: {options.RootName.LocalName}\");" + } + }, + { + "id": "7ee751fbf1a097b26a323aa2", + "exampleId": "Cuemon.Xml.XmlWriterDecoratorExtensions#1", + "uid": "Cuemon.Xml.XmlWriterDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Xml;\nusing Cuemon;\nusing Cuemon.Xml;\nusing Cuemon.Xml.Serialization;\n\nvar writer = new StringWriter();\nusing var xmlWriter = XmlWriter.Create(writer, new XmlWriterSettings { Indent = true });\nvar decorator = Decorator.Enclose(xmlWriter);\n\nvar person = new { FirstName = \"John\", LastName = \"Doe\", Age = 30 };\ndecorator.WriteXmlRootElement(person, (w, value, rootEntity) =>\n{\n w.WriteElementString(\"FirstName\", value.FirstName);\n w.WriteElementString(\"LastName\", value.LastName);\n w.WriteElementString(\"Age\", value.Age.ToString());\n}, new XmlQualifiedEntity(\"Person\"));\n\nxmlWriter.Flush();\nConsole.WriteLine(writer.ToString());\n\nvar manualWriter = new StringWriter();\nusing var manualXmlWriter = XmlWriter.Create(manualWriter, new XmlWriterSettings { Indent = true });\nvar manualDecorator = Decorator.Enclose(manualXmlWriter);\nmanualDecorator.WriteStartElement(new XmlQualifiedEntity(\"Person\"));\nmanualDecorator.WriteEncapsulatingElementIfNotNull(\"Doe\", new XmlQualifiedEntity(\"LastName\"), (w, value) => w.WriteString(value));\nmanualXmlWriter.WriteEndElement();\nmanualXmlWriter.Flush();\nConsole.WriteLine(manualWriter.ToString());\n\nvar versionWriter = new StringWriter();\nusing var versionXmlWriter = XmlWriter.Create(versionWriter, new XmlWriterSettings { Indent = true });\nvar versionDecorator = Decorator.Enclose(versionXmlWriter);\nversionDecorator.WriteObject(new Version(1, 0, 0, 0), o => o.Settings.RootName = new XmlQualifiedEntity(\"Version\"));\nversionXmlWriter.Flush();\nConsole.WriteLine(versionWriter.ToString());" + } + }, + { + "id": "7ef17850e7c84ccb8f84215f", + "exampleId": "Cuemon.Security.FowlerNollVo256#1", + "uid": "Cuemon.Security.FowlerNollVo256", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Numerics;\nusing System.Text;\nusing Cuemon;\nusing Cuemon.Security;\n\n// Create a FNV-1a 256-bit hash (default algorithm).\nvar fnv = new FowlerNollVo256();\n\nConsole.WriteLine($\"Bits: {fnv.Bits}\"); // 256\nConsole.WriteLine($\"Algorithm: {fnv.Options.Algorithm}\"); // Fnv1a\n\n// Compute hash of a UTF-8 encoded string.\nvar data = Encoding.UTF8.GetBytes(\"The quick brown fox jumps over the lazy dog\");\nvar hash = fnv.ComputeHash(data);\n\nConsole.WriteLine($\"Hash (hex): {hash.ToHexadecimalString()}\");\nConsole.WriteLine($\"Hash (b64): {hash.ToBase64String()}\");\nConsole.WriteLine($\"Hash length: {hash.GetBytes().Length} bytes\");\n\n// Configure byte order independently.\nvar fnvLe = new FowlerNollVo256(o =>\n{\n o.ByteOrder = Endianness.LittleEndian;\n});\nvar hashLe = fnvLe.ComputeHash(data);\nConsole.WriteLine($\"LE hash: {hashLe.ToHexadecimalString()}\");\n\n// Convert hash to an integer using the built-in converter.\nvar asBigInt = hash.To(b => new BigInteger(b));\nConsole.WriteLine($\"As integer: {asBigInt}\");" + } + }, + { + "id": "8014b51040d741e7f05caa9d", + "exampleId": "Cuemon.IO.StreamCopyOptions#1", + "uid": "Cuemon.IO.StreamCopyOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing Cuemon;\nusing Cuemon.IO;\n\n// Create and use StreamCopyOptions directly\nvar customOptions = new StreamCopyOptions { BufferSize = 4096, LeaveOpen = true };\nConsole.WriteLine($\"Buffer size: {customOptions.BufferSize}, Leave open: {customOptions.LeaveOpen}\");\n\n// Create a memory stream with some data\nvar source = new MemoryStream(Encoding.UTF8.GetBytes(\"Hello, StreamCopyOptions!\"));\n\n// Convert the stream to a byte array using custom StreamCopyOptions\nbyte[] bytes = Decorator.Enclose(source).ToByteArray(setup =>\n{\n setup.BufferSize = 4096;\n setup.LeaveOpen = true;\n});\n\nConsole.WriteLine($\"Read {bytes.Length} bytes\"); // 26\nConsole.WriteLine(Encoding.UTF8.GetString(bytes)); // Hello, StreamCopyOptions!\nConsole.WriteLine($\"Source stream is still open: {source.CanRead}\"); // True\n\n// Without LeaveOpen, the source stream is automatically disposed after reading\nvar temp = new MemoryStream(Encoding.UTF8.GetBytes(\"Temporary data.\"));\nbyte[] tempBytes = Decorator.Enclose(temp).ToByteArray(); // disposes 'temp'\nConsole.WriteLine(Encoding.UTF8.GetString(tempBytes)); // Temporary data.\nConsole.WriteLine($\"Stream was disposed: {!temp.CanRead}\"); // True\n\n// Using default options (BufferSize = 81920, LeaveOpen = false)\nvar data = new MemoryStream(Encoding.UTF8.GetBytes(\"Default options.\"));\nbyte[] result = Decorator.Enclose(data).ToByteArray();\nConsole.WriteLine(Encoding.UTF8.GetString(result)); // Default options." + } + }, + { + "id": "81b0607d5a43c84eea6fc977", + "exampleId": "Cuemon.Security.FowlerNollVoAlgorithm#1", + "uid": "Cuemon.Security.FowlerNollVoAlgorithm", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "using System;\nusing Cuemon.Security;\n\nnamespace MyApp.Examples;\n\npublic class FowlerNollVoAlgorithmExample\n{\n public static void Main()\n {\n FowlerNollVoAlgorithm[] variants = { FowlerNollVoAlgorithm.Fnv1, FowlerNollVoAlgorithm.Fnv1a };\n\n foreach (var variant in variants)\n {\n string label = variant switch\n {\n FowlerNollVoAlgorithm.Fnv1 => \"FNV-1 (original)\",\n FowlerNollVoAlgorithm.Fnv1a => \"FNV-1a (recommended)\",\n _ => \"Unknown\"\n };\n Console.WriteLine(\"{0} -> {1}\", variant, label);\n\n // Output:\n // Fnv1 -> FNV-1 (original)\n // Fnv1a -> FNV-1a (recommended)\n\n}}\n}" + } + }, + { + "id": "81ffca40f4929d80ab9e544a", + "exampleId": "Cuemon.Collections.Specialized.DictionaryDecoratorExtensions#1", + "uid": "Cuemon.Collections.Specialized.DictionaryDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "using System;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing Cuemon;\nusing Cuemon.Collections.Specialized;\n\nnamespace MyApp.Examples;\n\npublic class DictionaryDecoratorExtensionsExample\n{\n public static void Main()\n {\n var input = new Dictionary\n {\n [\"colors\"] = new[] { \"red\", \"green\", \"blue\" },\n [\"sizes\"] = new[] { \"small\", \"medium\", \"large\" }\n };\n\n // Wrap the dictionary with Decorator and call the extension method.\n NameValueCollection nvc = Decorator.Enclose(input).ToNameValueCollection();\n\n foreach (string key in nvc)\n {\n Console.WriteLine(\"{0} = {1}\", key, nvc[key]);\n\n // Output:\n // colors = red,green,blue\n // sizes = small,medium,large\n\n}}\n}" + } + }, + { + "id": "82c8bdf830073f26aa783121", + "exampleId": "Cuemon.Extensions.Data.Integrity.ChecksumBuilderExtensions#1", + "uid": "Cuemon.Extensions.Data.Integrity.ChecksumBuilderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Extensions.Data.Integrity@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Extensions.Data.Integrity;\nusing Cuemon.Security;\n\n// Create a ChecksumBuilder and use extension methods directly\nvar builder = new ChecksumBuilder(() => HashFactory.CreateFnv128());\n\n// Extension methods allow combining typed values without a Decorator wrapper\nbuilder.CombineWith(42); // int overload\nbuilder.CombineWith(3.14); // double overload\nbuilder.CombineWith(\"data\"); // string overload\n\nConsole.WriteLine($\"Combined checksum: {builder}\");\n\n// Works with all numeric types\nvar checksum = new ChecksumBuilder(() => HashFactory.CreateFnv32())\n .CombineWith((short)1)\n .CombineWith(2u)\n .CombineWith(3L)\n .CombineWith(4.0f)\n .CombineWith(5ul);\n\nConsole.WriteLine($\"All types: {checksum}\");\n\n// Combine with byte arrays\nvar withBytes = new ChecksumBuilder(() => HashFactory.CreateFnv32())\n .CombineWith(new byte[] { 0x01, 0x02, 0x03 });\n\nConsole.WriteLine($\"With bytes: {withBytes}\");" + } + }, + { + "id": "82c99822e33c2911937a0e68", + "exampleId": "Cuemon.AspNetCore.Http.BadRequestException#1", + "uid": "Cuemon.AspNetCore.Http.BadRequestException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http;\n\nvar missingFields = new[] { \"email\", \"displayName\" };\nvar exception = new BadRequestException(\n $\"The JSON payload is missing required fields: {string.Join(\", \", missingFields)}.\",\n new FormatException(\"Unexpected end of JSON input.\"));\n\nConsole.WriteLine(exception.StatusCode);\nConsole.WriteLine(exception.Message);\nConsole.WriteLine(exception.InnerException?.Message);" + } + }, + { + "id": "8374effecf66f5eec5c1e325", + "exampleId": "Cuemon.AspNetCore.Http.PreconditionFailedException#1", + "uid": "Cuemon.AspNetCore.Http.PreconditionFailedException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http;\n\nconst string currentEtag = \"\\\"v2\\\"\";\nconst string suppliedEtag = \"\\\"v1\\\"\";\nif (!string.Equals(suppliedEtag, currentEtag, StringComparison.Ordinal))\n{\n var exception = new PreconditionFailedException(\n $\"The supplied If-Match value {suppliedEtag} does not match the current ETag {currentEtag}.\",\n new InvalidOperationException(\"The resource changed after the client read it.\"));\n\n Console.WriteLine(exception.StatusCode);\n Console.WriteLine(exception.Message);\n Console.WriteLine(exception.InnerException?.Message);\n}" + } + }, + { + "id": "83acaca5a015390942bdfbe0", + "exampleId": "Cuemon.Resilience.TransientFaultEvidence#1", + "uid": "Cuemon.Resilience.TransientFaultEvidence", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Reflection;\nusing Cuemon.Resilience;\nusing MyApp.Resilience;\n\nTransientFaultEvidenceExamples.CreateWithMethodSignature();\n\nnamespace MyApp.Resilience\n{\n public class TransientFaultEvidenceExamples\n {\n public static void CreateWithMethodSignature()\n {\n var descriptor = new MethodSignature(\n \"MyApp.Services.PaymentService\",\n \"ProcessPayment\",\n new[] { \"orderId\", \"amount\" },\n new object[] { \"ORD-12345\", 99.99m }\n );\n\n var evidence = new TransientFaultEvidence(\n attempts: 3,\n recoveryWaitTime: TimeSpan.FromSeconds(2),\n totalRecoveryWaitTime: TimeSpan.FromSeconds(5),\n latency: TimeSpan.FromMilliseconds(1500),\n descriptor: descriptor\n );\n\n Console.WriteLine(evidence.ToString());\n Console.WriteLine(\"Attempts: {0}\", evidence.Attempts);\n Console.WriteLine(\"Last recovery wait: {0}\", evidence.RecoveryWaitTime);\n Console.WriteLine(\"Total recovery wait: {0}\", evidence.TotalRecoveryWaitTime);\n Console.WriteLine(\"Latency: {0}\", evidence.Latency);\n Console.WriteLine(\"Descriptor: {0}\", evidence.Descriptor);\n }\n\n public static void EqualityComparison()\n {\n var desc = new MethodSignature(\"App.MyClass\", \"DoWork\", new[] { \"id\" }, new object[] { 42 });\n\n var evidence1 = new TransientFaultEvidence(2, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), TimeSpan.FromMilliseconds(500), desc);\n var evidence2 = new TransientFaultEvidence(2, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), TimeSpan.FromMilliseconds(500), desc);\n\n Console.WriteLine(\"Equals: {0}\", evidence1.Equals(evidence2));\n Console.WriteLine(\"HashCode same: {0}\", evidence1.GetHashCode() == evidence2.GetHashCode());\n }\n\n public static void CreateWithMinimalInfo()\n {\n var descriptor = new MethodSignature(\"App.Service\", \"Execute\", Array.Empty(), Array.Empty());\n\n var evidence = new TransientFaultEvidence(\n attempts: 1,\n recoveryWaitTime: TimeSpan.Zero,\n totalRecoveryWaitTime: TimeSpan.Zero,\n latency: TimeSpan.FromMilliseconds(200),\n descriptor: descriptor\n );\n\n Console.WriteLine(\"Attempts: {0}\", evidence.Attempts);\n }\n }\n}" + } + }, + { + "id": "83b52d978d24338c0c1eab2e", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.HttpResponseExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Http.HttpResponseExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Net;\nusing System.Net.Http;\nusing System.Text;\nusing System.Threading.Tasks;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Extensions.AspNetCore.Http;\nusing Cuemon.Security;\nusing Microsoft.AspNetCore.Http;\n\nvar context = new DefaultHttpContext();\nvar request = context.Request;\nvar response = context.Response;\nresponse.Body = new MemoryStream();\n\nvar builder = new ChecksumBuilder(() => HashFactory.CreateFnv128());\nbuilder.CombineWith(Encoding.UTF8.GetBytes(\"Hello\"));\nresponse.AddOrUpdateEntityTagHeader(request, builder, isWeak: false);\n\nvar lastModified = new DateTime(2024, 6, 15, 10, 0, 0, DateTimeKind.Utc);\nresponse.AddOrUpdateLastModifiedHeader(request, lastModified);\n\nusing var message = new HttpResponseMessage(HttpStatusCode.OK);\nmessage.Headers.Add(\"X-Trace\", \"demo\");\nresponse.OnStartingInvokeTransformer(message, (source, target) =>\n{\n target.Headers[\"X-Transferred\"] = string.Join(string.Empty, source.Headers.GetValues(\"X-Trace\"));\n});\n\nawait response.WriteBodyAsync(() => new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F });\nawait response.StartAsync();\n\nConsole.WriteLine(response.Headers.ETag.ToString());\nConsole.WriteLine(response.Headers.LastModified.ToString());\nConsole.WriteLine(response.Headers[\"X-Transferred\"].ToString());\nresponse.Body.Position = 0;\nusing var reader = new StreamReader(response.Body);\nConsole.WriteLine(await reader.ReadToEndAsync());" + } + }, + { + "id": "83eb0aa8a7ea2218732f192e", + "exampleId": "Cuemon.Extensions.Collections.Generic.EnumerableExtensions#1", + "uid": "Cuemon.Extensions.Collections.Generic.EnumerableExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Collections.Generic@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon.Extensions.Collections.Generic;\nusing CuemonEnumerableExtensions = Cuemon.Extensions.Collections.Generic.EnumerableExtensions;\n\nvar values = new[] { 4, 1, 3, 2 };\nvar chunked = CuemonEnumerableExtensions.Chunk(values, 2).ToList();\nvar shuffled = CuemonEnumerableExtensions.Shuffle(values).ToArray();\nvar deterministicShuffle = CuemonEnumerableExtensions.Shuffle(values, (min, max) => min).ToArray();\nvar ascending = values.OrderAscending().ToArray();\nvar ascendingWithComparer = values.OrderAscending(Comparer.Default).ToArray();\nvar descending = CuemonEnumerableExtensions.OrderDescending(values).ToArray();\nvar random = values.RandomOrDefault();\nvar yielded = 5.Yield().Single();\nvar dictionary = CuemonEnumerableExtensions.ToDictionary(new[]\n{\n new KeyValuePair(\"alpha\", 1),\n new KeyValuePair(\"beta\", 2)\n});\nvar partitioner = values.ToPartitioner(2).ToList();\nvar pagination = values.ToPagination(() => values.Length).ToList();\nvar paginationList = values.ToPaginationList(() => values.Length);\n\nConsole.WriteLine(chunked.Count);\nConsole.WriteLine(shuffled.Length + deterministicShuffle.Length);\nConsole.WriteLine(string.Join(\", \", ascending));\nConsole.WriteLine(string.Join(\", \", ascendingWithComparer));\nConsole.WriteLine(string.Join(\", \", descending));\nConsole.WriteLine(random);\nConsole.WriteLine(yielded);\nConsole.WriteLine(dictionary[\"beta\"]);\nConsole.WriteLine(partitioner.Count);\nConsole.WriteLine(pagination.Count);\nConsole.WriteLine(paginationList.Count);" + } + }, + { + "id": "8597fc3e867998717795db56", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.CacheableObjectResultExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.CacheableObjectResultExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.AspNetCore.Mvc;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Extensions.AspNetCore.Mvc;\nusing Cuemon.Extensions.AspNetCore.Mvc.DocExamples;\n\nConsole.WriteLine(new CacheableObjectResultExample().CreateLastModifiedResult());\n\nnamespace Cuemon.Extensions.AspNetCore.Mvc.DocExamples\n{\n public sealed class CacheableObjectResultExample\n {\n public ICacheableObjectResult CreateLastModifiedResult()\n {\n var product = new ProductDto(42, \"Coffee Beans\");\n return product.WithLastModifiedHeader(options =>\n {\n options.TimestampProvider = _ => new DateTime(2024, 6, 1, 8, 0, 0, DateTimeKind.Utc);\n options.ChangedTimestampProvider = _ => new DateTime(2024, 6, 18, 8, 30, 0, DateTimeKind.Utc);\n });\n }\n\n public ICacheableObjectResult CreateEntityTagResult()\n {\n var product = new ProductDto(42, \"Coffee Beans\");\n return product.WithEntityTagHeader(options =>\n {\n options.ChecksumProvider = dto => Encoding.UTF8.GetBytes($\"{dto.Id}:{dto.Name}\");\n options.WeakChecksumProvider = _ => false;\n });\n }\n\n public ICacheableObjectResult CreateFullyCacheableResult()\n {\n var product = new ProductDto(42, \"Coffee Beans\");\n return product.WithCacheableHeaders(options =>\n {\n options.TimestampProvider = _ => new DateTime(2024, 6, 1, 8, 0, 0, DateTimeKind.Utc);\n options.ChangedTimestampProvider = _ => new DateTime(2024, 6, 18, 8, 30, 0, DateTimeKind.Utc);\n options.ChecksumProvider = dto => Encoding.UTF8.GetBytes($\"{dto.Id}:{dto.Name}\");\n options.WeakChecksumProvider = _ => false;\n });\n }\n\n public void Describe()\n {\n var result = CreateFullyCacheableResult();\n var timestamp = (IEntityDataTimestamp)result;\n var integrity = (IEntityDataIntegrity)result;\n var product = (ProductDto)result.Value;\n\n Console.WriteLine($\"{product.Name}: {(timestamp.Modified ?? timestamp.Created):O} [{integrity.Validation}]\");\n }\n }\n public sealed class ProductDto\n {\n public ProductDto(int id, string name)\n {\n Id = id;\n Name = name;\n }\n\n public int Id { get; }\n\n public string Name { get; }\n }\n}" + } + }, + { + "id": "85f77b7511583d36305c3374", + "exampleId": "Cuemon.Extensions.Text.Json.Utf8JsonReaderFunc`1#1", + "uid": "Cuemon.Extensions.Text.Json.Utf8JsonReaderFunc`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\nusing Cuemon.Extensions.Text.Json;\n\nUtf8JsonReaderFunc reader = (ref Utf8JsonReader jsonReader, Type _, JsonSerializerOptions __) =>\n Guid.Parse(jsonReader.GetString());\n\nvar converter = DynamicJsonConverter.Create(reader: reader);\nvar result = JsonSerializer.Deserialize(\"\\\"11111111-2222-3333-4444-555555555555\\\"\", new JsonSerializerOptions\n{\n TypeInfoResolver = new DefaultJsonTypeInfoResolver(),\n Converters = { converter }\n});\n\nConsole.WriteLine(result);" + } + }, + { + "id": "86260d5e2fdd88f222f3ccef", + "exampleId": "Cuemon.TesterFuncFactory`3#1", + "uid": "Cuemon.TesterFuncFactory`3", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Contoso.Validation;\n\nTesterFuncFactoryExample.Run();\n\nnamespace Contoso.Validation\n{\n public sealed class TesterFuncFactoryExample\n {\n public static void Run()\n {\n var factory = new TesterFuncFactory, string, bool>(\n (MutableTuple tuple, out string result) =>\n {\n result = $\"{tuple.Arg1},{tuple.Arg2},{tuple.Arg3}\";\n return true;\n },\n new MutableTuple(1, 2, 3));\n\n bool success = factory.ExecuteMethod(out string output);\n var clone = (TesterFuncFactory, string, bool>)factory.Clone();\n clone.ExecuteMethod(out string clonedOutput);\n\n Console.WriteLine($\"Success: {success}\");\n Console.WriteLine(output);\n Console.WriteLine(clonedOutput);\n }\n }\n}" + } + }, + { + "id": "874cda674becce3e326a75b8", + "exampleId": "Cuemon.AspNetCore.Mvc.TooManyRequestsObjectResult#1", + "uid": "Cuemon.AspNetCore.Mvc.TooManyRequestsObjectResult", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0" + ], + "source": "// Program.cs\nusing Cuemon.AspNetCore.Mvc;\nusing Microsoft.AspNetCore.Mvc;\nusing System;\nusing MyApp.Examples;\n\nConsole.WriteLine(new RateLimitController().GetData());\n\nnamespace MyApp.Examples\n{\n public class RateLimitController : Controller\n {\n [HttpGet(\"/api/rate-limited\")]\n public IActionResult GetData()\n {\n return new TooManyRequestsObjectResult(new\n {\n error = \"API rate limit exceeded. Please try again later.\",\n retryAfter = 60\n });\n\n }\n }\n}" + } + }, + { + "id": "8799955b6476bef870749b1b", + "exampleId": "Cuemon.Reflection.AssemblyContextOptions#1", + "uid": "Cuemon.Reflection.AssemblyContextOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing System.Reflection;\nusing Cuemon.Reflection;\nusing MyApp.Examples;\n\nnew AssemblyContextOptionsExample().FilterAssemblies();\n\nnamespace MyApp.Examples\n{\n public class AssemblyContextOptionsExample\n {\n public void FilterAssemblies()\n {\n // Configure to include only assemblies whose name contains \"Cuemon\"\n // and exclude the current assembly from results\n var assemblies = AssemblyContext.GetCurrentDomainAssemblies(o =>\n {\n o.AssemblyFilter = assembly =>\n assembly.FullName.StartsWith(\"Cuemon\", StringComparison.Ordinal);\n\n o.ReferencedAssemblyFilter = assemblyName =>\n assemblyName.FullName.StartsWith(\"Cuemon\", StringComparison.Ordinal);\n\n o.IncludeReferencedAssemblies = true;\n\n // Remove the default exclusion of Cuemon.Core\n o.ExcludedAssemblies.Clear();\n });\n\n foreach (var assembly in assemblies)\n {\n Console.WriteLine(assembly.GetName().Name);\n }\n }\n\n public void UseDefaults()\n {\n // Default options exclude System and Microsoft assemblies\n var options = new AssemblyContextOptions();\n Console.WriteLine($\"IncludeReferencedAssemblies: {options.IncludeReferencedAssemblies}\"); // true\n Console.WriteLine($\"AssemblyFilter: {(options.AssemblyFilter != null ? \"set\" : \"null\")}\");\n Console.WriteLine($\"ReferencedAssemblyFilter: {(options.ReferencedAssemblyFilter != null ? \"set\" : \"null\")}\");\n Console.WriteLine($\"ExcludedAssemblies count: {options.ExcludedAssemblies.Count}\");\n }\n\n public void GetCuemonAssemblies()\n {\n // Get all Cuemon assemblies in the current domain\n var cuemonAssemblies = AssemblyContext.GetCurrentDomainAssemblies(o =>\n {\n o.AssemblyFilter = a => a.FullName.StartsWith(\"Cuemon\", StringComparison.Ordinal);\n o.ReferencedAssemblyFilter = an => an.FullName.StartsWith(\"Cuemon\", StringComparison.Ordinal);\n o.IncludeReferencedAssemblies = true;\n o.ExcludedAssemblies.Clear();\n });\n\n Console.WriteLine($\"Found {cuemonAssemblies.Count} Cuemon assemblies:\");\n foreach (var asm in cuemonAssemblies)\n {\n Console.WriteLine($\" - {asm.GetName().Name} v{asm.GetName().Version}\");\n }\n }\n }\n}" + } + }, + { + "id": "880ff03e977cb10ea4747629", + "exampleId": "Cuemon.TypeArgumentOutOfRangeException#1", + "uid": "Cuemon.TypeArgumentOutOfRangeException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Contoso.Logging;\n\nTypeArgumentOutOfRangeExceptionExample.Run();\n\nnamespace Contoso.Logging\n{\n public sealed class TypeArgumentOutOfRangeExceptionExample\n {\n public static void Run()\n {\n LogLevel parsed = ParseEnum(\"Warning\");\n Console.WriteLine(parsed);\n\n try\n {\n ParseEnum(\"1\");\n }\n catch (TypeArgumentOutOfRangeException ex)\n {\n Console.WriteLine($\"{ex.ParamName}: {ex.ActualValue}\");\n }\n }\n\n private static TEnum ParseEnum(string text)\n where TEnum : struct\n {\n if (!typeof(TEnum).IsEnum)\n {\n throw new TypeArgumentOutOfRangeException(\n nameof(TEnum),\n typeof(TEnum),\n \"Type arguments must be enum types.\");\n }\n\n return (TEnum)Enum.Parse(typeof(TEnum), text, ignoreCase: true);\n }\n\n private enum LogLevel\n {\n Debug,\n Information,\n Warning,\n Error\n }\n }\n}" + } + }, + { + "id": "8882e8daf65f19468eab3d82", + "exampleId": "Cuemon.Collections.Generic.PartitionerEnumerable`1#1", + "uid": "Cuemon.Collections.Generic.PartitionerEnumerable`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.Collections.Generic;\n\n// Create a sequence of 1000 numbers\nvar numbers = Enumerable.Range(1, 1000);\n\n// Wrap in a partitioner with partition size of 100\nvar partitioner = new PartitionerEnumerable(numbers, partitionSize: 100);\n\nConsole.WriteLine(partitioner.PartitionSize); // 100\nConsole.WriteLine(partitioner.HasPartitions); // True\nConsole.WriteLine(partitioner.IteratedCount); // 0\n\n// Process the first partition (items 1-100)\nvar firstBatch = partitioner.ToList();\nConsole.WriteLine(firstBatch.Count); // 100\nConsole.WriteLine(firstBatch[0]); // 1\nConsole.WriteLine(firstBatch[99]); // 100\n\nConsole.WriteLine(partitioner.IteratedCount); // 1\nConsole.WriteLine(partitioner.HasPartitions); // True\n\n// Process the remaining partitions\nwhile (partitioner.HasPartitions)\n{\n var batch = partitioner.ToList();\n Console.WriteLine($\"Batch {partitioner.IteratedCount}: {batch.Count} items\");\n// After exhausting the sequence:\nConsole.WriteLine(partitioner.HasPartitions); // False\nConsole.WriteLine(partitioner.IteratedCount); // 10 (1000/100)\n\n// A partitioner can be iterated multiple times (each iteration\n// advances through the source sequence)\nvar words = new PartitionerEnumerable(\n new[] { \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\" },\n partitionSize: 3);\n\nwhile (words.HasPartitions)\n{\n var chunk = words.ToList();\n Console.WriteLine(string.Join(\",\", chunk));\n// Output:\n// a,b,c\n// d,e,f\n// g,h\n\n}}" + } + }, + { + "id": "88adb8381e9bdaffe39e4123", + "exampleId": "Cuemon.AspNetCore.Http.Headers.CacheableOptions#1", + "uid": "Cuemon.AspNetCore.Http.Headers.CacheableOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Microsoft.Net.Http.Headers;\nusing Cuemon.AspNetCore.Http.Headers;\n\n var options = new CacheableOptions\n{\n CacheControl = new CacheControlHeaderValue\n {\n Public = true,\n MaxAge = TimeSpan.FromHours(12)\n },\n Expires = new ExpiresHeaderValue(TimeSpan.FromHours(12))\n};\n\noptions.ValidateOptions();\nConsole.WriteLine($\"{options.UseCacheControl}:{options.UseExpires}\");" + } + }, + { + "id": "890011864474f5adaefd4c8f", + "exampleId": "Cuemon.AspNetCore.Http.Throttling.ThrottleQuota#1", + "uid": "Cuemon.AspNetCore.Http.Throttling.ThrottleQuota", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.AspNetCore.Http.Throttling;\n\n// Allow 100 requests per 1 minute window\nvar quotaPerMinute = new ThrottleQuota(100, 1, TimeUnit.Minutes);\nConsole.WriteLine($\"Rate limit: {quotaPerMinute.RateLimit}\");\nConsole.WriteLine($\"Window: {quotaPerMinute.Window.TotalMinutes} min\");\n\n// Allow 1000 requests per 1 hour window (using TimeSpan directly)\nvar quotaPerHour = new ThrottleQuota(1000, TimeSpan.FromHours(1));\nConsole.WriteLine($\"Rate limit: {quotaPerHour.RateLimit}\");\nConsole.WriteLine($\"Window: {quotaPerHour.Window.TotalHours} h\");\n\n// Allow 10 requests per 15 seconds\nvar quotaPer15Sec = new ThrottleQuota(10, 15, TimeUnit.Seconds);\nConsole.WriteLine($\"Rate limit: {quotaPer15Sec.RateLimit}\");\nConsole.WriteLine($\"Window: {quotaPer15Sec.Window.TotalSeconds} s\");\n\n// Use with ThrottleRequest to track usage\nvar request = new ThrottleRequest(quotaPerMinute);\nConsole.WriteLine($\"Initial total: {request.Total}\");\nConsole.WriteLine($\"Expires at: {request.Expires:R}\");\n\nrequest.IncrementTotal();\nConsole.WriteLine($\"After one request: {request.Total}\");\n\nrequest.Refresh(); // resets if window has expired" + } + }, + { + "id": "8a795658ae503c9d80e1a532", + "exampleId": "Cuemon.Diagnostics.Failure#1", + "uid": "Cuemon.Diagnostics.Failure", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Diagnostics;\n\nvar exception = new InvalidOperationException(\"The operation could not be completed.\");\nexception.Data[\"OperationId\"] = \"OP-42\";\n\nvar failure = new Failure(exception, FaultSensitivityDetails.StackTrace | FaultSensitivityDetails.Data);\n\nConsole.WriteLine(failure.Type);\nConsole.WriteLine(failure.Message);\nConsole.WriteLine(failure.Data[\"OperationId\"]);\nConsole.WriteLine(failure.GetUnderlyingSensitivity());" + } + }, + { + "id": "8accb88a0490330792c15a53", + "exampleId": "Cuemon.AspNetCore.Http.Headers.CacheableMiddleware#1", + "uid": "Cuemon.AspNetCore.Http.Headers.CacheableMiddleware", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading.Tasks;\nusing Cuemon.AspNetCore.Builder;\nusing Cuemon.AspNetCore.Http.Headers;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\nusing Microsoft.Net.Http.Headers;\n\nvar services = new ServiceCollection();\nservices.AddLogging();\nusing var provider = services.BuildServiceProvider();\nvar app = new ApplicationBuilder(provider);\n\nMiddlewareBuilderFactory.UseConfigurableMiddleware(app, options =>\n{\n options.CacheControl = new CacheControlHeaderValue\n {\n Public = true,\n MaxAge = TimeSpan.FromDays(1)\n };\n options.Expires = new ExpiresHeaderValue(TimeSpan.FromDays(1));\n});\n\nvar cacheOptions = Options.Create(new CacheableOptions\n{\n CacheControl = new CacheControlHeaderValue { Public = true, MaxAge = TimeSpan.FromDays(1) }\n});\nvar middleware = new CacheableMiddleware(_ => Task.CompletedTask, cacheOptions);\nConsole.WriteLine($\"CacheControl enabled: {cacheOptions.Value.UseCacheControl}\");" + } + }, + { + "id": "8b025d6616f341d7929ce679", + "exampleId": "Cuemon.Reflection.AssemblyDecoratorExtensions#1", + "uid": "Cuemon.Reflection.AssemblyDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing Cuemon;\nusing Cuemon.Reflection;\n\n // Get the entry assembly to inspect\n var assembly = Assembly.GetExecutingAssembly();\n var decorator = Decorator.Enclose(assembly);\n\n // Check if it's a debug build\n bool isDebug = decorator.IsDebugBuild(); // true in Debug config, false in Release\n\n // Get version information\n var asmVersion = decorator.GetAssemblyVersion(); // from AssemblyVersionAttribute\n var fileVersion = decorator.GetFileVersion(); // from AssemblyFileVersionAttribute\n var productVersion = decorator.GetProductVersion(); // from AssemblyInformationalVersionAttribute\n\n Console.WriteLine($\"Assembly version: {asmVersion}\");\n Console.WriteLine($\"File version: {fileVersion}\");\n Console.WriteLine($\"Product version: {productVersion}\");\n\n // Get types from the assembly, optionally filtered\n var allTypes = decorator.GetTypes(); // all types in the assembly\n var filteredByNamespace = decorator.GetTypes(namespaceFilter: \"Cuemon.Reflection\"); // types in a specific namespace\n var filteredByInterface = decorator.GetTypes(typeFilter: typeof(IDisposable)); // types implementing IDisposable\n\n // Load embedded manifest resources (partial name match)\n var resources = decorator.GetManifestResources(\"config\", ManifestResourceMatch.ContainsName);\n foreach (var resource in resources)\n {\n using var reader = new StreamReader(resource.Value);\n string content = reader.ReadToEnd();\n Console.WriteLine($\"Resource '{resource.Key}': {content.Length} chars\");\n\n // Find resources by file extension\n var jsonFiles = decorator.GetManifestResources(\".json\", ManifestResourceMatch.Extension);\n\n // Get a resource by exact name\n var singleResource = decorator.GetManifestResources(\"MyApp.Resources.data.xml\", ManifestResourceMatch.Name);\n\n}" + } + }, + { + "id": "8c26a1be0c8796d45dd2f0eb", + "exampleId": "Cuemon.Net.Mail.MailDistributor#1", + "uid": "Cuemon.Net.Mail.MailDistributor", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Mail;\nusing System.Threading.Tasks;\nusing Cuemon.Net.Mail;\n\nvar distributor = new MailDistributor(() => new SmtpClient(\"smtp.example.com\", 25), deliverySize: 10);\nusing var mail = new MailMessage(\"sender@example.com\", \"receiver@example.com\")\n{\n Subject = \"Docs sample\",\n Body = \"This message is filtered out before delivery.\"\n};\n\nawait distributor.SendOneAsync(mail, _ => false);\n\nConsole.WriteLine(\"Delivery skipped by filter.\");" + } + }, + { + "id": "8d2c5e4633bbb19e93f6a5f9", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.AppTagHelperOptions#1", + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.AppTagHelperOptions", + "fenceOrdinal": 1, + "strategy": "host", + "transports": [ + "native", + "docker" + ], + "framework": "net10.0", + "image": "codebeltnet/csrun:10", + "source": "using Cuemon.AspNetCore.Razor.TagHelpers;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace MyApp.Examples;\n\npublic class AppTagHelperOptionsExample\n{\n public static void Main(string[] args)\n {\n var builder = WebApplication.CreateBuilder(args);\n\n builder.Services.AddRazorPages();\n builder.Services.Configure(o =>\n {\n o.Scheme = ProtocolUriScheme.Https;\n o.BaseUrl = \"static.example.com\";\n });\n\n var app = builder.Build();\n app.Run();\n }\n}", + "hostHarness": { + "sdk": "Microsoft.NET.Sdk.Web", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0" + ], + "probePath": "/", + "probeMethod": "GET", + "timeoutSeconds": 60, + "expectedStatusCode": 404, + "expectedBodyContains": "", + "startupDelayMs": 1000 + } + }, + { + "id": "8ddfd23fa92558e3b81d76b0", + "exampleId": "Cuemon.Extensions.Hosting.Environments#1", + "uid": "Cuemon.Extensions.Hosting.Environments", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Hosting@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0", + "Microsoft.Extensions.Hosting@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nusing var host = Host.CreateDefaultBuilder()\n .UseEnvironment(Cuemon.Extensions.Hosting.Environments.LocalDevelopment)\n .Build();\n\nConsole.WriteLine(host.Services.GetRequiredService().EnvironmentName);" + } + }, + { + "id": "8de013a0b7f38829493d2d48", + "exampleId": "Cuemon.Xml.Serialization.Formatters.XmlFormatter#1", + "uid": "Cuemon.Xml.Serialization.Formatters.XmlFormatter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing Cuemon.Xml.Serialization.Formatters;\nusing MyApp.Examples;\n\nXmlFormatterExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class XmlFormatterExample\n {\n public static void Demonstrate()\n {\n var formatter = new XmlFormatter();\n var person = new Person { Name = \"John Doe\", Age = 42 };\n\n using var stream = formatter.Serialize(person, typeof(Person));\n stream.Position = 0;\n\n using var reader = new StreamReader(stream);\n var xml = reader.ReadToEnd();\n\n Console.WriteLine(xml.Contains(\"John Doe\"));\n Console.WriteLine(xml.Contains(\"42\"));\n }\n\n private sealed class Person\n {\n public string Name { get; set; }\n\n public int Age { get; set; }\n }\n }\n}" + } + }, + { + "id": "8e728635675872aff45149b3", + "exampleId": "Cuemon.Collections.Generic.Arguments#1", + "uid": "Cuemon.Collections.Generic.Arguments", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon.Collections.Generic;\n\nint[] first = Arguments.ToArrayOf(1, 2, 3);\nint[] second = Arguments.ToArrayOf(4, 5, 6);\n\n// Concat two arrays\nint[] combined = Arguments.Concat(first, second);\nConsole.WriteLine(string.Join(\", \", combined));\n\n// Yield a single element\nIEnumerable yielded = Arguments.Yield(42);\nConsole.WriteLine(yielded.First());\n\n// Convert to IEnumerable\nIEnumerable enumerable = Arguments.ToEnumerableOf(\"a\", \"b\", \"c\");\nConsole.WriteLine(string.Concat(enumerable));\n\n// Object overloads\nobject[] objs = Arguments.ToArray(1, \"two\", 3.0);\nIEnumerable objEnumerable = Arguments.ToEnumerable(true, false);" + } + }, + { + "id": "8eb48fab6caa4c4c83e5a38a", + "exampleId": "Cuemon.AspNetCore.Mvc.ContentBasedObjectResultOptions`1#1", + "uid": "Cuemon.AspNetCore.Mvc.ContentBasedObjectResultOptions`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Cryptography;\nusing System.Text;\nusing Cuemon.AspNetCore.Mvc;\n\nvar options = new ContentBasedObjectResultOptions\n{\n ChecksumProvider = value => SHA256.HashData(Encoding.UTF8.GetBytes(value)),\n WeakChecksumProvider = _ => false // use strong ETag\n};\n\n// Validate that the required properties are configured\noptions.ValidateOptions();\n\nConsole.WriteLine(\"ChecksumProvider is configured.\");" + } + }, + { + "id": "8ece33a7928a7d6dfdc4cd18", + "exampleId": "Cuemon.Threading.AsyncActionFactory#1", + "uid": "Cuemon.Threading.AsyncActionFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Cuemon.Threading;\n\nawait new AsyncActionFactoryExample().DemonstrateAsync();\n\nnamespace Cuemon.Threading\n{\n public class AsyncActionFactoryExample\n {\n public async Task DemonstrateAsync()\n {\n var factory = AsyncActionFactory.Create(ct =>\n {\n Console.WriteLine(\"Async operation executed\");\n return Task.CompletedTask;\n });\n await factory.ExecuteMethodAsync(CancellationToken.None);\n\n var factoryWithArg = AsyncActionFactory.Create(async (string msg, CancellationToken ct) =>\n {\n await Task.Delay(10, ct);\n Console.WriteLine(msg);\n }, \"Hello from async action\");\n await factoryWithArg.ExecuteMethodAsync(CancellationToken.None);\n }\n }\n}" + } + }, + { + "id": "8ed39f1d9706467796de299d", + "exampleId": "Cuemon.SortOrder#1", + "uid": "Cuemon.SortOrder", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon;\nusing Contoso.Search;\n\nSortOrderExample.Run();\n\nnamespace Contoso.Search\n{\n public sealed class SortOrderExample\n {\n public static void Run()\n {\n var names = new List { \"Charlie\", \"Alice\", \"Bob\" };\n\n Apply(names, SortOrder.Ascending);\n Console.WriteLine(string.Join(\", \", names));\n\n Apply(names, SortOrder.Descending);\n Console.WriteLine(string.Join(\", \", names));\n }\n\n private static void Apply(List names, SortOrder sortOrder)\n {\n names.Sort((left, right) =>\n {\n int result = string.Compare(left, right, StringComparison.Ordinal);\n return sortOrder == SortOrder.Descending ? -result : result;\n });\n }\n }\n}" + } + }, + { + "id": "8f3115f05ecc6f1191b7ac85", + "exampleId": "Cuemon.AspNetCore.Http.HttpStatusCodeExceptionDecoratorExtensions#1", + "uid": "Cuemon.AspNetCore.Http.HttpStatusCodeExceptionDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing Cuemon.AspNetCore.Http;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.Primitives;\nusing System.Linq;\nusing Cuemon;\n\nvar exception = new NotFoundException(\"Resource not found.\");\nvar headers = new HeaderDictionary\n{\n { \"X-Correlation-Id\", new StringValues(\"abc-123\") },\n { \"X-Request-Id\", new StringValues(\"req-456\") }\n};\n\nDecorator.Enclose(exception).AddResponseHeaders(headers);\n\nusing var message = new HttpResponseMessage();\nmessage.Headers.Add(\"X-Server-Id\", \"server-01\");\n\nDecorator.Enclose(exception).AddResponseHeaders(message.Headers);\n\nConsole.WriteLine($\"Correlation header: {headers[\"X-Correlation-Id\"]}\");\nConsole.WriteLine($\"Server header: {message.Headers.GetValues(\"X-Server-Id\").First()}\");" + } + }, + { + "id": "8f5a4231d2e45de3ff45e017", + "exampleId": "Cuemon.IO.StreamCompressionOptions#1", + "uid": "Cuemon.IO.StreamCompressionOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.IO.Compression;\nusing System.Text;\nusing Cuemon.IO;\n\n // Default options: Optimal compression level\n var defaultOptions = new StreamCompressionOptions();\n Console.WriteLine($\"Default compression level: {defaultOptions.Level}\"); // Optimal\n\n // Fastest compression (less CPU, larger output)\n var fastOptions = new StreamCompressionOptions\n {\n Level = CompressionLevel.Fastest\n };\n\n // No compression (for testing)\n var noCompression = new StreamCompressionOptions\n {\n Level = CompressionLevel.NoCompression\n };\n\n // Compress some data\n var originalData = Encoding.UTF8.GetBytes(\"This is a test string that will be compressed.\");\n using var source = new MemoryStream(originalData);\n using var compressed = new MemoryStream();\n using (var deflateStream = new DeflateStream(compressed, fastOptions.Level, leaveOpen: true))\n {\n source.CopyTo(deflateStream);\n\n Console.WriteLine($\"Original size: {originalData.Length} bytes\");\n Console.WriteLine($\"Compressed size: {compressed.Length} bytes\");\n\n}" + } + }, + { + "id": "8f8c17ccc69dd8579b97ea03", + "exampleId": "Cuemon.IO.AsyncStreamEncodingOptions#1", + "uid": "Cuemon.IO.AsyncStreamEncodingOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0" + ], + "source": "using System;\nusing System.IO;\nusing System.Text;\nusing System.Threading.Tasks;\nusing Cuemon.IO;\nusing Cuemon.Text;\n\nnamespace MyApp.Examples;\n\npublic class AsyncStreamEncodingOptionsExample\n{\n public static async Task Main()\n {\n var options = new AsyncStreamEncodingOptions\n {\n Encoding = Encoding.UTF8,\n Preamble = PreambleSequence.Remove,\n LeaveOpen = false\n };\n\n string text = \"Hello, AsyncStreamEncodingOptions!\";\n byte[] bytes = Encoding.UTF8.GetBytes(text);\n\n using var stream = new MemoryStream(bytes);\n using var reader = new StreamReader(stream, options.Encoding);\n\n string result = await reader.ReadToEndAsync();\n Console.WriteLine(result);\n\n // Output:\n // Hello, AsyncStreamEncodingOptions!\n\n}\n}" + } + }, + { + "id": "8fc8d5f63811d11d5219c0e5", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.AppLinkTagHelper#1", + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.AppLinkTagHelper", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Configuration;\nusing Cuemon.AspNetCore.Razor.TagHelpers;\nusing Microsoft.Extensions.Options;\nusing MyApp.Examples;\n\nAppLinkTagHelperExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class AppLinkTagHelperExample\n {\n private sealed class StylesheetVersion : ICacheBusting\n {\n public string Version => \"1.0.0\";\n }\n\n public static void Demonstrate()\n {\n var options = new AppTagHelperOptions\n {\n Scheme = ProtocolUriScheme.Relative,\n BaseUrl = \"static.cuemon.net\"\n };\n\n var version = new StylesheetVersion();\n var tagHelper = new AppLinkTagHelper(Options.Create(options), version)\n {\n Href = \"css/site.css\"\n };\n var stylesheetHref = $\"{tagHelper.Options.GetFormattedBaseUrl()}{tagHelper.Href}?v={version.Version}\";\n\n Console.WriteLine(stylesheetHref);\n }\n }\n}" + } + }, + { + "id": "90bb9fef9d2e4fdfb5b0f7cf", + "exampleId": "Cuemon.Resilience.TransientOperation#1", + "uid": "Cuemon.Resilience.TransientOperation", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Resilience@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing Cuemon.Resilience;\n\nnew TransientOperationExample().Demonstrate();\n\nnamespace Cuemon.Resilience\n{\n public class TransientOperationExample\n {\n public void Demonstrate()\n {\n var result = TransientOperation.WithFunc(() =>\n {\n using var client = new HttpClient();\n return client.GetStringAsync(\"https://example.com\").Result;\n }, options =>\n {\n options.RetryAttempts = 3;\n options.RetryStrategy = attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt));\n });\n\n Console.WriteLine($\"Response length: {result.Length}\");\n }\n }\n}" + } + }, + { + "id": "90cad92344abc109e4bb0dbd", + "exampleId": "Cuemon.Security.Cryptography.SecureHashAlgorithm256#1", + "uid": "Cuemon.Security.Cryptography.SecureHashAlgorithm256", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\n\nvar algorithm = new SecureHashAlgorithm256();\nvar result = algorithm.ComputeHash(Encoding.UTF8.GetBytes(\"The quick brown fox jumps over the lazy dog\"));\nvar repeated = algorithm.ComputeHash(Encoding.UTF8.GetBytes(\"The quick brown fox jumps over the lazy dog\"));\n\nConsole.WriteLine(SecureHashAlgorithm256.BitSize);\nConsole.WriteLine(result.GetBytes().Length);\nConsole.WriteLine(result.Equals(repeated));" + } + }, + { + "id": "912ff36e7843e049512c3941", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerDecoratorExtensions#1", + "uid": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Net;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing Cuemon;\nusing Cuemon.AspNetCore.Diagnostics;\n\nvar handler = new HttpExceptionDescriptorResponseHandler(\n new MediaTypeHeaderValue(\"application/json\"),\n ed => new HttpResponseMessage(HttpStatusCode.InternalServerError)\n {\n Content = new StringContent(ed.Message)\n });\nvar list = new List { handler };\n\nDecorator.Enclose(list).AddResponseHandler(o =>\n{\n o.ContentType = new MediaTypeHeaderValue(\"application/json\");\n o.ContentFactory = ed => new StringContent(ed.Message);\n o.StatusCodeFactory = ed => HttpStatusCode.InternalServerError;\n});\n\nConsole.WriteLine($\"Response handlers: {list.Count}\");" + } + }, + { + "id": "921c240c8a0813ef4a27284b", + "exampleId": "Cuemon.AssignmentOperator#1", + "uid": "Cuemon.AssignmentOperator", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\nint total = Calculator.Calculate(5, AssignmentOperator.Addition, 3);\nint shifted = Calculator.Calculate(5, AssignmentOperator.LeftShift, 2);\n\nConsole.WriteLine($\"Total: {total}\");\nConsole.WriteLine($\"Shifted: {shifted}\");" + } + }, + { + "id": "92e896778d423e473597a609", + "exampleId": "Cuemon.Xml.XmlDocumentFactory#1", + "uid": "Cuemon.Xml.XmlDocumentFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Xml;\nusing Cuemon.Xml;\n\nvar xml = \"\";\nvar doc = XmlDocumentFactory.CreateDocument(xml);\n\nvar root = doc.DocumentElement;\nConsole.WriteLine($\"Root element: {root?.Name}\");\n\nvar book = root?.SelectSingleNode(\"book\");\nConsole.WriteLine($\"Title: {book?.Attributes?[\"title\"]?.Value}\");" + } + }, + { + "id": "9350ef439be81fd7d95f9884", + "exampleId": "Cuemon.Data.DataManagerOptions#1", + "uid": "Cuemon.Data.DataManagerOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Data;\nusing Cuemon.Data;\n\nvar options = new DataManagerOptions\n{\n ConnectionString = \"Data Source=app.db\",\n PreferredReaderBehavior = CommandBehavior.SequentialAccess | CommandBehavior.CloseConnection,\n LeaveConnectionOpen = false,\n LeaveCommandOpen = false\n};\n\noptions.ValidateOptions();\n\nConsole.WriteLine($\"Connection: {options.ConnectionString}\");\nConsole.WriteLine($\"Reader behavior: {options.PreferredReaderBehavior}\");\nConsole.WriteLine($\"Leave connection open: {options.LeaveConnectionOpen}\");\nConsole.WriteLine($\"Leave command open: {options.LeaveCommandOpen}\");" + } + }, + { + "id": "937480803a2b64cf9a297384", + "exampleId": "Cuemon.SuccessfulValue#1", + "uid": "Cuemon.SuccessfulValue", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Contoso.Startup;\n\nSuccessfulValueExample.Run();\n\nnamespace Contoso.Startup\n{\n public sealed class SuccessfulValueExample\n {\n public static void Run()\n {\n ConditionalValue outcome = WarmUpCache(dependenciesReady: true);\n\n Console.WriteLine($\"Succeeded: {outcome.Succeeded}\");\n Console.WriteLine($\"Failure is null: {outcome.Failure is null}\");\n }\n\n private static ConditionalValue WarmUpCache(bool dependenciesReady)\n {\n if (!dependenciesReady)\n {\n return new UnsuccessfulValue(new InvalidOperationException(\"Dependencies are missing.\"));\n }\n\n return new SuccessfulValue();\n }\n }\n}" + } + }, + { + "id": "93b775d0d3c01eed7fbeda60", + "exampleId": "Cuemon.AspNetCore.Diagnostics.ServerTimingMiddleware#1", + "uid": "Cuemon.AspNetCore.Diagnostics.ServerTimingMiddleware", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.Hosting@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading.Tasks;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.FileProviders;\nusing Microsoft.Extensions.Hosting;\nusing Microsoft.Extensions.Logging;\nusing Microsoft.Extensions.Options;\n\nawait ServerTimingMiddlewareExample.DemonstrateAsync();\n\nnamespace Cuemon.AspNetCore.Diagnostics\n{\n public static class ServerTimingMiddlewareExample\n {\n public static async Task DemonstrateAsync()\n {\n var context = new DefaultHttpContext();\n var middleware = new ServerTimingMiddleware(httpContext => httpContext.Response.WriteAsync(\"Hello\"));\n\n using var loggerFactory = LoggerFactory.Create(builder => { });\n var serverTiming = new ServerTiming();\n serverTiming.AddServerTiming(\"db\", TimeSpan.FromMilliseconds(12), \"SQL query\");\n\n await middleware.InvokeAsync(\n context,\n loggerFactory.CreateLogger(),\n new SampleHostEnvironment(),\n serverTiming,\n Options.Create(new ServerTimingOptions { SuppressHeaderPredicate = _ => false }));\n\n // The middleware writes this header when the response starts.\n Console.WriteLine($\"{ServerTiming.HeaderName}: {string.Join(\", \", serverTiming.Metrics)}\");\n }\n\n private sealed class SampleHostEnvironment : IHostEnvironment\n {\n public string ApplicationName { get; set; } = \"Docs\";\n public IFileProvider ContentRootFileProvider { get; set; } = new NullFileProvider();\n public string ContentRootPath { get; set; } = \".\";\n public string EnvironmentName { get; set; } = Environments.Development;\n }\n }\n}" + } + }, + { + "id": "9467484df8998c5972543769", + "exampleId": "Cuemon.IO.StreamWriterOptions#1", + "uid": "Cuemon.IO.StreamWriterOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Globalization;\nusing System.IO;\nusing Cuemon;\nusing Cuemon.IO;\nusing Cuemon.Text;\n\nvar options = new StreamWriterOptions\n{\n AutoFlush = true,\n BufferSize = 256,\n Encoding = EncodingOptions.DefaultEncoding,\n Preamble = PreambleSequence.Remove,\n FormatProvider = CultureInfo.InvariantCulture,\n NewLine = \"\\n\"\n};\n\nusing Stream stream = StreamFactory.Create(writer =>\n{\n string formatted = string.Format(options.FormatProvider, \"Value: {0:F2}\", Math.PI);\n writer.WriteLine(formatted);\n}, setup =>\n{\n setup.AutoFlush = options.AutoFlush;\n setup.BufferSize = options.BufferSize;\n setup.Encoding = options.Encoding;\n setup.Preamble = options.Preamble;\n setup.FormatProvider = options.FormatProvider;\n setup.NewLine = options.NewLine;\n});\n\nstring output = Decorator.Enclose(stream).ToEncodedString(setup =>\n{\n setup.Encoding = options.Encoding;\n setup.Preamble = options.Preamble;\n setup.LeaveOpen = true;\n});\n\nConsole.WriteLine(output.Trim());" + } + }, + { + "id": "9593526bd234571d19685cf8", + "exampleId": "Cuemon.Collections.Generic.PaginationList`1#1", + "uid": "Cuemon.Collections.Generic.PaginationList`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon.Collections.Generic;\n\n var customers = new List\n {\n \"Alice\", \"Bob\", \"Carol\", \"Dave\", \"Eve\",\n \"Frank\", \"Grace\", \"Hank\", \"Iris\", \"Jack\",\n \"Kate\", \"Leo\", \"Mia\", \"Noah\", \"Olivia\"\n };\n\n // Eagerly materialize page 3 with 5 items per page\n var page = new PaginationList(customers, () => customers.Count, setup =>\n {\n setup.PageSize = 5;\n setup.PageNumber = 3;\n });\n\n Console.WriteLine($\"Page items (count: {page.Count})\");\n for (int i = 0; i < page.Count; i++)\n {\n Console.WriteLine($\" [{i}] {page[i]}\");\n Console.WriteLine($\"Total items: {page.TotalElementCount}\");\n Console.WriteLine($\"Total pages: {page.PageCount}\");\n Console.WriteLine($\"First page: {page.FirstPage}\");\n Console.WriteLine($\"Last page: {page.LastPage}\");\n\n}" + } + }, + { + "id": "965af4dc34598f2c8f4f0260", + "exampleId": "Cuemon.AspNetCore.Http.NotAcceptableException#1", + "uid": "Cuemon.AspNetCore.Http.NotAcceptableException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http;\n\nvar acceptHeader = \"application/xml\";\nvar exception = new NotAcceptableException($\"The endpoint cannot produce '{acceptHeader}'.\");\n\nConsole.WriteLine(exception.Message);\nConsole.WriteLine(exception.StatusCode);" + } + }, + { + "id": "971dec3e05c07ac80a9873c1", + "exampleId": "Cuemon.DisposableOptions#1", + "uid": "Cuemon.DisposableOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Contoso.IO;\n\nDisposableOptionsExample.Run();\n\nnamespace Contoso.IO\n{\n public sealed class DisposableOptionsExample\n {\n public static void Run()\n {\n var resource = new TrackedDisposable();\n var options = new DisposableOptions\n {\n LeaveOpen = true\n };\n\n DisposeWhenAllowed(resource, options);\n Console.WriteLine($\"Disposed after leave-open: {resource.IsDisposed}\");\n\n options.LeaveOpen = false;\n DisposeWhenAllowed(resource, options);\n Console.WriteLine($\"Disposed after close: {resource.IsDisposed}\");\n }\n\n private static void DisposeWhenAllowed(TrackedDisposable resource, DisposableOptions options)\n {\n if (!options.LeaveOpen)\n {\n resource.Dispose();\n }\n }\n\n private sealed class TrackedDisposable : IDisposable\n {\n public bool IsDisposed { get; private set; }\n\n public void Dispose()\n {\n IsDisposed = true;\n }\n }\n }\n}" + } + }, + { + "id": "980333a237875ec82825be9a", + "exampleId": "Cuemon.AspNetCore.Http.HeaderDictionaryDecoratorExtensions#1", + "uid": "Cuemon.AspNetCore.Http.HeaderDictionaryDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing Cuemon;\nusing Cuemon.AspNetCore.Http;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.Primitives;\n\n// Add non-existing headers from one dictionary into another\nvar target = new HeaderDictionary\n{\n { \"X-Existing\", \"value1\" }\n};\n\nvar source = new HeaderDictionary\n{\n { \"X-Existing\", \"value1\" },\n { \"X-New\", \"value2\" }\n};\n\n// Only adds headers that do not already exist in target\nDecorator.Enclose(target).AddRange(source);\n\nConsole.WriteLine(target[\"X-Existing\"]); // \"value1\"\nConsole.WriteLine(target[\"X-New\"]); // \"value2\"\n\n// Add or update a single header with control-character sanitization\nDecorator.Enclose(target).AddOrUpdateHeader(\n \"X-Sanitized\", new StringValues(\"hello\\r\\nworld\"), useAsciiEncodingConversion: false);\n\nConsole.WriteLine(target[\"X-Sanitized\"]); // \"helloworld\"\n\n// Copy response headers into an IHeaderDictionary\nusing var response = new HttpResponseMessage();\nresponse.Headers.Add(\"X-Custom\", new[] { \"alpha\", \"beta\" });\n\nDecorator.Enclose(target).AddOrUpdateHeaders(response.Headers);\n\nConsole.WriteLine(target[\"X-Custom\"]); // \"alpha,beta\"" + } + }, + { + "id": "983b44896018cf477dd1d6df", + "exampleId": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeaderBuilder#1", + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeaderBuilder", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Authentication.Digest;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Net.Http.Headers;\n\nvar headers = new HeaderDictionary\n{\n [HeaderNames.WWWAuthenticate] = \"Digest realm=\\\"docs-example\\\", qop=\\\"auth, auth-int\\\", nonce=\\\"abc123\\\", opaque=\\\"opaque456\\\", stale=false, algorithm=SHA-256\"\n};\n\nvar builder = new DigestAuthorizationHeaderBuilder(DigestCryptoAlgorithm.Sha256)\n .AddRealm(\"docs-example\")\n .AddUserName(\"Agent\")\n .AddUri(\"/resource\")\n .AddNc(1)\n .AddCnonce(\"client-nonce\")\n .AddQopAuthentication()\n .AddFromWwwAuthenticateHeader(headers)\n .AddResponse(\"Test\", \"GET\");\n\nvar header = builder.Build();\n\nConsole.WriteLine(header.ToString());" + } + }, + { + "id": "986b90c2da8ce04fad2885cd", + "exampleId": "Cuemon.AspNetCore.Http.InternalServerErrorException#1", + "uid": "Cuemon.AspNetCore.Http.InternalServerErrorException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http;\n\nvar failure = new InvalidOperationException(\"The invoice pipeline failed to commit the transaction.\");\nvar exception = new InternalServerErrorException(failure);\n\nConsole.WriteLine(exception.StatusCode);\nConsole.WriteLine(exception.InnerException?.Message);" + } + }, + { + "id": "99c89ff0aaf28ac8c13df795", + "exampleId": "Cuemon.IO.BufferWriterOptions#1", + "uid": "Cuemon.IO.BufferWriterOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0" + ], + "source": "using System;\nusing System.Buffers;\nusing System.Text;\nusing Cuemon.IO;\nusing Cuemon.Text;\n\nnamespace MyApp.Examples;\n\npublic class BufferWriterOptionsExample\n{\n public static void Main()\n {\n var options = new BufferWriterOptions\n {\n BufferSize = 1024,\n Encoding = Encoding.UTF8,\n Preamble = PreambleSequence.Remove\n };\n\n var writer = new ArrayBufferWriter(options.BufferSize);\n byte[] data = Encoding.UTF8.GetBytes(\"Hello, BufferWriterOptions!\");\n writer.Write(data);\n\n string result = Encoding.UTF8.GetString(writer.WrittenSpan);\n Console.WriteLine(result);\n\n // Output:\n // Hello, BufferWriterOptions!\n\n}\n}" + } + }, + { + "id": "9a2dbc05b2688f2d6cc9d3f6", + "exampleId": "Cuemon.Extensions.DependencyInjection.TypeExtensions#1", + "uid": "Cuemon.Extensions.DependencyInjection.TypeExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.DependencyInjection;\nusing Cuemon.Docs.Samples.DependencyInjection;\n\nTypeExtensionsExample.Demonstrate();\n\nnamespace Cuemon.Docs.Samples.DependencyInjection\n{\n public static class TypeExtensionsExample\n {\n public static void Demonstrate()\n {\n var marked = typeof(DefaultService).TryGetDependencyInjectionMarker(out var markerType);\n var plain = typeof(string).TryGetDependencyInjectionMarker(out _);\n\n Console.WriteLine(marked);\n Console.WriteLine(markerType == typeof(OrdersChannel));\n Console.WriteLine(plain);\n }\n\n public sealed class OrdersChannel\n {\n }\n\n public interface IMessageService\n {\n }\n\n public interface IMessageService : IMessageService, IDependencyInjectionMarker\n {\n }\n\n public sealed class DefaultService : IMessageService\n {\n }\n }\n}" + } + }, + { + "id": "9a75ce2826c1578cd66ba2f7", + "exampleId": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeaderBuilder#1", + "uid": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeaderBuilder", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Authentication.Basic;\n\nvar builder = new BasicAuthorizationHeaderBuilder();\nbuilder.AddUserName(\"alice\");\nbuilder.AddPassword(\"password\");\nvar headerValue = builder.Build(); // \"Basic YWxpY2U6cGFzc3dvcmQ=\"\nConsole.WriteLine(headerValue);" + } + }, + { + "id": "9b77afb4fb48355b96d3ad55", + "exampleId": "Cuemon.Xml.Serialization.Formatters.XmlFormatterOptions#1", + "uid": "Cuemon.Xml.Serialization.Formatters.XmlFormatterOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Net.Http.Headers;\nusing Cuemon.Diagnostics;\nusing Cuemon.Xml.Serialization.Formatters;\n\n// Configure XmlFormatter with custom settings.\nvar options = new XmlFormatterOptions\n{\n SynchronizeWithXmlConvert = true,\n SensitivityDetails = FaultSensitivityDetails.None\n};\n\n// Customize the supported media types.\noptions.SupportedMediaTypes = new List\n{\n XmlFormatterOptions.DefaultMediaType,\n new MediaTypeHeaderValue(\"text/xml\"),\n new MediaTypeHeaderValue(\"application/problem+xml\")\n};\n\nConsole.WriteLine($\"Default media type: {XmlFormatterOptions.DefaultMediaType}\"); // application/xml\nConsole.WriteLine($\"Supported types: {options.SupportedMediaTypes.Count}\"); // 3\nConsole.WriteLine($\"Synchronize: {options.SynchronizeWithXmlConvert}\"); // True\n\n// Validate before use.\noptions.ValidateOptions();\nConsole.WriteLine(\"Options are valid.\");\n\n// Use with a formatter.\nvar formatter = new XmlFormatter(options);\nConsole.WriteLine($\"Formatter created with {formatter.GetType().Name}.\");" + } + }, + { + "id": "9c67f469c3acad2b059d54bf", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpFaultResolver#1", + "uid": "Cuemon.AspNetCore.Diagnostics.HttpFaultResolver", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.Diagnostics;\n\nvar resolver = new HttpFaultResolver(\n exception => exception is ArgumentNullException,\n exception => new HttpExceptionDescriptor(exception, 400, null, \"Argument was null.\"));\n\nif (resolver.TryResolveFault(new ArgumentNullException(\"value\"), out var descriptor))\n{\n Console.WriteLine(descriptor.StatusCode); // 400\n}\n\nvar resolved = resolver.TryResolveFault(new InvalidOperationException(), out _);\nConsole.WriteLine(resolved); // False" + } + }, + { + "id": "9d13a697d398c17b65270438", + "exampleId": "Cuemon.Runtime.Caching.SlimMemoryCacheOptions#1", + "uid": "Cuemon.Runtime.Caching.SlimMemoryCacheOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Runtime.Caching@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Runtime.Caching;\n\nvar options = new SlimMemoryCacheOptions\n{\n EnableCleanup = false,\n FirstSweep = TimeSpan.FromSeconds(10),\n SucceedingSweep = TimeSpan.FromSeconds(30),\n KeyProvider = (key, ns) => key.Length + (ns == CacheEntry.NoScope ? 0 : ns.Length)\n};\n\noptions.ValidateOptions();\n\nConsole.WriteLine(options.EnableCleanup);\nConsole.WriteLine(options.FirstSweep);\nConsole.WriteLine(options.KeyProvider(\"session\", \"docs\"));" + } + }, + { + "id": "9d4e7595528c9d2aa17730fe", + "exampleId": "Cuemon.Data.DataStatement#1", + "uid": "Cuemon.Data.DataStatement", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Data;\nusing System.Linq;\nusing Cuemon.Data;\nusing MyApp.DataAccess;\n\nnew DataStatementExample().Demonstrate();\n\nnamespace MyApp.DataAccess\n{\n public sealed class DataStatementExample\n {\n public void Demonstrate()\n {\n DataStatement textStatement = \"SELECT * FROM Product\";\n Console.WriteLine(textStatement.Text);\n Console.WriteLine(textStatement.Type);\n\n var storedProcedure = new DataStatement(\"dbo.GetOrdersByDate\", options =>\n {\n options.Type = CommandType.StoredProcedure;\n options.Timeout = TimeSpan.FromSeconds(120);\n });\n Console.WriteLine($\"{storedProcedure.Text} ({storedProcedure.Type})\");\n\n var parameterized = new DataStatement(\"UPDATE Inventory SET Quantity = Quantity - @qty WHERE ProductId = @id\", options =>\n {\n options.Parameters = new IDataParameter[]\n {\n new DemoParameter(\"@qty\", 5),\n new DemoParameter(\"@id\", 1001)\n };\n });\n\n Console.WriteLine($\"Parameter count: {parameterized.Parameters.Length}\");\n Console.WriteLine(string.Join(\", \", parameterized.Parameters.Select(parameter => parameter.ParameterName)));\n }\n\n private sealed class DemoParameter : IDataParameter\n {\n public DemoParameter(string name, object value)\n {\n ParameterName = name;\n Value = value;\n }\n\n public DbType DbType { get; set; }\n\n public ParameterDirection Direction { get; set; } = ParameterDirection.Input;\n\n public bool IsNullable => true;\n\n public string ParameterName { get; set; }\n\n public string SourceColumn { get; set; } = string.Empty;\n\n public DataRowVersion SourceVersion { get; set; } = DataRowVersion.Current;\n\n public object Value { get; set; }\n }\n }\n}" + } + }, + { + "id": "9d886d7e4f68c003d3f4f6da", + "exampleId": "Cuemon.Extensions.ActionFactory#1", + "uid": "Cuemon.Extensions.ActionFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Extensions;\n\nAction callback = (name, count) =>\n{\n for (int i = 0; i < count; i++)\n Console.WriteLine(name);\n};\n\nvar factory = ActionFactory.Create(callback, \"Loop\", 3);\nfactory.ExecuteMethod();\n\nActionFactory.Invoke(tuple => Console.WriteLine(tuple.Arg1), MutableTupleFactory.CreateOne(\"Direct invoke\"));" + } + }, + { + "id": "9e0a6207d8d3862be1cf3da9", + "exampleId": "Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptionsDecoratorExtensions#1", + "uid": "Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptionsDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.AspNetCore.Http;\nusing Microsoft.AspNetCore.Http;\n\nvar options = new FaultDescriptorOptions();\nvar failure = new BadRequestException(\"Bad request\");\nvar context = new DefaultHttpContext();\n\nDecorator.Enclose(options).TryResolveHttpExceptionDescriptor(\n failure,\n context,\n descriptor => Console.WriteLine(\"Resolved descriptor\"),\n out var descriptor);\n\nConsole.WriteLine(descriptor.StatusCode);" + } + }, + { + "id": "9e8a8d5a5789ce8a01744b6c", + "exampleId": "Cuemon.Xml.Serialization.XmlSerializer#1", + "uid": "Cuemon.Xml.Serialization.XmlSerializer", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Xml.Serialization;\nusing MyApp.Examples;\n\nXmlSerializerExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class XmlSerializerExample\n {\n public static void Demonstrate()\n {\n var serializer = XmlSerializer.Create(new XmlSerializerOptions\n {\n RootName = new XmlQualifiedEntity(\"Order\")\n });\n\n var order = new Order\n {\n Id = 1001,\n Customer = \"John Doe\",\n Total = 299.99m\n };\n\n using var stream = serializer.Serialize(order, typeof(Order));\n stream.Position = 0;\n\n var deserialized = serializer.Deserialize(stream);\n\n Console.WriteLine(deserialized.Customer);\n Console.WriteLine(deserialized.Total);\n }\n\n private sealed class Order\n {\n public int Id { get; set; }\n\n public string Customer { get; set; }\n\n public decimal Total { get; set; }\n }\n }\n}" + } + }, + { + "id": "9f8b3201ad4fd814cf0c92a1", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationMvcOptionsSetup#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationMvcOptionsSetup", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json;\nusing Cuemon.Extensions.Text.Json.Formatters;\nusing Microsoft.AspNetCore.Mvc;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\n\nvar services = new ServiceCollection();\nservices.Configure(options =>\n{\n options.Settings.WriteIndented = true;\n});\nservices.AddTransient, JsonSerializationMvcOptionsSetup>();\n\nusing var provider = services.BuildServiceProvider();\nvar setup = provider.GetService>();\nConsole.WriteLine(setup is JsonSerializationMvcOptionsSetup);" + } + }, + { + "id": "9fa573620262e8a8da61a76c", + "exampleId": "Cuemon.Security.FowlerNollVo64#1", + "uid": "Cuemon.Security.FowlerNollVo64", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security;\nusing Cuemon;\n\n// Create FNV-1a 64-bit hash instance (default algorithm)\nvar fnv = new FowlerNollVo64();\n\n// Compute hash from a string\nbyte[] data = Encoding.UTF8.GetBytes(\"hello\");\nHashResult hash = fnv.ComputeHash(data);\n\n// Display the hash in hexadecimal format\nConsole.WriteLine(hash.ToHexadecimalString());\n\n// Switch to FNV-1 algorithm\nfnv.Options.Algorithm = FowlerNollVoAlgorithm.Fnv1;\nHashResult hashFnv1 = fnv.ComputeHash(data);\nConsole.WriteLine(hashFnv1.ToHexadecimalString());\n\n// Change byte order to little endian\nfnv.Options.ByteOrder = Endianness.LittleEndian;\nHashResult hashLe = fnv.ComputeHash(data);\nConsole.WriteLine(hashLe.ToHexadecimalString());" + } + }, + { + "id": "9ffd8e34ee97a0c92b04a947", + "exampleId": "Cuemon.TesterFunc`2#1", + "uid": "Cuemon.TesterFunc`2", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\nTesterFunc tryReadPort = (out int port) =>\n{\n var configuredPort = \"8080\";\n return int.TryParse(configuredPort, out port);\n};\n\nvar success = tryReadPort(out var port);\n\nConsole.WriteLine(success);\nConsole.WriteLine(port);" + } + }, + { + "id": "a111f64116f5474aeb6db136", + "exampleId": "Cuemon.Eradicate#1", + "uid": "Cuemon.Eradicate", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon;\n\n// Remove trailing zero bytes from a byte array\nbyte[] dataWithZeros = { 1, 2, 3, 0, 0, 0 };\nbyte[] cleaned = Eradicate.TrailingZeros(dataWithZeros);\nConsole.WriteLine(BitConverter.ToString(cleaned)); // 01-02-03\n\n// Remove specific trailing byte sequence (e.g., CR/LF)\nbyte[] dataWithCrLf = { 72, 101, 108, 108, 111, 13, 10, 13, 10 };\nbyte[] stripped = Eradicate.TrailingBytes(dataWithCrLf, new byte[] { 13, 10 });\nConsole.WriteLine(Encoding.UTF8.GetString(stripped)); // Hello" + } + }, + { + "id": "a116b0c2e5cef9d9afb997a3", + "exampleId": "Cuemon.AspNetCore.Http.HttpRequestDecoratorExtensions#1", + "uid": "Cuemon.AspNetCore.Http.HttpRequestDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Security;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Net.Http.Headers;\nusing Cuemon.AspNetCore.Http;\n\nvar context = new DefaultHttpContext();\ncontext.Request.Method = HttpMethods.Get;\n\nvar builder = new ChecksumBuilder(() => HashFactory.CreateFnv128());\ncontext.Request.Headers[HeaderNames.IfNoneMatch] =\n string.Concat(\"\\\"\", builder.Checksum.ToHexadecimalString(), \"\\\"\");\n\nvar request = Decorator.Enclose(context.Request);\nvar canServeFromCache = request.IsGetOrHeadMethod() && request.IsClientSideResourceCached(builder);\n\nConsole.WriteLine(canServeFromCache);" + } + }, + { + "id": "a29a9fd052fbb59215e84789", + "exampleId": "Cuemon.Net.StringDecoratorExtensions#1", + "uid": "Cuemon.Net.StringDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0", + "Cuemon.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing System.Text;\nusing Cuemon.Net;\nusing Cuemon.Text;\n\n// URL-encode a string with special characters\nstring raw = \"hello world & some \";\n\n// Invoke UrlEncode extension method\nstring encoded = Decorator.Enclose(raw).UrlEncode();\nConsole.WriteLine(encoded); // \"hello+world+%26+some+%3cstuff%3e\"\n\n// Also invoke as static method via the Cuemon.Net.StringDecoratorExtensions type\nstring encodedStatic = Cuemon.Net.StringDecoratorExtensions.UrlEncode(Decorator.Enclose(raw));\nConsole.WriteLine(encodedStatic); // \"hello+world+%26+some+%3cstuff%3e\"\n\n// URL-decode the encoded string back\nstring decoded = Decorator.Enclose(encoded).UrlDecode();\nConsole.WriteLine(decoded); // \"hello world & some \"\n\n// Invoke UrlDecode as static method via the Cuemon.Net.StringDecoratorExtensions type\nstring decodedStatic = Cuemon.Net.StringDecoratorExtensions.UrlDecode(Decorator.Enclose(encoded));\nConsole.WriteLine(decodedStatic); // \"hello world & some \"\n\n// Encode with a specific encoding\nstring encodedUtf8 = Decorator.Enclose(\"a=b&c=d\").UrlEncode(o =>\n{\n o.Encoding = Encoding.UTF8;\n});\nConsole.WriteLine(encodedUtf8); // \"a%3db%26c%3dd\"" + } + }, + { + "id": "a2d06bba70c21f21095e720a", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationMvcOptionsSetup#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationMvcOptionsSetup", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml@11.0.0", + "Cuemon.Xml@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml;\nusing Cuemon.Xml.Serialization.Formatters;\nusing Microsoft.AspNetCore.Mvc;\nusing Microsoft.Extensions.Options;\n\nvar formatterOptions = Options.Create(new XmlFormatterOptions());\nvar setup = new XmlSerializationMvcOptionsSetup(formatterOptions);\nvar mvcOptions = new MvcOptions();\n\nsetup.Configure(mvcOptions);\n\nConsole.WriteLine(mvcOptions.InputFormatters.Count);\nConsole.WriteLine(mvcOptions.OutputFormatters.Count);" + } + }, + { + "id": "a3ac9d6023b5dd27822edee5", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Diagnostics.MvcFaultDescriptorOptions#1", + "uid": "Cuemon.AspNetCore.Mvc.Filters.Diagnostics.MvcFaultDescriptorOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.AspNetCore.Mvc.Filters.Diagnostics;\nusing Cuemon.Diagnostics;\n\nvar options = new MvcFaultDescriptorOptions\n{\n MarkExceptionHandled = true,\n FaultDescriptor = PreferredFaultDescriptor.ProblemDetails,\n SensitivityDetails = FaultSensitivityDetails.Failure\n};\n\nConsole.WriteLine(options.MarkExceptionHandled);\nConsole.WriteLine(options.FaultDescriptor);\nConsole.WriteLine(options.HttpFaultResolvers.Count);" + } + }, + { + "id": "a53451276f9a17929f6adc1f", + "exampleId": "Cuemon.Xml.XmlReaderDecoratorExtensions#1", + "uid": "Cuemon.Xml.XmlReaderDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Xml;\nusing Cuemon;\nusing Cuemon.Xml;\n\nconst string xml = \"\";\n\nusing var reader = XmlReader.Create(new StringReader(xml));\nvar hasElement = Decorator.Enclose(reader).MoveToFirstElement();\n\nConsole.WriteLine(hasElement);\nConsole.WriteLine(reader.LocalName);\n\nusing var chunkReader = XmlReader.Create(new StringReader(xml));\nvar chunks = new List(Decorator.Enclose(chunkReader).Chunk(size: 2));\n\nConsole.WriteLine(chunks.Count);\n\nusing var hierarchyReader = XmlReader.Create(new StringReader(xml));\nvar hierarchy = Decorator.Enclose(hierarchyReader).ToHierarchy();\n\nConsole.WriteLine(hierarchy.Instance.Name);" + } + }, + { + "id": "a5f97890f767889de61c5c91", + "exampleId": "Cuemon.Extensions.AspNetCore.Text.Json.Converters.JsonConverterCollectionExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Text.Json.Converters.JsonConverterCollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Text.Json@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Text.Json;\nusing System.Text.Json.Serialization;\nusing System.Text.Json.Serialization.Metadata;\nusing Cuemon.Extensions.AspNetCore.Text.Json.Converters;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.Primitives;\n\nvar converters = new List();\n\n// Add converter for IHeaderDictionary\nconverters.AddHeaderDictionaryConverter();\n\n// Add converter for ProblemDetails\nconverters.AddProblemDetailsConverter();\n\n// Add converter for HttpExceptionDescriptor\nconverters.AddHttpExceptionDescriptorConverter();\n\n// Add converter for StringValues\nconverters.AddStringValuesConverter();\n\nvar options = new JsonSerializerOptions\n{\n TypeInfoResolver = new DefaultJsonTypeInfoResolver()\n};\nforeach (var converter in converters)\n{\n options.Converters.Add(converter);\n}\n\n// Example: serialize a HeaderDictionary\nvar headers = new HeaderDictionary\n{\n { \"X-Custom\", \"value1\" },\n { \"X-Another\", \"value2\" }\n};\n\nstring json = JsonSerializer.Serialize(headers, options);\nConsole.WriteLine(json);\n// Output: {\"X-Custom\":\"value1\",\"X-Another\":\"value2\"}\n\n// Example: serialize StringValues\nvar values = new StringValues(new[] { \"a\", \"b\", \"c\" });\nstring svJson = JsonSerializer.Serialize(values, options);\nConsole.WriteLine(svJson);" + } + }, + { + "id": "a616a6b827e8278b9dc6850e", + "exampleId": "Cuemon.Extensions.IntegerExtensions#1", + "uid": "Cuemon.Extensions.IntegerExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions;\n\nvar number = 17;\nbool isPrime = number.IsPrime();\nbool isEven = number.IsEven();\nbool isOdd = number.IsOdd();\n\nConsole.WriteLine(isPrime);\nConsole.WriteLine(isEven);\nConsole.WriteLine(isOdd);\nConsole.WriteLine(5.Max(10));\nConsole.WriteLine(15.Min(10));\nConsole.WriteLine(500L.Min(1000L));\nConsole.WriteLine(((short)3).Max((short)7));\nConsole.WriteLine(new[] { 1, 3, 5, 7 }.IsCountableSequence());" + } + }, + { + "id": "a647487cd2dd0efd2f431360", + "exampleId": "Cuemon.Extensions.Text.Json.Formatters.JsonFormatterOptions#1", + "uid": "Cuemon.Extensions.Text.Json.Formatters.JsonFormatterOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text.Json;\nusing System.Text.Json.Serialization;\nusing System.Text.Json.Serialization.Metadata;\nusing Cuemon.Diagnostics;\nusing Cuemon.Extensions.Text.Json.Formatters;\nusing MyApp.Examples;\n\nnew JsonFormatterOptionsExample().SerializeWithCustomOptions();\n\nnamespace MyApp.Examples\n{\n public class JsonFormatterOptionsExample\n {\n public void SerializeWithCustomOptions()\n {\n // Create options with custom JSON serializer settings\n var options = new JsonFormatterOptions\n {\n Settings = new JsonSerializerOptions\n {\n TypeInfoResolver = new DefaultJsonTypeInfoResolver(),\n PropertyNamingPolicy = JsonNamingPolicy.CamelCase,\n WriteIndented = true,\n DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,\n PropertyNameCaseInsensitive = true\n },\n SensitivityDetails = FaultSensitivityDetails.None\n };\n\n // Add custom converters\n options.Settings.Converters.Add(new JsonStringEnumConverter());\n\n var formatter = new JsonFormatter(options);\n var payload = new { UserName = \"johndoe\", Email = \"john@example.com\", Age = 30 };\n\n using (var stream = formatter.Serialize(payload))\n using (var reader = new StreamReader(stream))\n {\n string json = reader.ReadToEnd();\n Console.WriteLine(json);\n // Output:\n // {\n // \"userName\": \"johndoe\",\n // \"email\": \"john@example.com\",\n // \"age\": 30\n // }\n }\n }\n\n public void ConfigureDefaultMediaType()\n {\n // Access the default media type for JSON\n Console.WriteLine(JsonFormatterOptions.DefaultMediaType); // \"application/json\"\n\n // DefaultConverters are applied automatically at static initialization\n Console.WriteLine($\"Default converters configured: {JsonFormatterOptions.DefaultConverters != null}\"); // true\n }\n\n public void ValidateOptions()\n {\n var options = new JsonFormatterOptions();\n // ValidateOptions throws InvalidOperationException if Settings is null\n options.ValidateOptions();\n Console.WriteLine(\"Options are valid.\");\n }\n }\n}" + } + }, + { + "id": "a6d2e7f0a4c03c8dee411474", + "exampleId": "Cuemon.Extensions.AspNetCore.Text.Json.MinimalJsonOptions#1", + "uid": "Cuemon.Extensions.AspNetCore.Text.Json.MinimalJsonOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Text.Json@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text.Json;\nusing Cuemon.Extensions.AspNetCore.Text.Json;\nusing Cuemon.Extensions.Text.Json.Formatters;\nusing Microsoft.AspNetCore.Http.Json;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\n\nvar services = new ServiceCollection();\n\n// Configure JsonFormatterOptions with custom settings\nservices.Configure(o =>\n{\n o.Settings.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;\n o.Settings.WriteIndented = false;\n});\n\n// Register MinimalJsonOptions so that JsonOptions (minimal API)\n// receives the same settings and converters\nservices.AddTransient, MinimalJsonOptions>();\n\nvar provider = services.BuildServiceProvider();\nvar jsonOptions = provider.GetRequiredService>();\n\nConsole.WriteLine($\"Property naming policy: {jsonOptions.Value.SerializerOptions.PropertyNamingPolicy}\"); // CamelCase\nConsole.WriteLine($\"Write indented: {jsonOptions.Value.SerializerOptions.WriteIndented}\"); // False" + } + }, + { + "id": "a80ea690be127edb42abad6a", + "exampleId": "Cuemon.ExceptionHandler`2#1", + "uid": "Cuemon.ExceptionHandler`2", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\nTesterFunc parsePort = (out int value) => int.TryParse(\"70000\", out value);\n\nExceptionHandler handler =\n new ExceptionCondition().IsTrue(parsePort);\n\nvar invoker = handler.Create(port =>\n new ArgumentOutOfRangeException(nameof(port), port, \"Ports must be between 0 and 65535.\"));\n\ntry\n{\n invoker.TryThrow();\n}\ncatch (ArgumentOutOfRangeException ex)\n{\n Console.WriteLine($\"Rejected port: {ex.ActualValue}\");\n}" + } + }, + { + "id": "a8659fe8339088b7b883c517", + "exampleId": "System.Runtime.CompilerServices.CallerArgumentExpressionAttribute#1", + "uid": "System.Runtime.CompilerServices.CallerArgumentExpressionAttribute", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net48", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Runtime.CompilerServices;\n\nnew CallerArgumentExpressionAttributeExample().Demonstrate();\n\nnamespace System.Runtime.CompilerServices\n{\n public class CallerArgumentExpressionAttributeExample\n {\n public void Demonstrate()\n {\n var attr = new CallerArgumentExpressionAttribute(\"condition\");\n Console.WriteLine(attr.ParameterName); // \"condition\"\n\n var value = 42;\n Validate(value > 0);\n }\n\n public void Validate(bool condition, [CallerArgumentExpression(\"condition\")] string expression = null)\n {\n if (!condition)\n {\n Console.WriteLine($\"Assertion failed: {expression}\");\n }\n else\n {\n Console.WriteLine($\"Assertion passed: {expression}\");\n }\n }\n }\n}" + } + }, + { + "id": "a8ed9e4532b234819fc65f92", + "exampleId": "Cuemon.Data.Integrity.EntityDataIntegrityMethod#1", + "uid": "Cuemon.Data.Integrity.EntityDataIntegrityMethod", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Data.Integrity; // for EntityDataIntegrityMethod\n\n// Unaltered - the checksum is left as-is (default)\nEntityDataIntegrityMethod method = EntityDataIntegrityMethod.Unaltered;\nConsole.WriteLine(method); // Unaltered\n\n// Combined - the checksum is computed from all inputs combined\nmethod = EntityDataIntegrityMethod.Combined;\nConsole.WriteLine(method); // Combined\n\n// Timestamp - the checksum is generated from date-time inputs\nmethod = EntityDataIntegrityMethod.Timestamp;\nConsole.WriteLine(method); // Timestamp\n\n// Switch on the method to determine behavior\nswitch (method)\n{\n case EntityDataIntegrityMethod.Unaltered:\n Console.WriteLine(\"Checksum unchanged.\");\n break;\n case EntityDataIntegrityMethod.Combined:\n Console.WriteLine(\"Checksum computed from all data.\");\n break;\n case EntityDataIntegrityMethod.Timestamp:\n Console.WriteLine(\"Checksum based on timestamp.\");\n break;\n\n}" + } + }, + { + "id": "a93f8d9a5cf54715cd7847c5", + "exampleId": "Cuemon.Extensions.Collections.Specialized.DictionaryExtensions#1", + "uid": "Cuemon.Extensions.Collections.Specialized.DictionaryExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Collections.Specialized@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing Cuemon;\nusing Cuemon.Extensions.Collections.Specialized;\n\n// Create a dictionary with string array values\nvar source = new Dictionary\n{\n [\"colors\"] = new[] { \"red\", \"green\", \"blue\" },\n [\"sizes\"] = new[] { \"small\", \"large\" }\n};\n\n// Convert to a NameValueCollection (default delimiter is comma)\nNameValueCollection nvc = source.ToNameValueCollection();\n\nConsole.WriteLine(nvc[\"colors\"]); // \"red,green,blue\"\nConsole.WriteLine(nvc[\"sizes\"]); // \"small,large\"\n\n// Convert with a custom delimiter\nNameValueCollection nvcSemicolon = source.ToNameValueCollection(o =>\n{\n o.Delimiter = \";\";\n});\n\nConsole.WriteLine(nvcSemicolon[\"colors\"]); // \"red;green;blue\"\nConsole.WriteLine(nvcSemicolon[\"sizes\"]); // \"small;large\"" + } + }, + { + "id": "a9c21ea8954b3fe52501f453", + "exampleId": "Cuemon.AspNetCore.Mvc.CacheableFactory#1", + "uid": "Cuemon.AspNetCore.Mvc.CacheableFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Cryptography;\nusing System.Text;\nusing Cuemon.AspNetCore.Mvc;\n\nvar content = \"hello-world\";\n\nvar lastModified = CacheableFactory.CreateHttpLastModified(content, o =>\n{\n o.TimestampProvider = _ => DateTime.UtcNow;\n o.ChangedTimestampProvider = _ => DateTime.UtcNow;\n});\n\nvar entityTag = CacheableFactory.CreateHttpEntityTag(content, o =>\n{\n o.ChecksumProvider = value => SHA256.HashData(Encoding.UTF8.GetBytes(value));\n o.WeakChecksumProvider = _ => false;\n});\n\nvar combined = CacheableFactory.Create(content, o =>\n{\n o.TimestampProvider = _ => DateTime.UtcNow;\n o.ChecksumProvider = value => SHA256.HashData(Encoding.UTF8.GetBytes(value));\n o.ChangedTimestampProvider = _ => DateTime.UtcNow;\n o.WeakChecksumProvider = _ => false;\n});\n\nConsole.WriteLine(lastModified is ICacheableObjectResult);\nConsole.WriteLine(entityTag is ICacheableObjectResult);\nConsole.WriteLine(combined is ICacheableObjectResult);" + } + }, + { + "id": "ab4819cf02194658cca4eb99", + "exampleId": "Cuemon.Security.FowlerNollVo32#1", + "uid": "Cuemon.Security.FowlerNollVo32", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon; // for Endianness\nusing Cuemon.Security; // for FowlerNollVo32\nusing Cuemon;\n\nvar fnv = new FowlerNollVo32();\n\n// Compute hash of a string\nbyte[] data = Encoding.UTF8.GetBytes(\"hello\");\nvar hash = fnv.ComputeHash(data);\n\nConsole.WriteLine(hash.ToHexadecimalString()); // F970D0C7 (big-endian default)\nConsole.WriteLine(hash.ToBase64String()); // +XDQxw==\nConsole.WriteLine(fnv.Bits); // 32\n\n// Configure for little-endian output\nvar fnvLe = new FowlerNollVo32(o => o.ByteOrder = Endianness.LittleEndian);\nbyte[] hashBytes = fnvLe.ComputeHash(data).GetBytes();\nConsole.WriteLine(BitConverter.ToString(hashBytes)); // C7-D0-70-F9\n\n// Use FNV-1 variant instead of FNV-1a\nfnv.Options.Algorithm = FowlerNollVoAlgorithm.Fnv1;\nhash = fnv.ComputeHash(data);\nConsole.WriteLine(hash.ToHexadecimalString()); // E973FD3B" + } + }, + { + "id": "ab4f0fb10ddff761784f333b", + "exampleId": "Cuemon.Extensions.Collections.Generic.StackExtensions#1", + "uid": "Cuemon.Extensions.Collections.Generic.StackExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Collections.Generic@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon.Extensions.Collections.Generic;\n\nvar stack = new Stack();\nstack.Push(\"bottom\");\nstack.Push(\"top\");\n\nif (stack.TryPop(out string item))\n{\n Console.WriteLine($\"Popped: {item}\");\n}\n\nstack.TryPop(out string next);\nConsole.WriteLine(next);\n\nstack.TryPop(out string empty);\nConsole.WriteLine(empty == null);" + } + }, + { + "id": "abb649a7ebe9bd6f8bc0cde2", + "exampleId": "Cuemon.Extensions.ExceptionExtensions#1", + "uid": "Cuemon.Extensions.ExceptionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing Cuemon.Extensions;\n\nvar exception = new InvalidOperationException(\n \"First\",\n new AmbiguousMatchException(\n \"Second\",\n new OutOfMemoryException(\n \"Third\",\n new AggregateException(new AccessViolationException(\"Fourth\")))));\n\nIEnumerable flattened = exception.Flatten();\n\nConsole.WriteLine(flattened.Count());\nforeach (var ex in flattened)\n{\n Console.WriteLine(ex.Message);\n}" + } + }, + { + "id": "abb962aacf72012d3ddb5d77", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Filters.Diagnostics.HttpFaultResolverExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Filters.Diagnostics.HttpFaultResolverExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.AspNetCore.Http;\nusing Cuemon.Extensions.AspNetCore.Mvc.Filters.Diagnostics;\n\nvar resolvers = new List()\n .AddHttpFaultResolver(\n message: \"The request payload could not be processed.\",\n helpLink: new Uri(\"https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400\"))\n .AddHttpFaultResolver(\n exception => new HttpExceptionDescriptor(exception),\n exception => exception is TooManyRequestsException);\n\nvar resolved = resolvers[1].TryResolveFault(new TooManyRequestsException(), out var descriptor);\n\nConsole.WriteLine($\"{resolved}: {descriptor.StatusCode} {descriptor.Code}\");" + } + }, + { + "id": "ac626c141f3b289e29fa5f19", + "exampleId": "Cuemon.Extensions.Collections.Generic.DictionaryExtensions#1", + "uid": "Cuemon.Extensions.Collections.Generic.DictionaryExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Collections.Generic@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon.Extensions.Collections.Generic;\n\nIDictionary source = new Dictionary\n{\n [\"alpha\"] = 1,\n [\"beta\"] = 2\n};\n\nvar destination = new Dictionary();\nsource.CopyTo(destination);\n\nsource.TryAdd(\"gamma\", 3, dictionary => !dictionary.ContainsKey(\"gamma\"));\nsource.AddOrUpdate(\"beta\", 20);\n\nvar configuredFallback = source.GetValueOrDefault(\"delta\", () => 42);\nvar foundFallback = source.TryGetValueOrFallback(\"missing\", keys => keys.OrderBy(key => key).First(), out var fallbackValue);\nvar rows = source.ToEnumerable().Select(pair => $\"{pair.Key}:{pair.Value}\");\n\nConsole.WriteLine(destination.Count);\nConsole.WriteLine(configuredFallback);\nConsole.WriteLine(foundFallback);\nConsole.WriteLine(fallbackValue);\nConsole.WriteLine(string.Join(\", \", rows));" + } + }, + { + "id": "acdf6dc45a6bd609df331f40", + "exampleId": "Cuemon.IntegerDecoratorExtensions#1", + "uid": "Cuemon.IntegerDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\n// Wrap an int with Decorator.Enclose to access the Max extension\nint value = 42;\nint minimum = 100;\n\n// Returns the larger of the wrapped value and the specified minimum\nint result = Decorator.Enclose(value).Max(minimum);\nConsole.WriteLine(result); // Output: 100\n\n// When the wrapped value is larger than the minimum\nvalue = 500;\nresult = Decorator.Enclose(value).Max(minimum);\nConsole.WriteLine(result); // Output: 500\n\n// Works with any int expression\nresult = Decorator.Enclose(-10).Max(0);\nConsole.WriteLine(result); // Output: 0" + } + }, + { + "id": "ace8a96789e27dbc32d5ba88", + "exampleId": "Cuemon.Extensions.Data.Integrity.AssemblyExtensions#1", + "uid": "Cuemon.Extensions.Data.Integrity.AssemblyExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Data.Integrity@11.0.0" + ], + "source": "using System;\nusing System.Reflection;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Extensions.Data.Integrity;\n\nnamespace MyApp.Examples;\n\npublic class AssemblyExtensionsExample\n{\n public static void Main()\n {\n // Get a reference to any loaded assembly\n Assembly assembly = typeof(AssemblyExtensionsExample).Assembly;\n\n // Generate a CacheValidator from the assembly's file metadata\n CacheValidator validator = assembly.GetCacheValidator();\n\n Console.WriteLine($\"Assembly: {assembly.GetName().Name}\");\n Console.WriteLine($\"Created (UTC): {validator.Created:O}\");\n Console.WriteLine($\"Modified (UTC): {validator.Modified?.ToString(\"O\") ?? \"N/A\"}\");\n Console.WriteLine($\"Checksum (hex): {validator.Checksum.ToHexadecimalString()}\");\n Console.WriteLine($\"Validation strength: {validator.Validation}\");\n\n // Use the CacheValidator for HTTP cache validation scenarios\n Console.WriteLine($\"\\nETag candidate: \\\"{validator.Checksum.ToHexadecimalString()}\\\"\");\n\n}\n}" + } + }, + { + "id": "ad301e3ab06e907116724bda", + "exampleId": "Cuemon.AspNetCore.Http.PayloadTooLargeException#1", + "uid": "Cuemon.AspNetCore.Http.PayloadTooLargeException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System.IO;\nusing System;\nusing Cuemon.AspNetCore.Http;\n\n// Create a PayloadTooLargeException with default message\nvar ex = new PayloadTooLargeException();\nConsole.WriteLine(ex.StatusCode); // 413\nConsole.WriteLine(ex.ReasonPhrase); // Payload Too Large\n\n// Create with a custom message\nvar custom = new PayloadTooLargeException(\"Upload size exceeds the maximum of 10 MB.\");\nConsole.WriteLine(custom.Message);\n\n// Create with inner exception\nvar inner = new InvalidOperationException(\"Stream exceeded configured limit.\");\nvar withInner = new PayloadTooLargeException(\"Request entity too large.\", inner);\nConsole.WriteLine(withInner.InnerException?.Message); // Stream exceeded configured limit.\n\n// Use TryParse from the base class to resolve by status code\nif (HttpStatusCodeException.TryParse(413, \"File exceeds 10 MB limit.\", out var parsed))\n{\n Console.WriteLine(parsed.Message); // File exceeds 10 MB limit.\n Console.WriteLine(parsed.StatusCode); // 413\n}\n\n// Simulate a payload size check\nlong uploadSize = 15 * 1024 * 1024; // 15 MB\nlong maxSize = 10 * 1024 * 1024; // 10 MB\nif (uploadSize > maxSize)\n{\n var rejected = new PayloadTooLargeException(\n $\"Upload of {uploadSize / 1024 / 1024} MB exceeds the {maxSize / 1024 / 1024} MB limit.\");\n Console.WriteLine(rejected.Message);\n\n}" + } + }, + { + "id": "ad6b693cb8151ff494a6b781", + "exampleId": "Cuemon.Runtime.Serialization.Formatters.Formatter#1", + "uid": "Cuemon.Runtime.Serialization.Formatters.Formatter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Runtime.Serialization.Formatters;\n\nvar type = Formatter.GetType(\"System.DateTime, mscorlib\");\nConsole.WriteLine($\"Resolved type: {type}\");\n\nif (Formatter.TryGetType(\"Cuemon.GuidStringOptions, Cuemon.Core\", out var optionsType))\n{\n Console.WriteLine($\"Found type: {optionsType}\");\n}" + } + }, + { + "id": "adb6a986c371daad49cc0500", + "exampleId": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationMiddleware#1", + "uid": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationMiddleware", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Claims;\nusing System.Threading.Tasks;\nusing Cuemon.AspNetCore.Authentication.Hmac;\nusing MyApp.Examples;\n\nHmacAuthenticationMiddlewareExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class HmacAuthenticationMiddlewareExample\n {\n public static void Demonstrate()\n {\n var middleware = new HmacAuthenticationMiddleware(_ => Task.CompletedTask, options =>\n {\n options.AuthenticationScheme = \"hmac-docs\";\n options.RequireSecureConnection = false;\n options.Authenticator = (string clientId, out string clientSecret) =>\n {\n clientSecret = clientId == \"Agent-Api\" ? \"Test\" : null;\n return clientSecret == null ? null : new ClaimsPrincipal(new ClaimsIdentity());\n };\n });\n\n Console.WriteLine(middleware.Options.AuthenticationScheme);\n }\n }\n}" + } + }, + { + "id": "af07d7e2075dd585d241c990", + "exampleId": "Cuemon.Extensions.FuncFactory#1", + "uid": "Cuemon.Extensions.FuncFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Extensions;\n\nFunc formatter = (x, y) => $\"{x} + {y} = {x + y}\";\n\nvar factory = FuncFactory.Create(formatter, 3, 4);\nstring result = factory.ExecuteMethod();\n\nConsole.WriteLine(result);\n\nint sum = FuncFactory.Invoke, int>(tuple => tuple.Arg1 + tuple.Arg2, MutableTupleFactory.CreateTwo(10, 20));\nConsole.WriteLine(sum);" + } + }, + { + "id": "af1f226a232e1c7816b2412a", + "exampleId": "Cuemon.Runtime.DependencyEventArgs#1", + "uid": "Cuemon.Runtime.DependencyEventArgs", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Runtime;\nusing MyApp.Runtime;\n\nDependencyEventArgsExamples.CreateEventArgs();\n\nnamespace MyApp.Runtime\n{\n public class DependencyEventArgsExamples\n {\n public static void CreateEventArgs()\n {\n // Create event args with the UTC time of the last dependency change.\n var args = new DependencyEventArgs(DateTime.UtcNow);\n Console.WriteLine(\"Last modified (UTC): {0:O}\", args.UtcLastModified);\n }\n\n public static void CreateEventArgsWithPastTimestamp()\n {\n // Create event args with a specific past timestamp.\n var lastWrite = new DateTime(2026, 6, 1, 12, 0, 0, DateTimeKind.Utc);\n var args = new DependencyEventArgs(lastWrite);\n Console.WriteLine(\"Last dependency change: {0:O}\", args.UtcLastModified);\n }\n\n public static void UseEmptySentinel()\n {\n // Use the static Empty sentinel to represent no change.\n DependencyEventArgs args = DependencyEventArgs.Empty;\n Console.WriteLine(\"Is empty: {0}\", args.UtcLastModified == DateTime.MinValue); // true\n }\n\n public static void RaiseDependencyEvent()\n {\n var monitor = new DependencyMonitor();\n monitor.DependencyChanged += (sender, args) =>\n {\n Console.WriteLine(\"Dependency last changed at: {0:O}\", args.UtcLastModified);\n };\n\n monitor.CheckForChanges();\n }\n }\n\n public class DependencyMonitor\n {\n public event EventHandler DependencyChanged;\n\n public void CheckForChanges()\n {\n DependencyChanged?.Invoke(this, new DependencyEventArgs(DateTime.UtcNow));\n }\n }\n}" + } + }, + { + "id": "af4d35fd754a2665db716636", + "exampleId": "Cuemon.AspNetCore.Hosting.HostingEnvironmentMiddleware#1", + "uid": "Cuemon.AspNetCore.Hosting.HostingEnvironmentMiddleware", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.Hosting@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading.Tasks;\nusing Cuemon.AspNetCore.Hosting;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.FileProviders;\nusing Microsoft.Extensions.Hosting;\nusing Microsoft.Extensions.Options;\n\nawait HostingEnvironmentMiddlewareExample.DemonstrateAsync();\n\nnamespace Cuemon.AspNetCore.Hosting\n{\n public static class HostingEnvironmentMiddlewareExample\n {\n public static async Task DemonstrateAsync()\n {\n var context = new DefaultHttpContext();\n var environment = new SampleHostEnvironment();\n var options = Options.Create(new HostingEnvironmentOptions\n {\n HeaderName = \"X-Environment\",\n SuppressHeaderPredicate = _ => false\n });\n\n var middleware = new HostingEnvironmentMiddleware(\n httpContext => httpContext.Response.WriteAsync(\"Hello\"),\n options);\n\n await middleware.InvokeAsync(context, environment);\n\n // The middleware writes this header when the response starts.\n Console.WriteLine($\"{options.Value.HeaderName}: {environment.EnvironmentName}\");\n }\n\n private sealed class SampleHostEnvironment : IHostEnvironment\n {\n public string ApplicationName { get; set; } = \"Docs\";\n public IFileProvider ContentRootFileProvider { get; set; } = new NullFileProvider();\n public string ContentRootPath { get; set; } = \".\";\n public string EnvironmentName { get; set; } = Environments.Staging;\n }\n }\n}" + } + }, + { + "id": "af92af51de25fcdd014819bd", + "exampleId": "Cuemon.Data.Integrity.ChecksumBuilder#1", + "uid": "Cuemon.Data.Integrity.ChecksumBuilder", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Security;\n\nvar builder = new ChecksumBuilder(() => HashFactory.CreateFnv128());\nConsole.WriteLine($\"Empty checksum: {builder.Checksum.ToHexadecimalString()}\");\n\nbuilder.CombineWith(BitConverter.GetBytes(42L));\nbuilder.CombineWith(Encoding.UTF8.GetBytes(\"Hello, World!\"));\n\nvar comparison = new ChecksumBuilder(BitConverter.GetBytes(42L), () => HashFactory.CreateFnv128());\ncomparison.CombineWith(Encoding.UTF8.GetBytes(\"Hello, World!\"));\n\nConsole.WriteLine($\"Current checksum: {builder}\");\nConsole.WriteLine($\"Checksums match: {builder.Equals(comparison)}\");\nConsole.WriteLine($\"Hash code: {builder.GetHashCode()}\");" + } + }, + { + "id": "af9a275d7cff798d2c928dae", + "exampleId": "Cuemon.AspNetCore.Mvc.ExceptionDescriptorResult#1", + "uid": "Cuemon.AspNetCore.Mvc.ExceptionDescriptorResult", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.AspNetCore.Http;\nusing Cuemon.AspNetCore.Mvc;\nusing Microsoft.AspNetCore.Mvc;\n\nvar descriptorResult = new ExceptionDescriptorResult(\n new HttpExceptionDescriptor(new BadRequestException(\"City name is required.\")));\n\nvar descriptor = (HttpExceptionDescriptor)descriptorResult.Value;\nConsole.WriteLine(descriptor.StatusCode);\n\nvar problemResult = new ExceptionDescriptorResult(\n new ProblemDetails { Title = \"Validation failed.\" });\n\nConsole.WriteLine(problemResult.Value is IDecorator);" + } + }, + { + "id": "afb42fa010ef466f00ec2665", + "exampleId": "Cuemon.Extensions.Runtime.Hierarchy`1#1", + "uid": "Cuemon.Extensions.Runtime.Hierarchy`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.Extensions.Runtime;\n\nvar root = new Hierarchy();\nvar rootNode = root.Add(\"Root\");\nvar child = root.Add(\"Child\");\nvar grandchild = child.Add(\"Grandchild\");\nvar sibling = root.Add(\"Sibling\");\n\nConsole.WriteLine($\"Root depth: {root.Depth}, index: {root.Index}\"); // 0, 0\nConsole.WriteLine($\"Child depth: {child.Depth}, index: {child.Index}\"); // 1, 1\nConsole.WriteLine($\"Grandchild depth: {grandchild.Depth}\"); // 2\nConsole.WriteLine($\"Path: {grandchild.GetPath()}\"); // Root.Child.Grandchild\nConsole.WriteLine($\"HasChildren: {root.HasChildren}\"); // True\nConsole.WriteLine($\"HasParent: {child.HasParent}\"); // True\n\n// Retrieve via indexer\nConsole.WriteLine(root[0].Instance); // Root\nConsole.WriteLine(root[2].Instance); // Grandchild\n\n// Enumerate children\nforeach (var node in root.GetChildren())\n{\n Console.WriteLine(node.Instance);\n// Output: Child, Sibling\n\n}" + } + }, + { + "id": "afbbea59b34e56653be0dbec", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.ModelBinding.DisableModelBindingAttribute#1", + "uid": "Cuemon.AspNetCore.Mvc.Filters.ModelBinding.DisableModelBindingAttribute", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Mvc.Filters.ModelBinding;\nusing Microsoft.AspNetCore.Mvc;\nusing Microsoft.AspNetCore.Mvc.ModelBinding;\n\n// Direct instantiation of DisableModelBindingAttribute\nvar attribute = new DisableModelBindingAttribute(typeof(FormValueProviderFactory));\nConsole.WriteLine($\"Disabled type: {attribute.ValueProviderFactoryType.Name}\");" + } + }, + { + "id": "aff4a5a5f457fb4d51f3f330", + "exampleId": "Cuemon.Reflection.TargetFrameworkMoniker#1", + "uid": "Cuemon.Reflection.TargetFrameworkMoniker", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Reflection;\nusing Cuemon.Reflection;\n\nvar parsed = TargetFrameworkMoniker.Parse(\".NETCoreApp,Version=v10.0\");\nvar current = TargetFrameworkMoniker.ResolveCurrent();\nvar library = TargetFrameworkMoniker.Resolve(typeof(TargetFrameworkMoniker).Assembly);\nvar outputPath = TargetFrameworkMoniker.ResolveFromPath(AppContext.BaseDirectory);\n\nConsole.WriteLine($\"Parsed TFM: {parsed}\");\nConsole.WriteLine($\"Current TFM: {current}\");\nConsole.WriteLine($\"Example assembly TFM: {library}\");\nConsole.WriteLine($\"Output path TFM: {outputPath}\");\n\nif (TargetFrameworkMoniker.TryResolve(Assembly.GetExecutingAssembly(), out var executingAssemblyTfm))\n{\n Console.WriteLine($\"Executing assembly TFM: {executingAssemblyTfm}\");\n}" + } + }, + { + "id": "b05ce02bb71bac4f15c66f5b", + "exampleId": "Cuemon.Extensions.Text.Json.Converters.DateTimeConverter#1", + "uid": "Cuemon.Extensions.Text.Json.Converters.DateTimeConverter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Globalization;\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\nusing Cuemon.Extensions.Text.Json.Converters;\n\nvar options = new JsonSerializerOptions\n{\n TypeInfoResolver = new DefaultJsonTypeInfoResolver()\n};\n\n// Register a converter that writes dates in the French \"dd/MM/yyyy\" format\noptions.Converters.Add(new DateTimeConverter(\"dd/MM/yyyy\", new CultureInfo(\"fr-FR\")));\n\nvar original = new DateTime(2026, 6, 16, 14, 30, 0, DateTimeKind.Utc);\n\nstring json = JsonSerializer.Serialize(original, options);\nConsole.WriteLine(json); // \"16/06/2026\"\n\nvar restored = JsonSerializer.Deserialize(json, options);\nConsole.WriteLine(restored.ToString(\"dd/MM/yyyy\")); // 16/06/2026" + } + }, + { + "id": "b0a50b9ab2c39935758cf8ff", + "exampleId": "Cuemon.Data.Integrity.FileChecksumOptions#1", + "uid": "Cuemon.Data.Integrity.FileChecksumOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data.Integrity@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing Cuemon.Data.Integrity;\n\nvar defaults = new FileChecksumOptions();\nConsole.WriteLine($\"Default method: {defaults.Method}\");\nConsole.WriteLine($\"Default bytes to read: {defaults.BytesToRead}\");\n\nvar path = Path.Combine(AppContext.BaseDirectory, \"payload.txt\");\nFile.WriteAllText(path, \"cuemon\");\n\ntry\n{\n var file = new FileInfo(path);\n\n var combinedValidator = CacheValidatorFactory.CreateValidator(file, setup: options =>\n {\n options.Method = EntityDataIntegrityMethod.Combined;\n });\n\n var strongValidator = CacheValidatorFactory.CreateValidator(file, setup: options =>\n {\n options.BytesToRead = 4;\n });\n\n Console.WriteLine($\"Combined method: {combinedValidator.Method}\");\n Console.WriteLine($\"Strong validation: {strongValidator.Validation}\");\n}\nfinally\n{\n if (File.Exists(path)) { File.Delete(path); }\n}" + } + }, + { + "id": "b1fc5dd131a8daacb5db8ba8", + "exampleId": "Cuemon.Extensions.StringExtensions#1", + "uid": "Cuemon.Extensions.StringExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Text;\nusing Cuemon;\nusing Cuemon.Extensions;\nusing Cuemon.Text;\n\nvar value = \" Hello, World! \";\nvar answer = \"yes\";\nvar chunkSource = \"abcdefgh\";\nvar plainText = \"Hello\";\nvar encodedText = \"SGVsbG8=\";\nvar binarySource = \"00001101\";\nvar dayName = \"Monday\";\nvar timeSource = \"42\";\nvar counted = \"hello\";\nvar quoted = \"hello's\";\nvar guidSource = \"550e8400-e29b-41d4-a716-446655440000\";\nvar uriSource = \"https://example.com\";\nvar sequence = new[] { \"1\", \"2\", \"3\" };\nvar emptySource = string.Empty;\n\n// Trim all whitespace characters\nvar trimmed = value.TrimAll(); // \"Hello,World!\"\n\n// Convert to different casing styles\nvar lower = value.ToCasing(CasingMethod.LowerCase); // \" hello, world! \"\nvar upper = value.ToCasing(CasingMethod.UpperCase); // \" HELLO, WORLD! \"\nvar title = value.ToCasing(CasingMethod.TitleCase, new CultureInfo(\"en-US\")); // \" Hello, World! \"\n\n// Check string characteristics\nbool isEmail = value.IsEmailAddress(); // false\nbool isGuid = value.IsGuid(); // false\nbool isHex = value.IsHex(); // false\nbool isNumeric = value.IsNumeric(); // false\nbool isBase64 = value.IsBase64(); // false\n\n// Substring operations\nvar before = value.SubstringBefore(\",\"); // \" Hello\"\nvar after = value.SuffixWithForwardingSlash(); // \" Hello, World! /\"\nvar prefixed = value.PrefixWith(\">>\"); // \">> Hello, World! \"\n\n// Remove and replace\nvar removed = value.RemoveAll(\" \", \"!\"); // \"Hello,World\"\nvar replaced = value.ReplaceAll(\"world\", \"Earth\"); // \" Hello, Earth! \"\n\n// Contains checks\nbool hasHello = value.ContainsAny(\"Hello\", \"World\"); // true\nbool hasAll = value.ContainsAll(\"Hello\", \"World\"); // true\nbool hasChar = value.ContainsAny('o', 'x'); // true\n\n// Equality checks\nbool equalsAny = answer.EqualsAny(\"yes\", \"no\"); // true\nbool equalsAnyIgnoreCase = answer.EqualsAny(StringComparison.OrdinalIgnoreCase, \"YES\", \"NO\"); // true\n\n// StartsWith\nbool starts = value.StartsWith(\" Hello\"); // true\n\n// Chunk\nIEnumerable chunks = chunkSource.Chunk(3); // [\"abc\", \"def\", \"gh\"]\nvar chunksDefault = chunkSource.Chunk(); // [\"abc\", \"def\", \"gh\"]\n\n// Encoding conversions\nbyte[] bytes = plainText.ToByteArray(o => o.Encoding = Encoding.UTF8);\nstring hex = plainText.ToHexadecimal();\nstring fromHex = hex.FromHexadecimal();\n\n// Base64\nbyte[] base64Bytes = encodedText.FromBase64();\nvar urlB64 = encodedText.FromUrlEncodedBase64(); // \"Hello\"\n\n// Enum parsing\nvar day = dayName.ToEnum(); // DayOfWeek.Monday\n\n// TimeSpan from string\nvar ts = timeSource.ToTimeSpan(TimeUnit.Minutes); // 00:42:00\n\n// Delimited string splitting\nstring csv = \"apple,\\\"orange, citrus\\\",banana\";\nstring[] parts = csv.SplitDelimited(); // [\"apple\", \"orange, citrus\", \"banana\"]\n\n// Validate a sequence of strings against a target type\nbool isIntegerSequence = sequence.IsSequenceOf(); // true\n\n// Additional string utilities\nint charCount = counted.Count('l'); // 2\nstring diff = counted.Difference(\"world\"); // \"world\"\nvar biDigits = binarySource.FromBinaryDigits(); // new byte[] { 13 }\nbool emptyCheck = emptySource.IsNullOrEmpty(); // true\nbool emptySequenceCheck = sequence.IsNullOrEmpty(); // false\nvar whitespaceSource = \" \";\nbool whiteSpaceCheck = whitespaceSource.IsNullOrWhiteSpace(); // true\nstring jsEsc = quoted.JsEscape(); // \"hello\\\\u0027s\"\nstring jsUnesc = quoted.JsUnescape(); // \"hello's\"\nstring suffixed = counted.SuffixWith(\" world\"); // \"hello world\"\nGuid asGuid = guidSource.ToGuid();\nUri asUri = uriSource.ToUri();\nConsole.WriteLine(isIntegerSequence);" + } + }, + { + "id": "b1fe980dc799326bfed8dccf", + "exampleId": "Cuemon.Collections.Generic.DynamicComparer#1", + "uid": "Cuemon.Collections.Generic.DynamicComparer", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon.Collections.Generic;\n\nstring[] fruits = [\"apple\", \"pear\", \"banana\", \"kiwi\"];\n\n// Create a dynamic comparer that sorts by string length\nIComparer lengthComparer = DynamicComparer.Create((x, y) =>\n x.Length.CompareTo(y.Length));\n\nArray.Sort(fruits, lengthComparer);\nConsole.WriteLine(string.Join(\", \", fruits));\n\n// Create a comparer that sorts descending\nIComparer descendingComparer = DynamicComparer.Create((x, y) =>\n string.Compare(y, x, StringComparison.Ordinal));\n\nArray.Sort(fruits, descendingComparer);\nConsole.WriteLine(string.Join(\", \", fruits));" + } + }, + { + "id": "b2d4656bd77614b4388440ff", + "exampleId": "Cuemon.Data.QueryFormat#1", + "uid": "Cuemon.Data.QueryFormat", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Data;\n\n// QueryFormat controls how query fragments are formatted.\n\n// Delimited: value, value, value\nstring delimited = QueryBuilder.EncodeFragment(QueryFormat.Delimited, new[] { \"FirstName\", \"LastName\", \"Email\" });\nConsole.WriteLine($\"Delimited: {delimited}\"); // FirstName,LastName,Email\n\n// DelimitedString: 'value', 'value', 'value'\nstring delimitedString = QueryBuilder.EncodeFragment(QueryFormat.DelimitedString, new[] { \"John\", \"Doe\" });\nConsole.WriteLine($\"DelimitedString: {delimitedString}\"); // 'John','Doe'\n\n// DelimitedSquareBracket: [value], [value], [value]\nstring delimitedSquareBracket = QueryBuilder.EncodeFragment(QueryFormat.DelimitedSquareBracket, new[] { \"FirstName\", \"LastName\" });\nConsole.WriteLine($\"DelimitedSquareBracket: {delimitedSquareBracket}\"); // [FirstName],[LastName]\n\n// Distinct option removes duplicates\nstring distinct = QueryBuilder.EncodeFragment(QueryFormat.Delimited, new[] { \"A\", \"B\", \"A\", \"C\" }, distinct: true);\nConsole.WriteLine($\"Distinct: {distinct}\"); // A,B,C" + } + }, + { + "id": "b2f4d8efa4d34ec62871001f", + "exampleId": "Cuemon.Xml.Serialization.Converters.XmlConverterDecoratorExtensions#1", + "uid": "Cuemon.Xml.Serialization.Converters.XmlConverterDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon;\nusing Cuemon.Diagnostics;\nusing Cuemon.Xml.Serialization.Converters;\n\nvar converters = new List();\nvar decorator = Decorator.Enclose((IList)converters);\n\ndecorator.AddDateTimeConverter();\ndecorator.AddTimeSpanConverter();\ndecorator.AddStringConverter();\ndecorator.AddUriConverter();\ndecorator.AddEnumerableConverter();\ndecorator.AddExceptionConverter(false, false);\ndecorator.AddFailureConverter();\ndecorator.AddExceptionDescriptorConverter(options => options.SensitivityDetails = FaultSensitivityDetails.All);\ndecorator.AddXmlConverter(\n (writer, version, qe) =>\n {\n writer.WriteStartElement(qe?.LocalName ?? \"Version\");\n writer.WriteString(version.ToString());\n writer.WriteEndElement();\n },\n (reader, type) => Version.Parse(reader.ReadElementContentAsString())\n);\ndecorator.InsertXmlConverter(0);\n\nvar writerConverter = decorator.FirstOrDefaultWriterConverter(typeof(Version));\nvar readerConverter = decorator.FirstOrDefaultReaderConverter(typeof(Uri));\n\nConsole.WriteLine(writerConverter != null);\nConsole.WriteLine(readerConverter != null);\nConsole.WriteLine(converters.Count);" + } + }, + { + "id": "b37a7e0ffa7ee36ab1da1cc2", + "exampleId": "Cuemon.Data.InOperatorResult#1", + "uid": "Cuemon.Data.InOperatorResult", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ], + "source": "using System;\nusing System.Data;\nusing System.Linq;\nusing Cuemon.Data;\n\nnamespace MyApp.Examples;\n\npublic class InOperatorResultExample\n{\n public static void Main()\n {\n var safeOperator = new IntInOperator();\n InOperatorResult result = safeOperator.ToSafeResult(10, 20, 30);\n\n Console.WriteLine(\"Arguments CSV: {0}\", result);\n Console.WriteLine(\"Parameter count: {0}\", result.Parameters.Count());\n Console.WriteLine(\"First parameter value: {0}\", result.Parameters.First().Value);\n\n // Output:\n // Arguments CSV: @p0,@p1,@p2\n // Parameter count: 3\n // First parameter value: 10\n }\n\n private sealed class IntInOperator : InOperator\n {\n public IntInOperator() : base(() => \"@p\") { }\n\n protected override IDbDataParameter ParametersSelector(int expression, int index)\n {\n return new SimpleParameter(string.Concat(ParameterPrefix, index), expression);\n }\n\n private sealed class SimpleParameter : IDbDataParameter\n {\n public SimpleParameter(string name, object value)\n {\n ParameterName = name;\n Value = value;\n }\n\n public DbType DbType { get; set; } = DbType.Int32;\n public ParameterDirection Direction { get; set; } = ParameterDirection.Input;\n public bool IsNullable => false;\n public string ParameterName { get; set; }\n public int Size { get; set; }\n public string SourceColumn { get; set; } = string.Empty;\n public bool SourceColumnNullMapping { get; set; }\n public DataRowVersion SourceVersion { get; set; } = DataRowVersion.Current;\n public object Value { get; set; }\n public byte Precision { get; set; }\n public byte Scale { get; set; }\n }\n }\n}" + } + }, + { + "id": "b3f5e20c5005f3b2b214973d", + "exampleId": "Cuemon.Collections.Generic.PaginationOptions#1", + "uid": "Cuemon.Collections.Generic.PaginationOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon.Collections.Generic;\n\n// Create a source sequence with 100 items\nvar allItems = Enumerable.Range(1, 100).ToList();\n\n// Configure pagination options directly\nvar options = new PaginationOptions { PageSize = 10, PageNumber = 3 };\nConsole.WriteLine($\"Page size: {options.PageSize}, Page number: {options.PageNumber}\");\n\n// Paginate with 10 items per page, starting at page 3\nvar page = new PaginationEnumerable(allItems,\n () => allItems.Count,\n setup =>\n {\n setup.PageSize = 10; // show 10 items per page\n setup.PageNumber = 3; // go to page 3\n });\n\nConsole.WriteLine($\"Page 3 items: {string.Join(\", \", page)}\"); // 21..30\nConsole.WriteLine($\"Total pages: {page.PageCount}\"); // 10\nConsole.WriteLine($\"Total items: {page.TotalElementCount}\"); // 100\nConsole.WriteLine($\"Has next page: {page.HasNextPage}\"); // True\nConsole.WriteLine($\"First page: {page.FirstPage}\"); // False\nConsole.WriteLine($\"Last page: {page.LastPage}\"); // False\n\n// Default PaginationOptions: page 1, 25 items per page\nvar firstPage = new PaginationEnumerable(allItems,\n () => allItems.Count);\n\nConsole.WriteLine($\"First page items: {string.Join(\", \", firstPage)}\"); // 1..25\nConsole.WriteLine($\"Has previous page: {firstPage.HasPreviousPage}\"); // False\n\n// Using PaginationList for eager materialization with indexer access\nvar thirdPage = new PaginationList(allItems,\n () => allItems.Count,\n setup =>\n {\n setup.PageSize = 10;\n setup.PageNumber = 3;\n });\n\nConsole.WriteLine($\"Third item on page 3: {thirdPage[2]}\"); // 23 (zero-based index)\nConsole.WriteLine($\"Page 3 count: {thirdPage.Count}\"); // 10" + } + }, + { + "id": "b402f17819a76486beec2497", + "exampleId": "Cuemon.Net.Http.HttpAuthenticationSchemes#1", + "uid": "Cuemon.Net.Http.HttpAuthenticationSchemes", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http.Headers;\nusing System.Text;\nusing Cuemon.Net.Http;\n\n// Use scheme constants to construct Authorization headers\nstring basic = HttpAuthenticationSchemes.Basic;\nstring bearer = HttpAuthenticationSchemes.Bearer;\nstring digest = HttpAuthenticationSchemes.Digest;\n\nConsole.WriteLine($\"Basic: {basic}\");\nConsole.WriteLine($\"Bearer: {bearer}\");\nConsole.WriteLine($\"Digest: {digest}\");\n\n// Example: create a Basic authentication header value\nstring credentials = Convert.ToBase64String(\n Encoding.UTF8.GetBytes(\"user:password\"));\nstring authHeader = $\"{basic} {credentials}\";\nConsole.WriteLine($\"Authorization: {authHeader}\");" + } + }, + { + "id": "b4155603fad628f1354816f1", + "exampleId": "Cuemon.Xml.StreamDecoratorExtensions#1", + "uid": "Cuemon.Xml.StreamDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing System.Xml;\nusing Cuemon;\nusing Cuemon.Xml;\n\nconst string xml = \"hello\";\n\nusing var stream = new MemoryStream(Encoding.UTF8.GetBytes(xml));\nusing XmlReader reader = Decorator.Enclose(stream).ToXmlReader();\nreader.MoveToContent();\n\nConsole.WriteLine(reader.LocalName);\n\nusing var detectStream = new MemoryStream(Encoding.UTF8.GetBytes(xml));\nvar detected = Decorator.Enclose(detectStream).TryDetectXmlEncoding(out var encoding);\n\nConsole.WriteLine(detected);\nConsole.WriteLine(encoding.EncodingName);" + } + }, + { + "id": "b418c59f6a61ed2f5745e0ec", + "exampleId": "Cuemon.Extensions.Xml.StreamExtensions#1", + "uid": "Cuemon.Extensions.Xml.StreamExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing System.Xml;\nusing Cuemon.Extensions.Xml;\nusing MyApp.Xml;\n\nnew StreamExtensionsExample().Demonstrate();\n\nnamespace MyApp.Xml\n{\n public class StreamExtensionsExample\n {\n public void Demonstrate()\n {\n const string xml = \"Value\";\n\n using (var reader = CreateStream(xml).ToXmlReader())\n {\n while (reader.Read())\n {\n if (reader.NodeType == XmlNodeType.Element)\n {\n Console.WriteLine(reader.Name);\n }\n }\n }\n\n using (var copy = CreateStream(xml).CopyXmlStream(o => o.Indent = true))\n using (var streamReader = new StreamReader(copy))\n {\n Console.WriteLine(streamReader.ReadToEnd());\n }\n\n using (var encodingStream = CreateStream(xml))\n {\n if (encodingStream.TryDetectXmlEncoding(out var encoding))\n {\n Console.WriteLine(encoding.EncodingName);\n }\n }\n\n using (var noNamespace = CreateStream(xml).RemoveXmlNamespaceDeclarations())\n using (var streamReader = new StreamReader(noNamespace))\n {\n Console.WriteLine(streamReader.ReadToEnd());\n }\n }\n\n private static MemoryStream CreateStream(string xml)\n {\n return new MemoryStream(Encoding.UTF8.GetBytes(xml));\n }\n }\n}" + } + }, + { + "id": "b442de0156c2c1bb64cd7f5d", + "exampleId": "Cuemon.Extensions.Net.ByteArrayExtensions#1", + "uid": "Cuemon.Extensions.Net.ByteArrayExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Extensions.Net;\nusing Cuemon.Text;\n\n// Encode a byte array for safe URL transmission\nbyte[] data = Encoding.UTF8.GetBytes(\"hello world\");\n\n// URL-encode the entire byte array\nbyte[] encoded = data.UrlEncode(0, data.Length);\nConsole.WriteLine(Encoding.UTF8.GetString(encoded));\n// Output: hello%20world\n\n// Encode only a portion starting at position 0 for 5 bytes\nbyte[] partial = data.UrlEncode(position: 0, bytesToRead: 5);\nConsole.WriteLine(Encoding.UTF8.GetString(partial));\n// Output: hello\n\n// Use a custom encoding (e.g., UTF-32)\nbyte[] utf32Data = Encoding.UTF32.GetBytes(\"test data\");\nbyte[] utf32Encoded = utf32Data.UrlEncode(0, utf32Data.Length, setup: o => o.Encoding = Encoding.UTF32);\nstring result = Encoding.UTF32.GetString(utf32Encoded);\nConsole.WriteLine(result);" + } + }, + { + "id": "b4d86e97733b6444844a05d4", + "exampleId": "Cuemon.Security.HashFactory#1", + "uid": "Cuemon.Security.HashFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security;\n\nvar fnvHash = HashFactory.CreateFnv32();\nvar input = \"Hello World\";\nvar hash = fnvHash.ComputeHash(Encoding.UTF8.GetBytes(input));\nConsole.WriteLine($\"FNV-1a 32-bit: {BitConverter.ToString(hash.To(bytes => bytes)).Replace(\"-\", \"\")}\");\n\nvar crcHash = HashFactory.CreateCrc32();\nhash = crcHash.ComputeHash(Encoding.UTF8.GetBytes(input));\nConsole.WriteLine($\"CRC-32: {BitConverter.ToString(hash.To(bytes => bytes)).Replace(\"-\", \"\")}\");\n\nvar fnv256Hash = HashFactory.CreateFnv256();\nhash = fnv256Hash.ComputeHash(Encoding.UTF8.GetBytes(input));\nConsole.WriteLine($\"FNV-1a 256-bit: {BitConverter.ToString(hash.To(bytes => bytes)).Replace(\"-\", \"\")}\");" + } + }, + { + "id": "b5d458a8c345ebe80fd9277b", + "exampleId": "Cuemon.Text.ParserFactory#1", + "uid": "Cuemon.Text.ParserFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Text;\n\nvar guidParser = ParserFactory.FromGuid();\nvar result = guidParser.Parse(\"6B29FC40-CA47-1067-B31D-00DD010662DA\");\nConsole.WriteLine($\"Parsed GUID: {result}\");\n\nvar base64Parser = ParserFactory.FromBase64();\nvar bytes = base64Parser.Parse(\"SGVsbG8gV29ybGQ=\");\nConsole.WriteLine($\"Base64 decoded bytes: {bytes.Length}\");\n\nvar uriParser = ParserFactory.FromUri();\nvar uri = uriParser.Parse(\"https://example.com/resource\");\nConsole.WriteLine($\"Parsed URI: {uri}\");" + } + }, + { + "id": "b64e9d161a031a573a4582e0", + "exampleId": "Cuemon.Extensions.Xml.HierarchyExtensions#1", + "uid": "Cuemon.Extensions.Xml.HierarchyExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0", + "Cuemon.Extensions.Xml@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Xml.Serialization;\nusing Cuemon.Extensions.Runtime.Serialization;\nusing Cuemon.Extensions.Xml;\nusing Cuemon.Xml.Serialization;\nusing DocExamples;\n\nHierarchyExtensionsExample.Demonstrate();\n\nnamespace DocExamples\n{\n public static class HierarchyExtensionsExample\n {\n public static void Demonstrate()\n {\n var documentNodes = new HierarchySerializer(new CatalogDocument()).Nodes.GetChildren().ToList();\n var idNode = documentNodes.Single(node => node.MemberReference?.Name == nameof(CatalogDocument.Id));\n var tagsNode = documentNodes.Single(node => node.MemberReference?.Name == nameof(CatalogDocument.Tags));\n\n var ignoredNodes = new HierarchySerializer(new IgnoredDocument()).Nodes.GetChildren().ToList();\n var hiddenNode = ignoredNodes.Single(node => node.MemberReference?.Name == nameof(IgnoredDocument.Hidden));\n var overrideEntity = new XmlQualifiedEntity(\"Override\");\n\n Console.WriteLine(idNode.GetXmlQualifiedEntity().LocalName);\n Console.WriteLine(idNode.GetXmlQualifiedEntity(overrideEntity).LocalName);\n Console.WriteLine(tagsNode.IsNodeEnumerable());\n Console.WriteLine(hiddenNode.HasXmlIgnoreAttribute());\n\n var reordered = new[] { tagsNode, idNode }.OrderByXmlAttributes().ToList();\n Console.WriteLine(reordered[0].MemberReference?.Name);\n }\n\n private sealed class CatalogDocument\n {\n [XmlAttribute]\n public Guid Id { get; } = Guid.Empty;\n\n public List Tags { get; } = new() { \"xml\", \"docfx\" };\n }\n\n private sealed class IgnoredDocument\n {\n [XmlIgnore]\n public string Hidden => \"internal\";\n\n public string Visible => \"public\";\n }\n }\n}" + } + }, + { + "id": "b69cffc3764e21a4fcae313a", + "exampleId": "Cuemon.Data.Integrity.CacheValidatorFactory#1", + "uid": "Cuemon.Data.Integrity.CacheValidatorFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Security;\n\nvar file = new FileInfo(Path.GetTempFileName());\ntry\n{\n File.WriteAllText(file.FullName, \"Hello, world!\");\n\n CacheValidator validator = CacheValidatorFactory.CreateValidator(file);\n Console.WriteLine($\"Created (UTC): {validator.Created:O}\");\n Console.WriteLine($\"Modified (UTC): {validator.Modified:O}\");\n Console.WriteLine($\"Validation: {validator.Validation}\");\n Console.WriteLine($\"Method: {validator.Method}\");\n Console.WriteLine($\"Checksum: {validator.Checksum.ToHexadecimalString()}\");\n\n // Create validator using a custom hash algorithm\n CacheValidator shaValidator = CacheValidatorFactory.CreateValidator(\n file,\n () => HashFactory.CreateFnv128());\n Console.WriteLine($\"SHA-256: {shaValidator.Checksum.ToHexadecimalString()}\");\n}\nfinally\n{\n file.Delete();\n}" + } + }, + { + "id": "b6a8447a34c2618c33e351ad", + "exampleId": "Cuemon.Extensions.ObjectExtensions#1", + "uid": "Cuemon.Extensions.ObjectExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon.Extensions;\nusing MyApp.Examples;\n\nObjectExtensionsExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class ObjectExtensionsExample\n {\n public static void Demonstrate()\n {\n object raw = \"42\";\n int number = raw.As(0);\n int fallback = \"not-a-number\".As(99);\n object nullValue = null;\n int safe = nullValue.As(0);\n string upper = \"hello\".As(value => value.ToUpperInvariant());\n object converted = raw.As(typeof(int));\n\n var wrapped = \"docs\".UseWrapper(extender =>\n {\n extender[\"source\"] = \"example\";\n });\n\n var memberWrapped = 42.UseWrapper(typeof(int).GetMethod(nameof(ToString), Type.EmptyTypes), data =>\n {\n data[\"category\"] = \"number\";\n });\n\n var numbers = new List { 1, 2, 3 };\n var adjusted = numbers.Adjust(list =>\n {\n var copy = new List(list);\n copy.Add(4);\n return copy;\n });\n var altered = numbers.Alter(list => list.Add(4));\n string delimited = adjusted.ToDelimitedString(options => options.Delimiter = \";\");\n\n Console.WriteLine(number);\n Console.WriteLine(fallback);\n Console.WriteLine(safe);\n Console.WriteLine(upper);\n Console.WriteLine(converted);\n Console.WriteLine(wrapped.Data[\"source\"]);\n Console.WriteLine(memberWrapped.MemberReference?.Name);\n Console.WriteLine(adjusted.GetHashCode32());\n Console.WriteLine(altered.GetHashCode64());\n Console.WriteLine(delimited);\n Console.WriteLine(default(int?).IsNullable());\n }\n }\n}" + } + }, + { + "id": "b6f1f250a405c0ea37510f35", + "exampleId": "Cuemon.Xml.XPath.XPathDocumentFactory#1", + "uid": "Cuemon.Xml.XPath.XPathDocumentFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Xml.XPath;\nusing Cuemon.Xml.XPath;\n\nvar xml = \"Hello\";\nvar doc = XPathDocumentFactory.CreateDocument(xml);\n\nvar navigator = doc.CreateNavigator();\nvar value = navigator.SelectSingleNode(\"//item/text()\")?.Value;\nConsole.WriteLine($\"XPath result: {value}\");" + } + }, + { + "id": "b7d831942ac1e33a1435d49f", + "exampleId": "Cuemon.Net.Http.HttpManagerOptions#1", + "uid": "Cuemon.Net.Http.HttpManagerOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing Cuemon.Net.Http;\n\nvar options = new HttpManagerOptions\n{\n Timeout = TimeSpan.FromSeconds(10),\n HandlerFactory = () => new HttpClientHandler(),\n DefaultRequestHeaders =\n {\n [\"X-Correlation-Id\"] = \"docs-123\"\n }\n};\n\noptions.ValidateOptions();\n\nConsole.WriteLine(options.Timeout.TotalSeconds);\nConsole.WriteLine(options.DefaultRequestHeaders[\"X-Correlation-Id\"]);" + } + }, + { + "id": "b85db4a9e8813e6f34b79ef9", + "exampleId": "Cuemon.Extensions.Collections.Generic.ListExtensions#1", + "uid": "Cuemon.Extensions.Collections.Generic.ListExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Collections.Generic@11.0.0" + ], + "source": "using System;\nusing System.Collections.Generic;\nusing Cuemon.Extensions.Collections.Generic;\n\nnamespace DocExamples\n{\n public static class ListExtensionsExample\n {\n public static void Main()\n {\n var fruits = new List { \"Apple\", \"Banana\", \"Cherry\", \"Date\" };\n\n // Remove the first element matching a condition\n bool removed = fruits.Remove(f => f == \"Banana\");\n Console.WriteLine($\"Removed 'Banana': {removed}\");\n Console.WriteLine($\"Fruits after removal: {string.Join(\", \", fruits)}\");\n\n // Check if an index exists in the list\n bool hasIndex = fruits.HasIndex(5);\n Console.WriteLine($\"Has index 5: {hasIndex}\");\n Console.WriteLine($\"Has index 1: {fruits.HasIndex(1)}\");\n\n // Get the next element relative to an index\n string next = fruits.Next(0);\n Console.WriteLine($\"Element after index 0: {next}\");\n\n // Get the previous element relative to an index\n string prev = fruits.Previous(2);\n Console.WriteLine($\"Element before index 2: {prev}\");\n\n // Returns default when out of bounds\n string beyond = fruits.Next(10);\n Console.WriteLine($\"Element after index 10: {(beyond == null ? \"null (default)\" : beyond)}\");\n\n // Try to add an element (only if not already present)\n bool added = fruits.TryAdd(\"Cherry\");\n Console.WriteLine($\"Added 'Cherry' (duplicate): {added}\");\n\n bool addedNew = fruits.TryAdd(\"Elderberry\");\n Console.WriteLine($\"Added 'Elderberry' (new): {addedNew}\");\n Console.WriteLine($\"Fruits: {string.Join(\", \", fruits)}\");\n\n}}\n}" + } + }, + { + "id": "bafa13dc7f0bff3268cab954", + "exampleId": "Cuemon.Security.HashResult#1", + "uid": "Cuemon.Security.HashResult", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "using System;\nusing Cuemon.Security;\n\nnamespace MyApp.Examples;\n\npublic class HashResultExample\n{\n public static void Main()\n {\n // Simulate a computed hash value (e.g., from any hash algorithm).\n byte[] hashBytes = { 0xdf, 0xfd, 0x60, 0x21, 0xbb, 0x2b, 0xd5, 0xb0, 0xaf, 0x67, 0x62, 0x90, 0x80, 0x9e, 0xc3, 0xa5, 0x31, 0x91, 0xdd, 0x81, 0xc7, 0xf7, 0x0a, 0x4b, 0x28, 0x68, 0x8a, 0x36, 0x21, 0x82, 0x98, 0x6f };\n\n var hashResult = new HashResult(hashBytes);\n\n // Check if the hash has a value\n Console.WriteLine(\"HasValue: {0}\", hashResult.HasValue);\n\n // Convert to various string formats\n Console.WriteLine(\"Hex: {0}\", hashResult.ToHexadecimalString());\n Console.WriteLine(\"Base64: {0}\", hashResult.ToBase64String());\n Console.WriteLine(\"Url-safe Base64: {0}\", hashResult.ToUrlEncodedBase64String());\n\n // Default ToString() returns hexadecimal\n Console.WriteLine(\"ToString: {0}\", hashResult.ToString());\n\n // Output:\n // HasValue: True\n // Hex: dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f\n // Base64: 3/1gIbsr1bCvZ2KQgJ7DpTGR3YHH9wpLKGiKNiGCmG8=\n // Url-safe Base64: 3_1gIbsr1bCvZ2KQgJ7DpTGR3YHH9wpLKGiKNiGCmG8\n // ToString: dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f\n\n}\n}" + } + }, + { + "id": "bb082d4ab608618129311195", + "exampleId": "Cuemon.Collections.Generic.CollectionDecoratorExtensions#1", + "uid": "Cuemon.Collections.Generic.CollectionDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon;\nusing Cuemon.Collections.Generic;\n\nvar list = new List { \"apple\", \"banana\" };\n\n// Use Decorator to access non-common extension methods\nDecorator.Enclose(list).AddRange(\"cherry\", \"date\", \"elderberry\");\nDecorator.Enclose(list).AddRange(new[] { \"fig\", \"grape\" });\n\nConsole.WriteLine(string.Join(\", \", list));" + } + }, + { + "id": "bb7040215b715afea36c9c22", + "exampleId": "Cuemon.AspNetCore.Http.Headers.RetryConditionScope#1", + "uid": "Cuemon.AspNetCore.Http.Headers.RetryConditionScope", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http.Headers;\nusing Cuemon.AspNetCore.Http.Headers;\n\nvar scope = RetryConditionScope.DeltaSeconds;\nstring retryAfter = scope == RetryConditionScope.DeltaSeconds\n ? new RetryConditionHeaderValue(TimeSpan.FromSeconds(30)).ToString()\n : new RetryConditionHeaderValue(DateTimeOffset.UtcNow.AddMinutes(1)).ToString();\n\nConsole.WriteLine(retryAfter);" + } + }, + { + "id": "bb9004b3debb41d00082b474", + "exampleId": "Cuemon.Data.SqlClient.SqlInOperator`1#1", + "uid": "Cuemon.Data.SqlClient.SqlInOperator`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0", + "Cuemon.Data.SqlClient@11.0.0", + "Microsoft.Data.SqlClient@7.1.1" + ], + "source": "// Program.cs\nusing System;\nusing System.Data;\nusing Cuemon.Data;\nusing Cuemon.Data.SqlClient;\nusing Microsoft.Data.SqlClient;\n\nvar inOperator = new SqlInOperator(() => \"@color\");\nInOperatorResult result = inOperator.ToSafeResult(\"Red\", \"Green\", \"Blue\");\n\nvar commandText = $\"SELECT * FROM Products WHERE Color IN ({result})\";\nusing var command = new SqlCommand(commandText);\n\nforeach (IDataParameter dbParameter in result.ToParametersArray())\n{\n command.Parameters.Add((SqlParameter)dbParameter);\n Console.WriteLine($\"{dbParameter.ParameterName} = {dbParameter.Value}\");\n}\n\nConsole.WriteLine(command.CommandText);\nConsole.WriteLine(string.Join(\", \", result.Arguments));" + } + }, + { + "id": "bbb8a277e43674cb4922b1e0", + "exampleId": "Cuemon.Extensions.AspNetCore.Hosting.ApplicationBuilderExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Hosting.ApplicationBuilderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0", + "Microsoft.Extensions.Hosting@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Hosting;\nusing Cuemon.Extensions.AspNetCore.Hosting;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nusing var host = Host.CreateDefaultBuilder()\n .ConfigureServices(services =>\n {\n services.AddLogging();\n services.Configure(options =>\n {\n options.HeaderName = \"X-Environment\";\n });\n })\n .Build();\n\nvar app = new ApplicationBuilder(host.Services);\napp.UseHostingEnvironment(options =>\n{\n options.HeaderName = \"X-Environment\";\n});\n\nConsole.WriteLine(\"Hosting environment middleware configured.\");" + } + }, + { + "id": "bc59d014ae74109ff069236f", + "exampleId": "Cuemon.EndianOptions#1", + "uid": "Cuemon.EndianOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\nvar options = new EndianOptions\n{\n ByteOrder = Endianness.BigEndian\n};\n\nvar byteOrder = options.ByteOrder;\nvar isSystemLittleEndian = BitConverter.IsLittleEndian;\n\nConsole.WriteLine($\"Configured byte order: {byteOrder}\");\nConsole.WriteLine($\"System is little-endian: {isSystemLittleEndian}\");" + } + }, + { + "id": "bd24fa00d3699a703f2e43f6", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcBuilderExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcBuilderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Diagnostics;\nusing Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json;\nusing Microsoft.Extensions.DependencyInjection;\n\nvar services = new ServiceCollection();\nservices.AddLogging();\nvar builder = services.AddControllers();\n\nbuilder.AddJsonFormatters(options =>\n{\n options.SensitivityDetails = FaultSensitivityDetails.All;\n options.Settings.WriteIndented = true;\n});\n\nbuilder.AddJsonFormattersOptions(options =>\n{\n options.Settings.WriteIndented = true;\n});\n\nusing var provider = services.BuildServiceProvider();\nConsole.WriteLine(\"MVC JSON formatters configured.\");" + } + }, + { + "id": "bdc2c0e82941d0102b6f6846", + "exampleId": "Cuemon.Data.DsvDataReader#1", + "uid": "Cuemon.Data.DsvDataReader", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing Cuemon.Data;\n\nvar csv = \"Name,Age,City\" + Environment.NewLine +\n \"Alice,30,New York\" + Environment.NewLine +\n \"Bob,25,London\" + Environment.NewLine +\n \"Charlie,35,Tokyo\";\n\nusing var stream = new MemoryStream(Encoding.UTF8.GetBytes(csv));\nusing var reader = new DsvDataReader(new StreamReader(stream));\n\nConsole.WriteLine($\"Delimiter: {reader.Delimiter}\");\nConsole.WriteLine(\"Header: \" + string.Join(\", \", reader.Header));\n\nwhile (reader.Read())\n{\n Console.WriteLine($\"Row {reader.RowCount}: Name={reader[\"Name\"]}, Age={reader[\"Age\"]}, City={reader[\"City\"]}\");\n}" + } + }, + { + "id": "bff55b894df177d6e9a15db1", + "exampleId": "Cuemon.Collections.Generic.DictionaryDecoratorExtensions#1", + "uid": "Cuemon.Collections.Generic.DictionaryDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon;\nusing Cuemon.Collections.Generic;\n\nIDictionary catalog = new Dictionary\n{\n [1] = \"apples\",\n [2] = \"bananas\"\n};\n\nvar decorated = Decorator.Enclose(catalog);\nstring fallback = decorated.GetValueOrDefault(3, () => \"not found\");\nbool found = decorated.TryGetValueOrFallback(42, keys => 2, out var alias);\nbool added = decorated.TryAdd(3, \"cherries\");\ndecorated.AddOrUpdate(2, \"blueberries\");\nKeyValuePair[] entries = decorated.ToEnumerable().ToArray();\n\nIDictionary copy = decorated.CopyTo(new Dictionary());\n\nIDictionary> depthIndexes = new Dictionary>();\nint depthIndex = Decorator.Enclose(depthIndexes).GetDepthIndex(readerDepth: 0, index: 1, nesting: 0);\n\nConsole.WriteLine($\"Fallback: {fallback}\");\nConsole.WriteLine($\"Found fallback key: {found} -> {alias}\");\nConsole.WriteLine($\"Added key 3: {added}\");\nConsole.WriteLine($\"Enumerated entries: {entries.Length}\");\nConsole.WriteLine($\"Copied entries: {copy.Count}\");\nConsole.WriteLine($\"Depth index: {depthIndex}\");" + } + }, + { + "id": "c040252cb98d09df0bd3bf99", + "exampleId": "Cuemon.Extensions.IO.StreamExtensions#1", + "uid": "Cuemon.Extensions.IO.StreamExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.IO@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing System.Threading.Tasks;\nusing Cuemon.Extensions.IO;\nusing MyApp.Examples;\n\nawait StreamExtensionsExample.DemonstrateAsync();\n\nnamespace MyApp.Examples\n{\n public static class StreamExtensionsExample\n {\n public static async Task DemonstrateAsync()\n {\n using var first = CreateStream(\"Cue\");\n using var second = CreateStream(\"mon\");\n using var combined = first.Concat(second, options => options.LeaveOpen = true);\n Console.WriteLine(combined.ToEncodedString(options => options.LeaveOpen = true));\n\n var bytes = CreateStream(\"Cuemon\").ToByteArray();\n var bytesAsync = await CreateStream(\"Cuemon\").ToByteArrayAsync();\n var chars = CreateStream(\"Cuemon\").ToCharArray();\n var text = CreateStream(\"Cuemon\").ToEncodedString();\n var asyncText = await CreateStream(\"Cuemon\").ToEncodedStringAsync();\n\n Console.WriteLine(bytes.Length == bytesAsync.Length);\n Console.WriteLine(chars.Length);\n Console.WriteLine(text == asyncText);\n\n using var bomStream = CreateStream(\"Hello with BOM\", includePreamble: true);\n bomStream.TryDetectUnicodeEncoding(out var detectedEncoding);\n Console.WriteLine(detectedEncoding?.WebName);\n\n using var writable = new MemoryStream();\n await writable.WriteAllAsync(Encoding.UTF8.GetBytes(\"written asynchronously\"));\n writable.Position = 0;\n Console.WriteLine(writable.ToEncodedString());\n\n using var gzipSource = CreateStream(\"gzip payload\");\n using var gzipCompressed = gzipSource.CompressGZip();\n gzipCompressed.Position = 0;\n using var gzipDecompressed = gzipCompressed.DecompressGZip();\n gzipDecompressed.Position = 0;\n Console.WriteLine(gzipDecompressed.ToEncodedString());\n\n using var gzipAsyncSource = CreateStream(\"gzip async payload\");\n using var gzipCompressedAsync = await gzipAsyncSource.CompressGZipAsync();\n gzipCompressedAsync.Position = 0;\n using var gzipDecompressedAsync = await gzipCompressedAsync.DecompressGZipAsync();\n gzipDecompressedAsync.Position = 0;\n Console.WriteLine(await gzipDecompressedAsync.ToEncodedStringAsync());\n\n using var deflateSource = CreateStream(\"deflate payload\");\n using var deflateCompressed = deflateSource.CompressDeflate();\n deflateCompressed.Position = 0;\n using var deflateDecompressed = deflateCompressed.DecompressDeflate();\n deflateDecompressed.Position = 0;\n Console.WriteLine(deflateDecompressed.ToEncodedString());\n\n using var deflateAsyncSource = CreateStream(\"deflate async payload\");\n using var deflateCompressedAsync = await deflateAsyncSource.CompressDeflateAsync();\n deflateCompressedAsync.Position = 0;\n using var deflateDecompressedAsync = await deflateCompressedAsync.DecompressDeflateAsync();\n deflateDecompressedAsync.Position = 0;\n Console.WriteLine(await deflateDecompressedAsync.ToEncodedStringAsync());\n\n using var brotliSource = CreateStream(\"brotli payload\");\n using var brotliCompressed = brotliSource.CompressBrotli();\n brotliCompressed.Position = 0;\n using var brotliDecompressed = brotliCompressed.DecompressBrotli();\n brotliDecompressed.Position = 0;\n Console.WriteLine(brotliDecompressed.ToEncodedString());\n\n using var brotliAsyncSource = CreateStream(\"brotli async payload\");\n using var brotliCompressedAsync = await brotliAsyncSource.CompressBrotliAsync();\n brotliCompressedAsync.Position = 0;\n using var brotliDecompressedAsync = await brotliCompressedAsync.DecompressBrotliAsync();\n brotliDecompressedAsync.Position = 0;\n Console.WriteLine(await brotliDecompressedAsync.ToEncodedStringAsync());\n }\n\n private static MemoryStream CreateStream(string value, bool includePreamble = false)\n {\n var content = Encoding.UTF8.GetBytes(value);\n if (!includePreamble)\n {\n return new MemoryStream(content);\n }\n\n var preamble = Encoding.UTF8.GetPreamble();\n var buffer = new byte[preamble.Length + content.Length];\n Buffer.BlockCopy(preamble, 0, buffer, 0, preamble.Length);\n Buffer.BlockCopy(content, 0, buffer, preamble.Length, content.Length);\n return new MemoryStream(buffer);\n }\n }\n}" + } + }, + { + "id": "c095b428e5385f0df6d3edc9", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Diagnostics.FaultDescriptorFilter#1", + "uid": "Cuemon.AspNetCore.Mvc.Filters.Diagnostics.FaultDescriptorFilter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.AspNetCore.Mvc.Filters.Diagnostics;\nusing Cuemon.Diagnostics;\nusing Microsoft.Extensions.Options;\n\nvar options = Options.Create(new MvcFaultDescriptorOptions\n{\n MarkExceptionHandled = true,\n FaultDescriptor = PreferredFaultDescriptor.ProblemDetails,\n SensitivityDetails = FaultSensitivityDetails.Failure\n});\n\nvar filter = new FaultDescriptorFilter(options);\n\nConsole.WriteLine(filter.Options.MarkExceptionHandled);\nConsole.WriteLine(filter.Options.FaultDescriptor);" + } + }, + { + "id": "c0caa21ee002bb81f4cf786a", + "exampleId": "Cuemon.AspNetCore.Http.PreconditionRequiredException#1", + "uid": "Cuemon.AspNetCore.Http.PreconditionRequiredException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http;\n\nvar hasConditionHeader = false;\nvar exception = hasConditionHeader\n ? new PreconditionRequiredException()\n : new PreconditionRequiredException(\"Supply an If-Match header before retrying the update.\");\n\nConsole.WriteLine(exception.Message);\nConsole.WriteLine(exception.StatusCode);" + } + }, + { + "id": "c20a953ef91a8cbfe7ebf47e", + "exampleId": "Cuemon.Security.CyclicRedundancyCheckAlgorithm#1", + "uid": "Cuemon.Security.CyclicRedundancyCheckAlgorithm", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Security; // for CyclicRedundancyCheckAlgorithm\n\n// Select commonly used CRC algorithms\nCyclicRedundancyCheckAlgorithm crc32 = CyclicRedundancyCheckAlgorithm.Crc32;\nCyclicRedundancyCheckAlgorithm crc32C = CyclicRedundancyCheckAlgorithm.Crc32C;\nCyclicRedundancyCheckAlgorithm crc64 = CyclicRedundancyCheckAlgorithm.Crc64;\n\nConsole.WriteLine(crc32); // Crc32\nConsole.WriteLine(crc32C); // Crc32C\nConsole.WriteLine(crc64); // Crc64\n\n// Switch on algorithm\nstring GetDescription(CyclicRedundancyCheckAlgorithm algo) => algo switch\n{\n CyclicRedundancyCheckAlgorithm.Crc32 => \"CRC-32 (ISO-HDLC, PKZIP)\",\n CyclicRedundancyCheckAlgorithm.Crc32C => \"CRC-32C (ISCSI, Castagnoli)\",\n CyclicRedundancyCheckAlgorithm.Crc64 => \"CRC-64 (ECMA-182)\",\n _ => \"Unknown\"\n};\n\nConsole.WriteLine(GetDescription(crc32C)); // CRC-32C (ISCSI, Castagnoli)" + } + }, + { + "id": "c352476ee24c231643f772dd", + "exampleId": "Cuemon.Data.Integrity.EntityInfo#1", + "uid": "Cuemon.Data.Integrity.EntityInfo", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Security;\n\n// Create EntityInfo with only a creation timestamp.\nvar entity = new EntityInfo(new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc));\nConsole.WriteLine(\"Created: {0:O}\", entity.Created);\nConsole.WriteLine(\"Modified: {0}\", entity.Modified.HasValue ? entity.Modified.Value.ToString(\"O\") : \"null\");\nConsole.WriteLine(\"Has checksum: {0}\", entity.Checksum.HasValue);\nConsole.WriteLine(\"Validation: {0}\", entity.Validation);\n\n// Create EntityInfo with creation and modification timestamps.\nvar modified = new EntityInfo(\n new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc),\n new DateTime(2025, 6, 15, 12, 30, 0, DateTimeKind.Utc));\nConsole.WriteLine(\"Modified entity: Created={0:O}, LastModified={1:O}\",\n modified.Created, modified.Modified);\n\n// Create EntityInfo with a checksum for data integrity validation.\n// The checksum can be used to detect changes to the underlying data.\nbyte[] checksumBytes = { 0x1A, 0x2B, 0x3C, 0x4D };\nvar validated = new EntityInfo(\n new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc),\n null,\n checksumBytes,\n EntityDataIntegrityValidation.Strong);\n\nConsole.WriteLine(\"Validated entity: Checksum={0}, Validation={1}\",\n validated.Checksum.ToHexadecimalString(),\n validated.Validation);\n\n// Timestamps are always normalized to UTC.\nvar localTime = new EntityInfo(new DateTime(2025, 6, 1, 10, 0, 0, DateTimeKind.Local));\nConsole.WriteLine(\"UTC created: {0:O}\", localTime.Created);" + } + }, + { + "id": "c38cac57fc823be54704af69", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.RazorPages.PageBaseExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.RazorPages.PageBaseExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc.RazorPages@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading.Tasks;\nusing Cuemon.AspNetCore.Razor.TagHelpers;\nusing Cuemon.Extensions.AspNetCore.Mvc.RazorPages;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.Mvc.RazorPages;\nusing Microsoft.Extensions.DependencyInjection;\n\nvar services = new ServiceCollection();\nservices.Configure(options =>\n{\n options.Scheme = ProtocolUriScheme.Relative;\n options.BaseUrl = \"static.cuemon.net\";\n});\nservices.Configure(options =>\n{\n options.Scheme = ProtocolUriScheme.Https;\n options.BaseUrl = \"nblcdn.net\";\n});\n\nusing var provider = services.BuildServiceProvider();\nvar page = new ExamplePage\n{\n PageContext = new PageContext\n {\n HttpContext = new DefaultHttpContext { RequestServices = provider }\n }\n};\n\nConsole.WriteLine(page.GetAppUrl(\"js/site.js\"));\nConsole.WriteLine(page.GetCdnUrl(\"images/logo.png\"));\n\npublic sealed class ExamplePage : PageBase\n{\n public override Task ExecuteAsync()\n {\n return Task.CompletedTask;\n }\n}" + } + }, + { + "id": "c3eaf28dee6b2538f764dcf9", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.CdnImageTagHelper#1", + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.CdnImageTagHelper", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Configuration;\nusing Cuemon.AspNetCore.Razor.TagHelpers;\nusing Microsoft.Extensions.Options;\nusing MyApp.Examples;\n\nCdnImageTagHelperExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class CdnImageTagHelperExample\n {\n private sealed class AssetVersion : ICacheBusting\n {\n public string Version => \"2.1.0\";\n }\n\n public static void Demonstrate()\n {\n var settings = new CdnTagHelperOptions\n {\n Scheme = ProtocolUriScheme.Https,\n BaseUrl = \"nblcdn.net\"\n };\n\n var version = new AssetVersion();\n var tagHelper = new CdnImageTagHelper(Options.Create(settings), version)\n {\n Src = \"images/logo.svg\",\n Alt = \"Codebelt logo\"\n };\n var imageUrl = tagHelper.Options.GetFormattedBaseUrl() + tagHelper.Src + \"?v=\" + version.Version;\n\n Console.WriteLine(imageUrl);\n }\n }\n}" + } + }, + { + "id": "c421cdd9e84a346c1187a2b3", + "exampleId": "Cuemon.Reflection.MethodSignature#1", + "uid": "Cuemon.Reflection.MethodSignature", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Reflection;\nusing MyApp.Examples;\n\nMethodSignatureExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class MethodSignatureExample\n {\n public static void Demonstrate()\n {\n var signature = new MethodSignature(\n typeof(PaymentGateway).FullName ?? nameof(PaymentGateway),\n nameof(PaymentGateway.Authorize),\n new[] { typeof(string).Name, typeof(decimal).Name },\n new object[] { \"INV-42\", 19.95m });\n\n Console.WriteLine(signature.ToString());\n Console.WriteLine(string.Join(\", \", signature.Parameters ?? Array.Empty()));\n Console.WriteLine(signature.Arguments?.Length ?? 0);\n }\n }\n public sealed class PaymentGateway\n {\n public void Authorize(string orderId, decimal amount)\n {\n }\n }\n}" + } + }, + { + "id": "c49d8919a7e1fe62796c9966", + "exampleId": "Cuemon.Data.DbTypeDecoratorExtensions#1", + "uid": "Cuemon.Data.DbTypeDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ], + "source": "using System;\nusing System.Data;\nusing Cuemon;\nusing Cuemon.Data;\n\nnamespace MyApp.Examples;\n\npublic class DbTypeDecoratorExtensionsExample\n{\n public static void Main()\n {\n DbType[] types = { DbType.Int32, DbType.String, DbType.DateTime, DbType.Boolean };\n\n foreach (var dbType in types)\n {\n Type clrType = Decorator.Enclose(dbType).ToType();\n Console.WriteLine(\"DbType.{0} -> {1}\", dbType, clrType);\n\n // Output:\n // DbType.Int32 -> System.Int32\n // DbType.String -> System.String\n // DbType.DateTime -> System.DateTime\n // DbType.Boolean -> System.Boolean\n\n}}\n}" + } + }, + { + "id": "c50aa604b9b7f3de4de12834", + "exampleId": "Cuemon.Xml.XmlStreamFactory#1", + "uid": "Cuemon.Xml.XmlStreamFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Xml;\nusing Cuemon.Xml;\n\nusing var stream = XmlStreamFactory.CreateStream(writer =>\n{\n writer.WriteStartDocument();\n writer.WriteStartElement(\"Configuration\");\n writer.WriteElementString(\"AppName\", \"MyApp\");\n writer.WriteElementString(\"Version\", \"1.0\");\n writer.WriteEndElement();\n writer.WriteEndDocument();\n});\n\nusing var reader = new StreamReader(stream);\nvar xml = reader.ReadToEnd();\nConsole.WriteLine(xml);" + } + }, + { + "id": "c56bd9e998427f9a635e9df0", + "exampleId": "Cuemon.Data.DataTransferColumn#1", + "uid": "Cuemon.Data.DataTransferColumn", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Data;\nusing Cuemon.Data;\n\n // Create a DataTable as a sample data source\n var table = new DataTable(\"Employees\");\n table.Columns.Add(\"EmployeeId\", typeof(int));\n table.Columns.Add(\"FirstName\", typeof(string));\n table.Columns.Add(\"LastName\", typeof(string));\n table.Columns.Add(\"HireDate\", typeof(System.DateTime));\n\n table.Rows.Add(1, \"John\", \"Doe\", new DateTime(2023, 6, 1));\n table.Rows.Add(2, \"Jane\", \"Smith\", new DateTime(2024, 1, 15));\n\n // Obtain a DataTransferColumnCollection from an IDataReader via DataTransfer\n using var reader = table.CreateDataReader();\n var columns = DataTransfer.GetColumns(reader);\n\n Console.WriteLine($\"Columns ({columns.Count}):\");\n foreach (DataTransferColumn column in columns)\n {\n Console.WriteLine($\" [{column.Ordinal}] {column.Name} ({column.DataType.Name})\");\n\n // Output:\n // [0] EmployeeId (Int32)\n // [1] FirstName (String)\n // [2] LastName (String)\n // [3] HireDate (DateTime)\n\n // Access columns by name\n DataTransferColumn firstNameCol = columns[\"FirstName\"];\n Console.WriteLine($\"Ordinal of 'FirstName': {firstNameCol.Ordinal}\"); // 1\n\n // ToString() returns the column name\n Console.WriteLine($\"Column ToString: {firstNameCol}\"); // FirstName\n\n}" + } + }, + { + "id": "c713f7694e44c7009497da2e", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationOutputFormatter#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationOutputFormatter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json;\nusing Cuemon.Extensions.Text.Json.Formatters;\n\nvar options = new JsonFormatterOptions();\nvar formatter = new JsonSerializationOutputFormatter(options);\n\nConsole.WriteLine($\"Supported media types: {string.Join(\", \", formatter.SupportedMediaTypes)}\");\nConsole.WriteLine($\"Supported encodings: {string.Join(\", \", formatter.SupportedEncodings.Select(e => e.WebName))}\");" + } + }, + { + "id": "c77f5cdfc1d3a69459c75880", + "exampleId": "Cuemon.DoubleDecoratorExtensions#1", + "uid": "Cuemon.DoubleDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\n// Convert 1.5 days to a TimeSpan\ndouble days = 1.5;\nTimeSpan duration = Decorator.Enclose(days).ToTimeSpan(TimeUnit.Days);\nConsole.WriteLine(duration); // Output: 1.12:00:00\n\n// Convert 90 minutes to a TimeSpan\ndouble minutes = 90;\nTimeSpan meeting = Decorator.Enclose(minutes).ToTimeSpan(TimeUnit.Minutes);\nConsole.WriteLine(meeting); // Output: 01:30:00\n\n// Convert 5000 milliseconds to a TimeSpan\ndouble ms = 5000;\nTimeSpan interval = Decorator.Enclose(ms).ToTimeSpan(TimeUnit.Milliseconds);\nConsole.WriteLine(interval); // Output: 00:00:05\n\n// Convert 2.5 hours to a TimeSpan\ndouble hours = 2.5;\nTimeSpan task = Decorator.Enclose(hours).ToTimeSpan(TimeUnit.Hours);\nConsole.WriteLine(task); // Output: 02:30:00" + } + }, + { + "id": "c7a8b4566dfbb4c82fed3938", + "exampleId": "Cuemon.ExceptionHandler`1#1", + "uid": "Cuemon.ExceptionHandler`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\n// Build the chain: Condition -> Handler -> Invoker\nExceptionInvoker invoker = new ExceptionCondition()\n .IsTrue(() => string.IsNullOrEmpty(Environment.GetEnvironmentVariable(\"API_KEY\")))\n .Create(() => new ArgumentException(\"API_KEY environment variable is not set.\"));\n\n// When TryThrow is called, it evaluates the condition\n// and throws the exception created by the handler if the condition matches\ntry\n{\n invoker.TryThrow();\n}\ncatch (ArgumentException ex)\n{\n Console.WriteLine(ex.Message);\n}\n\n// The handler can be stored and reused to create different invokers\nExceptionHandler handler =\n new ExceptionCondition().IsTrue(() => true);\n\n// Create different invokers from the same handler\nvar invokerA = handler.Create(() => new InvalidOperationException(\"Reason A\"));\nvar invokerB = handler.Create(() => new InvalidOperationException(\"Reason B\"));" + } + }, + { + "id": "c8370b3d2ca0490027bb3a25", + "exampleId": "Cuemon.Threading.TimerFactory#1", + "uid": "Cuemon.Threading.TimerFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading;\nusing Cuemon.Threading;\n\nusing var timer = TimerFactory.CreateNonCapturingTimer(\n state => Console.WriteLine(\"Timer ticked\"),\n null,\n TimeSpan.FromSeconds(1),\n TimeSpan.FromSeconds(2));\n\nConsole.WriteLine(\"Timer started (1s delay, 2s interval)\");\nThread.Sleep(5000);" + } + }, + { + "id": "c8391951d6c4393524ce9aad", + "exampleId": "Cuemon.IO.StreamEncodingOptions#1", + "uid": "Cuemon.IO.StreamEncodingOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing Cuemon;\nusing Cuemon.IO;\nusing Cuemon.Text;\n\n// Directly instantiate and use StreamEncodingOptions\nvar defaultOptions = new StreamEncodingOptions();\nConsole.WriteLine($\"Default preamble handling: {defaultOptions.Preamble}\");\n\n// Create a stream with UTF-32 encoded content including a BOM\nvar text = \"Hello with BOM!\";\nvar preamble = Encoding.UTF32.GetPreamble();\nvar encoded = Encoding.UTF32.GetBytes(text);\n\nvar stream = new MemoryStream(preamble.Length + encoded.Length);\nstream.Write(preamble, 0, preamble.Length);\nstream.Write(encoded, 0, encoded.Length);\nstream.Position = 0;\n\n// Read the stream as a string using StreamReaderOptions (which inherits StreamEncodingOptions)\n// This auto-detects the encoding from the BOM and removes the preamble from the output\nstring result = Decorator.Enclose(stream).ToEncodedString(setup =>\n{\n setup.Encoding = EncodingOptions.DefaultEncoding; // auto-detect from BOM\n setup.Preamble = PreambleSequence.Remove; // strip the BOM from output\n setup.LeaveOpen = true; // keep stream open for reuse\n});\n\nConsole.WriteLine($\"Read: {result}\"); // Hello with BOM!\n\n// Read again, this time keeping the BOM preamble\nstream.Position = 0;\nstring withBom = Decorator.Enclose(stream).ToEncodedString(setup =>\n{\n setup.Encoding = Encoding.UTF32;\n setup.Preamble = PreambleSequence.Keep;\n setup.LeaveOpen = false; // let the extension dispose the stream\n});\n\nConsole.WriteLine($\"With BOM length: {withBom.Length}\"); // includes BOM bytes\nConsole.WriteLine($\"Stream disposed: {!stream.CanRead}\"); // True" + } + }, + { + "id": "c8ab26d5e14c64223b39886a", + "exampleId": "Cuemon.Diagnostics.TimeMeasure#1", + "uid": "Cuemon.Diagnostics.TimeMeasure", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Diagnostics@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading;\nusing Cuemon.Diagnostics;\nusing MyApp.Examples;\n\nTimeMeasureExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class TimeMeasureExample\n {\n public static void Demonstrate()\n {\n // Profile an action with no parameters\n TimeMeasureProfiler actionProfiler = TimeMeasure.WithAction(() =>\n {\n Thread.Sleep(50);\n });\n Console.WriteLine($\"Action elapsed: {actionProfiler.Elapsed}\");\n Console.WriteLine($\"Member: {actionProfiler.Member}\");\n\n // Profile an action with one parameter\n TimeMeasureProfiler paramProfiler = TimeMeasure.WithAction(\n (int ms) => Thread.Sleep(ms), 75);\n Console.WriteLine($\"Param action elapsed: {paramProfiler.Elapsed}\");\n\n // Profile a function that returns a value\n TimeMeasureProfiler funcProfiler = TimeMeasure.WithFunc(() =>\n {\n Thread.Sleep(100);\n return 42;\n });\n Console.WriteLine($\"Func result: {funcProfiler.Result}\");\n Console.WriteLine($\"Func elapsed: {funcProfiler.Elapsed}\");\n\n // Profile a function with parameters\n TimeMeasureProfiler greetProfiler = TimeMeasure.WithFunc(\n (string name) => $\"Hello, {name}!\", \"World\");\n Console.WriteLine($\"Func result: {greetProfiler.Result}\");\n\n // Configure options\n TimeMeasureProfiler configured = TimeMeasure.WithAction(\n () => Thread.Sleep(200),\n options => options.TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(50));\n Console.WriteLine($\"Configured elapsed: {configured.Elapsed}\");\n }\n }\n}" + } + }, + { + "id": "c8da50a994d379136eec9afd", + "exampleId": "Cuemon.AspNetCore.Mvc.GoneResult#1", + "uid": "Cuemon.AspNetCore.Mvc.GoneResult", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Mvc;\n\nvar result = new GoneResult();\n\nConsole.WriteLine(result.StatusCode);" + } + }, + { + "id": "c8ea7d5ef35238756d393931", + "exampleId": "Cuemon.Xml.Serialization.DynamicXmlSerializable#1", + "uid": "Cuemon.Xml.Serialization.DynamicXmlSerializable", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Xml;\nusing System.Xml.Serialization;\nusing Cuemon.Xml.Serialization;\n\nvar data = new { Name = \"Alice\", Score = 95 };\nvar serializable = DynamicXmlSerializable.Create(data,\n writer: (w, src) =>\n {\n w.WriteStartElement(\"Person\");\n w.WriteElementString(\"Name\", src.Name);\n w.WriteElementString(\"Score\", src.Score.ToString());\n w.WriteEndElement();\n });\n\nusing var sw = new StringWriter();\nusing var writer = XmlWriter.Create(sw);\nserializable.WriteXml(writer);\nwriter.Flush();\nConsole.WriteLine(sw.ToString());" + } + }, + { + "id": "c94d0a4f40c2d553346cccd1", + "exampleId": "Cuemon.Net.Collections.Specialized.NameValueCollectionDecoratorExtensions#1", + "uid": "Cuemon.Net.Collections.Specialized.NameValueCollectionDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ], + "source": "using System;\nusing System.Collections.Specialized;\nusing Cuemon;\nusing Cuemon.Net;\nusing Cuemon.Net.Collections.Specialized;\n\nnamespace MyApp.Examples;\n\npublic class NameValueCollectionDecoratorExtensionsExample\n{\n public static void Main()\n {\n var nvc = new NameValueCollection\n {\n [\"name\"] = \"John Doe\",\n [\"city\"] = \"Copenhagen\",\n [\"country\"] = \"Denmark\"\n };\n\n // Convert to URL query string with ampersand separator and URL encoding.\n string queryString = Decorator.Enclose(nvc).ToString(FieldValueSeparator.Ampersand, urlEncode: true);\n Console.WriteLine(queryString);\n\n // Output:\n // ?name=John+Doe&city=Copenhagen&country=Denmark\n\n}\n}" + } + }, + { + "id": "c95a7c9ff4e7da2d7d120bfb", + "exampleId": "Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelMiddleware#1", + "uid": "Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelMiddleware", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading.Tasks;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.Options;\nusing Cuemon.AspNetCore.Http.Throttling;\n\nawait ThrottlingSentinelMiddlewareExample.DemonstrateAsync();\n\nnamespace Cuemon.AspNetCore.Http.Throttling\n{\n public static class ThrottlingSentinelMiddlewareExample\n {\n public static async Task DemonstrateAsync()\n {\n var context = new DefaultHttpContext();\n var options = Options.Create(new ThrottlingSentinelOptions\n {\n ContextResolver = _ => \"client-1\",\n Quota = new ThrottleQuota(10, TimeSpan.FromMinutes(1))\n });\n\n var middleware = new ThrottlingSentinelMiddleware(\n httpContext =>\n {\n httpContext.Response.StatusCode = StatusCodes.Status200OK;\n return Task.CompletedTask;\n },\n options);\n\n await middleware.InvokeAsync(context, new MemoryThrottlingCache());\n Console.WriteLine(context.Response.Headers[options.Value.RateLimitHeaderName].ToString());\n }\n }\n}" + } + }, + { + "id": "c9b474f26b0501743c71aa79", + "exampleId": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeader#1", + "uid": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeader", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Authentication.Hmac;\n\nvar header = HmacAuthorizationHeader.Create(\n HmacFields.Scheme,\n \"HMAC Credential=alice/some-scope, SignedHeaders=date;host, Signature=abc123\");\nvar clientId = header.ClientId; // \"alice\"\nConsole.WriteLine(clientId);" + } + }, + { + "id": "ca0b6187b9f0b2f6ec1235d2", + "exampleId": "Cuemon.AspNetCore.Authentication.MemoryNonceTracker#1", + "uid": "Cuemon.AspNetCore.Authentication.MemoryNonceTracker", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Authentication;\n\nusing var tracker = new MemoryNonceTracker();\n\ntracker.TryAddEntry(\"nonce-1\", 7);\n\nif (tracker.TryGetEntry(\"nonce-1\", out var entry))\n{\n Console.WriteLine(entry.Count);\n}\n\nConsole.WriteLine(tracker.TryRemoveEntry(\"nonce-1\"));" + } + }, + { + "id": "ca3a997bc3bdcb81405e2bed", + "exampleId": "Cuemon.Data.UniqueIndexViolationException#1", + "uid": "Cuemon.Data.UniqueIndexViolationException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Data;\n\ntry\n{\n throw new UniqueIndexViolationException(\"Cannot insert duplicate key row in object 'dbo.Users'.\");\n}\ncatch (UniqueIndexViolationException ex)\n{\n Console.WriteLine(ex.Message);\n}\n\nvar wrapped = new UniqueIndexViolationException(\n \"Failed to register user.\",\n new InvalidOperationException(\"IX_Users_Email was violated.\"));\n\nConsole.WriteLine(wrapped.Message);\nConsole.WriteLine(wrapped.InnerException?.Message);\n\nvar empty = new UniqueIndexViolationException();\nConsole.WriteLine($\"Default exception has no inner exception: {empty.InnerException is null}\");" + } + }, + { + "id": "ca6ef14e13670f55a7f76f10", + "exampleId": "Cuemon.ActionFactory`1#1", + "uid": "Cuemon.ActionFactory`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\n// Create a mutable tuple with string and int arguments\nvar tuple = new MutableTuple(\"Hello\", 42);\n\n// Define an action that processes the tuple\nvoid Process(MutableTuple t)\n{\n Console.WriteLine($\"Message: {t.Arg1}, Value: {t.Arg2}\");\n}\n\n// Wrap the action and tuple in an ActionFactory\nvar factory = new ActionFactory>(Process, tuple);\n\n// Inspect factory state\nConsole.WriteLine(factory.HasDelegate); // True\nConsole.WriteLine(factory.GenericArguments.Arg1); // \"Hello\"\nConsole.WriteLine(factory.GenericArguments.Arg2); // 42\n\n// Invoke the wrapped delegate\nfactory.ExecuteMethod(); // Output: \"Message: Hello, Value: 42\"\n\n// Create a clone for safe concurrent use\nvar clone = factory.Clone() as ActionFactory>;\nclone?.ExecuteMethod();" + } + }, + { + "id": "cb044ae61458e41ca68933d5", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationInputFormatter#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationInputFormatter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json;\nusing Cuemon.Extensions.Text.Json.Formatters;\n\nvar options = new JsonFormatterOptions();\nvar formatter = new JsonSerializationInputFormatter(options);\n\nConsole.WriteLine($\"Supported media types: {string.Join(\", \", formatter.SupportedMediaTypes)}\");\nConsole.WriteLine($\"Supported encodings: {string.Join(\", \", formatter.SupportedEncodings.Select(e => e.WebName))}\");" + } + }, + { + "id": "ccc348cf8b60acb282b945a2", + "exampleId": "Cuemon.Extensions.Net.StringExtensions#1", + "uid": "Cuemon.Extensions.Net.StringExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Net@11.0.0" + ], + "source": "// Program.cs\nusing System.Text;\nusing System;\nusing Cuemon.Extensions.Net;\nusing Cuemon.Text;\nusing Cuemon;\n\n// URL-encode a string directly (no Decorator needed)\nstring encoded = \"hello world\".UrlEncode();\nConsole.WriteLine(encoded); // \"hello+world\"\n\n// URL-decode a previously encoded string\nstring decoded = \"hello+world\".UrlDecode();\nConsole.WriteLine(decoded); // \"hello world\"\n\n// Encode with a custom encoding\nstring encodedUtf32 = \"a & b\".UrlEncode(o =>\n{\n o.Encoding = Encoding.UTF32;\n});\n\n// Encode query-string special characters\nstring queryEncoded = \"name=Jane Doe&city=Copenhagen\".UrlEncode();\nConsole.WriteLine(queryEncoded); // \"name%3dJane+Doe%26city%3dCopenhagen\"\n\n// Decode back\nstring queryDecoded = queryEncoded.UrlDecode();\nConsole.WriteLine(queryDecoded); // \"name=Jane Doe&city=Copenhagen\"\n\n// Handle null input safely\nstring nullResult = ((string)null).UrlEncode();\nConsole.WriteLine(nullResult == null); // True" + } + }, + { + "id": "cd04881a86de27f98218d100", + "exampleId": "Cuemon.Security.Cryptography.HmacSecureHashAlgorithm256#1", + "uid": "Cuemon.Security.Cryptography.HmacSecureHashAlgorithm256", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\n\nvar secret = Encoding.UTF8.GetBytes(\"unittest-secret\");\nvar payload = Encoding.UTF8.GetBytes(\"Authenticate this message\");\nvar algorithm = new HmacSecureHashAlgorithm256(secret, null);\nvar result = algorithm.ComputeHash(payload);\n\nConsole.WriteLine(result.GetBytes().Length);\nConsole.WriteLine(result.ToHexadecimalString());" + } + }, + { + "id": "cd129cf1f6aca8ba5492e9c6", + "exampleId": "Cuemon.Condition#1", + "uid": "Cuemon.Condition", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Threading.Tasks;\nusing Cuemon;\n\n // AreEqual / AreNotEqual with default and custom comparers\n if (Condition.AreEqual(\"hello\", \"hello\"))\n {\n Console.WriteLine(\"Strings are equal using default ordinal comparison.\");\n\n if (Condition.AreEqual(\"hello\", \"HELLO\", StringComparer.OrdinalIgnoreCase))\n {\n Console.WriteLine(\"Strings are equal ignoring case.\");\n\n if (Condition.AreNotEqual(\"hello\", \"world\"))\n {\n Console.WriteLine(\"Strings are different.\");\n\n // Reference equality checks\n var same = new object();\n var different = new object();\n Console.WriteLine(Condition.AreSame(same, same)); // True\n Console.WriteLine(Condition.AreSame(same, different)); // False\n\n // FlipFlop - executes one of two actions based on condition\n var log = new List();\n Condition.FlipFlop(true,\n () => log.Add(\"condition was true\"),\n () => log.Add(\"condition was false\"));\n\n Condition.FlipFlop(false,\n (int x) => log.Add($\"got {x}\"),\n (int x) => log.Add($\"skipped {x}\"),\n 42);\n\n Console.WriteLine(string.Join(\", \", log)); // \"condition was true, skipped 42\"\n\n // TernaryIf - functional ternary\n var result = Condition.TernaryIf(true,\n () => \"first branch\",\n () => \"second branch\");\n Console.WriteLine(result); // \"first branch\"\n\n var guided = Condition.TernaryIf(42 > 10,\n (int x) => x * 2,\n (int x) => x / 2,\n 42);\n Console.WriteLine(guided); // 84\n\n // IsTrue / IsFalse as conditional invocations\n Condition.IsTrue(Condition.IsEmailAddress(\"user@example.com\"), () =>\n {\n Console.WriteLine(\"Valid email address.\");\n });\n\n Condition.IsFalse(string.IsNullOrEmpty(\"hello\"), () =>\n {\n Console.WriteLine(\"String is not null or empty.\");\n });\n\n // Validation checks\n Console.WriteLine(Condition.IsGuid(\"550e8400-e29b-41d4-a716-446655440000\")); // True\n Console.WriteLine(Condition.IsGuid(\"not-a-guid\")); // False\n Console.WriteLine(Condition.IsUri(\"https://example.com\")); // True\n Console.WriteLine(Condition.IsNumeric(\"3.14\", NumberStyles.Float, CultureInfo.InvariantCulture)); // True\n Console.WriteLine(Condition.IsEmailAddress(\"test@test.com\")); // True\n Console.WriteLine(Condition.IsEven(42)); // True\n Console.WriteLine(Condition.IsOdd(41)); // True\n Console.WriteLine(Condition.IsPrime(17)); // True\n Console.WriteLine(Condition.IsDefault(0)); // True\n Console.WriteLine(Condition.IsNotDefault(42)); // True\n Console.WriteLine(Condition.IsHex(\"FF00A1\")); // True\n Console.WriteLine(Condition.IsBase64(\"SGVsbG8=\")); // True\n\n // Range checks\n Console.WriteLine(Condition.IsWithinRange(5, 1, 10)); // True\n Console.WriteLine(Condition.IsNotWithinRange(15, 1, 10)); // True\n Console.WriteLine(Condition.IsGreaterThan(100, 50)); // True\n Console.WriteLine(Condition.IsLowerThan(3, 10)); // True\n\n // Consecutive characters\n Console.WriteLine(Condition.HasConsecutiveCharacters(\"bookkeeper\", 'o')); // True\n Console.WriteLine(Condition.HasConsecutiveCharacters(\"abc\", new[] { 'x', 'y' })); // False\n\n // Countable sequences\n Console.WriteLine(Condition.IsCountableSequence(new[] { 1, 3, 5, 7 })); // True\n Console.WriteLine(Condition.IsCountableSequence(\"abc\")); // True\n\n // Async flip-flop\n var asyncLog = new List();\n var task = Condition.FlipFlopAsync(true,\n async () => { asyncLog.Add(\"async:true\"); await Task.CompletedTask; },\n async () => { asyncLog.Add(\"async:false\"); await Task.CompletedTask; });\n task.Wait();\n Console.WriteLine(string.Join(\", \", asyncLog)); // \"async:true\"\n\n}}}" + } + }, + { + "id": "cd62a9db1f3ff4c649b5a55a", + "exampleId": "Cuemon.Collections.Generic.PaginationEnumerable`1#1", + "uid": "Cuemon.Collections.Generic.PaginationEnumerable`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon.Collections.Generic;\n\n var fruits = new[] { \"Apple\", \"Banana\", \"Cherry\", \"Date\", \"Elderberry\", \"Fig\", \"Grape\", \"Honeydew\" };\n\n // Show page 2 with 3 items per page\n var page = new PaginationEnumerable(fruits, () => fruits.Length, setup =>\n {\n setup.PageSize = 3;\n setup.PageNumber = 2;\n });\n\n Console.WriteLine($\"Page {2} of {page.PageCount} (total items: {page.TotalElementCount})\");\n Console.WriteLine($\"Has previous page: {page.HasPreviousPage}\");\n Console.WriteLine($\"Has next page: {page.HasNextPage}\");\n Console.WriteLine(\"Items on this page:\");\n foreach (var item in page)\n {\n Console.WriteLine($\" {item}\");\n\n}" + } + }, + { + "id": "cda4cdbde74cbc2a85a9d06d", + "exampleId": "Cuemon.Security.Cryptography.KeyedCryptoAlgorithm#1", + "uid": "Cuemon.Security.Cryptography.KeyedCryptoAlgorithm", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Cryptography;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\n\n// KeyedCryptoAlgorithm specifies the HMAC algorithm to use.\n// HmacMd5 = -2 (HMAC-MD5, 128 bits)\n// HmacSha1 = -1 (HMAC-SHA1, 160 bits)\n// HmacSha256 = 0 (HMAC-SHA256,256 bits)\n// HmacSha384 = 1 (HMAC-SHA384,384 bits)\n// HmacSha512 = 2 (HMAC-SHA512,512 bits)\n\nbyte[] key = Encoding.UTF8.GetBytes(\"my-secret-key\");\nbyte[] data = Encoding.UTF8.GetBytes(\"The quick brown fox jumps over the lazy dog\");\n\n// HMAC-SHA256 (default/recommended)\nusing var hmacSha256 = new HMACSHA256(key);\nbyte[] hash256 = hmacSha256.ComputeHash(data);\nConsole.WriteLine($\"HmacSha256: {BitConverter.ToString(hash256).Replace(\"-\", \"\").ToLowerInvariant()}\");\n\n// HMAC-SHA384\nusing var hmacSha384 = new HMACSHA384(key);\nbyte[] hash384 = hmacSha384.ComputeHash(data);\nConsole.WriteLine($\"HmacSha384: {BitConverter.ToString(hash384).Replace(\"-\", \"\").ToLowerInvariant()}\");\n\n// HMAC-SHA512\nusing var hmacSha512 = new HMACSHA512(key);\nbyte[] hash512 = hmacSha512.ComputeHash(data);\nConsole.WriteLine($\"HmacSha512: {BitConverter.ToString(hash512).Replace(\"-\", \"\").ToLowerInvariant()}\");\n\n// HMAC-SHA1\nusing var hmacSha1 = new HMACSHA1(key);\nbyte[] hashSha1 = hmacSha1.ComputeHash(data);\nConsole.WriteLine($\"HmacSha1: {BitConverter.ToString(hashSha1).Replace(\"-\", \"\").ToLowerInvariant()}\");\n\n// Using KeyedCryptoAlgorithm to select algorithm dynamically\nKeyedCryptoAlgorithm algorithm = KeyedCryptoAlgorithm.HmacSha384;\nstring algorithmName = algorithm switch\n{\n KeyedCryptoAlgorithm.HmacMd5 => \"MD5\",\n KeyedCryptoAlgorithm.HmacSha1 => \"SHA1\",\n KeyedCryptoAlgorithm.HmacSha256 => \"SHA256\",\n KeyedCryptoAlgorithm.HmacSha384 => \"SHA384\",\n KeyedCryptoAlgorithm.HmacSha512 => \"SHA512\",\n _ => \"SHA256\"\n};\nConsole.WriteLine($\"Selected HMAC algorithm: HMAC-{algorithmName}\");\n\n// Enum value comparison\nConsole.WriteLine($\"HmacSha256 == 0: {KeyedCryptoAlgorithm.HmacSha256 == (KeyedCryptoAlgorithm)0}\"); // True" + } + }, + { + "id": "cdca439be791342610a197b0", + "exampleId": "Cuemon.Reflection.MemberArgumentDecoratorExtensions#1", + "uid": "Cuemon.Reflection.MemberArgumentDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon;\nusing Cuemon.Reflection;\nusing MyApp.Examples;\n\nConsole.WriteLine(new MemberArgumentDecoratorExtensionsExample().ReconstructException());\n\nnamespace MyApp.Examples\n{\n public class MemberArgumentDecoratorExtensionsExample\n {\n public Exception ReconstructException()\n {\n // Simulate a recorded stack of member arguments representing an exception chain\n var stack = new Stack>();\n\n var innerArgs = new List\n {\n new MemberArgument(\"type\", typeof(InvalidOperationException)),\n new MemberArgument(\"message\", \"Inner operation failed.\")\n };\n stack.Push(innerArgs);\n\n var outerArgs = new List\n {\n new MemberArgument(\"type\", typeof(ArgumentException)),\n new MemberArgument(\"message\", \"Outer argument error.\"),\n new MemberArgument(\"paramName\", \"myParam\"),\n };\n stack.Push(outerArgs);\n\n // Reconstruct the exception chain from the recorded arguments\n return Decorator.Enclose(stack).CreateException();\n\n }\n }\n}" + } + }, + { + "id": "ce261fa5e4c42172dba24385", + "exampleId": "Cuemon.Net.Http.HttpRequestOptions#1", + "uid": "Cuemon.Net.Http.HttpRequestOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing System.Threading.Tasks;\nusing Cuemon.Net.Http;\nusing HttpRequestOptions = Cuemon.Net.Http.HttpRequestOptions;\n\n// Direct instantiation of HttpRequestOptions\nvar requestOptions = new HttpRequestOptions();\nrequestOptions.Request.Method = HttpMethod.Get;\n\nrequestOptions.Request.Headers.Add(\"Accept\", \"application/json\");\nConsole.WriteLine($\"{requestOptions.Request.Method} {string.Join(\", \", requestOptions.Request.Headers.Accept)}\");" + } + }, + { + "id": "cef1735e26b87a3ce1022981", + "exampleId": "Cuemon.Extensions.Wrapper#1", + "uid": "Cuemon.Extensions.Wrapper", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Extensions;\n\nvar wrapped = new Wrapper(42);\nConsole.WriteLine(wrapped.Instance);\nConsole.WriteLine(wrapped.InstanceType);\n\nstring parsed = Wrapper.ParseInstance(wrapped);\nConsole.WriteLine(parsed);\n\nint asInt = wrapped.InstanceAs();\nConsole.WriteLine(asInt);\n\nvar wrappedString = new Wrapper(\"Hello, World!\");\nConsole.WriteLine(Wrapper.ParseInstance(wrappedString));" + } + }, + { + "id": "cf25fad2c9f63850f5f01e5a", + "exampleId": "Cuemon.Runtime.Caching.CacheEntryEventArgs#1", + "uid": "Cuemon.Runtime.Caching.CacheEntryEventArgs", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Runtime.Caching@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading.Tasks;\nusing Cuemon.Runtime;\nusing Cuemon.Runtime.Caching;\nusing MyApp.Examples;\n\nCacheEntryEventArgsExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class CacheEntryEventArgsExample\n {\n public static void Demonstrate()\n {\n var cache = new SlimMemoryCache();\n var dependency = new DependencyStub();\n var entry = new CacheEntry(\"key\", \"value\");\n CacheEntryEventArgs captured = null;\n\n entry.Expired += (_, e) =>\n {\n captured = e;\n };\n\n cache.Add(entry, new CacheInvalidation(new[] { dependency }));\n dependency.SignalChanged();\n\n Console.WriteLine($\"Cache entry expired: {captured is not null}\");\n }\n\n private sealed class DependencyStub : IDependency\n {\n public event EventHandler DependencyChanged;\n\n public DateTime? UtcLastModified { get; private set; }\n\n public bool HasChanged { get; private set; }\n\n public void Start()\n {\n }\n\n public Task StartAsync()\n {\n return Task.CompletedTask;\n }\n\n public void SignalChanged()\n {\n UtcLastModified = DateTime.UtcNow;\n HasChanged = true;\n DependencyChanged?.Invoke(this, new DependencyEventArgs(UtcLastModified.Value));\n }\n }\n }\n}" + } + }, + { + "id": "cfa3512232ba117e79cecbd1", + "exampleId": "Cuemon.AspNetCore.Mvc.SeeOtherResult#1", + "uid": "Cuemon.AspNetCore.Mvc.SeeOtherResult", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Mvc;\n\nvar result = new SeeOtherResult(new Uri(\"https://example.com/orders/42\"));\n\nConsole.WriteLine(result.StatusCode);\nConsole.WriteLine(result.Location);" + } + }, + { + "id": "cfb45ea20d1a9ba0bbe798e2", + "exampleId": "Cuemon.Extensions.DateTimeExtensions#1", + "uid": "Cuemon.Extensions.DateTimeExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Extensions;\n\nvar utc = new DateTime(2025, 6, 16, 14, 33, 22, DateTimeKind.Utc);\nvar local = new DateTime(2025, 6, 16, 14, 33, 22, DateTimeKind.Local);\n\nvar floorHour = utc.Floor(TimeSpan.FromHours(1));\nvar ceilingHour = utc.Ceiling(TimeSpan.FromHours(1));\nvar floorFifteenMinutes = utc.Floor(15, TimeUnit.Minutes);\nvar roundedUp = utc.Round(TimeSpan.FromMinutes(30), VerticalDirection.Up);\nvar isWithinRange = utc.IsWithinRange(new DateTimeRange(utc.AddHours(-1), utc.AddHours(1)));\n\nvar isNight = new DateTime(2025, 6, 16, 22, 15, 0, DateTimeKind.Utc).IsTimeOfDayNight();\nvar isMorning = new DateTime(2025, 6, 16, 6, 15, 0, DateTimeKind.Utc).IsTimeOfDayMorning();\nvar isForenoon = new DateTime(2025, 6, 16, 10, 15, 0, DateTimeKind.Utc).IsTimeOfDayForenoon();\nvar isAfternoon = utc.IsTimeOfDayAfternoon();\nvar isEvening = new DateTime(2025, 6, 16, 19, 15, 0, DateTimeKind.Utc).IsTimeOfDayEvening();\n\nvar utcKind = local.ToUtcKind();\nvar localKind = utc.ToLocalKind();\nvar unspecifiedKind = utc.ToDefaultKind();\n\nvar unixTime = utc.ToUnixEpochTime();\nvar restored = unixTime.FromUnixEpochTime();\n\nConsole.WriteLine(floorHour.ToString(\"O\"));\nConsole.WriteLine(ceilingHour.ToString(\"O\"));\nConsole.WriteLine(floorFifteenMinutes.ToString(\"O\"));\nConsole.WriteLine(roundedUp.ToString(\"O\"));\nConsole.WriteLine(isWithinRange);\nConsole.WriteLine($\"{isNight}, {isMorning}, {isForenoon}, {isAfternoon}, {isEvening}\");\nConsole.WriteLine($\"{utcKind.Kind}, {localKind.Kind}, {unspecifiedKind.Kind}\");\nConsole.WriteLine(restored.ToString(\"O\"));" + } + }, + { + "id": "cff308a6e84282fbce049084", + "exampleId": "Cuemon.Extensions.Xml.UriExtensions#1", + "uid": "Cuemon.Extensions.Xml.UriExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing System.Xml;\nusing Cuemon.Extensions.Xml;\n\nvar xml = \"42\";\nvar filePath = Path.Combine(AppContext.BaseDirectory, \"settings.xml\");\nFile.WriteAllText(filePath, xml, Encoding.UTF8);\n\ntry\n{\n using var reader = new Uri(filePath).ToXmlReader(settings =>\n {\n settings.IgnoreComments = true;\n settings.DtdProcessing = DtdProcessing.Ignore;\n });\n\n if (reader.MoveToFirstElement())\n {\n Console.WriteLine(reader.LocalName);\n }\n}\nfinally\n{\n if (File.Exists(filePath))\n {\n File.Delete(filePath);\n }\n}" + } + }, + { + "id": "caaa6221b36cc8db6affaba4", + "exampleId": "Cuemon.Extensions.ActionExtensions#1", + "uid": "Cuemon.Extensions.ActionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Configuration;\nusing Cuemon.Extensions;\nusing MyApp.Examples;\n\nActionExtensionsExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class ActionExtensionsExample\n {\n private sealed class MyOptions : IParameterObject\n {\n public string Delimiter { get; set; } = \",\";\n\n public string Qualifier { get; set; } = \"\\\"\";\n }\n\n private sealed class MyService\n {\n public string ConnectionString { get; set; } = string.Empty;\n\n public int Timeout { get; set; } = 30;\n }\n\n public static void Demonstrate()\n {\n var options = new Action(setup =>\n {\n setup.Delimiter = \";\";\n setup.Qualifier = \"'\";\n }).Configure();\n\n var service = new Action(factory =>\n {\n factory.ConnectionString = \"Server=(localdb)\\\\MSSQLLocalDB;Database=Docs\";\n factory.Timeout = 60;\n }).CreateInstance();\n\n Console.WriteLine($\"{options.Delimiter} {options.Qualifier}\");\n Console.WriteLine($\"{service.ConnectionString} ({service.Timeout}s)\");\n }\n }\n}" + } + }, + { + "id": "d04b722e2fa86cb4be70e5ac", + "exampleId": "Cuemon.AspNetCore.Http.MethodNotAllowedException#1", + "uid": "Cuemon.AspNetCore.Http.MethodNotAllowedException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http;\n\nvar allowedMethods = string.Join(\", \", new[] { \"POST\", \"PUT\" });\nvar exception = new MethodNotAllowedException($\"Only {allowedMethods} are supported for /orders.\");\n\nConsole.WriteLine(exception.Message);\nConsole.WriteLine(exception.StatusCode);" + } + }, + { + "id": "d14d5072b889b7678c32d73d", + "exampleId": "Cuemon.AspNetCore.Http.Headers.VaryAcceptMiddleware#1", + "uid": "Cuemon.AspNetCore.Http.Headers.VaryAcceptMiddleware", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading.Tasks;\nusing Cuemon.AspNetCore.Http.Headers;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Net.Http.Headers;\n\nvar context = new DefaultHttpContext();\nvar middleware = new VaryAcceptMiddleware(httpContext => httpContext.Response.WriteAsync(\"Hello\"));\n\nawait middleware.InvokeAsync(context);\n\n// The middleware writes this header when the response starts.\nConsole.WriteLine($\"{HeaderNames.Vary}: {HeaderNames.Accept}\");" + } + }, + { + "id": "d171c7f0056936b799e08a85", + "exampleId": "Cuemon.AspNetCore.Configuration.CacheBustingOptions#1", + "uid": "Cuemon.AspNetCore.Configuration.CacheBustingOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Configuration;\nusing Cuemon.AspNetCore.Configuration;\n\n var options = new CacheBustingOptions\n{\n PreferredCasing = CasingMethod.UpperCase\n};\n\nConsole.WriteLine(options.PreferredCasing);" + } + }, + { + "id": "d1ba84fca57818397fad30ce", + "exampleId": "Cuemon.MutableTuple#1", + "uid": "Cuemon.MutableTuple", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\nMutableTuple empty = new MutableTuple();\nvar pair = new MutableTuple(\"Alice\", 30);\n\npair.Arg2 = 31;\n\nobject[] values = pair.ToArray(\"verified\");\nvar clone = (MutableTuple)pair.Clone();\n\nConsole.WriteLine($\"Empty: {empty.IsEmpty}\");\nConsole.WriteLine($\"{clone.Arg1}:{clone.Arg2}\");\nConsole.WriteLine($\"Array length: {values.Length}\");" + } + }, + { + "id": "d1d5f02230e88bcf5abf2552", + "exampleId": "Cuemon.Extensions.Net.Security.StringExtensions#1", + "uid": "Cuemon.Extensions.Net.Security.StringExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security;\nusing System.Text;\nusing Cuemon.Extensions.Net.Security;\n\nvar secret = Encoding.UTF8.GetBytes(\"1234\");\nvar uriString = \"https://example.com/search?q=cuemon\";\nvar signedUri = uriString.ToSignedUri(secret, DateTime.UtcNow.AddMinutes(-1), DateTime.UtcNow.AddMinutes(1));\n\nsignedUri.OriginalString.ValidateSignedUri(secret);\n\nConsole.WriteLine(signedUri);\n\ntry\n{\n var tampered = new UriBuilder(signedUri);\n tampered.Query = tampered.Query.TrimStart('?') + \"&tampered=1\";\n tampered.Uri.OriginalString.ValidateSignedUri(secret);\n}\ncatch (SecurityException ex)\n{\n Console.WriteLine(ex.Message);\n}" + } + }, + { + "id": "d206ece36dfda1c486b946ed", + "exampleId": "Cuemon.Reflection.ParameterSignature#1", + "uid": "Cuemon.Reflection.ParameterSignature", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing System.Reflection;\nusing Cuemon.Reflection;\n\n MethodInfo method = typeof(string).GetMethod(\"IndexOf\", new[] { typeof(string), typeof(StringComparison) });\n\n if (method != null)\n {\n var signatures = ParameterSignature.Parse(method).ToList();\n\n foreach (var signature in signatures)\n {\n Console.WriteLine($\"Parameter: {signature.ParameterName}, Type: {signature.ParameterType.Name}\");\n\n}}" + } + }, + { + "id": "d288d1da3282f8bdef8a22df", + "exampleId": "Cuemon.Threading.AsyncPatterns#1", + "uid": "Cuemon.Threading.AsyncPatterns", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Threading@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Cuemon.Threading;\nusing Contoso.Streaming;\n\nawait AsyncPatternsExample.RunAsync();\n\nnamespace Contoso.Streaming\n{\n public sealed class AsyncPatternsExample\n {\n public static async Task RunAsync()\n {\n var result = await AsyncPatterns.SafeInvokeAsync(\n () => new MemoryStream(),\n async (stream, ct) =>\n {\n byte[] buffer = Encoding.UTF8.GetBytes(\"Cuemon\");\n await stream.WriteAsync(buffer, 0, buffer.Length, ct);\n stream.Position = 0;\n return stream;\n },\n ct: CancellationToken.None);\n\n using (result)\n using (var reader = new StreamReader(result, Encoding.UTF8, true, 1024, true))\n {\n Console.WriteLine(await reader.ReadToEndAsync());\n }\n\n Console.WriteLine(ReferenceEquals(AsyncPatterns.Use, AsyncPatterns.Use));\n }\n }\n}" + } + }, + { + "id": "d289c39563c36beafdc42f19", + "exampleId": "Cuemon.Reflection.AssemblyContext#1", + "uid": "Cuemon.Reflection.AssemblyContext", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.Reflection;\n\nvar assemblies = AssemblyContext.GetCurrentDomainAssemblies(options =>\n{\n options.AssemblyFilter = a => a.FullName?.StartsWith(\"Cuemon\") == true;\n});\n\nforeach (var assembly in assemblies)\n{\n Console.WriteLine($\"Assembly: {assembly.GetName().Name}\");\n}" + } + }, + { + "id": "d2a9361be849962a624cb48d", + "exampleId": "Cuemon.Extensions.TimeSpanExtensions#1", + "uid": "Cuemon.Extensions.TimeSpanExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Extensions;\n\nvar hour = TimeSpan.FromHours(1);\nvar duration = TimeSpan.FromMinutes(280);\nvar shortDuration = TimeSpan.FromMinutes(45);\n\nConsole.WriteLine(hour.GetTotalNanoseconds());\nConsole.WriteLine(hour.GetTotalMicroseconds());\nConsole.WriteLine(duration.Floor(1, TimeUnit.Hours));\nConsole.WriteLine(duration.Ceiling(1, TimeUnit.Hours));\nConsole.WriteLine(shortDuration.Round(TimeSpan.FromHours(1), VerticalDirection.Up));\nConsole.WriteLine(shortDuration.Round(30, TimeUnit.Minutes, VerticalDirection.Down));" + } + }, + { + "id": "d339a86d1317c4cb71bbbdf1", + "exampleId": "Cuemon.Tweaker#1", + "uid": "Cuemon.Tweaker", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon;\n\n// Adjust: transform a value using a converter function\nint doubled = Tweaker.Adjust(21, x => x * 2);\nConsole.WriteLine(doubled); // 42\n\n// Alter: modify an object in-place via an action delegate\nvar list = new List { \"a\", \"b\", \"c\" };\nTweaker.Alter(list, lst => lst.Add(\"d\"));\nConsole.WriteLine(string.Join(\", \", list)); // a, b, c, d\n\n// Change: convert a value to a different type\nstring asString = Tweaker.Change(42, x => x.ToString());\nConsole.WriteLine(asString); // 42\n\n// Adjust with null converter returns the original value unchanged\nint same = Tweaker.Adjust(10, null as Func);\nConsole.WriteLine(same); // 10" + } + }, + { + "id": "d3ac33bea615aa19576fdd5d", + "exampleId": "Cuemon.Text.GuidStringOptions#1", + "uid": "Cuemon.Text.GuidStringOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Text;\n\n// Direct instantiation of GuidStringOptions\nvar options = new GuidStringOptions\n{\n Formats = GuidFormats.D\n};\n\nvar parser = ParserFactory.FromGuid();\nvar guidString = \"{3f2504e0-4f89-41d3-9a0c-0305e82c3301}\";\n\nvar result = parser.Parse(guidString, o =>\n{\n o.Formats = GuidFormats.B;\n});\n\nConsole.WriteLine(result);\n// outputs: 3f2504e0-4f89-41d3-9a0c-0305e82c3301" + } + }, + { + "id": "d471aef628db4ad536725236", + "exampleId": "Cuemon.Security.CyclicRedundancyCheck64#1", + "uid": "Cuemon.Security.CyclicRedundancyCheck64", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security;\n\n// Create CRC-64 instance with default ECMA-182 polynomial\nvar crc64 = new CyclicRedundancyCheck64();\n\n// Compute checksum from ASCII input\nbyte[] data = Encoding.ASCII.GetBytes(\"123456789\");\nHashResult result = crc64.ComputeHash(data);\n\n// Display the checksum in hexadecimal\nstring hex = result.ToHexadecimalString();\nConsole.WriteLine(hex); // 6c40df5f0b497347\n\n// Create CRC-64 with custom polynomial\nvar customCrc = new CyclicRedundancyCheck64(\n polynomial: 0x42F0E1EBA9EA3693,\n initialValue: 0xFFFFFFFFFFFFFFFF,\n finalXor: 0xFFFFFFFFFFFFFFFF);\n\nHashResult customResult = customCrc.ComputeHash(data);\nConsole.WriteLine(customResult.ToHexadecimalString());" + } + }, + { + "id": "d4e360ed423b58ef93ba5af6", + "exampleId": "Cuemon.AspNetCore.Diagnostics.ServerTimingOptions#1", + "uid": "Cuemon.AspNetCore.Diagnostics.ServerTimingOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Diagnostics;\n\nvar options = new ServerTimingOptions\n{\n TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(10)\n};\n\nConsole.WriteLine($\"Threshold: {options.TimeMeasureCompletedThreshold}\");" + } + }, + { + "id": "d5aff871e73d85e6a71a08bf", + "exampleId": "Cuemon.Reflection.PropertyInfoDecoratorExtensions#1", + "uid": "Cuemon.Reflection.PropertyInfoDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Reflection;\nusing Cuemon;\nusing Cuemon.Reflection;\nusing MyApp.Examples;\n\nPropertyInfoDecoratorExtensionsExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class PropertyInfoDecoratorExtensionsExample\n {\n public static void Demonstrate()\n {\n PropertyInfo code = typeof(Product).GetProperty(nameof(Product.Code))!;\n PropertyInfo label = typeof(Product).GetProperty(nameof(Product.Label))!;\n PropertyInfo summary = typeof(FeaturedProduct).GetProperty(nameof(Product.Summary))!;\n\n Console.WriteLine(Decorator.Enclose(code).IsAutoProperty());\n Console.WriteLine(Decorator.Enclose(label).IsAutoProperty());\n Console.WriteLine(Decorator.Enclose(summary).IsOverridden());\n }\n }\n public class Product\n {\n public string Code { get; set; } = string.Empty;\n\n public string Label => $\"Product:{Code}\";\n\n public virtual string Summary => \"standard\";\n }\n public sealed class FeaturedProduct : Product\n {\n public override string Summary => \"featured\";\n }\n}" + } + }, + { + "id": "d5dacc9d63b78677731bb864", + "exampleId": "Cuemon.Data.DataTransferRowCollection#1", + "uid": "Cuemon.Data.DataTransferRowCollection", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Data;\nusing Cuemon.Data;\n\nvar table = new DataTable(\"Products\");\ntable.Columns.Add(\"Id\", typeof(int));\ntable.Columns.Add(\"Name\", typeof(string));\ntable.Columns.Add(\"Created\", typeof(DateTime));\ntable.Columns.Add(\"Notes\", typeof(string));\ntable.Rows.Add(1, \"Apples\", new DateTime(2024, 1, 2, 3, 4, 5, DateTimeKind.Utc), \"Fresh\");\ntable.Rows.Add(2, \"Bananas\", new DateTime(2024, 2, 3, 4, 5, 6, DateTimeKind.Utc), DBNull.Value);\n\nusing var reader = table.CreateDataReader();\nDataTransferRowCollection rows = DataTransfer.GetRows(reader);\n\nConsole.WriteLine(\"Columns: \" + string.Join(\", \", rows.ColumnNames));\nConsole.WriteLine($\"Row count: {rows.Count}\");\n\nDataTransferRow firstRow = rows[0];\nConsole.WriteLine(firstRow.ToString());\nConsole.WriteLine($\"First row name: {firstRow[\"Name\"]}\");\nConsole.WriteLine($\"Created: {firstRow.As(\"Created\"):O}\");\n\nDataTransferRow secondRow = rows[1];\nConsole.WriteLine($\"Second row notes are null: {secondRow[\"Notes\"] == null}\");\nConsole.WriteLine($\"Contains first row: {rows.Contains(firstRow)}\");\nConsole.WriteLine($\"Index of first row: {rows.IndexOf(firstRow)}\");" + } + }, + { + "id": "d613c939b0c631c5c3595301", + "exampleId": "Cuemon.Data.DataTransferRow#1", + "uid": "Cuemon.Data.DataTransferRow", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Data;\nusing Cuemon.Data;\n\n // Build a DataTable to simulate a database result set.\n var table = new DataTable();\n table.Columns.Add(\"Id\", typeof(int));\n table.Columns.Add(\"Name\", typeof(string));\n table.Columns.Add(\"Created\", typeof(DateTime));\n table.Columns.Add(\"Notes\", typeof(string));\n table.Rows.Add(1, \"Alice\", new DateTime(2024, 1, 2, 3, 4, 5, DateTimeKind.Utc), \"First\");\n table.Rows.Add(2, \"Bob\", new DateTime(2024, 2, 3, 4, 5, 6, DateTimeKind.Utc), DBNull.Value);\n\n // Convert the reader to rows.\n using (IDataReader reader = table.CreateDataReader())\n {\n DataTransferRowCollection rows = DataTransfer.GetRows(reader);\n\n // Access individual rows.\n DataTransferRow first = rows[0];\n DataTransferRow second = rows[1];\n\n Console.WriteLine(\"Row numbers: {0}, {1}\", first.Number, second.Number);\n\n // Access values by column index.\n object idValue = first[0];\n Console.WriteLine(\"First row Id: {0}\", idValue);\n\n // Access values by column name.\n object nameValue = first[\"Name\"];\n Console.WriteLine(\"First row Name: {0}\", nameValue);\n\n // Access values by DataTransferColumn object.\n DataTransferColumn idCol = first.Columns[\"Id\"];\n object viaColumn = first[idCol];\n Console.WriteLine(\"First row Id (via column): {0}\", viaColumn);\n\n // Type-safe access using generics.\n int idTyped = first.As(\"Id\");\n DateTime created = first.As(\"Created\");\n Console.WriteLine(\"Typed: Id={0}, Created={1:O}\", idTyped, created);\n\n // Nullable value (DBNull is converted to null).\n object notes = second[\"Notes\"];\n Console.WriteLine(\"Second row Notes is null: {0}\", notes == null);\n\n // String representation of the row.\n Console.WriteLine(\"Row string: {0}\", first);\n\n}" + } + }, + { + "id": "d652111fd38378d9c6130996", + "exampleId": "Cuemon.StringDecoratorExtensions#1", + "uid": "Cuemon.StringDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Globalization;\nusing System.IO;\nusing System.Text;\nusing Cuemon;\nusing Cuemon.Text;\n\nstring value = \" Hello World! \";\nvar decorator = Decorator.Enclose(value);\n\n// Change casing via decorator\nstring lower = decorator.ToCasing(CasingMethod.LowerCase); // \" hello world! \"\nstring upper = decorator.ToCasing(CasingMethod.UpperCase); // \" HELLO WORLD! \"\nstring title = decorator.ToCasing(CasingMethod.TitleCase, new CultureInfo(\"en-US\")); // \" Hello World! \"\n\n// Convert to byte array\nbyte[] bytes = decorator.ToByteArray(o => o.Encoding = Encoding.UTF8);\n\n// Convert to stream\nusing Stream stream = decorator.ToStream(o => o.Encoding = Encoding.UTF8);\n\n// Convert to URI\nstring url = \"https://www.example.com\";\nvar uriDecorator = Decorator.Enclose(url);\nUri uri = uriDecorator.ToUri(); // https://www.example.com/\n\n// Encoding conversions\nstring ascii = decorator.ToAsciiEncodedString(o => o.Encoding = Encoding.UTF8); // \" Hello World! \" (non-ASCII chars replaced with empty)\nstring encoded = decorator.ToEncodedString(o =>\n{\n o.TargetEncoding = Encoding.ASCII;\n o.EncoderFallback = new EncoderReplacementFallback(\"?\");\n});\n\n// StartsWith checks\nbool starts = decorator.StartsWith(\" Hello\"); // true\nbool startsIgnore = decorator.StartsWith(StringComparison.OrdinalIgnoreCase, \"hello\"); // true\nbool startsAny = decorator.StartsWith(\"Hi\", \"Hello\"); // true\n\n// Set difference\nvar helloDecorator = Decorator.Enclose(\"Hello World!\");\nstring diff = helloDecorator.Difference(\"Hello Universe!\"); // \"Universe!\"\n\n// ContainsAny for characters\nbool hasChar = decorator.ContainsAny('o', StringComparison.Ordinal); // true\nbool hasChars = decorator.ContainsAny(StringComparison.Ordinal, 'x', 'y'); // false\n\nConsole.WriteLine(lower);\nConsole.WriteLine(upper);\nConsole.WriteLine(bytes.Length);\nConsole.WriteLine(uri);\nConsole.WriteLine(starts);\nConsole.WriteLine(startsIgnore);\nConsole.WriteLine(startsAny);\nConsole.WriteLine(diff);\nConsole.WriteLine(hasChar);\nConsole.WriteLine(hasChars);" + } + }, + { + "id": "d663e6d4312fed07eb976d3d", + "exampleId": "Cuemon.Reflection.MemberInfoDecoratorExtensions#1", + "uid": "Cuemon.Reflection.MemberInfoDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.ComponentModel;\nusing System.Reflection;\nusing Cuemon;\nusing Cuemon.Reflection;\nusing MyApp.Reflection;\n\nnew MemberInfoDecoratorExtensionsExample().Demonstrate();\n\nnamespace MyApp.Reflection\n{\n public class MemberInfoDecoratorExtensionsExample\n {\n public void Demonstrate()\n {\n // Get a MemberInfo for a method\n MemberInfo demoMethod = typeof(MemberInfoDecoratorExtensionsExample)\n .GetMethod(nameof(Demonstrate));\n\n // Check if the method has a specific attribute\n bool hasObsolete = Decorator.Enclose(demoMethod)\n .HasAttribute(typeof(ObsoleteAttribute));\n Console.WriteLine($\"Has ObsoleteAttribute: {hasObsolete}\"); // False\n\n // Check for multiple attributes at once\n bool hasAny = Decorator.Enclose(demoMethod)\n .HasAttribute(typeof(ObsoleteAttribute), typeof(EditorBrowsableAttribute));\n Console.WriteLine($\"Has Obsolete or EditorBrowsable: {hasAny}\"); // False\n\n // A member with an attribute\n MemberInfo deprecatedMethod = typeof(MemberInfoDecoratorExtensionsExample)\n .GetMethod(nameof(OldMethod));\n\n bool isDeprecated = Decorator.Enclose(deprecatedMethod)\n .HasAttribute(typeof(ObsoleteAttribute));\n Console.WriteLine($\"OldMethod has ObsoleteAttribute: {isDeprecated}\"); // True\n }\n\n [Obsolete(\"Use Demonstrate instead.\")]\n public void OldMethod()\n {\n }\n }\n}" + } + }, + { + "id": "d69dd38b6adad346c75761f5", + "exampleId": "Cuemon.Net.Http.HttpMethodConverter#1", + "uid": "Cuemon.Net.Http.HttpMethodConverter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing Cuemon.Net.Http;\n\nHttpMethod get = HttpMethod.Get;\nHttpMethods result = HttpMethodConverter.ToHttpMethod(get);\nConsole.WriteLine(result); // Get" + } + }, + { + "id": "d71f37fff44ff60a7ae3183f", + "exampleId": "Cuemon.TimeUnit#1", + "uid": "Cuemon.TimeUnit", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon; // for Decorator and ToTimeSpan\nusing Cuemon;\n\ndouble value = 2.5;\n\nTimeSpan days = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Days);\nConsole.WriteLine(days); // 2.12:00:00\n\nTimeSpan hours = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Hours);\nConsole.WriteLine(hours); // 02:30:00\n\nTimeSpan minutes = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Minutes);\nConsole.WriteLine(minutes); // 00:02:30\n\nTimeSpan seconds = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Seconds);\nConsole.WriteLine(seconds); // 00:00:02.5000000\n\nTimeSpan ticks = Decorator.Enclose(50000000.0).ToTimeSpan(TimeUnit.Ticks);\nConsole.WriteLine(ticks); // 00:00:05" + } + }, + { + "id": "d79b7496c0557321609a26ad", + "exampleId": "Cuemon.Data.Integrity.CacheValidator#1", + "uid": "Cuemon.Data.Integrity.CacheValidator", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Security;\n\nvar entity = new EntityInfo(\n DateTime.UtcNow.AddHours(-2),\n DateTime.UtcNow.AddMinutes(-30)\n);\n\nvar validator = new CacheValidator(entity, () => HashFactory.CreateFnv128(), EntityDataIntegrityMethod.Combined);\n\nConsole.WriteLine($\"Created (UTC): {validator.Created:O}\");\nConsole.WriteLine($\"Modified (UTC): {validator.Modified:O}\");\nConsole.WriteLine($\"Validation: {validator.Validation}\");\nConsole.WriteLine($\"Method: {validator.Method}\");\nConsole.WriteLine($\"Checksum: {validator.Checksum.ToHexadecimalString()}\");\n\n// Combine with additional data\nvalidator.CombineWith(BitConverter.GetBytes(67890L));\nConsole.WriteLine($\"Combined: {validator}\");\n\n// Get the most significant from a sequence\nvar v1 = new CacheValidator(new EntityInfo(new DateTime(2024, 1, 1, 0, 0, 0, DateTimeKind.Utc)), () => HashFactory.CreateFnv128());\nvar v2 = new CacheValidator(new EntityInfo(DateTime.UtcNow.AddDays(-1)), () => HashFactory.CreateFnv128());\nvar mostSignificant = CacheValidator.GetMostSignificant(v1, v2);\n\nConsole.WriteLine($\"Most significant created: {mostSignificant.Created:O}\");\n\n// Use assembly reference point\nCacheValidator.AssemblyReference = typeof(CacheValidator).Assembly;\nvar referencePoint = CacheValidator.ReferencePoint;\nConsole.WriteLine($\"Reference point: {referencePoint}\");" + } + }, + { + "id": "d7ecb2daefff94e8f8024695", + "exampleId": "Cuemon.AspNetCore.Mvc.Breadcrumb#1", + "uid": "Cuemon.AspNetCore.Mvc.Breadcrumb", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon.AspNetCore.Mvc;\n\n// Build a breadcrumb trail for a product detail page\nvar breadcrumbs = new List\n{\n new() { Label = \"Home\", ControllerName = \"Home\", ActionName = \"Index\" },\n new() { Label = \"Products\", ControllerName = \"Product\", ActionName = \"Index\" },\n new() { Label = \"Electronics\", ControllerName = \"Product\", ActionName = \"Category\" },\n new() { Label = \"Smartphone X\", ControllerName = \"Product\", ActionName = \"Details\" }\n};\n\n// Render breadcrumb items\nforeach (var crumb in breadcrumbs)\n{\n Console.WriteLine($\"{crumb.Label}\");\n// Output:\n// Home\n// Products\n// Electronics\n// Smartphone X\n\n// The last breadcrumb typically represents the current page (no link)\nvar current = breadcrumbs[^1];\nConsole.WriteLine($\"{current.Label}\");\n// Output: Smartphone X\n\n}" + } + }, + { + "id": "d8433388fb926817aa3d077b", + "exampleId": "Cuemon.Xml.Serialization.Converters.ExceptionConverter#1", + "uid": "Cuemon.Xml.Serialization.Converters.ExceptionConverter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing System.Xml;\nusing Cuemon.Xml.Serialization;\nusing Cuemon.Xml.Serialization.Converters;\nusing Cuemon.Xml.Serialization.Formatters;\nusing MyApp.Examples;\n\nnew ExceptionConverterExample().SerializeExceptionWithStackTrace();\n\nnamespace MyApp.Examples\n{\n public class ExceptionConverterExample\n {\n public void SerializeExceptionWithStackTrace()\n {\n // Create an exception with inner exception and custom data\n var inner = new ArgumentNullException(\"connectionString\", \"Value cannot be null.\");\n var outer = new InvalidOperationException(\"Failed to connect to the database.\", inner);\n outer.Data[\"Server\"] = \"db01.prod.example.com\";\n\n // Configure the XML formatter with ExceptionConverter including stack trace and data\n var options = new XmlFormatterOptions();\n options.Settings.Converters.Add(new ExceptionConverter(includeStackTrace: true, includeData: true));\n\n // Serialize to XML\n var formatter = new XmlFormatter(options);\n using (var stream = formatter.Serialize(outer))\n using (var reader = new StreamReader(stream, Encoding.UTF8))\n {\n string xml = reader.ReadToEnd();\n Console.WriteLine(xml);\n // The output resembles:\n // \n // \n // ...\n // Failed to connect to the database.\n // \n // at ExceptionConverterExample.SerializeExceptionWithStackTrace() ...\n // \n // \n // db01.prod.example.com\n // \n // ...\n // \n }\n }\n\n public void DeserializeExceptionFromXml()\n {\n string xml = @\"\n \n MyApp\n Something went wrong.\n \";\n\n var converter = new ExceptionConverter();\n using (var reader = XmlReader.Create(new StringReader(xml)))\n {\n var restored = converter.ReadXml(typeof(InvalidOperationException), reader);\n Console.WriteLine(restored.Message); // \"Something went wrong.\"\n }\n }\n\n public void SerializeWithoutStackTraceAndData()\n {\n var exception = new TimeoutException(\"The operation timed out.\");\n var options = new XmlFormatterOptions();\n options.Settings.Converters.Add(new ExceptionConverter()); // defaults: false, false\n\n var formatter = new XmlFormatter(options);\n using (var stream = formatter.Serialize(exception))\n using (var reader = new StreamReader(stream, Encoding.UTF8))\n {\n string xml = reader.ReadToEnd();\n // Stack trace and Data are excluded from the output\n Console.WriteLine(xml);\n }\n }\n }\n}" + } + }, + { + "id": "d8524252ae56be0b5b4972cb", + "exampleId": "Cuemon.AspNetCore.Http.Headers.ApiKeySentinelMiddleware#1", + "uid": "Cuemon.AspNetCore.Http.Headers.ApiKeySentinelMiddleware", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.Options;\nusing Cuemon.AspNetCore.Http.Headers;\n\nawait ApiKeySentinelMiddlewareExample.DemonstrateAsync();\n\nnamespace Cuemon.AspNetCore.Http.Headers\n{\n public static class ApiKeySentinelMiddlewareExample\n {\n public static async Task DemonstrateAsync()\n {\n var context = new DefaultHttpContext();\n var options = Options.Create(new ApiKeySentinelOptions\n {\n AllowedKeys = new List { \"secret-key\" }\n });\n\n context.Request.Headers[options.Value.HeaderName] = \"secret-key\";\n\n var middleware = new ApiKeySentinelMiddleware(\n httpContext =>\n {\n httpContext.Response.StatusCode = StatusCodes.Status200OK;\n return Task.CompletedTask;\n },\n options);\n\n await middleware.InvokeAsync(context);\n Console.WriteLine(context.Response.StatusCode);\n }\n }\n}" + } + }, + { + "id": "d94ab6c85c5cec15eb7839bc", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.Headers.ApplicationBuilderExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Http.Headers.ApplicationBuilderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http.Headers;\nusing Cuemon.Extensions.AspNetCore.Http.Headers;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Net.Http.Headers;\n\nvar services = new ServiceCollection();\nservices.AddLogging();\nservices.AddOptions();\nusing var provider = services.BuildServiceProvider();\n\nvar app = new ApplicationBuilder(provider);\napp.UseCorrelationIdentifier(options => options.HeaderName = \"X-Correlation-ID\");\napp.UseRequestIdentifier(options => options.HeaderName = \"X-Request-ID\");\napp.UseUserAgentSentinel(options =>\n{\n options.RequireUserAgentHeader = true;\n options.ValidateUserAgentHeader = true;\n options.AllowedUserAgents.Add(\"Cuemon-Agent\");\n});\napp.UseApiKeySentinel(options =>\n{\n options.HeaderName = \"X-Test-Key\";\n options.AllowedKeys.Add(\"known-key\");\n});\napp.UseCacheControl(options =>\n{\n options.CacheControl.MaxAge = TimeSpan.FromHours(1);\n options.CacheControl.Public = true;\n options.Expires = new ExpiresHeaderValue(TimeSpan.FromHours(1));\n});\napp.UseVaryAccept();\n\nConsole.WriteLine(\"Correlation, request, agent, API key, cache-control and Vary middleware configured.\");" + } + }, + { + "id": "d96fa6934f2cbaf56a5b25ec", + "exampleId": "Cuemon.UriScheme#1", + "uid": "Cuemon.UriScheme", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing Cuemon;\nusing System;\n\nvar httpsScheme = StringFactory.CreateUriScheme(UriScheme.Https);\nvar ftpScheme = StringFactory.CreateUriScheme(UriScheme.Ftp);\n\nConsole.WriteLine(httpsScheme); // outputs: https://\nConsole.WriteLine(ftpScheme); // outputs: ftp://" + } + }, + { + "id": "d995af415206ec341978fd65", + "exampleId": "Cuemon.AspNetCore.Http.HttpResponseDecoratorExtensions#1", + "uid": "Cuemon.AspNetCore.Http.HttpResponseDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon;\nusing Cuemon.AspNetCore.Http;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Security;\nusing Microsoft.AspNetCore.Http;\n\nvar context = new DefaultHttpContext();\nvar builder = new ChecksumBuilder(() => HashFactory.CreateFnv128());\nbuilder.CombineWith(Encoding.UTF8.GetBytes(\"content-data\"));\n\nDecorator.Enclose(context.Response).AddOrUpdateEntityTagHeader(context.Request, builder);\nvar lastModified = new DateTime(2025, 6, 1, 12, 0, 0, DateTimeKind.Utc);\nDecorator.Enclose(context.Response).AddOrUpdateLastModifiedHeader(context.Request, lastModified);\n\nConsole.WriteLine(context.Response.Headers.ETag.ToString());\nConsole.WriteLine(context.Response.Headers.LastModified.ToString());" + } + }, + { + "id": "d9b359d65ea80b03a9e6073d", + "exampleId": "Cuemon.Extensions.Hosting.HostBuilderExtensions#1", + "uid": "Cuemon.Extensions.Hosting.HostBuilderExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Hosting@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon.Extensions.Hosting;\nusing Microsoft.Extensions.Configuration;\nusing Microsoft.Extensions.Configuration.Memory;\nusing Microsoft.Extensions.Hosting;\n\nvar hostBuilder = Host.CreateDefaultBuilder()\n .ConfigureConfigurationSources((environment, sources) =>\n {\n sources.Add(new MemoryConfigurationSource\n {\n InitialData = new Dictionary\n {\n [\"App:Environment\"] = environment.EnvironmentName\n }\n });\n })\n .RemoveConfigurationSource((environment, source) =>\n environment.IsProduction() && source is MemoryConfigurationSource);\n\nusing var host = hostBuilder.Build();\nvar configuration = (IConfiguration)host.Services.GetService(typeof(IConfiguration));\n\nConsole.WriteLine(configuration[\"App:Environment\"] == null);" + } + }, + { + "id": "d9fa2d65af955fe21a4294a7", + "exampleId": "Cuemon.Threading.ForLoopRuleset`1#1", + "uid": "Cuemon.Threading.ForLoopRuleset`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon;\nusing Cuemon.Threading;\n\nvar rules = new ForLoopRuleset(\n from: 0,\n to: 5,\n step: 1,\n relation: RelationalOperator.LessThanOrEqual,\n assignment: AssignmentOperator.Addition);\n\nvar values = new List();\nint current = rules.From;\n\nwhile (rules.Condition(current, rules.Relation, rules.To))\n{\n values.Add(current);\n current = rules.Iterator(current, rules.Assignment, rules.Step);\n}\n\nConsole.WriteLine(string.Join(\", \", values));" + } + }, + { + "id": "da7732ce6ecff5ecd0e14c47", + "exampleId": "Cuemon.Extensions.Data.DbTypeExtensions#1", + "uid": "Cuemon.Extensions.Data.DbTypeExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Data@11.0.0" + ], + "source": "using System;\nusing System.Data;\nusing Cuemon.Extensions.Data;\n\nnamespace MyApp.Examples;\n\npublic class DbTypeExtensionsExample\n{\n public static void Main()\n {\n // Access the extension method via the declaring type explicitly\n var stringType = DbTypeExtensions.ToType(DbType.String);\n var int32Type = DbTypeExtensions.ToType(DbType.Int32);\n var dateTimeType = DbTypeExtensions.ToType(DbType.DateTime);\n\n Console.WriteLine($\"DbType.String -> {stringType}\"); // System.String\n Console.WriteLine($\"DbType.Int32 -> {int32Type}\"); // System.Int32\n Console.WriteLine($\"DbType.DateTime -> {dateTimeType}\"); // System.DateTime\n\n // Equivalent form using extension method syntax on DbType value\n var extended = DbType.Decimal.ToType();\n Console.WriteLine($\"DbType.Decimal -> {extended}\"); // System.Decimal\n\n}\n}" + } + }, + { + "id": "da7bcefb630db38e68fe334c", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.CdnTagHelperOptions#1", + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.CdnTagHelperOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Razor.TagHelpers;\n\nvar options = new CdnTagHelperOptions\n{\n Scheme = ProtocolUriScheme.Https,\n BaseUrl = \"nblcdn.net\"\n};\n\nConsole.WriteLine(options.GetFormattedBaseUrl());" + } + }, + { + "id": "db20c1ea9d6c5131581ff7f6", + "exampleId": "Cuemon.Endianness#1", + "uid": "Cuemon.Endianness", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing Cuemon;\nusing System;\n\nvar options = new EndianOptions\n{\n ByteOrder = Endianness.BigEndian\n};\n\nConsole.WriteLine(options.ByteOrder == Endianness.BigEndian);\n// outputs: True" + } + }, + { + "id": "db61efb5417ae12c98f5d55d", + "exampleId": "Cuemon.Security.Cryptography.HmacSecureHashAlgorithm512#1", + "uid": "Cuemon.Security.Cryptography.HmacSecureHashAlgorithm512", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\n\nvar secret = Encoding.UTF8.GetBytes(\"docs-secret-sha512\");\nvar algorithm = new HmacSecureHashAlgorithm512(secret, null);\nvar first = algorithm.ComputeHash(Encoding.UTF8.GetBytes(\"first\"));\nvar second = algorithm.ComputeHash(Encoding.UTF8.GetBytes(\"second\"));\n\nConsole.WriteLine(first.GetBytes().Length);\nConsole.WriteLine(!first.Equals(second));" + } + }, + { + "id": "dc303ae667b1fad5a852e79c", + "exampleId": "Cuemon.Diagnostics.TimeMeasureOptions#1", + "uid": "Cuemon.Diagnostics.TimeMeasureOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Diagnostics@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading;\nusing Cuemon.Diagnostics;\n\n// Configure options with a threshold\nvar options = new TimeMeasureOptions\n{\n TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(100)\n};\n\n// Use with TimeMeasure to profile an action\nvar profiler = TimeMeasure.WithAction(() =>\n{\n // Simulate work\n Thread.Sleep(50);\n}, setup: o =>\n{\n o.TimeMeasureCompletedThreshold = TimeSpan.FromMilliseconds(100);\n});\n\n// The CompletedCallback will be invoked if elapsed time >= threshold\nConsole.WriteLine($\"Elapsed: {profiler.Elapsed}\");" + } + }, + { + "id": "dcebc1c971522db2f8fdf030", + "exampleId": "Cuemon.Reflection.MethodDescriptor#1", + "uid": "Cuemon.Reflection.MethodDescriptor", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing System.Reflection;\nusing Cuemon.Reflection;\n\n // Create a MethodDescriptor from a MethodInfo.\n MethodInfo methodInfo = typeof(string).GetMethod(\"IndexOf\",\n new[] { typeof(string), typeof(StringComparison) });\n var descriptor = new MethodDescriptor(methodInfo);\n\n Console.WriteLine(\"Caller: {0}\", descriptor.Caller.FullName); // System.String\n Console.WriteLine(\"Method: {0}\", descriptor.MethodName); // IndexOf\n Console.WriteLine(\"Signature: {0}\", descriptor.ToString(true));\n // Output: System.String.IndexOf(String value, StringComparison comparisonType)\n\n // List all parameters.\n Console.WriteLine(\"Parameters:\");\n foreach (var param in descriptor.Parameters)\n {\n Console.WriteLine(\" {0} {1}\", param.ParameterType.Name, param.ParameterName);\n\n // Append runtime arguments for debugging or logging.\n descriptor.AppendRuntimeArguments(\"Hello\", StringComparison.OrdinalIgnoreCase);\n Console.WriteLine(\"Runtime arguments:\");\n foreach (var kvp in descriptor.RuntimeArguments)\n {\n Console.WriteLine(\" {0} = {1}\", kvp.Key, kvp.Value);\n\n // Static factory method.\n var fromFactory = MethodDescriptor.Create(\n typeof(Math).GetMethod(\"Max\", new[] { typeof(int), typeof(int) }));\n Console.WriteLine(\"Factory: {0}\", fromFactory.ToString(false));\n\n // Merge parameters with runtime values.\n var merged = MethodDescriptor.MergeParameters(\n new[] {\n new ParameterSignature(typeof(string), \"input\"),\n new ParameterSignature(typeof(int), \"count\")\n },\n \"test\", 3);\n Console.WriteLine(\"Merged: input={0}, count={1}\", merged[\"input\"], merged[\"count\"]);\n\n}}" + } + }, + { + "id": "ddf6e88746e4103ae34f2222", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.HeaderDictionaryExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Http.HeaderDictionaryExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing System.Net.Http.Headers;\nusing Cuemon.Extensions.AspNetCore.Http;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.Primitives;\n\nvar headers = new HeaderDictionary();\n\n// Add or update a single header\nheaders.AddOrUpdateHeader(\"X-Custom\", new StringValues(\"my-value\"));\n\n// Add or update multiple headers from an HttpResponseHeaders collection\nvar responseMessage = new HttpResponseMessage();\nresponseMessage.Headers.Add(\"X-Trace\", \"abc123\");\nresponseMessage.Headers.Add(\"X-Session\", \"session-456\");\n\nheaders.AddOrUpdateHeaders(responseMessage.Headers);\n\n// Verify headers\nConsole.WriteLine(headers[\"X-Custom\"]); // my-value\nConsole.WriteLine(headers[\"X-Trace\"]); // abc123\nConsole.WriteLine(headers[\"X-Session\"]); // session-456" + } + }, + { + "id": "de1f2e1db2c942a856cf8498", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.HttpRequestExtensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Http.HttpRequestExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing System.Collections.Generic;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Extensions.AspNetCore.Http;\nusing Cuemon.Security;\nusing Microsoft.AspNetCore.Http;\n\nvar context = new DefaultHttpContext();\nvar request = context.Request;\n\nrequest.Headers[\"Accept\"] = \"text/html;q=0.8, application/json;q=0.9, */*;q=0.1\";\nIEnumerable preferredTypes = request.AcceptMimeTypesOrderedByQuality();\nConsole.WriteLine(string.Join(\", \", preferredTypes));\n\nrequest.Method = \"GET\";\nConsole.WriteLine(request.IsGetOrHeadMethod());\n\nrequest.Method = \"POST\";\nConsole.WriteLine(request.IsGetOrHeadMethod());\n\nrequest.Method = \"GET\";\nrequest.Headers[\"If-None-Match\"] = \"\\\"abc123\\\"\";\nvar checksumBuilder = new ChecksumBuilder(() => HashFactory.CreateFnv128());\nchecksumBuilder.CombineWith(Encoding.UTF8.GetBytes(\"content-data\"));\nConsole.WriteLine(request.IsClientSideResourceCached(checksumBuilder));\n\nrequest.Headers[\"If-Modified-Since\"] = \"Tue, 15 Jun 2024 10:00:00 GMT\";\nvar lastModified = new DateTime(2024, 6, 15, 9, 0, 0, DateTimeKind.Utc);\nConsole.WriteLine(request.IsClientSideResourceCached(lastModified));" + } + }, + { + "id": "de32d97f5e42e87b0ed99e98", + "exampleId": "Cuemon.Collections.Generic.DynamicEqualityComparer#1", + "uid": "Cuemon.Collections.Generic.DynamicEqualityComparer", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon.Collections.Generic;\n\nstring[] words = [\"Hello\", \"world\", \"hello\", \"World\", \"HELLO\"];\n\n// Create a case-insensitive equality comparer for strings\nIEqualityComparer caseInsensitive = DynamicEqualityComparer.Create(\n hashCalculator: s => StringComparer.OrdinalIgnoreCase.GetHashCode(s),\n equalityComparer: (x, y) => string.Equals(x, y, StringComparison.OrdinalIgnoreCase));\n\nstring[] distinct = words.Distinct(caseInsensitive).ToArray();\nConsole.WriteLine(string.Join(\", \", distinct));" + } + }, + { + "id": "de55cb16d8fff5f20a41a219", + "exampleId": "Cuemon.Extensions.Runtime.HierarchyOptions#1", + "uid": "Cuemon.Extensions.Runtime.HierarchyOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.Extensions.Runtime;\n\n// Direct instantiation of HierarchyOptions\nvar hierarchyOptions = new HierarchyOptions\n{\n MaxDepth = 2,\n SkipPropertyType = t => t == typeof(string) || t.IsValueType\n};\n\nvar source = new\n{\n Name = \"Root\",\n Value = 42,\n Nested = new\n {\n Deep = new\n {\n Deeper = \"found\"\n }\n }\n};\n\n// Limit depth to 2 and skip string types\nvar hierarchy = Hierarchy.GetObjectHierarchy(source, o =>\n{\n o.MaxDepth = 2;\n o.SkipPropertyType = t => t == typeof(string) || t.IsValueType;\n});\n\nvar root = hierarchy;\nConsole.WriteLine($\"Root type: {root.InstanceType.Name}\"); // Anonymous type\n\nvar children = root.GetChildren().ToList();\nConsole.WriteLine($\"Children count: {children.Count}\"); // 0 (all primitive types skipped)" + } + }, + { + "id": "dea7db6ff31f2171b63e9110", + "exampleId": "Cuemon.Reflection.ManifestResourceMatch#1", + "uid": "Cuemon.Reflection.ManifestResourceMatch", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Reflection;\n\nvar match = ManifestResourceMatch.Extension;\n\nswitch (match)\n{\n case ManifestResourceMatch.Name:\n Console.WriteLine(\"Match by exact resource name.\");\n break;\n case ManifestResourceMatch.ContainsName:\n Console.WriteLine(\"Match by partial name match.\");\n break;\n case ManifestResourceMatch.Extension:\n Console.WriteLine(\"Match by file extension (e.g., .json).\");\n break;\n case ManifestResourceMatch.ContainsExtension:\n Console.WriteLine(\"Match by partial extension match.\");\n break;\n\n}" + } + }, + { + "id": "ded1637126f62de68fe51c12", + "exampleId": "Cuemon.Net.Http.HttpWatcher#1", + "uid": "Cuemon.Net.Http.HttpWatcher", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Net.Http;\n\nvar watcher = new HttpWatcher(new Uri(\"https://example.com/feed\"), options =>\n{\n options.ReadResponseBody = true;\n options.Period = TimeSpan.FromSeconds(10);\n});\n\nConsole.WriteLine(watcher.Location);\nConsole.WriteLine(watcher.ReadResponseBody);\nConsole.WriteLine(watcher.HashFactory != null);" + } + }, + { + "id": "dedd4508c5725f81d3680da2", + "exampleId": "Cuemon.ExceptionInsights#1", + "uid": "Cuemon.ExceptionInsights", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Reflection;\nusing Cuemon;\n\ntry\n{\n throw new InvalidOperationException(\"Something went wrong.\");\n}\ncatch (InvalidOperationException ex)\n{\n // Enrich the exception with thread and environment information\n ExceptionInsights.Embed(ex,\n runtimeParameters: new object[] { \"param1\", 42 },\n snapshots: SystemSnapshots.CaptureThreadInfo | SystemSnapshots.CaptureEnvironmentInfo);\n\n // The enriched exception now has embedded insight data in its Data dictionary\n Console.WriteLine(ex.Data.Contains(ExceptionInsights.Key)\n ? \"Insights embedded successfully.\"\n : \"No insights available.\");\n}" + } + }, + { + "id": "df2e30c119abdf2a5e231072", + "exampleId": "Cuemon.Data.Integrity.FileIntegrityOptions#1", + "uid": "Cuemon.Data.Integrity.FileIntegrityOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Security;\nusing MyApp.Examples;\n\nnew FileIntegrityOptionsExample().Demonstrate();\n\nnamespace MyApp.Examples\n{\n public sealed class FileIntegrityOptionsExample\n {\n public void Demonstrate()\n {\n var defaults = new FileIntegrityOptions();\n Console.WriteLine($\"Default bytes to read: {defaults.BytesToRead}\");\n\n var path = Path.Combine(AppContext.BaseDirectory, \"sample.dat\");\n File.WriteAllText(path, \"Hello, World!\");\n\n try\n {\n IDataIntegrity integrity = DataIntegrityFactory.CreateIntegrity(new FileInfo(path), options =>\n {\n options.BytesToRead = 8;\n options.IntegrityConverter = (file, bytes) => new FilePreviewIntegrity(file.Name, bytes);\n });\n\n Console.WriteLine($\"Checksum: {integrity.Checksum.ToHexadecimalString()}\");\n }\n finally\n {\n if (File.Exists(path)) { File.Delete(path); }\n }\n }\n\n private sealed class FilePreviewIntegrity : IDataIntegrity\n {\n public FilePreviewIntegrity(string fileName, byte[] bytes)\n {\n FileName = fileName;\n Checksum = HashFactory.CreateFnv128().ComputeHash(bytes);\n }\n\n public string FileName { get; }\n\n public HashResult Checksum { get; }\n }\n }\n}" + } + }, + { + "id": "df9125bbac8efa37734c95c7", + "exampleId": "Cuemon.Collections.Generic.EnumerableSizeComparer`1#1", + "uid": "Cuemon.Collections.Generic.EnumerableSizeComparer`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing Cuemon.Collections.Generic;\n\nvar shortList = new[] { 10, 20, 30 };\nvar longList = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };\nvar equalList = new[] { \"x\", \"y\", \"z\" };\n\nvar comparer = EnumerableSizeComparer.Default;\n\nint result1 = comparer.Compare(shortList, longList); // -1 (shortList has fewer elements)\nint result2 = comparer.Compare(longList, shortList); // 1 (longList has more elements)\nint result3 = comparer.Compare(shortList, equalList); // 0 (both have 3 elements)\nint result4 = comparer.Compare(null, longList); // -1 (null is less than any non-null)\nint result5 = comparer.Compare(shortList, null); // 1 (non-null is greater than null)\n\nConsole.WriteLine($\"shortList vs longList : {result1}\");\nConsole.WriteLine($\"longList vs shortList : {result2}\");\nConsole.WriteLine($\"shortList vs equalList: {result3}\");\nConsole.WriteLine($\"null vs longList : {result4}\");\nConsole.WriteLine($\"shortList vs null : {result5}\");" + } + }, + { + "id": "e028d11cd6c2e90b7827f043", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorDecoratorExtensions#1", + "uid": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.AspNetCore.Http;\nusing Cuemon.Diagnostics;\nusing Microsoft.AspNetCore.Mvc;\nusing Cuemon.AspNetCore.Diagnostics;\n\nvar descriptor = new HttpExceptionDescriptor(new BadRequestException())\n{\n CorrelationId = \"corr-42\",\n RequestId = \"req-42\",\n TraceId = \"trace-42\"\n};\n\nProblemDetails problem = Decorator.Enclose(descriptor).ToProblemDetails(FaultSensitivityDetails.None);\nConsole.WriteLine(problem.Title);" + } + }, + { + "id": "e0724bf05a90cdb3db53e167", + "exampleId": "Cuemon.AspNetCore.Http.Headers.RequestIdentifierOptions#1", + "uid": "Cuemon.AspNetCore.Http.Headers.RequestIdentifierOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Messaging;\nusing Cuemon.AspNetCore.Http.Headers;\n\n var options = new RequestIdentifierOptions\n{\n Token = new RequestToken(\"req-42\")\n};\n\noptions.ValidateOptions();\nConsole.WriteLine(options.Token.RequestId);" + } + }, + { + "id": "e0adcbaa31b1dd7e8b402da4", + "exampleId": "Cuemon.IO.StreamDecoratorExtensions#1", + "uid": "Cuemon.IO.StreamDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing System.IO;\nusing System.Text;\nusing System.Threading.Tasks;\nusing Cuemon;\nusing Cuemon.IO;\n\n// ---- InvokeToByteArray: convert stream to byte array ----\nvar source0 = new MemoryStream(Encoding.UTF8.GetBytes(\"Invoke test.\"));\nDecorator.Enclose(source0).InvokeToByteArray();\n\n// ---- ToByteArray: convert stream to byte array ----\nvar source1 = new MemoryStream(Encoding.UTF8.GetBytes(\"Hello, World!\"));\nbyte[] bytes = Decorator.Enclose(source1).ToByteArray();\nConsole.WriteLine($\"Byte array length: {bytes.Length}\"); // 13\n\n// ---- ToByteArrayAsync: async version ----\nvar source2 = new MemoryStream(Encoding.UTF8.GetBytes(\"Async bytes.\"));\nbyte[] asyncBytes = await Decorator.Enclose(source2).ToByteArrayAsync();\nConsole.WriteLine($\"Async bytes length: {asyncBytes.Length}\"); // 11\n\n// ---- ToEncodedString: stream to string ----\nvar source3 = new MemoryStream(Encoding.UTF8.GetBytes(\"Read me as text.\"));\nstring text = Decorator.Enclose(source3).ToEncodedString(setup =>\n{\n setup.LeaveOpen = true;\n});\nConsole.WriteLine(text); // Read me as text.\n\n// ---- ToEncodedStringAsync: async stream to string ----\nsource3.Position = 0;\nstring textAsync = await Decorator.Enclose(source3).ToEncodedStringAsync(setup =>\n{\n setup.LeaveOpen = true;\n});\nConsole.WriteLine(textAsync); // Read me as text.\n\n// ---- CopyStreamAsync: async copy to destination stream ----\nvar source4 = new MemoryStream(Encoding.UTF8.GetBytes(\"Copy me.\"));\nusing var destination = new MemoryStream();\nawait Decorator.Enclose(source4).CopyStreamAsync(destination, bufferSize: 8192, changePosition: true);\nConsole.WriteLine($\"Destination length: {destination.Length}\"); // 8\n\n// ---- CopyStream: synchronous copy ----\nvar source4b = new MemoryStream(Encoding.UTF8.GetBytes(\"Sync copy.\"));\nusing var dest4b = new MemoryStream();\nDecorator.Enclose(source4b).CopyStream(dest4b);\nConsole.WriteLine($\"Sync copy length: {dest4b.Length}\"); // 9\n\n// ---- CompressGZip / DecompressGZip ----\nvar source5 = new MemoryStream(Encoding.UTF8.GetBytes(\"GZip compress this.\"));\nusing var gzipCompressed = Decorator.Enclose(source5).CompressGZip();\nConsole.WriteLine($\"GZip compressed size: {gzipCompressed.Length}\");\ngzipCompressed.Position = 0;\nvar gzipDecompressed = Decorator.Enclose(gzipCompressed).DecompressGZip();\nvar gzipText = await Decorator.Enclose(gzipDecompressed).ToEncodedStringAsync();\nConsole.WriteLine(gzipText); // GZip compress this.\n\n// ---- CompressGZipAsync / DecompressGZipAsync ----\nvar source5b = new MemoryStream(Encoding.UTF8.GetBytes(\"Async GZip test.\"));\nvar gzipCompressedAsync = await Decorator.Enclose(source5b).CompressGZipAsync();\nvar gzipDecompressedAsync = await Decorator.Enclose(gzipCompressedAsync).DecompressGZipAsync();\nvar gzipAsyncText = await Decorator.Enclose(gzipDecompressedAsync).ToEncodedStringAsync();\nConsole.WriteLine(gzipAsyncText); // Async GZip test.\n\n// ---- CompressDeflate / DecompressDeflate (sync) ----\nvar source6 = new MemoryStream(Encoding.UTF8.GetBytes(\"Deflate test.\"));\nusing var deflated = Decorator.Enclose(source6).CompressDeflate();\ndeflated.Position = 0;\nvar deflatedResult = Decorator.Enclose(deflated).DecompressDeflate();\nvar deflateText = await Decorator.Enclose(deflatedResult).ToEncodedStringAsync();\nConsole.WriteLine(deflateText); // Deflate test.\n\n// ---- CompressDeflateAsync / DecompressDeflateAsync ----\nvar source6b = new MemoryStream(Encoding.UTF8.GetBytes(\"Async Deflate.\"));\nvar deflatedAsync = await Decorator.Enclose(source6b).CompressDeflateAsync();\nvar deflatedDecompAsync = await Decorator.Enclose(deflatedAsync).DecompressDeflateAsync();\nvar deflateAsyncText = await Decorator.Enclose(deflatedDecompAsync).ToEncodedStringAsync();\nConsole.WriteLine(deflateAsyncText); // Async Deflate.\n\n// ---- ToByteArrayAsync / ToEncodedStringAsync (async byte/string conversion) ----\nvar sourceBytes = new MemoryStream(Encoding.UTF8.GetBytes(\"Async byte conversion.\"));\nvar bytesAsync = await Decorator.Enclose(sourceBytes).ToByteArrayAsync(o => o.LeaveOpen = true);\nConsole.WriteLine(bytesAsync.Length); // 22\n\nsourceBytes.Position = 0;\nvar strAsync = await Decorator.Enclose(sourceBytes).ToEncodedStringAsync(o => o.LeaveOpen = true);\nConsole.WriteLine(strAsync); // Async byte conversion.\n\n// ---- CompressBrotli / DecompressBrotli (sync, netstandard2.1+ or net9.0+) ----\nvar source7 = new MemoryStream(Encoding.UTF8.GetBytes(\"Brotli test.\"));\nvar brotliCompressed = Decorator.Enclose(source7).CompressBrotli();\nbrotliCompressed.Position = 0;\nvar brotliDecompressed = Decorator.Enclose(brotliCompressed).DecompressBrotli();\nvar brotliText = await Decorator.Enclose(brotliDecompressed).ToEncodedStringAsync();\nConsole.WriteLine(brotliText); // Brotli test.\n\n// ---- CompressBrotliAsync / DecompressBrotliAsync ----\nvar source7b = new MemoryStream(Encoding.UTF8.GetBytes(\"Async Brotli.\"));\nvar brotliCompressedAsync = await Decorator.Enclose(source7b).CompressBrotliAsync();\nvar brotliDecompressedAsync = await Decorator.Enclose(brotliCompressedAsync).DecompressBrotliAsync();\nvar brotliAsyncText = await Decorator.Enclose(brotliDecompressedAsync).ToEncodedStringAsync();\nConsole.WriteLine(brotliAsyncText); // Async Brotli.\n\n// ---- WriteAllAsync: write bytes to stream ----\nvar target = new MemoryStream();\nbyte[] data = Encoding.UTF8.GetBytes(\"Write this.\");\nawait Decorator.Enclose(target).WriteAllAsync(data);\nConsole.WriteLine($\"Written bytes: {target.Length}\"); // 10" + } + }, + { + "id": "e160e2f577d47e1ce4f2d98d", + "exampleId": "Cuemon.Resilience.TransientFaultException#1", + "uid": "Cuemon.Resilience.TransientFaultException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Reflection;\nusing Cuemon.Reflection;\nusing Cuemon.Resilience;\n\nvar evidence = new TransientFaultEvidence(\n attempts: 5,\n recoveryWaitTime: TimeSpan.FromSeconds(2),\n totalRecoveryWaitTime: TimeSpan.FromSeconds(10),\n latency: TimeSpan.FromSeconds(1),\n descriptor: MethodDescriptor.Create(MethodBase.GetCurrentMethod()!));\n\nvar exception = new TransientFaultException(\"Operation failed after retries.\", evidence);\n\nConsole.WriteLine(exception.Message);\nConsole.WriteLine(exception.Evidence.Attempts);\nConsole.WriteLine(exception.Evidence.TotalRecoveryWaitTime);" + } + }, + { + "id": "e2801b6a393c7bda6967dec0", + "exampleId": "Cuemon.AspNetCore.Configuration.DynamicCacheBustingOptions#1", + "uid": "Cuemon.AspNetCore.Configuration.DynamicCacheBustingOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Configuration;\nusing Microsoft.Extensions.Options;\nusing Cuemon.AspNetCore.Configuration;\n\n var options = new DynamicCacheBustingOptions\n{\n PreferredCasing = CasingMethod.UpperCase,\n PreferredLength = 6,\n TimeToLive = TimeSpan.FromMinutes(5)\n};\n\nvar cacheBusting = new DynamicCacheBusting(Options.Create(options));\nConsole.WriteLine(cacheBusting.Version);" + } + }, + { + "id": "e40265e8d83a12a55c10245a", + "exampleId": "Cuemon.Threading.RelationalOperator#1", + "uid": "Cuemon.Threading.RelationalOperator", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.Threading;\n\nvar rules = new ForLoopRuleset(0, 10, 2, RelationalOperator.LessThan);\n\nAdvancedParallelFactory.For(rules, i =>\n{\n Console.WriteLine($\"Processing iteration: {i}\");\n});" + } + }, + { + "id": "e42820e117d0c9c78b0b235b", + "exampleId": "Cuemon.AspNetCore.Diagnostics.ServerTiming#1", + "uid": "Cuemon.AspNetCore.Diagnostics.ServerTiming", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.AspNetCore.Diagnostics;\n\n var timing = new ServerTiming();\ntiming.AddServerTiming(\"db\", TimeSpan.FromMilliseconds(12), \"SQL query\");\n\nvar metric = timing.Metrics.First();\nConsole.WriteLine($\"{metric.Name}:{metric.Duration}\");" + } + }, + { + "id": "e42d326ddb523935687d1402", + "exampleId": "Cuemon.Extensions.Net.Security.SignedUriOptions#1", + "uid": "Cuemon.Extensions.Net.Security.SignedUriOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.Net.Security;\nusing Cuemon.Security.Cryptography;\n\nvar options = new SignedUriOptions\n{\n Algorithm = KeyedCryptoAlgorithm.HmacSha256,\n SignatureFieldName = \"sig\",\n StartFieldName = \"st\",\n ExpiryFieldName = \"se\",\n UrlEncode = true\n};\n\nConsole.WriteLine(options.Algorithm);\nConsole.WriteLine(options.SignatureFieldName);\nConsole.WriteLine(options.UrlEncode);" + } + }, + { + "id": "e4505be4d29a05cf0dff5dd3", + "exampleId": "Cuemon.Extensions.Xml.Linq.StringExtensions#1", + "uid": "Cuemon.Extensions.Xml.Linq.StringExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Xml.Linq;\nusing Cuemon.Extensions.Xml.Linq;\n\nstring xml = \"Value\";\n\n// Try to parse the XML string into an XElement\nif (xml.TryParseXElement(out XElement element))\n{\n Console.WriteLine(element.Name); // root\n Console.WriteLine(element.Element(\"item\")?.Value); // Value\n\n// Check if a string is valid XML\nbool isValid = xml.IsXmlString();\nConsole.WriteLine(isValid); // True\n\n// Invalid XML returns false\nstring invalid = \"\";\nbool isInvalid = invalid.IsXmlString();\nConsole.WriteLine(isInvalid); // False\n\n}" + } + }, + { + "id": "e67ee4017482d99c116136a0", + "exampleId": "Cuemon.Extensions.Collections.Specialized.NameValueCollectionExtensions#1", + "uid": "Cuemon.Extensions.Collections.Specialized.NameValueCollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Collections.Specialized@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Collections.Specialized;\nusing Cuemon;\nusing Cuemon.Extensions.Collections.Specialized;\n\n// Create a NameValueCollection with some query parameters\nvar nvc = new NameValueCollection\n{\n { \"name\", \"John Doe\" },\n { \"tag\", \"dotnet\" },\n { \"tag\", \"csharp\" }\n};\n\n// Check if a key exists (case-insensitive)\nbool hasName = nvc.ContainsKey(\"NAME\");\nConsole.WriteLine(hasName); // True\n\nbool hasMissing = nvc.ContainsKey(\"missing\");\nConsole.WriteLine(hasMissing); // False\n\n// Convert to a dictionary with string[] values\nIDictionary dict = nvc.ToDictionary();\n\nConsole.WriteLine(dict[\"name\"][0]); // \"John Doe\"\nConsole.WriteLine(dict[\"tag\"][0]); // \"dotnet\"\nConsole.WriteLine(dict[\"tag\"][1]); // \"csharp\"\n\n// Use a custom delimiter for splitting values\nvar nvcSemicolon = new NameValueCollection\n{\n { \"items\", \"a;b;c\" }\n};\n\nIDictionary dictSemicolon = nvcSemicolon.ToDictionary(o =>\n{\n o.Delimiter = \";\";\n});\n\nConsole.WriteLine(dictSemicolon[\"items\"].Length); // 3" + } + }, + { + "id": "e6c441a1a44682b3077c0dfe", + "exampleId": "Cuemon.AspNetCore.Http.Int32DecoratorExtensions#1", + "uid": "Cuemon.AspNetCore.Http.Int32DecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Cuemon.AspNetCore.Http;\n\nint statusCode = 500;\n\n// Wrap the int in a Decorator and use the extension methods\nvar decorator = Decorator.Enclose(statusCode);\n\nbool isInfo = decorator.IsInformationStatusCode();\nbool isSuccess = decorator.IsSuccessStatusCode();\nbool isRedirect = decorator.IsRedirectionStatusCode();\nbool isClientError = decorator.IsClientErrorStatusCode();\nbool isServerError = decorator.IsServerErrorStatusCode();\nbool isNotModified = decorator.IsNotModifiedStatusCode();\n\nConsole.WriteLine($\"HTTP {statusCode}:\");\nConsole.WriteLine($\" Informational (100-199): {isInfo}\");\nConsole.WriteLine($\" Successful (200-299): {isSuccess}\");\nConsole.WriteLine($\" Redirection (300-399): {isRedirect}\");\nConsole.WriteLine($\" Client Error (400-499): {isClientError}\");\nConsole.WriteLine($\" Server Error (500-599): {isServerError}\");\nConsole.WriteLine($\" Not Modified (304): {isNotModified}\");\n\n// Use with a success status code\nint ok = 200;\nvar okDecorator = Decorator.Enclose(ok);\nConsole.WriteLine($\"\\n{ok} is success: {okDecorator.IsSuccessStatusCode()}\"); // True\nConsole.WriteLine($\"404 is client error: {Decorator.Enclose(404).IsClientErrorStatusCode()}\"); // True" + } + }, + { + "id": "e6e487eb8bf31e471a681057", + "exampleId": "Cuemon.Extensions.Threading.Tasks.TaskExtensions#1", + "uid": "Cuemon.Extensions.Threading.Tasks.TaskExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Threading@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading.Tasks;\nusing Cuemon.Extensions.Threading.Tasks;\n\nawait Task.Delay(10).ContinueWithCapturedContext();\nawait Task.Delay(10).ContinueWithSuppressedContext();\n\nvar captured = await Task.FromResult(42).ContinueWithCapturedContext();\nvar suppressed = await Task.FromResult(42).ContinueWithSuppressedContext();\n\nConsole.WriteLine(captured);\nConsole.WriteLine(suppressed);" + } + }, + { + "id": "e72ce3328f2222abe30fa1ac", + "exampleId": "Cuemon.Collections.Generic.StackDecoratorExtensions#1", + "uid": "Cuemon.Collections.Generic.StackDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon;\nusing Cuemon.Collections.Generic;\n\nvar stack = new Stack();\nstack.Push(\"first\");\nstack.Push(\"second\");\nstack.Push(\"third\");\n\n#if NETFRAMEWORK || NETSTANDARD2_0_OR_GREATER\nvar decorator = Decorator.Enclose(stack);\nwhile (decorator.TryPop(out string result))\n{\n Console.WriteLine(\"Popped: \" + result);\n}\nConsole.WriteLine(\"Stack is now empty\");\n#else\nwhile (stack.Count > 0)\n{\n Console.WriteLine(\"Popped: \" + stack.Pop());\n}\nConsole.WriteLine(\"Stack is now empty\");\n#endif" + } + }, + { + "id": "e76b7e41242ac6868f1f3008", + "exampleId": "Cuemon.Extensions.Text.Json.Formatters.JsonFormatter#1", + "uid": "Cuemon.Extensions.Text.Json.Formatters.JsonFormatter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0", + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text.Json.Serialization.Metadata;\nusing Cuemon;\nusing Cuemon.IO;\nusing Cuemon.Extensions.Text.Json.Formatters;\nusing MyApp.Examples;\n\nnew Example().Run();\n\nnamespace MyApp.Examples\n{\n public record Product(int Id, string Name, decimal Price);\n public class Example\n {\n public void Run()\n {\n // Create a JsonFormatter with default settings\n var formatter = new JsonFormatter(o => o.Settings.TypeInfoResolver = new DefaultJsonTypeInfoResolver());\n\n // Serialize an object to a stream\n var product = new Product(1, \"Wireless Mouse\", 29.99m);\n using var jsonStream = formatter.Serialize(product, typeof(Product));\n\n // Read the JSON string (leave the stream open for reuse)\n Console.WriteLine(\"Serialized JSON:\");\n Console.WriteLine(Decorator.Enclose(jsonStream).ToEncodedString(o => o.LeaveOpen = true));\n\n // Reset position and deserialize from the same stream\n jsonStream.Position = 0;\n var deserialized = (Product)formatter.Deserialize(jsonStream, typeof(Product));\n Console.WriteLine($\"Deserialized: Id={deserialized.Id}, Name={deserialized.Name}, Price={deserialized.Price}\");\n\n // Use static convenience methods\n using var json = JsonFormatter.SerializeObject(product, o => o.Settings.TypeInfoResolver = new DefaultJsonTypeInfoResolver());\n json.Position = 0;\n Console.WriteLine($\"Static round-trip: {JsonFormatter.DeserializeObject(json, o => o.Settings.TypeInfoResolver = new DefaultJsonTypeInfoResolver()).Name}\");\n\n }\n }\n}" + } + }, + { + "id": "e8328d9b8eef1bc11a24482b", + "exampleId": "Cuemon.Decorator#1", + "uid": "Cuemon.Decorator", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\nvar wrappedString = Decorator.Enclose(\"Hello, World!\");\nConsole.WriteLine(wrappedString.Inner); // \"Hello, World!\"\nConsole.WriteLine(wrappedString.ArgumentName); // \"\"\n\nvar withArg = Decorator.EncloseToExpose(\"test\", argumentName: \"myArg\");\nConsole.WriteLine(withArg.ArgumentName); // \"myArg\"\n\nvar syntactic = Decorator.Syntactic();\nConsole.WriteLine(syntactic.Inner); // \"01-01-0001 00:00:00\" (default(DateTime))\n\nvar raw = Decorator.RawEnclose(null);\nConsole.WriteLine(raw.Inner is null); // True" + } + }, + { + "id": "e8877b9842aaa91c8e5bbfa0", + "exampleId": "Cuemon.Data.DataReaderDecoratorExtensions#1", + "uid": "Cuemon.Data.DataReaderDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Data;\nusing System.IO;\nusing System.Threading.Tasks;\nusing Cuemon;\nusing Cuemon.Data;\n\nvar table = new DataTable();\ntable.Columns.Add(\"Value\", typeof(string));\ntable.Rows.Add(\"1001\");\ntable.Rows.Add(\"1002\");\ntable.Rows.Add(\"1003\");\n\nusing (var reader = table.CreateDataReader())\n{\n string result = Decorator.Enclose((IDataReader)reader).ToEncodedString();\n Console.WriteLine(result);\n}\n\nusing (var asyncReader = table.CreateDataReader())\n{\n string asyncResult = await Decorator.Enclose((IDataReader)asyncReader).ToEncodedStringAsync();\n Console.WriteLine(asyncResult);\n}\n\nusing (var streamReader = table.CreateDataReader())\n{\n Stream dataStream = Decorator.Enclose((IDataReader)streamReader).ToStream();\n Console.WriteLine($\"Stream length: {dataStream.Length}\");\n}" + } + }, + { + "id": "e8b4a308a70933793d69cfa7", + "exampleId": "Cuemon.MutableTuple`1#1", + "uid": "Cuemon.MutableTuple`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\nvar tuple = new MutableTuple(\"example\");\nConsole.WriteLine(tuple.Arg1); // \"example\"\n\ntuple.Arg1 = \"updated\";\nConsole.WriteLine(tuple.Arg1); // \"updated\"" + } + }, + { + "id": "e99519768547ebea5218730b", + "exampleId": "Cuemon.AspNetCore.Authentication.Digest.DigestFields#1", + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestFields", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Authentication.Digest;\n\nvar builder = new DigestAuthorizationHeaderBuilder(DigestCryptoAlgorithm.Sha256);\nbuilder.AddRealm(\"my-realm\");\nbuilder.AddUserName(\"alice\");\nbuilder.AddUri(\"/api/resource\");\nbuilder.AddNc(1);\nbuilder.AddCnonce(Guid.NewGuid().ToString(\"N\"));\n\nConsole.WriteLine(DigestFields.Realm);\nConsole.WriteLine(DigestFields.Nonce);\nConsole.WriteLine(DigestFields.QualityOfProtection);" + } + }, + { + "id": "e9c63f5c6611f7f0b083e106", + "exampleId": "Cuemon.AspNetCore.Http.HttpContextDecoratorExtensions#1", + "uid": "Cuemon.AspNetCore.Http.HttpContextDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Net;\nusing System.Net.Http;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Cuemon;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.AspNetCore.Http.Headers;\nusing Cuemon.AspNetCore.Http.Throttling;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Net.Http.Headers;\nusing HttpMediaTypeHeaderValue = System.Net.Http.Headers.MediaTypeHeaderValue;\nusing Cuemon.AspNetCore.Http;\n\nvar context = new DefaultHttpContext();\ncontext.Request.Headers[\"X-Api-Key\"] = \"secret-key\";\ncontext.Request.Headers[HeaderNames.UserAgent] = \"Cuemon Docs\";\n\nvar throttlingOptions = new ThrottlingSentinelOptions\n{\n ContextResolver = _ => \"client-1\",\n Quota = new ThrottleQuota(2, TimeSpan.FromMinutes(1))\n};\n\nawait Decorator.Enclose(context).InvokeThrottlerSentinelAsync(new MemoryThrottlingCache(), throttlingOptions);\n\nvar apiKeyOptions = new ApiKeySentinelOptions\n{\n AllowedKeys = new List { \"secret-key\" }\n};\n\nawait Decorator.Enclose(context).InvokeApiKeySentinelAsync(apiKeyOptions);\n\nvar userAgentOptions = new UserAgentSentinelOptions();\nawait Decorator.Enclose(context).InvokeUserAgentSentinelAsync(userAgentOptions);\n\nvar handler = new HttpExceptionDescriptorResponseHandler(\n new HttpMediaTypeHeaderValue(\"text/plain\"),\n exceptionDescriptor => new HttpResponseMessage((HttpStatusCode)exceptionDescriptor.StatusCode)\n {\n Content = new StringContent(exceptionDescriptor.Message)\n });\n\nvar descriptor = new HttpExceptionDescriptor(new InvalidOperationException(\"Bad request\"), StatusCodes.Status400BadRequest);\nawait Decorator.Enclose(context).WriteExceptionDescriptorResponseAsync(handler, descriptor, CancellationToken.None);\n\nConsole.WriteLine(context.Response.StatusCode);" + } + }, + { + "id": "ea4b05b305fc02f38f80b08a", + "exampleId": "Cuemon.IO.TextReaderDecoratorExtensions#1", + "uid": "Cuemon.IO.TextReaderDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System.Text;\nusing System;\nusing System.IO;\nusing System.Threading.Tasks;\nusing Cuemon;\nusing Cuemon.IO;\n\nstring source = \"Line 1\\nLine 2\\nLine 3\\n\";\n\n// Copy content from a TextReader to a TextWriter asynchronously\nusing var reader = new StringReader(source);\nusing var writer = new StringWriter();\n\nawait Decorator.Enclose(reader).CopyToAsync(writer);\n\nstring result = writer.ToString();\nConsole.WriteLine(result); // \"Line 1\\nLine 2\\nLine 3\\n\"\n\n// Use a custom buffer size\nusing var readerSmallBuffer = new StringReader(source);\nusing var writerSmallBuffer = new StringWriter();\n\nawait Decorator.Enclose(readerSmallBuffer).CopyToAsync(writerSmallBuffer, bufferSize: 1024);\n\nstring resultSmallBuffer = writerSmallBuffer.ToString();\nConsole.WriteLine(resultSmallBuffer); // \"Line 1\\nLine 2\\nLine 3\\n\"\n\n// Copy between different TextReader/TextWriter types\nusing var streamReader = new StreamReader(new MemoryStream(\n Encoding.UTF8.GetBytes(\"Stream content\")));\nusing var stringWriter = new StringWriter();\n\nawait Decorator.Enclose(streamReader).CopyToAsync(stringWriter);\nConsole.WriteLine(stringWriter.ToString()); // \"Stream content\"" + } + }, + { + "id": "ea8ea38a981d8329f9c1acc7", + "exampleId": "Cuemon.ExceptionCondition`1#1", + "uid": "Cuemon.ExceptionCondition`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing MyApp.Examples;\n\nnew ExceptionConditionExample().Demonstrate();\n\nnamespace MyApp.Examples\n{\n public class ExceptionConditionExample\n {\n public void Demonstrate()\n {\n // Throw InvalidOperationException only when a condition is true\n var invoker = new ExceptionCondition()\n .IsTrue(() => DateTime.Now.DayOfWeek == DayOfWeek.Monday)\n .Create(() => new InvalidOperationException(\"Cannot run this operation on Mondays.\"));\n\n // If today is Monday, TryThrow will throw InvalidOperationException\n // If today is not Monday, TryThrow does nothing\n try\n {\n invoker.TryThrow();\n }\n catch (InvalidOperationException ex)\n {\n Console.WriteLine(ex.Message);\n }\n\n // Throw ArgumentException only when a condition is false\n var falseInvoker = new ExceptionCondition()\n .IsFalse(() => Environment.UserName == \"admin\")\n .Create(() => new ArgumentException(\"Only admin can call this method.\"));\n\n try\n {\n falseInvoker.TryThrow();\n }\n catch (ArgumentException ex)\n {\n Console.WriteLine(ex.Message);\n }\n\n // Use the TesterFunc overload to pass data to the exception\n TesterFunc tryGetValue = (out string value) =>\n {\n value = \"cached-data\";\n return true; // data exists\n };\n\n var dataInvoker = new ExceptionCondition()\n .IsTrue(tryGetValue)\n .Create(data => new InvalidOperationException(\n $\"Value '{data}' has expired. Please refresh.\"));\n\n // Since condition returns true, this throws\n try\n {\n dataInvoker.TryThrow();\n }\n catch (InvalidOperationException ex)\n {\n Console.WriteLine(ex.Message);\n }\n\n }\n }\n}" + } + }, + { + "id": "eb06a734e14fd73cde88b074", + "exampleId": "Cuemon.DelimitedString#1", + "uid": "Cuemon.DelimitedString", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Globalization;\nusing Cuemon;\n\nvar numbers = new[] { 1, 2, 3, 4, 5 };\nstring csv = DelimitedString.Create(numbers, o =>\n{\n o.Delimiter = \",\";\n o.StringConverter = value => value.ToString();\n});\nConsole.WriteLine(csv); // \"1,2,3,4,5\"\n\nstring[] parts = DelimitedString.Split(csv, o =>\n{\n o.Delimiter = \",\";\n});\nConsole.WriteLine(string.Join(\" | \", parts)); // \"1 | 2 | 3 | 4 | 5\"" + } + }, + { + "id": "eb2672f67d28cd9e77131c03", + "exampleId": "Cuemon.Net.Http.HttpMethods#1", + "uid": "Cuemon.Net.Http.HttpMethods", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Net.Http;\n\nvar allowedMethods = HttpMethods.Get | HttpMethods.Post | HttpMethods.Head;\n\nConsole.WriteLine(allowedMethods.HasFlag(HttpMethods.Get));\nConsole.WriteLine(allowedMethods.HasFlag(HttpMethods.Delete));\nConsole.WriteLine(allowedMethods & ~HttpMethods.Head);" + } + }, + { + "id": "eb2848e0c0975bfa2d50261d", + "exampleId": "Cuemon.Extensions.Net.NameValueCollectionExtensions#1", + "uid": "Cuemon.Extensions.Net.NameValueCollectionExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Specialized;\nusing Cuemon.Extensions.Net;\n\nvar nvc = new NameValueCollection\n{\n { \"name\", \"John Doe\" },\n { \"city\", \"Copenhagen\" },\n { \"hobbies\", \"reading\" },\n { \"hobbies\", \"coding\" }\n};\n\n// Convert NameValueCollection to a query string (not URL-encoded)\nstring queryString = nvc.ToQueryString();\nConsole.WriteLine(queryString);\n// Output: name=John Doe&city=Copenhagen&hobbies=reading&hobbies=coding\n\n// URL-encode the values for safe HTTP transmission\nstring encoded = nvc.ToQueryString(urlEncode: true);\nConsole.WriteLine(encoded);\n// Output: name=John+Doe&city=Copenhagen&hobbies=reading&hobbies=coding\n\n// Empty collection\nvar empty = new NameValueCollection();\nstring emptyResult = empty.ToQueryString();\nConsole.WriteLine($\"Empty: '{emptyResult}'\"); // Empty: ''" + } + }, + { + "id": "ebc3994820ebf6dd1adb3a71", + "exampleId": "Cuemon.Alphanumeric#1", + "uid": "Cuemon.Alphanumeric", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\nConsole.WriteLine(Alphanumeric.Numbers); // \"0123456789\"\nConsole.WriteLine(Alphanumeric.UppercaseLetters); // \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nConsole.WriteLine(Alphanumeric.Hexadecimal); // \"0123456789ABCDEF\"\nConsole.WriteLine(Alphanumeric.PunctuationMarks); // \"!@#$%^&*()_-+=[{]};:<>|.,/?`~\\\"'\"" + } + }, + { + "id": "ecccd973a87c327f3678a3d5", + "exampleId": "Cuemon.AspNetCore.Mvc.ForbiddenObjectResult#1", + "uid": "Cuemon.AspNetCore.Mvc.ForbiddenObjectResult", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Mvc;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.Mvc;\nusing MyApp.Mvc;\n\nConsole.WriteLine(new ForbiddenObjectResultExample().Demonstrate());\n\nnamespace MyApp.Mvc\n{\n public class ForbiddenObjectResultExample\n {\n public IActionResult Demonstrate()\n {\n // Return 403 Forbidden with a diagnostic message\n var forbidden = new ForbiddenObjectResult(\n new { error = \"Insufficient permissions\", requiredRole = \"admin\" });\n\n Console.WriteLine($\"Status code: {forbidden.StatusCode}\");\n Console.WriteLine($\"Value: {forbidden.Value}\");\n\n return forbidden;\n }\n\n public IActionResult DemonstrateWithCustomStatusCode()\n {\n // Return 404 Not Found instead of 403 (to \"hide\" the resource existence)\n var hidden = new ForbiddenObjectResult(\n \"Resource not found.\",\n StatusCodes.Status404NotFound);\n\n Console.WriteLine($\"Status code: {hidden.StatusCode}\");\n\n return hidden;\n }\n }\n}" + } + }, + { + "id": "ee475f1993ba5ca6f3b40dd3", + "exampleId": "Cuemon.Extensions.Reflection.PropertyInfoExtensions#1", + "uid": "Cuemon.Extensions.Reflection.PropertyInfoExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Reflection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Reflection;\nusing Cuemon.Extensions.Reflection;\nusing MyApp.Examples;\n\nPropertyInfoExtensionsExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class PropertyInfoExtensionsExample\n {\n public static void Demonstrate()\n {\n var autoProperty = typeof(Sample).GetProperty(nameof(Sample.AutoProperty), BindingFlags.Instance | BindingFlags.Public);\n var manualProperty = typeof(Sample).GetProperty(nameof(Sample.ManualProperty), BindingFlags.Instance | BindingFlags.Public);\n\n Console.WriteLine(autoProperty.IsAutoProperty());\n Console.WriteLine(manualProperty.IsAutoProperty());\n }\n\n private sealed class Sample\n {\n private string _manual;\n\n public string AutoProperty { get; set; }\n\n public string ManualProperty\n {\n get => _manual;\n set => _manual = value ?? throw new ArgumentNullException(nameof(value));\n }\n }\n }\n}" + } + }, + { + "id": "eefd8a3b81a7571d1a5d9fde", + "exampleId": "Cuemon.Security.Cryptography.SecureHashAlgorithm1#1", + "uid": "Cuemon.Security.Cryptography.SecureHashAlgorithm1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\n\nvar algorithm = new SecureHashAlgorithm1();\nvar result = algorithm.ComputeHash(Encoding.UTF8.GetBytes(\"legacy-compatible digest\"));\n\nConsole.WriteLine(SecureHashAlgorithm1.BitSize);\nConsole.WriteLine(result.GetBytes().Length);" + } + }, + { + "id": "ef06b063c666179616129890", + "exampleId": "Cuemon.DataPair#1", + "uid": "Cuemon.DataPair", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\n// Create a generic DataPair for compile-time type safety\nvar pair = new DataPair(\"Age\", 30);\nConsole.WriteLine(pair);\n// Output: Name: Age, Value: 30, Type: Int32\n\nConsole.WriteLine(pair.Name); // Age\nConsole.WriteLine(pair.Value); // 30\nConsole.WriteLine(pair.Type); // System.Int32\nConsole.WriteLine(pair.HasValue); // True\n\n// Create a non-generic DataPair\nvar generic = new DataPair(\"CreatedAt\", DateTime.UtcNow, typeof(DateTime));\nConsole.WriteLine(generic);\n// Output: Name: CreatedAt, Value: ..., Type: DateTime\n\n// DataPair with null value\nvar nullPair = new DataPair(\"MiddleName\", null);\nConsole.WriteLine(nullPair.HasValue); // False\nConsole.WriteLine(nullPair);" + } + }, + { + "id": "ef14a96086c0b672f21e011f", + "exampleId": "Cuemon.AspNetCore.Http.Headers.ApiKeySentinelOptions#1", + "uid": "Cuemon.AspNetCore.Http.Headers.ApiKeySentinelOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing Cuemon.AspNetCore.Http.Headers;\n\n var options = new ApiKeySentinelOptions\n{\n AllowedKeys = new List { \"secret-key\" }\n};\n\noptions.ValidateOptions();\nusing var response = options.ResponseHandler(\"wrong-key\");\nvar message = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();\nConsole.WriteLine(message);" + } + }, + { + "id": "ef6cdd6cb2a12a8ef742b1f8", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.ProtocolUriScheme#1", + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.ProtocolUriScheme", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing Cuemon.AspNetCore.Razor.TagHelpers;\nusing System;\n\nvar options = new CdnTagHelperOptions\n{\n Scheme = ProtocolUriScheme.Https,\n BaseUrl = \"cdn.example.com\"\n};\n\nvar formatted = options.GetFormattedBaseUrl();\nConsole.WriteLine(formatted); // Output: https://cdn.example.com/" + } + }, + { + "id": "ef74236c0cf2bc9238bf142d", + "exampleId": "Cuemon.UnsuccessfulValue`1#1", + "uid": "Cuemon.UnsuccessfulValue`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\nusing Contoso.Calculations;\n\nUnsuccessfulValueOfTResultExample.Run();\n\nnamespace Contoso.Calculations\n{\n public sealed class UnsuccessfulValueOfTResultExample\n {\n public static void Run()\n {\n ConditionalValue outcome = Divide(10, 0);\n\n Console.WriteLine($\"Succeeded: {outcome.Succeeded}\");\n Console.WriteLine($\"Result: {outcome.Result}\");\n Console.WriteLine($\"Failure: {outcome.Failure?.GetType().Name}\");\n }\n\n private static ConditionalValue Divide(int dividend, int divisor)\n {\n if (divisor == 0)\n {\n return new UnsuccessfulValue(new DivideByZeroException(\"Cannot divide by zero.\"), -1);\n }\n\n return new SuccessfulValue(dividend / divisor);\n }\n }\n}" + } + }, + { + "id": "efa6bca934177fdf18207677", + "exampleId": "Cuemon.Data.DataStatementOptions#1", + "uid": "Cuemon.Data.DataStatementOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Data;\nusing Cuemon.Data;\n\n// Create options for a text command with default timeout (90 seconds)\nvar options = new DataStatementOptions\n{\n Type = CommandType.Text,\n Timeout = TimeSpan.FromSeconds(30)\n};\n\nConsole.WriteLine($\"Command type: {options.Type}\");\nConsole.WriteLine($\"Timeout: {options.Timeout.TotalSeconds} seconds\");\nConsole.WriteLine($\"Default timeout: {DataStatementOptions.DefaultTimeout.TotalSeconds} seconds\");\n\n// Configure for a stored procedure\nvar spOptions = new DataStatementOptions\n{\n Type = CommandType.StoredProcedure,\n Timeout = TimeSpan.FromMinutes(5),\n Parameters = Array.Empty()\n};\n\n// Validate that parameters is not null\nspOptions.ValidateOptions();\nConsole.WriteLine(\"Stored procedure options are valid.\");" + } + }, + { + "id": "f014e8b935d6c041436987ae", + "exampleId": "Cuemon.Convertible#1", + "uid": "Cuemon.Convertible", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\nbyte[] intBytes = Convertible.GetBytes(12345);\nConsole.WriteLine(intBytes.Length); // 4\nConsole.WriteLine(BitConverter.ToInt32(intBytes)); // 12345\n\nbyte[] stringBytes = Convertible.GetBytes(\"Hello\");\nConsole.WriteLine(stringBytes.Length); // 5\n\nint restored = BitConverter.ToInt32(intBytes);\nConsole.WriteLine(restored); // 12345" + } + }, + { + "id": "f04cce3d8591dbab7fecf590", + "exampleId": "Cuemon.Net.FieldValueSeparator#1", + "uid": "Cuemon.Net.FieldValueSeparator", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Net@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Net;\n\nvar separator = FieldValueSeparator.Ampersand;\n\nswitch (separator)\n{\n case FieldValueSeparator.Ampersand:\n Console.WriteLine(\"Using & separator for query string parameters (default).\");\n break;\n case FieldValueSeparator.Semicolon:\n Console.WriteLine(\"Using ; separator for query string parameters.\");\n break;\n\n}" + } + }, + { + "id": "f0efccf4e4aded40e2507d37", + "exampleId": "Cuemon.TypeArgumentException#1", + "uid": "Cuemon.TypeArgumentException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing Cuemon;\nusing Contoso.DependencyInjection;\n\nTypeArgumentExceptionExample.Run();\n\nnamespace Contoso.DependencyInjection\n{\n public sealed class TypeArgumentExceptionExample\n {\n public static void Run()\n {\n IDisposable disposable = Create();\n disposable.Dispose();\n\n try\n {\n Create();\n }\n catch (TypeArgumentException ex)\n {\n Console.WriteLine($\"{ex.ParamName}: {ex.Message}\");\n }\n }\n\n private static TService Create()\n where TImplementation : class, new()\n {\n if (!typeof(TService).IsAssignableFrom(typeof(TImplementation)))\n {\n throw new TypeArgumentException(\n nameof(TImplementation),\n $\"{typeof(TImplementation).Name} must implement {typeof(TService).Name}.\");\n }\n\n return (TService)(object)new TImplementation();\n }\n\n private sealed class Widget\n {\n }\n }\n}" + } + }, + { + "id": "f10ac0db264deb7bd03a1c1d", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Headers.ApiKeySentinelAttribute#1", + "uid": "Cuemon.AspNetCore.Mvc.Filters.Headers.ApiKeySentinelAttribute", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Mvc.Filters.Headers;\nusing Microsoft.AspNetCore.Mvc;\n\nvar attribute = new ApiKeySentinelAttribute();\n\nConsole.WriteLine(attribute.ServiceType == typeof(ApiKeySentinelFilter));\nConsole.WriteLine(attribute.IsReusable);" + } + }, + { + "id": "f111ba3a93cd78316117d884", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.Int32Extensions#1", + "uid": "Cuemon.Extensions.AspNetCore.Http.Int32Extensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.AspNetCore.Http;\n\nint statusCode = 404;\n\n// Check the status code range\nbool isInfo = statusCode.IsInformationStatusCode();\nbool isSuccess = statusCode.IsSuccessStatusCode();\nbool isRedirect = statusCode.IsRedirectionStatusCode();\nbool isClientError = statusCode.IsClientErrorStatusCode();\nbool isServerError = statusCode.IsServerErrorStatusCode();\nbool isNotModified = statusCode.IsNotModifiedStatusCode();\n\nConsole.WriteLine($\"HTTP {statusCode}:\");\nConsole.WriteLine($\" Informational: {isInfo}\");\nConsole.WriteLine($\" Success: {isSuccess}\");\nConsole.WriteLine($\" Redirection: {isRedirect}\");\nConsole.WriteLine($\" Client Error: {isClientError}\");\nConsole.WriteLine($\" Server Error: {isServerError}\");\nConsole.WriteLine($\" Not Modified: {isNotModified}\");\n\n// Use with common HTTP status codes\nint ok = 200;\nint notFound = 404;\nint serverError = 500;\n\nConsole.WriteLine($\"\\n{ok} is success: {ok.IsSuccessStatusCode()}\");\nConsole.WriteLine($\"{notFound} is client error: {notFound.IsClientErrorStatusCode()}\");\nConsole.WriteLine($\"{serverError} is server error: {serverError.IsServerErrorStatusCode()}\");" + } + }, + { + "id": "f15599ea0257bb435d4beae7", + "exampleId": "Cuemon.Collections.Generic.EnumReadOnlyDictionary`1#1", + "uid": "Cuemon.Collections.Generic.EnumReadOnlyDictionary`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System.Collections.Generic;\nusing System;\nusing System.Linq;\nusing Cuemon.Collections.Generic;\n\n// Create a dictionary that maps DayOfWeek values to their string names\nvar days = new EnumReadOnlyDictionary();\n\nConsole.WriteLine(days.Count); // 7\n\n// Iterate through all entries (keys are the underlying integral values)\nforeach (var kvp in days.OrderBy(kvp => kvp.Key.ToInt32(null)))\n{\n Console.WriteLine($\"{kvp.Key.ToInt32(null)} -> {kvp.Value}\");\n// Output:\n// 0 -> Sunday\n// 1 -> Monday\n// 2 -> Tuesday\n// 3 -> Wednesday\n// 4 -> Thursday\n// 5 -> Friday\n// 6 -> Saturday\n\n// Access the values collection directly\nforeach (var name in days.Values)\n{\n Console.WriteLine(name); // Sunday, Monday, ..., Saturday\n\n// Access the keys collection\nforeach (var key in days.Keys)\n{\n Console.WriteLine(key.ToInt32(null)); // 0, 1, 2, ..., 6\n\n}}}" + } + }, + { + "id": "f21a8d9b1358965fc5223ed8", + "exampleId": "Cuemon.Diagnostics.ExceptionDescriptorAttribute#1", + "uid": "Cuemon.Diagnostics.ExceptionDescriptorAttribute", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.Diagnostics;\nusing MyApp.Examples;\n\nExceptionDescriptorAttributeExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class ExceptionDescriptorAttributeExample\n {\n [ExceptionDescriptor(typeof(ArgumentNullException),\n Code = \"ERR_NULL_ARGUMENT\",\n Message = \"A required parameter was not provided.\",\n HelpLink = \"https://example.com/errors/null-argument\")]\n public static void ProcessOrder(string orderId)\n {\n if (orderId == null) { throw new ArgumentNullException(nameof(orderId)); }\n }\n\n public static void Demonstrate()\n {\n var attribute = (ExceptionDescriptorAttribute)Attribute\n .GetCustomAttributes(typeof(ExceptionDescriptorAttributeExample).GetMethod(nameof(ProcessOrder))!, typeof(ExceptionDescriptorAttribute))\n .Single();\n\n Console.WriteLine(attribute.FailureType.Name);\n Console.WriteLine(attribute.Code);\n Console.WriteLine(attribute.Message);\n Console.WriteLine(attribute.HelpLink);\n }\n }\n}" + } + }, + { + "id": "f28dbb695d6a3caccc6242b6", + "exampleId": "Cuemon.AspNetCore.Http.NotFoundException#1", + "uid": "Cuemon.AspNetCore.Http.NotFoundException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http;\nusing MyApp.Examples;\n\nnew NotFoundExceptionExample().Demonstrate();\n\nnamespace MyApp.Examples\n{\n public class NotFoundExceptionExample\n {\n public void Demonstrate()\n {\n try\n {\n var userId = 999;\n var user = FindUser(userId);\n if (user == null)\n {\n throw new NotFoundException($\"User with ID {userId} was not found.\");\n }\n }\n catch (NotFoundException ex)\n {\n Console.WriteLine(ex.StatusCode); // 404\n Console.WriteLine(ex.Message); // User with ID 999 was not found.\n }\n }\n\n private object FindUser(int id) => null;\n }\n}" + } + }, + { + "id": "f2c381e78849e37218bac586", + "exampleId": "Cuemon.Extensions.DependencyInjection.ServiceOptions#1", + "uid": "Cuemon.Extensions.DependencyInjection.ServiceOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.DependencyInjection@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.DependencyInjection;\nusing Microsoft.Extensions.DependencyInjection;\nusing Cuemon.Docs.Samples.DependencyInjection;\n\nServiceOptionsExample.Demonstrate();\n\nnamespace Cuemon.Docs.Samples.DependencyInjection\n{\n public static class ServiceOptionsExample\n {\n public static void Demonstrate()\n {\n var defaults = new ServiceOptions();\n Console.WriteLine(defaults.Lifetime);\n\n var registration = new ServiceOptions\n {\n Lifetime = ServiceLifetime.Singleton\n };\n\n var services = new ServiceCollection();\n services.Add(registration.Lifetime);\n\n using var provider = services.BuildServiceProvider();\n\n var first = provider.GetRequiredService();\n var second = provider.GetRequiredService();\n\n Console.WriteLine(object.ReferenceEquals(first, second));\n }\n\n public interface IMessageWriter\n {\n void Write(string message);\n }\n\n public sealed class ConsoleMessageWriter : IMessageWriter\n {\n public void Write(string message)\n {\n Console.WriteLine(message);\n }\n }\n }\n}" + } + }, + { + "id": "f302cc68d1c4e064ba355414", + "exampleId": "Cuemon.Reflection.VersionResult#1", + "uid": "Cuemon.Reflection.VersionResult", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Reflection;\n\n// Numerical version (parsable to System.Version)\nvar numeric = new VersionResult(\"1.2.3.4\");\nConsole.WriteLine($\"Value: {numeric.Value}\");\nConsole.WriteLine($\"HasAlphanumericVersion: {numeric.HasAlphanumericVersion}\");\nConsole.WriteLine($\"IsSemanticVersion: {numeric.IsSemanticVersion()}\");\n\n// Semantic/alphanumeric version (not a pure numerical version)\nvar semantic = new VersionResult(\"2.0.0-beta.1\");\nConsole.WriteLine($\"\\nValue: {semantic.Value}\");\nConsole.WriteLine($\"HasAlphanumericVersion: {semantic.HasAlphanumericVersion}\");\nConsole.WriteLine($\"IsSemanticVersion: {semantic.IsSemanticVersion()}\");\n\n// Static helper check\nvar check = VersionResult.IsSemanticVersion(\"3.0.0-rc.1\");\nConsole.WriteLine($\"\\nIs '3.0.0-rc.1' semantic? {check}\");" + } + }, + { + "id": "f3d4d37585f759ad5e64145f", + "exampleId": "Cuemon.DelegateDecoratorExtensions#1", + "uid": "Cuemon.DelegateDecoratorExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Reflection;\nusing Cuemon;\n\n// Create a delegate\nFunc add = (a, b) => a + b;\n\n// Resolve the MethodInfo from the original delegate;\n// the decorator is used as fallback when original is null\nMethodInfo methodInfo = Decorator.Enclose(null, false).ResolveDelegateInfo(add);\n\nConsole.WriteLine($\"Method name: {methodInfo.Name}\");\nConsole.WriteLine($\"Declaring type: {methodInfo.DeclaringType?.Name}\");\nConsole.WriteLine($\"Is static: {methodInfo.IsStatic}\");\n\n// When the delegate is not available but the wrapper is:\nAction greet = () => Console.WriteLine(\"Hello!\");\nMethodInfo fromWrapper = Decorator.Enclose(greet).ResolveDelegateInfo(null);\nConsole.WriteLine($\"\\nGreet method: {fromWrapper.Name}\");" + } + }, + { + "id": "f4356a48652e2d33aeb3429c", + "exampleId": "Cuemon.AspNetCore.Http.Throttling.ThrottlingException#1", + "uid": "Cuemon.AspNetCore.Http.Throttling.ThrottlingException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http.Throttling;\n\ntry\n{\n // Simulate a rate-limit violation\n var resetTime = DateTime.UtcNow.AddMinutes(5);\n throw new ThrottlingException(\n \"API rate limit exceeded.\",\n rateLimit: 100,\n delta: TimeSpan.FromMinutes(5),\n reset: resetTime);\n}\ncatch (ThrottlingException ex)\n{\n Console.WriteLine($\"Message: {ex.Message}\"); // API rate limit exceeded.\n Console.WriteLine($\"RateLimit: {ex.RateLimit}\"); // 100\n Console.WriteLine($\"Delta: {ex.Delta.TotalMinutes} minutes\"); // 5\n Console.WriteLine($\"Reset: {ex.Reset}\"); // UTC reset time\n Console.WriteLine($\"StatusCode: {ex.StatusCode}\"); // 429\n}" + } + }, + { + "id": "f436f13f63d1ee614757bcf3", + "exampleId": "Cuemon.Extensions.Text.Json.Converters.ExceptionConverter#1", + "uid": "Cuemon.Extensions.Text.Json.Converters.ExceptionConverter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\nusing Cuemon.Extensions.Text.Json.Converters;\n\nvar options = new JsonSerializerOptions\n{\n TypeInfoResolver = new DefaultJsonTypeInfoResolver(),\n WriteIndented = true\n};\n\n// Include both stack trace and exception data\noptions.Converters.Add(new ExceptionConverter(includeStackTrace: true, includeData: true));\n\nvar inner = new InvalidOperationException(\"Inner operation failed.\");\nvar ex = new InvalidOperationException(\"Outer operation failed.\", inner);\nex.Data[\"CorrelationId\"] = \"abc-123\";\n\nstring json = JsonSerializer.Serialize(ex, options);\nConsole.WriteLine(json);" + } + }, + { + "id": "f4961bbd14cf8c257ce320ca", + "exampleId": "Cuemon.AspNetCore.Http.Headers.UserAgentException#1", + "uid": "Cuemon.AspNetCore.Http.Headers.UserAgentException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Microsoft.AspNetCore.Http;\nusing Cuemon.AspNetCore.Http.Headers;\n\n var exception = new UserAgentException(StatusCodes.Status400BadRequest, \"The User-Agent header is required.\");\nConsole.WriteLine($\"{exception.StatusCode} {exception.ReasonPhrase}\");" + } + }, + { + "id": "f4f1da0ff1a479d0c033197f", + "exampleId": "Cuemon.Security.Cryptography.MessageDigest5#1", + "uid": "Cuemon.Security.Cryptography.MessageDigest5", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon.Security.Cryptography;\n\nvar algorithm = new MessageDigest5();\nvar result = algorithm.ComputeHash(Encoding.UTF8.GetBytes(\"The quick brown fox jumps over the lazy dog\"));\n\nConsole.WriteLine(MessageDigest5.BitSize);\nConsole.WriteLine(result.GetBytes().Length);\nConsole.WriteLine(result.ToHexadecimalString());" + } + }, + { + "id": "f5353e66d277406435d5b620", + "exampleId": "Cuemon.AspNetCore.Diagnostics.ServerTimingMetric#1", + "uid": "Cuemon.AspNetCore.Diagnostics.ServerTimingMetric", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Diagnostics;\n\n // Record a metric for a database query\n var dbMetric = new ServerTimingMetric(\"db-query\",\n TimeSpan.FromMilliseconds(135.2),\n \"Customer order lookup\");\n\n Console.WriteLine($\"Name: {dbMetric.Name}\");\n Console.WriteLine($\"Duration: {dbMetric.Duration}ms\");\n Console.WriteLine($\"Description: {dbMetric.Description}\");\n Console.WriteLine($\"Header value: {dbMetric}\");\n // Output: db-query;dur=135.2;desc=\"Customer order lookup\"\n\n // Record a metric without duration (marker only)\n var marker = new ServerTimingMetric(\"cache-hit\");\n Console.WriteLine(marker);\n // Output: cache-hit\n\n // Record a metric without description\n var fastMetric = new ServerTimingMetric(\"redis-get\",\n TimeSpan.FromMilliseconds(3.7));\n Console.WriteLine(fastMetric);\n // Output: redis-get;dur=3.7\n\n // Use with IServerTiming to add to response\n IServerTiming serverTiming = new ServerTiming();\n serverTiming\n .AddServerTiming(\"auth\", TimeSpan.FromMilliseconds(12.5), \"Token validation\")\n .AddServerTiming(\"sql\", TimeSpan.FromMilliseconds(89.1), \"Product search\");\n\n foreach (var metric in serverTiming.Metrics)\n {\n Console.WriteLine(metric);\n\n}" + } + }, + { + "id": "f5a0f3e7f5c6c1ef7da01516", + "exampleId": "Cuemon.Diagnostics.TimeMeasureProfiler#1", + "uid": "Cuemon.Diagnostics.TimeMeasureProfiler", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Diagnostics@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading;\nusing Cuemon.Diagnostics;\n\nTimeMeasureProfiler profiler = TimeMeasure.WithAction(() => Thread.Sleep(25));\nvar measured = TimeMeasure.WithFunc(() => 42);\n\nConsole.WriteLine(profiler.Elapsed > TimeSpan.Zero);\nConsole.WriteLine(profiler.IsRunning);\nConsole.WriteLine(measured.Result);\nConsole.WriteLine(measured.Elapsed > TimeSpan.Zero);" + } + }, + { + "id": "f6fb09153ea2c9d49a6b578e", + "exampleId": "Cuemon.Decorator`1#1", + "uid": "Cuemon.Decorator`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\nvar numbers = new[] { 10, 20, 30 };\nvar decorator = Decorator.Enclose(numbers);\n\n// Access the wrapped inner value through the Inner property\nint[] inner = decorator.Inner;\nConsole.WriteLine(string.Join(\", \", inner)); // \"10, 20, 30\"\n\n// ArgumentName is set automatically when using EncloseToExpose\nvar withArgName = Decorator.EncloseToExpose(numbers);\nConsole.WriteLine(withArgName.ArgumentName); // \"numbers\"\n\n// Syntactic sugar for type-level decoration\nvar syntactic = Decorator.Syntactic();\nConsole.WriteLine(syntactic.Inner); // null (default)" + } + }, + { + "id": "f6fde2bb005cea9e7e460361", + "exampleId": "Cuemon.IO.AsyncDisposableOptions#1", + "uid": "Cuemon.IO.AsyncDisposableOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0" + ], + "source": "using System;\nusing System.IO;\nusing System.Threading.Tasks;\nusing Cuemon.IO;\n\nnamespace MyApp.Examples;\n\npublic class AsyncDisposableOptionsExample\n{\n public static async Task Main()\n {\n var options = new AsyncDisposableOptions\n {\n LeaveOpen = true\n };\n\n var stream = new MemoryStream();\n // Use options.LeaveOpen to decide disposal behavior\n if (!options.LeaveOpen)\n {\n stream.Dispose();\n }\n\n Console.WriteLine(\"LeaveOpen: {0}\", options.LeaveOpen);\n Console.WriteLine(\"Stream still open: {0}\", stream.CanWrite);\n\n // Output:\n // LeaveOpen: True\n // Stream still open: True\n }\n}" + } + }, + { + "id": "f7ca66249506a7f49827f0f6", + "exampleId": "Cuemon.Threading.AsyncWorkloadOptions#1", + "uid": "Cuemon.Threading.AsyncWorkloadOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Cuemon;\nusing Cuemon.Threading;\nusing MyApp.Examples;\n\nawait new AsyncWorkloadOptionsExample().DemonstrateAsync();\n\nnamespace MyApp.Examples\n{\n public class AsyncWorkloadOptionsExample\n {\n public async Task DemonstrateAsync()\n {\n // Direct instantiation of AsyncWorkloadOptions\n var workloadOptions = new AsyncWorkloadOptions\n {\n PartitionSize = 4\n };\n\n var rules = new ForLoopRuleset(0, 20, 1);\n\n await AdvancedParallelFactory.ForAsync(rules, (i, ct) =>\n {\n Console.WriteLine($\"Processing item {i}\");\n return Task.CompletedTask;\n }, o =>\n {\n o.PartitionSize = 4;\n });\n\n }\n }\n}" + } + }, + { + "id": "f7d0d7179789e5fea4574199", + "exampleId": "Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptions#1", + "uid": "Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Diagnostics;\nusing Cuemon.Diagnostics;\n\nvar options = new FaultDescriptorOptions\n{\n SensitivityDetails = FaultSensitivityDetails.FailureWithStackTrace,\n RootHelpLink = new Uri(\"https://example.com/errors\")\n};\n\nConsole.WriteLine(options.SensitivityDetails);" + } + }, + { + "id": "f87695fb8519d321c37f8de4", + "exampleId": "Cuemon.Reflection.MemberParser#1", + "uid": "Cuemon.Reflection.MemberParser", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Cuemon.Reflection;\nusing MyApp.Examples;\n\nMemberParserExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class MemberParserExample\n {\n public static void Demonstrate()\n {\n var arguments = new List\n {\n new(\"sku\", \"SKU-42\"),\n new(\"price\", 19.95m),\n new(\"stock\", 12)\n };\n\n var parser = new MemberParser(typeof(CatalogItem), arguments);\n var item = (CatalogItem)parser.CreateInstance(ctor => ctor.GetParameters().Length == 2);\n\n Console.WriteLine(item.Sku);\n Console.WriteLine(item.Price);\n Console.WriteLine(item.Stock);\n Console.WriteLine(string.Join(\", \", parser.ProcessedMemberArguments.Select(argument => argument.Name)));\n }\n }\n public sealed class CatalogItem\n {\n public CatalogItem(string sku, decimal price)\n {\n Sku = sku;\n Price = price;\n }\n\n public string Sku { get; }\n\n public decimal Price { get; }\n\n public int Stock { get; set; }\n }\n}" + } + }, + { + "id": "f8bbfdc259cd20e8f7ffa98f", + "exampleId": "Cuemon.Runtime.Caching.SlimMemoryCache#1", + "uid": "Cuemon.Runtime.Caching.SlimMemoryCache", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Runtime.Caching@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Runtime.Caching;\n\n // Create a cache with automatic cleanup\n var cache = new SlimMemoryCache(o =>\n {\n o.EnableCleanup = true;\n o.FirstSweep = TimeSpan.FromSeconds(30);\n o.SucceedingSweep = TimeSpan.FromSeconds(10);\n });\n\n // Add an entry with absolute expiration\n cache.Add(\"config\", new { Theme = \"Dark\", Locale = \"en-US\" }, DateTime.UtcNow.AddMinutes(5));\n\n // Add an entry with sliding expiration (resets on each access)\n cache.Add(\"session\", new { UserId = 42, Role = \"Admin\" }, TimeSpan.FromMinutes(20), \"sessions\");\n\n Console.WriteLine($\"Config: {cache[\"config\"]}\");\n\n // Use TryGet for safe retrieval\n if (cache.TryGet(\"session\", \"sessions\", out var session))\n {\n Console.WriteLine($\"Session: {session}\");\n\n // Update an existing entry using the indexer\n cache[\"config\"] = new { Theme = \"Light\", Locale = \"en-US\" };\n Console.WriteLine($\"Updated config: {cache[\"config\"]}\");\n\n // Check if entry exists and remove it\n if (cache.Contains(\"config\"))\n {\n cache.Remove(\"config\");\n Console.WriteLine(\"Config removed.\");\n\n // Count entries within a namespace\n cache.Add(\"item1\", 100, DateTime.MaxValue, \"data\");\n cache.Add(\"item2\", 200, DateTime.MaxValue, \"data\");\n Console.WriteLine($\"Items in 'data' namespace: {cache.Count(\"data\")}\");\n\n // Remove all entries from a namespace\n cache.RemoveAll(\"data\");\n Console.WriteLine($\"After removal: {cache.Count(\"data\")}\");\n\n cache.Dispose();\n\n}}" + } + }, + { + "id": "f8d73f39bc8e190257b57d33", + "exampleId": "Cuemon.AspNetCore.Authentication.Hmac.HmacFields#1", + "uid": "Cuemon.AspNetCore.Authentication.Hmac.HmacFields", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Net.Http;\nusing Cuemon.AspNetCore.Authentication.Hmac;\n\nusing var request = new HttpRequestMessage(HttpMethod.Get, \"https://api.example.com/resource\");\nrequest.Headers.Date = DateTimeOffset.UtcNow;\nrequest.Headers.Host = \"api.example.com\";\n\nvar builder = new HmacAuthorizationHeaderBuilder()\n .AddFromRequest(request)\n .AddClientId(\"my-client\")\n .AddClientSecret(\"my-secret\")\n .AddCredentialScope(\"20250101/us-east-1/service/aws4_request\");\n\nvar header = builder.Build();\n\nConsole.WriteLine(HmacFields.Scheme);\nConsole.WriteLine(HmacFields.SignedHeaders);\nConsole.WriteLine(HmacFields.CanonicalRequest);" + } + }, + { + "id": "f966be9c65502cf8bed9a5f5", + "exampleId": "Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierOptions#1", + "uid": "Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Messaging;\nusing Cuemon.AspNetCore.Http.Headers;\n\n var options = new CorrelationIdentifierOptions\n{\n Token = new CorrelationToken(\"corr-42\")\n};\n\noptions.ValidateOptions();\nConsole.WriteLine(options.Token.CorrelationId);" + } + }, + { + "id": "f9702ad8e72ee921cb71d346", + "exampleId": "Cuemon.Extensions.Data.QueryFormatExtensions#1", + "uid": "Cuemon.Extensions.Data.QueryFormatExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Data@11.0.0" + ], + "source": "using System;\nusing System.Collections.Generic;\nusing Cuemon.Data;\nusing Cuemon.Extensions.Data;\n\nnamespace MyApp.Examples;\n\npublic class QueryFormatExtensionsExample\n{\n public static void Main()\n {\n // Embed string values in a delimited format: value, value, value\n var productIds = new[] { \"ALFKI\", \"BONAP\", \"FRANS\" };\n string delimited = QueryFormat.Delimited.Embed(productIds);\n Console.WriteLine(delimited); // Output: ALFKI,BONAP,FRANS\n\n // Embed string values with single quotes: 'value', 'value', 'value'\n string delimitedString = QueryFormat.DelimitedString.Embed(productIds);\n Console.WriteLine(delimitedString); // Output: 'ALFKI','BONAP','FRANS'\n\n // Embed integer values\n var ids = new[] { 1, 2, 3, 4, 5 };\n string intEmbedded = QueryFormat.Delimited.Embed(ids);\n Console.WriteLine(intEmbedded); // Output: 1,2,3,4,5\n\n // Embed with distinct filtering to remove duplicates\n var withDuplicates = new[] { \"apple\", \"banana\", \"apple\", \"cherry\" };\n string distinctFragment = QueryFormat.DelimitedString.Embed(withDuplicates, distinct: true);\n Console.WriteLine(distinctFragment); // Output: 'apple','banana','cherry'\n\n}\n}" + } + }, + { + "id": "f993953cb86ea051a807bab5", + "exampleId": "Cuemon.DelimitedStringOptions`1#1", + "uid": "Cuemon.DelimitedStringOptions`1", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Globalization;\nusing Cuemon;\n\nvar options = new DelimitedStringOptions\n{\n Delimiter = \" | \",\n StringConverter = number => number.ToString(\"X2\", CultureInfo.InvariantCulture)\n};\n\nint[] numbers = { 1, 2, 3, 4 };\nstring hex = DelimitedString.Create(numbers, setup =>\n{\n setup.Delimiter = options.Delimiter;\n setup.StringConverter = options.StringConverter;\n});\n\nConsole.WriteLine(hex);" + } + }, + { + "id": "f9c726bf7c661116d8e57f4f", + "exampleId": "Cuemon.AspNetCore.Authentication.Digest.DigestCryptoAlgorithm#1", + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestCryptoAlgorithm", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Authentication.Digest;\n\nvar builder = new DigestAuthorizationHeaderBuilder(DigestCryptoAlgorithm.Sha512Slash256);\n\nConsole.WriteLine(builder.DigestAlgorithm);" + } + }, + { + "id": "fa5fe03dbb66e3eb809adcde", + "exampleId": "Cuemon.AspNetCore.Http.ForbiddenException#1", + "uid": "Cuemon.AspNetCore.Http.ForbiddenException", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Http;\n\ntry\n{\n var userRole = \"guest\";\n if (userRole != \"admin\")\n {\n throw new ForbiddenException(\"Only administrators can perform this action.\");\n }\n}\ncatch (ForbiddenException ex)\n{\n Console.WriteLine(ex.StatusCode); // 403\n Console.WriteLine(ex.Message); // Only administrators can perform this action.\n}" + } + }, + { + "id": "fa929d9d250ca4468d3b9b8c", + "exampleId": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticator#1", + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticator", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Security.Claims;\nusing Cuemon.AspNetCore.Authentication.Digest;\n\nDigestAuthenticator authenticator = (string username, out string password) =>\n{\n password = username == \"Agent\" ? \"Test\" : null;\n return password == null\n ? null\n : new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, username) }, DigestAuthorizationHeader.Scheme));\n};\n\nvar principal = authenticator(\"Agent\", out var password);\n\nConsole.WriteLine(password);\nConsole.WriteLine(principal?.Identity?.Name);" + } + }, + { + "id": "fa98cc084b8c266f00294224", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.TagHelperBaseUrlMode#1", + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.TagHelperBaseUrlMode", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Razor.TagHelpers;\nusing Microsoft.AspNetCore.Http;\n\nvar configured = new CdnTagHelperOptions\n{\n BaseUrlMode = TagHelperBaseUrlMode.Configured,\n Scheme = ProtocolUriScheme.Https,\n BaseUrl = \"static.example.com\"\n};\nConsole.WriteLine(configured.GetFormattedBaseUrl()); // Output: https://static.example.com/\n\nvar automatic = new CdnTagHelperOptions\n{\n BaseUrlMode = TagHelperBaseUrlMode.Automatic,\n BaseUrl = null // No fixed origin, so fall back to the current HTTP request.\n};\nvar request = new DefaultHttpContext().Request;\nrequest.Scheme = \"https\";\nrequest.Host = new HostString(\"app.example.com\");\nrequest.PathBase = \"/myapp\";\nConsole.WriteLine(automatic.GetFormattedBaseUrl(request)); // Output: https://app.example.com/myapp/" + } + }, + { + "id": "fc5bc2b379d6ad6e5386b6b5", + "exampleId": "Cuemon.IO.AsyncStreamCompressionOptions#1", + "uid": "Cuemon.IO.AsyncStreamCompressionOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.IO.Compression;\nusing System.Text;\nusing System.Threading.Tasks;\nusing Cuemon.IO;\n\n // Default compression: Optimal balance of speed and size\n var defaultOptions = new AsyncStreamCompressionOptions();\n Console.WriteLine($\"Default level: {defaultOptions.Level}\"); // Optimal\n Console.WriteLine($\"Default buffer size: {defaultOptions.BufferSize}\"); // 81920\n\n // Fastest compression for CPU-sensitive scenarios\n var fastOptions = new AsyncStreamCompressionOptions\n {\n Level = CompressionLevel.Fastest,\n BufferSize = 4096\n };\n\n // Compress data using the configured options\n byte[] original = Encoding.UTF8.GetBytes(\"This is sample data that will be compressed using AsyncStreamCompressionOptions.\");\n using var source = new MemoryStream(original);\n using var compressed = new MemoryStream();\n\n using (var deflateStream = new DeflateStream(compressed, fastOptions.Level, leaveOpen: true))\n {\n await source.CopyToAsync(deflateStream, fastOptions.BufferSize);\n\n Console.WriteLine($\"Original size: {original.Length} bytes\");\n Console.WriteLine($\"Compressed size: {compressed.Length} bytes\");\n\n // No compression level for testing or passthrough scenarios\n var noCompressionOptions = new AsyncStreamCompressionOptions\n {\n Level = CompressionLevel.NoCompression\n };\n Console.WriteLine($\"No compression level: {noCompressionOptions.Level}\");\n\n}" + } + }, + { + "id": "fcf5ec8ead9633d1e9c1add3", + "exampleId": "Cuemon.Runtime.WatcherEventArgs#1", + "uid": "Cuemon.Runtime.WatcherEventArgs", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Runtime;\n\nvar immediate = new WatcherEventArgs(DateTime.UtcNow);\nvar postponed = new WatcherEventArgs(DateTime.UtcNow.AddSeconds(-5), TimeSpan.FromMilliseconds(250));\nvar empty = WatcherEventArgs.Empty;\n\nConsole.WriteLine(immediate.UtcLastModified.Kind);\nConsole.WriteLine(postponed.Delayed.TotalMilliseconds);\nConsole.WriteLine(empty.UtcLastModified == DateTime.MinValue);" + } + }, + { + "id": "fd163b7e321a578d6f38628e", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.CdnScriptTagHelper#1", + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.CdnScriptTagHelper", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.AspNetCore.Configuration;\nusing Cuemon.AspNetCore.Razor.TagHelpers;\nusing Microsoft.Extensions.Options;\nusing MyApp.Examples;\n\nCdnScriptTagHelperExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class CdnScriptTagHelperExample\n {\n private sealed class ScriptVersion : ICacheBusting\n {\n public string Version => \"1.0.0\";\n }\n\n public static void Demonstrate()\n {\n var options = Options.Create(new CdnTagHelperOptions\n {\n Scheme = ProtocolUriScheme.Https,\n BaseUrl = \"nblcdn.net\"\n });\n\n var cacheBusting = new ScriptVersion();\n var tagHelper = new CdnScriptTagHelper(options, cacheBusting)\n {\n Src = \"packages/fontawesome/5.15.3/js/all.js\",\n Defer = true\n };\n var scriptPath = string.Concat(tagHelper.Options.GetFormattedBaseUrl(), tagHelper.Src, \"?v=\", cacheBusting.Version);\n\n Console.WriteLine(scriptPath);\n }\n }\n}" + } + }, + { + "id": "fd1f9e9be5f84af8b7ac9b2b", + "exampleId": "Cuemon.Extensions.Reflection.TypeExtensions#1", + "uid": "Cuemon.Extensions.Reflection.TypeExtensions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Reflection@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Linq;\nusing Cuemon;\nusing Cuemon.Extensions.Reflection;\nusing Cuemon.Reflection;\nusing MyApp.Examples;\n\nTypeExtensionsExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class TypeExtensionsExample\n {\n public static void Demonstrate()\n {\n var streamType = typeof(Stream);\n var derivedTypes = streamType.GetDerivedTypes().Where(type => type.IsPublic).Select(type => type.Name).Take(3).ToArray();\n var inheritedTypes = streamType.GetInheritedTypes().Select(type => type.Name).ToArray();\n var properties = typeof(TypeArgumentOutOfRangeException).GetAllProperties().Select(property => property.Name).ToArray();\n var events = typeof(TypeCatalog).GetAllEvents().Select(@event => @event.Name).ToArray();\n var fields = typeof(TypeCatalog).GetAllFields().Select(field => field.Name).ToArray();\n var methods = typeof(TypeCatalog).GetAllMethods().Select(method => method.Name).ToArray();\n var hierarchy = typeof(Stream).GetHierarchyTypes().Select(type => type.Name).ToArray();\n var resources = typeof(TypeExtensionsExample).GetEmbeddedResources(\"missing\", ManifestResourceMatch.ContainsName);\n var ownProperties = typeof(TypeCatalog).GetRuntimePropertiesExceptOf().Select(property => property.Name).ToArray();\n var fullName = typeof(TypeCatalog).ToFullNameIncludingAssemblyName();\n\n Console.WriteLine(string.Join(\", \", derivedTypes));\n Console.WriteLine(string.Join(\", \", inheritedTypes));\n Console.WriteLine(properties.Contains(nameof(TypeArgumentOutOfRangeException.ActualValue)));\n Console.WriteLine(events.Contains(nameof(TypeCatalog.Changed)));\n Console.WriteLine(fields.Contains(nameof(TypeCatalog._state)));\n Console.WriteLine(methods.Contains(nameof(TypeCatalog.MarkChanged)));\n Console.WriteLine(hierarchy.Contains(nameof(Stream)));\n Console.WriteLine(resources.Count);\n Console.WriteLine(ownProperties.Contains(nameof(TypeCatalog.Name)));\n Console.WriteLine(fullName.Contains(nameof(TypeCatalog)));\n }\n\n private abstract class BaseCatalog\n {\n public int Id { get; set; }\n }\n\n private sealed class TypeCatalog : BaseCatalog\n {\n internal string _state = \"draft\";\n\n public string Name { get; set; } = \"Extensions\";\n\n public event EventHandler Changed;\n\n public void MarkChanged()\n {\n Changed?.Invoke(this, EventArgs.Empty);\n }\n }\n }\n}" + } + }, + { + "id": "fdafd0473d3d2579eb4f8099", + "exampleId": "Cuemon.Messaging.RequestToken#1", + "uid": "Cuemon.Messaging.RequestToken", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Messaging;\n\n// Each request gets its own unique ID\nvar request1 = new RequestToken();\nvar request2 = new RequestToken();\n\nConsole.WriteLine($\"Request 1 ID: {request1}\");\nConsole.WriteLine($\"Request 2 ID: {request2}\");\nConsole.WriteLine($\"Are they different? {request1.RequestId != request2.RequestId}\");" + } + }, + { + "id": "fdb368f878c6231684d661ad", + "exampleId": "Cuemon.StringFactory#1", + "uid": "Cuemon.StringFactory", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon;\n\n// Convert bytes to hexadecimal string\nbyte[] binaryData = { 0x0F, 0xA0, 0x01 };\nstring hex = StringFactory.CreateHexadecimal(binaryData);\nConsole.WriteLine(hex); // 0fa001\n\n// Convert string to hexadecimal representation\nstring hexFromString = StringFactory.CreateHexadecimal(\"Hello\");\nConsole.WriteLine(hexFromString); // 48656c6c6f\n\n// Create binary digit string from bytes\nstring binary = StringFactory.CreateBinaryDigits(new byte[] { 0, 1, 255 });\nConsole.WriteLine(binary); // 000000000000000111111111\n\n// Create URL-safe Base64 string\nstring urlSafe = StringFactory.CreateUrlEncodedBase64(new byte[] { 251, 255 });\nConsole.WriteLine(urlSafe); // -_8\n\n// Create a protocol-relative URL (// prefix replaces https://)\nstring relativeUrl = StringFactory.CreateProtocolRelativeUrl(\n new Uri(\"https://www.cuemon.net/about\"));\nConsole.WriteLine(relativeUrl); // //www.cuemon.net/about\n\n// Get string representation of a URI scheme enum\nstring scheme = StringFactory.CreateUriScheme(UriScheme.Https);\nConsole.WriteLine(scheme); // https" + } + }, + { + "id": "fecb58b2357d4f41b14c6984", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpEntityTagHeaderOptions#1", + "uid": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpEntityTagHeaderOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.IO;\nusing System.Text;\nusing Cuemon.AspNetCore.Mvc.Filters.Cacheable;\nusing Cuemon.Data.Integrity;\nusing Cuemon.Security;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Net.Http.Headers;\nusing MyApp.Examples;\n\nHttpEntityTagHeaderOptionsExample.Demonstrate();\n\nnamespace MyApp.Examples\n{\n public static class HttpEntityTagHeaderOptionsExample\n {\n public static void Demonstrate()\n {\n var options = new HttpEntityTagHeaderOptions\n {\n UseEntityTagResponseParser = true\n };\n\n var context = new DefaultHttpContext();\n context.Request.Method = HttpMethods.Get;\n\n options.EntityTagProvider(new SampleEntityDataIntegrity(), context);\n\n using var body = new MemoryStream(Encoding.UTF8.GetBytes(\"payload\"));\n options.EntityTagResponseParser(body, context.Request, context.Response);\n\n Console.WriteLine(options.HasEntityTagProvider);\n Console.WriteLine(options.HasEntityTagResponseParser);\n Console.WriteLine(context.Response.Headers.ContainsKey(HeaderNames.ETag));\n }\n\n private sealed class SampleEntityDataIntegrity : IEntityDataIntegrity\n {\n public HashResult Checksum => new HashResult(new byte[] { 1, 2, 3 });\n\n public EntityDataIntegrityValidation Validation => EntityDataIntegrityValidation.Strong;\n }\n }\n}" + } + }, + { + "id": "aa20d15c123168d422065d85", + "exampleId": "Cuemon.Extensions.DependencyInjection.TypeForwardServiceOptions#1", + "uid": "Cuemon.Extensions.DependencyInjection.TypeForwardServiceOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.DependencyInjection@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing Cuemon.Extensions.DependencyInjection;\nusing Microsoft.Extensions.DependencyInjection;\nusing Cuemon.Docs.Samples.DependencyInjection;\n\nTypeForwardServiceOptionsExample.Demonstrate();\n\nnamespace Cuemon.Docs.Samples.DependencyInjection\n{\n public static class TypeForwardServiceOptionsExample\n {\n public static void Demonstrate()\n {\n var forwarding = new TypeForwardServiceOptions\n {\n Lifetime = ServiceLifetime.Singleton,\n NestedTypeSelector = type => type.GetInterfaces(),\n NestedTypePredicate = type => type == typeof(IMessageHandler)\n };\n\n Console.WriteLine(forwarding.UseNestedTypeForwarding);\n forwarding.ValidateOptions();\n\n var services = new ServiceCollection();\n services.Add(options =>\n {\n options.Lifetime = forwarding.Lifetime;\n options.UseNestedTypeForwarding = forwarding.UseNestedTypeForwarding;\n options.NestedTypeSelector = forwarding.NestedTypeSelector;\n options.NestedTypePredicate = forwarding.NestedTypePredicate;\n });\n\n using var provider = services.BuildServiceProvider();\n\n var dispatcher = provider.GetRequiredService();\n var handler = provider.GetRequiredService();\n var diagnostics = provider.GetService();\n\n Console.WriteLine(object.ReferenceEquals(dispatcher, handler));\n Console.WriteLine(diagnostics is null);\n }\n\n public interface IMessageHandler\n {\n void Handle(string message);\n }\n\n public interface IDiagnosticSink\n {\n void Write(string message);\n }\n\n public sealed class MessageDispatcher : IMessageHandler, IDiagnosticSink\n {\n public void Handle(string message)\n {\n Console.WriteLine(message);\n }\n\n public void Write(string message)\n {\n Console.WriteLine(message);\n }\n }\n }\n}" + } + }, + { + "id": "aa961b0a9781b98d35f11e61", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationOutputFormatter#1", + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationOutputFormatter", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml@11.0.0", + "Cuemon.Xml@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Linq;\nusing Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml;\nusing Cuemon.Xml.Serialization.Formatters;\n\nvar options = new XmlFormatterOptions();\nvar formatter = new XmlSerializationOutputFormatter(options);\n\nConsole.WriteLine($\"Supported media types: {string.Join(\", \", formatter.SupportedMediaTypes)}\");\nConsole.WriteLine($\"Supported encodings: {string.Join(\", \", formatter.SupportedEncodings.Select(e => e.WebName))}\");" + } + }, + { + "id": "aae23689419b3461efdffd94", + "exampleId": "Cuemon.Security.CyclicRedundancyCheckOptions#1", + "uid": "Cuemon.Security.CyclicRedundancyCheckOptions", + "fenceOrdinal": 1, + "strategy": "standalone", + "transports": [ + "native", + "docker" + ], + "image": "codebeltnet/csrun:10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ], + "source": "// Program.cs\nusing System;\nusing System.Text;\nusing Cuemon;\nusing Cuemon.Security;\n\nvar options = new CyclicRedundancyCheckOptions\n{\n ByteOrder = Endianness.LittleEndian,\n ReflectInput = true,\n ReflectOutput = true\n};\n\nvar checksum = new CyclicRedundancyCheck32(setup: configured =>\n{\n configured.ByteOrder = options.ByteOrder;\n configured.ReflectInput = options.ReflectInput;\n configured.ReflectOutput = options.ReflectOutput;\n});\n\nConsole.WriteLine(options.ByteOrder);\nConsole.WriteLine(options.ReflectInput);\nConsole.WriteLine(options.ReflectOutput);\nConsole.WriteLine(checksum.ComputeHash(Encoding.ASCII.GetBytes(\"123456789\")).ToHexadecimalString());" + } + } + ] +} diff --git a/.docfx/run-actions.settings.json b/.docfx/run-actions.settings.json new file mode 100644 index 000000000..cb6bbaf9d --- /dev/null +++ b/.docfx/run-actions.settings.json @@ -0,0 +1,8400 @@ +{ + "examples": [ + { + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.AppTagHelperOptions", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.AppTagHelperOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "2D0879DBE31F041DD0B37DE186C02FBBD8087F92D294C850C7D35033CBC91E55", + "mode": "host", + "hostHarness": { + "sdk": "Microsoft.NET.Sdk.Web", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0" + ], + "probePath": "/", + "probeMethod": "GET", + "timeoutSeconds": 60, + "expectedStatusCode": 404 + } + }, + { + "uid": "Cuemon.Collections.Specialized.DictionaryDecoratorExtensions", + "sourceSha256": "56FD1F9FFE7B92079BAB359D421C6FE9A46FC595974F8989D361B8D18D06160D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.DbTypeDecoratorExtensions", + "sourceSha256": "54F5B7FB3229C4334DDF28AEE08D8B9C1A188B25A3D5B2975B2A07F42EC3A2E2", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.InOperatorResult", + "sourceSha256": "C69B0398D41DBD3A28ACC399B9AE65C316AC49291AB443DF8F6D4A38C7642CC0", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.QueryType", + "sourceSha256": "2FBDBCE1AB4D53F7EF2F9DD7D55A36E401E49266D6BE7AB58DC650C687552679", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Collections.Generic.ListExtensions", + "sourceSha256": "0AAE5D909CE69E2301CE86C82D7E33AC85D1C21ABD86C4351C44C635A7428C21", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Collections.Generic@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Data.DbTypeExtensions", + "sourceSha256": "60E6C13BB555EEA9B80AEC290B2DC35741576A9834EF638404E2A10CF22A45C2", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Data.Integrity.AssemblyExtensions", + "sourceSha256": "77FFF51D035B17FFDC11FE3802104DBED5B21FF2D808BA5CDB0061FEF3AB6E52", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Data.Integrity@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Data.Integrity.DateTimeExtensions", + "sourceSha256": "1017644D9D8FB9AE713EEF9E6A5A169FED2173053C4C71E4FA2DCE8E670CCC29", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Data.Integrity@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Data.Integrity.FileInfoExtensions", + "sourceSha256": "F1289EE377CC0E75DCEF446352D1A3075DA18D05FEF538E534C51B7AB7C72501", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Data.Integrity@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Data.QueryFormatExtensions", + "sourceSha256": "B5E7E71F69855D304FC03CC23CA576163122431F8AE2DA4A09CAB25A9FD61415", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.DependencyInjection.ServiceCollectionExtensions", + "sourceSha256": "FA9AFB3644833D7EFC101EB60FD80EBA1B430E08C17FDEBF05FC28FEA6AD77E5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Net.HttpStatusCodeExtensions", + "sourceSha256": "949138C1E5CCA936115F9B0E86B976FF3CF0E939043ED3C896B58FF28D1BEC93", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Reflection.MemberInfoExtensions", + "sourceSha256": "8BDAC24E9B4B4B674501150F8AECFBC60767A273BFFA7ABC32E7A09451AEAA7F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Reflection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.EncodingOptionsExtensions", + "sourceSha256": "DB4368F303580602282348DA2C40CFA32BFC83EF2BC14E9065C5CCB228076414", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.Json.JsonNamingPolicyExtensions", + "sourceSha256": "8C856FFA2DB124B1AC114BD23188B14DED5092563E540169F16D8C7950DAC6E8", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.Json.JsonSerializerOptionsExtensions", + "sourceSha256": "ACF75C11A8D99F696975A74E338C5C14E800AF29473680A59A18BF3DA2802BC9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.Json.Utf8JsonWriterExtensions", + "sourceSha256": "A5196A5454BED2C675407BC433CC8F30BD0D00D9132A6B25A2C5DA25D0618879", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IO.AsyncDisposableOptions", + "sourceSha256": "75CC193DF082CBE38D387BC06A62986C5D1A5CEA6E42A838E41E565EBCF82BA5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IO.AsyncStreamEncodingOptions", + "sourceSha256": "4F0E379BA277286723C85E59532F16F00CA1DF2C3B7D6945E6267715D1A94B59", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IO.BufferWriterOptions", + "sourceSha256": "AD32CD53FAA7A8CA91DE3DAD9CE572EA491F562162EC51445F569BAEE9D2B67A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.Collections.Specialized.NameValueCollectionDecoratorExtensions", + "sourceSha256": "5D3D85B234D4CBB7E8916E48D61AC32DB27DA9AE0DD5E5046CC00C6AC9263425", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.ObjectDecoratorExtensions", + "sourceSha256": "D7AFADE7CC4F9D91132FCA5EA4237725FFAF76767FCACAE2C0EF8DF4A45FF6CC", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.FowlerNollVoAlgorithm", + "sourceSha256": "F774169CA6ABC38767EDE7854A1B321C029F88B214DA9DF79D0F2CA33FD1AF7B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.FowlerNollVoOptions", + "sourceSha256": "6436B4FF5FB18063F4A7D1602EE22E23C274486058F8C049A1E362187B0044B2", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.HashResult", + "sourceSha256": "EBA078C65B51DF30A4CC085251BEB4C637E98B65B5D2E85CBB291EB3DA6A3B8F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.NonCryptoAlgorithm", + "sourceSha256": "851D6F4109AB15BE691729D271EAF6439076E4163D2A329C3A30E8E4022C48AC", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.Serialization.XmlSerializerOptionsDecoratorExtensions", + "sourceSha256": "398D831103BFBFD741FB92B30BD1FBD30E325179FD47D2DDD5B8BC8AD50620F6", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Alphanumeric", + "sourceSha256": "9AB15EE6803B62DA918899949B01B6DBBBE87869546800B38C39DCED9A6C650F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.AuthenticationHandlerFeature", + "sourceSha256": "2064475CF7E0814CD5207725F05E2795A921851651AC211E76C83B7E03FB41FC", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Authenticator", + "sourceSha256": "CC5F13E944A654724D520D2B46470A57686182CE2A0F8C7FA27AA88DBB686FF5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.AuthorizationHeaderOptions", + "sourceSha256": "390D74DA21A30E7575DF19C4455F12D4748FD9F3D75A2881B681790FF24B5A75", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationOptions", + "sourceSha256": "F3F8ACA7E39B6260FE81C7DB1CC33806F77A828D8BE168BCE39B1E700C2BF29F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticator", + "sourceSha256": "51008DBF4EED08F848EA8660DDAA1A67ABB5A4C3BBF097FA66432D737E3C7410", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeader", + "sourceSha256": "E43A7496461C1559E3594F8616F754E93F8627EA494FFBD19FAE85380E02EE8A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Basic.BasicFields", + "sourceSha256": "9E4E6929C72042BEA6C6C93121740D119AB37D5964BDEAF8F65354DF24641623", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationOptions", + "sourceSha256": "6DEE14D5D501C3F328075C310B817EE3549323EB9FCD307D49203D47DD661C5D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticator", + "sourceSha256": "B4DAD83741EC7FDA591947331A9B29B9D022CC4749CBD8BB9FAAD05E54F06862", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeader", + "sourceSha256": "3441239AA82E8B5054720F8A46F90FEAD05F44F269696D164B1A7C23FED54292", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthorizationHeaderBuilder", + "sourceSha256": "65713B31CAA93DC2695F6A699DA65C5E48836D8E0187D8B02F069EE586CB0C78", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestCryptoAlgorithm", + "sourceSha256": "68322AC7E43DDD05CFE13CD317DD901F3B73C3CDC688E7DA9E839D1BE9614EBF", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestHashFactory", + "sourceSha256": "51F55B68605D1A13B85C7DB07DBF00EFF07FD8A6A95C1461C5AF9A56EAF6B832", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationOptions", + "sourceSha256": "72FDF1DABC271B4882E6A738DF706E32B60324856C0FA9FBAA96B5135DD2D65F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticator", + "sourceSha256": "4BA7CA37288FE016343F7005CF76178A414C70C1400C893C66E8C2BBBC9CD7E0", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.MemoryNonceTracker", + "sourceSha256": "66678F1F7BB3D570FFFBE3C59CDB31088C76FFCD5F978C9DC93B43D7438BC8B0", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Configuration.DynamicCacheBusting", + "sourceSha256": "69A2072F571A482F3E6D8AD7472B4C7E972955BE4C2150B292B578003DBF7AAF", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.HttpFaultResolver", + "sourceSha256": "72F57187D74B682E636D2D513619B81989035F6D38B22F7A476A71DEE126DBC3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.ForbiddenException", + "sourceSha256": "0209E4B7CC46EAD7E12608A5B5D21414E68D9B5F7F28D52EF3AAA1691C6B1B70", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.ExpiresHeaderValue", + "sourceSha256": "55F0AD2BA43235BE9EF2BA55072C7580755EFB8B4104373EFC2B56F962EFBAFD", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.TooManyRequestsException", + "sourceSha256": "41FEADFC9E87D625E2973783BF257A008A916B701F3045D07280E9FA3833D8F1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.UnsupportedMediaTypeException", + "sourceSha256": "39477C9A6806E0FEB366D9C3B07DE9B3F79076948FED14A2642D8E73190F3373", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Breadcrumb", + "sourceSha256": "F035EA1B50BA764DBC26EFD3207C74A5D9DDB291ED8FB5D2E2240C9DFDF0D1EC", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.ContentBasedObjectResultOptions`1", + "sourceSha256": "2BC101CF3F6593617CE52FE44AF129260D08EE22821D2902FA1CEC7583BAF825", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.ExceptionDescriptorResult", + "sourceSha256": "0BA2C7CBBFE7E23F474E24E458A5F85CF41F240AF4606CA9E2510A7210A60EC1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpCacheableFilter", + "sourceSha256": "95C4134B416C0209725BA7FD5D48964F4F7B29836E83682D638630983A39EB45", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpCacheableOptions", + "sourceSha256": "C421CB8B97E524AAA61972F56DFB90506D8F076646BDFDCB76CE4D6DCF492102", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpEntityTagHeaderFilter", + "sourceSha256": "10AF126CC091811A03DFE2300D29F0BB2950D4513F09D69C46C8520AB059C98E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpLastModifiedHeaderFilter", + "sourceSha256": "3B42AE120F5E18EF1FAE0E1480325A2F2A1B5A4DAB2C9BA4003ED0E1D69A377E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Filters.Diagnostics.FaultDescriptorFilter", + "sourceSha256": "D392F65CC34EE75FDCCCFA93B995CD18BB7D2CC5635375F13AD48CADB9D4103F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Filters.Diagnostics.MvcFaultDescriptorOptions", + "sourceSha256": "0FED3D8E818B318AEE57D9F4AA37FF1E48675672B69D24547D92C5D983AFBEFD", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Filters.Headers.ApiKeySentinelAttribute", + "sourceSha256": "F23E48B8494D85AD723881925E47803278A1A4F24B2B29533EB0512EFA4AFAE7", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Filters.Headers.UserAgentSentinelFilter", + "sourceSha256": "F590EC99F9FF4AA0C95848D44260AE66784A82715CC18CE9432A89BB5D0AF1A0", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Filters.ModelBinding.DisableModelBindingAttribute", + "sourceSha256": "7B999456E87C931D6C1F9B763503D2A5E03F983A054B3BCBF8350D5F36BAD545", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Filters.Throttling.ThrottlingSentinelFilter", + "sourceSha256": "DE57EC376FD5D403F5D7A3531EA83603357F64918376C9351C88B7BEBAF5B043", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.ForbiddenResult", + "sourceSha256": "4BCE8976FBF3979B18A4C06C5991BEFF592F9F3DA519D2AAC71397911DABEBEB", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.GoneResult", + "sourceSha256": "D64C6E528490FD7DF40B4FFB7CB5738242FD09985576B6F353E74AB55CC11F20", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.SeeOtherResult", + "sourceSha256": "B89E747B748B7F9B99F5B2436A096CEC68CD0062C0DC9B52D9E246B2B81B6EF3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.TimeBasedObjectResultOptions`1", + "sourceSha256": "CD1F4A79DD3DE6F5AF3F18694D35808B683FF4FFCBABAB377399DA50713BBF7F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.AppScriptTagHelper", + "sourceSha256": "DA0F3F28340CA4CF12DDAB0ED44B392090CF7CCFFD245E12DF6524FAE4E8E8E3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.CdnTagHelperOptions", + "sourceSha256": "85869DA3760EC5AB8B47F2BC6D118C3D9749EC05CBE6C155635EB2301ECD88D1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.ProtocolUriScheme", + "sourceSha256": "2A1A0780C9AFEC6B6B7354519C7B9EB4EDA5DDBA0D609D2929F482D9BEC6A92D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.TagHelperBaseUrlMode", + "sourceSha256": "CC84929A0AFB003AB0F20AC7588C45C81C35F5C56DE7723DD0B0C1D8F58B1BB5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Calculator", + "sourceSha256": "B5CCFE32F7FCA4C50FB4C3443BE4702430BDCB9B545A3C16041627CD64BA2973", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.CasingMethod", + "sourceSha256": "2AF214D903C12BE48905A830D76D8C802E5113EA013470469056F643DF0C3DD2", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Collections.Generic.Arguments", + "sourceSha256": "B3597F5C04628EEEF5CAF5546F778FB6B0DAA83DB046B2C9A22DFD4831357E1D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Collections.Generic.DynamicComparer", + "sourceSha256": "AC2AB351AD7FF3D9E72E31CB4FEC7E6743D9DBB3EE55E3D672AEB826CFEB57E3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Collections.Generic.DynamicEqualityComparer", + "sourceSha256": "99B8E80B067D88B169E15C58925E425193330AAA9C01EC0898FEA4FD2780ED4E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Collections.Generic.EnumReadOnlyDictionary`1", + "sourceSha256": "974C856C260C2DB546B18D79D559C45F8378B1E4E37EA65A0CFEDFC2001A85A8", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Collections.Generic.PaginationOptions", + "sourceSha256": "4DFEF6F7EC27D1529CC1608791FFE1186D5F4CD65FBCAB5A9418812EB864D95D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Collections.Generic.PartitionerEnumerable`1", + "sourceSha256": "170B056D1A6CC0F67983A0983CFC780F35574382874FE96BCCC5FD142FC6099B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Collections.Generic.ReferenceComparer`1", + "sourceSha256": "D1F5A621080AA1E183133F6FA05864CD3E58E0BE98569300040F43C20A5F825A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Collections.Generic.StackDecoratorExtensions", + "sourceSha256": "1525C38F5AF4CD1632C9394F3C4422ED4BBC6C0BE58965DC2CABFACD16EBF4B2", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Convertible", + "sourceSha256": "4B8698E8D29B16CA391490A8137976AD5E0EAF34D88A74DDC028D91A6199FD08", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.Integrity.EntityDataIntegrityMethod", + "sourceSha256": "A7CA77841F15F9C45EF497365CDFC7B4CED7E11BE39807B2525CD5634F1F98FF", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Decorator`1", + "sourceSha256": "32DE58B8C7F6799C574BD46C9E3A7DAAE7D6583D9972203AFE2E03AE752274E3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Decorator", + "sourceSha256": "5AC17098ED829DD3FF64A90CC3A15373FDAFF09172C55326A78ABDFC99D20881", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.DelimitedString", + "sourceSha256": "8E210DBF770A1CB8911D4639B6704BFDF9F54F525E2BC32269E36CAF3EE76966", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.DelimitedStringOptions", + "sourceSha256": "E39A5481D40CFC0CF3AC41DB0AFACAA834FE0E30D334B85691BC39A07B5FC737", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Diagnostics.ExceptionDescriptor", + "sourceSha256": "A92E505BD0254D14261E14C797D2BB074064AE17C6727AA6608156BC147EEED0", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Diagnostics.ExceptionDescriptorOptions", + "sourceSha256": "6FD1D578C5727CE47119462B5CAA60ACEEFF2973C211848878DB12C52EDCAF4C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Diagnostics.Failure", + "sourceSha256": "F6CF29D6AE9FF7786325853E9AF21C82A89E138C83D3A28B30F5AAA0DA1AF86C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Diagnostics.FaultSensitivityDetails", + "sourceSha256": "D90E3E5F7E5D4A5B8C6C955D521D68374DEF02ADC186DB8F9C8F10FB9FCDC4A0", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Endianness", + "sourceSha256": "F8BDEC9801C7C41D01A770D33A3E82F2AD9323528FF5A9FBF022C78925B601F9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.EndianOptions", + "sourceSha256": "CF081BDE8F6E88DED0E71421F584677A35E8EADE0D8DD57796542F4A012A4F56", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.ExceptionInvoker`1", + "sourceSha256": "7D7689977F52C102CEAEC69074DB71702535A610C4DE281D941AAC63B5B88F7A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.ActionFactory", + "sourceSha256": "97984BD5246619087B39742832738497AA98F49DE937E3DBC7763ABACABF20A8", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Authentication.ApplicationBuilderExtensions", + "sourceSha256": "F580ED4ABD73B10BE84998CE0633B1394FBAF1FF7CA69D6FD08879D4FC77D872", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Authentication@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Authentication.AuthorizationResponseHandler", + "sourceSha256": "5AA1FF9CAA13A162C5E81FC6B9628A8CB4CB48E1A0A6CA65F00999CEBA0D3165", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Authentication@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Configuration.AssemblyCacheBusting", + "sourceSha256": "EA94711B9E9D82503C8D57D60072B98A3F885B4CB8A4AA458A334873633830E5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationInputFormatter", + "sourceSha256": "5CA621EC436086C35A6FB28067E8E2006300372477B895E41AA5FA12385321E2", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationOutputFormatter", + "sourceSha256": "7E653CE725FBA43E1B6CC447A0109539F0414F63C59F05159777DA2D59CB65FC", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationInputFormatter", + "sourceSha256": "6A2DAEE54F68F33445EDB8C89BB79F73F07497A06E9A6C568B221B53E761DE74", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationOutputFormatter", + "sourceSha256": "6F34B34169E943CC7765AC9613BA590D48CC2874CFB2D9A96577FE034835ED45", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Text.Json.MinimalJsonOptions", + "sourceSha256": "406D9206813717BEE2CCBA13DC323BF637DD6A063CC7DAB83C0A290A2624DFC0", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Text.Json@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Xml.Converters.XmlConverterExtensions", + "sourceSha256": "7C3026559EBB0604192590C8733574434C3DB85A7124DB4A48A6FB82F3AD34F0", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Xml@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.ByteExtensions", + "sourceSha256": "36929335829974EB019393B219F75134D2F52C457D1B2C887EFEC90BE539A93C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.CharExtensions", + "sourceSha256": "445AF4F0CF388CB6CA618AAC9FA58131722E379046DB7877E02F12FA332655F2", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Collections.Generic.CollectionExtensions", + "sourceSha256": "6CA6561CA6CF7634E6E51D341F32D4F9C9B9450022E301517338FCAA9D5EDFC3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Collections.Generic@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Collections.Generic.QueueExtensions", + "sourceSha256": "4B1F10FEB3D0850C52D9AFD6B07DC2D2A0775AA4C531B0058D4467B3D1A6F1B1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Collections.Generic@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Collections.Generic.StackExtensions", + "sourceSha256": "60746152528C6BBD0D2480274F8F38FC29884DC4EB1B289D89CA8CEC6DAD1187", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Collections.Generic@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.DateTimeExtensions", + "sourceSha256": "C76B4FBC386E469BBA027F9BC133619F805A6E369AEC3A61A8C30ACB2FB54CEE", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.DoubleExtensions", + "sourceSha256": "199686E96925C9EC275E5A3BCC974782B3EB07651442E790DF5841C0BC09531B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.FileProviders.PortablePhysicalFileProvider", + "sourceSha256": "1C4938D8C2F85B97D96309839103C5C6224414BCCEC63A2644AF59600C7C197B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.FileProviders.Physical@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.FuncFactory", + "sourceSha256": "254F8AE602BC157E3AB3977A4F34A430251DE835AC41E4E0653CBD40B8236CE8", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Hosting.HostBuilderExtensions", + "sourceSha256": "7A24E6B848624FAFAF7900BAAB4E902399A25D9809722EFB724E128006738536", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Hosting@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.IntegerExtensions", + "sourceSha256": "7B5471897D5DFB54E42655A4846C7AE1651448A1E2FE4353C5DDDF4F5EB4559C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.MutableTupleFactory", + "sourceSha256": "43F0B1986F50D8BB30322E10272990F1E8AD73F0C8E13CBEC3DF2C050E3AE9F4", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.RoundOffAccuracy", + "sourceSha256": "A78F5F0BCA3798CD67DFBFD8ABFFFB3016EC1708D3B9C11DE84BDBB1E01EB1A5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Runtime.Hierarchy", + "sourceSha256": "CC82646EBEC4683401C9E58CA6124D8082409A83AB7BEE70C49FEA856AB8EBAB", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Runtime.HierarchyOptions", + "sourceSha256": "57B76E186E6CDA0527769169AC636A11FB11C9DC81214B9940D65A4785DD43F3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Runtime.Hierarchy`1", + "sourceSha256": "30C20294D8EB14F26A7D899079187F60956CB7388AEECA1B35F7491A779DFA18", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.TesterFuncFactory", + "sourceSha256": "D57EFF3CD4346E4C41E6ABCB9A3537466A6BB1836289560F027B76D343F3CC01", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.TimeSpanExtensions", + "sourceSha256": "733B9CD95222FEF93D294D5AC46F947D72D84AFEDC4891C5BCF65E497D3A2792", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.VerticalDirection", + "sourceSha256": "B54981B7E5D0CCACCF6E6A0F601413B787B5F900D69C5CE2A5081842BB1E46D8", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Wrapper", + "sourceSha256": "65381E786FE6E0BF810671AA93F3FBCE3ACAB25CD2F34A495C8625E8B5021D10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Xml.ByteArrayExtensions", + "sourceSha256": "B9C6AFDB0D8B99E6DC315BB6E9B0FA57805E1064CB26E855D9783E95066C053B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Xml.Linq.StringExtensions", + "sourceSha256": "62AF2BFCD6CA71D635938592845CD98641C73EAC0773FF4A53B46DE546493819", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.FormattingOptions", + "sourceSha256": "F37F4F8B00448AEFDDC9CEAAC3B7C91FB31C994B1EE14F9C8EFCCD7BB6DE1C1E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Globalization.StatisticalRegionInfo", + "sourceSha256": "363DA77E0A0E8925EB347583D92F75BC44A1EDFD34BB941C08082753EBC98F53", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Globalization.StatisticalRegionKind", + "sourceSha256": "7591C87ED5204E5F7FE5F77A7806B59D95ACACE865CB73917EF2415F53C8E69F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Globalization.World", + "sourceSha256": "12C944DC59C7352346618B5B5F157BFFB94735FC2A374E6986AB7BDA221C66BD", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.GuidFormats", + "sourceSha256": "7FA1F3FE53408D432A1897F92C94A75B7F27FA753EB90FEA1DC9987A8B7863F4", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Messaging.RequestToken", + "sourceSha256": "0D2A225184D799DF1E5FCA2A9155051BEE09389FBCCA06ED6BEBE736D56A14F9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.MutableTuple`1", + "sourceSha256": "1D3B8A4F6AE0526471175C1DFA2D2F2636D026C8DB54AC06F6294AE8EA2D3362", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.FieldValueSeparator", + "sourceSha256": "66635D02B3EC6170C1EE6B64979BD85AF3FE54FCD0535ABBD6A85291C99769D0", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.ObjectFormattingOptions", + "sourceSha256": "7F48C176FD091279A6E4F8BCCF86ABD46F010D4D2BF35A010D32E646FACD31FE", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.ActivatorFactory", + "sourceSha256": "100E3BF01B07F67AE0DD9DC79BCF57584E27A0EBA197923E4670F70BB8085645", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.AssemblyContext", + "sourceSha256": "26E60C5A032C02A472F4DF62F925FFAA0B79B2694355EE92532B2F5BBA6DD946", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.ManifestResourceMatch", + "sourceSha256": "D8047A8C6A239DF7281A2D98D39CA875826FF323B43B846A9A0F08EE5B6955BE", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.VersionResult", + "sourceSha256": "BBFC15CC349F6FF09E1FD3FF2EFF11D19F5345BFBDEA0BFCE36D5349A64A6FBE", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Runtime.Caching.CacheEntry", + "sourceSha256": "C8A100F45270519709998138BAEC51D7432F144D1C8A5AD015E25AABD5362E0F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Runtime.Caching@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Runtime.Caching.CacheInvalidation", + "sourceSha256": "4474047C34A1302ED9EB63A9BB7167C8C981B6A15F01197C2985337A574272FD", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Runtime.Caching@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Runtime.Caching.SlimMemoryCacheOptions", + "sourceSha256": "A42DD71A074B108DB0F186C6BD1F79B7F37E2DDEB137FAA08323DA236007441B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Runtime.Caching@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Runtime.Serialization.Formatters.Formatter", + "sourceSha256": "244DAA99E4B5427334CDBEC1400B5D864828531F1761D80480ECAA4685F92F90", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.AesCryptorOptions", + "sourceSha256": "749ED5DAC48D64725011182184CAB2C6B35EB5EA1B929B7B8397F0533B8AFE4B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.AesSize", + "sourceSha256": "DE0829EC12CF7F97D3AC253FD84E8686B697E9226C98674AB24C470491342EFF", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.HmacSecureHashAlgorithm256", + "sourceSha256": "472FB862E97DE13CD8C644B21AAEF216867592443FCFC5EFEC74A39948A47EEA", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.HmacSecureHashAlgorithm384", + "sourceSha256": "CC0A44FAF6BB5C4F4780CB8DBF199898A7AC8A6DFB18A4684BA09B235CA6DF54", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.HmacSecureHashAlgorithm512", + "sourceSha256": "B3269621478CA44D0F53C83BD6C3B40E136FB23521C9FC848869FBE58FA4EBA7", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.KeyedHashFactory", + "sourceSha256": "F489155F2E548A8FEA63E6C455006856C116201145B87B8F6A8A2C851C0CE0EF", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.MessageDigest5", + "sourceSha256": "81813DB3B9490472BF012DBD851636A664E0D2133E213884789D41E96E569E93", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.SecureHashAlgorithm1", + "sourceSha256": "67238F44658FDA52A1EBBD58E5488F4695A36F4B858AB0028F8D1ACAB2513311", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.SecureHashAlgorithm256", + "sourceSha256": "7D03804546E5DE5C6908F15292E27633971A839269BDB5148CCC09680DCB45D2", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.SecureHashAlgorithm384", + "sourceSha256": "02AAB8B966CD1701EDD07256C8A60CBD867DD771456B532E0189F60098FC368A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.SecureHashAlgorithm512", + "sourceSha256": "CD1CBDD90FBA5EC17E5E53537C80CC4D7AB4D8A31074E451E18CB5C52512B0E4", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.SecureHashAlgorithm512256", + "sourceSha256": "268BE417A561E0CECE3F113983C5674B7E9973B9BACCE843BC74CF1B6C54C62A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.SHA512256", + "sourceSha256": "28BF592846669F213E607ABC0533F2B8C5C8F68B13518F537C1824EFF8BE0B6A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.UnkeyedHashFactory", + "sourceSha256": "690577B43957BB2B4349CEBB65CB338751D93DF59AAAD77650C0C9CB67822F60", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.CyclicRedundancyCheck32", + "sourceSha256": "83A65A26FEE49F39D6E66210F79C0BC2F71C936942C7B1F97F7DF630D6AC070A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.CyclicRedundancyCheck64", + "sourceSha256": "0B64CB4DEC49F0464FA2F417B209CDE25358865912FA8DFB147A9E188867B444", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.CyclicRedundancyCheckAlgorithm", + "sourceSha256": "D67681ACE048ECA107E2840E777BB7B4733E11026911E26E44EBD770F7EB2BE6", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.CyclicRedundancyCheckOptions", + "sourceSha256": "DC1398D73C910652E2225899533442B06AAC7420ED9F9B48B2F0A3C1D917FE40", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.FowlerNollVo1024", + "sourceSha256": "4452F6CF30E5CC478C62ABDA2DD5E9B85659FA1884B3A408CC10E84A87763CF2", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.FowlerNollVo32", + "sourceSha256": "0575462C28C7EC6869BD17C95B689B7DE74688A6225F94C65A96088CB7104044", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.FowlerNollVo64", + "sourceSha256": "0114710110D84EA66FF56785C766C569E04111264FA83BC60AFDF80296BDFC30", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.HashFactory", + "sourceSha256": "A5F8B8885E2892347DADA03F9ECCB9823F25485DA757B4FABAEE935D1316B915", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.StringReplacePair", + "sourceSha256": "C01D1C0C388CDE5144EBC21BA247E06DE0DD6EE74E3A0BB35F8AD38D1B5D6B6C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.TesterFunc`2", + "sourceSha256": "7A153664980E6609FFC906FEB9084DF9AFF8FF60DE409E9A58C482B81383E622", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Text.EncodingOptions", + "sourceSha256": "3F9C59294EE2A1AC4983ED91E39F15B3FCE06F76998825915EEE6EE4818A28E0", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Text.EnumStringOptions", + "sourceSha256": "67B4CD7F246806933483ADBA5AF344C94B5BC5E07C9B0F4BB3EB0430EA44EF06", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Text.GuidStringOptions", + "sourceSha256": "F8B784AC4F65EBB1A1BA5A95E0B923AB9CBB2C9D4D46446743F8A2E89B357AFA", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Text.ParserFactory", + "sourceSha256": "119046A46B2CFC3A38246A3B236FC1F5D580FA804A020B7994A0A160708EBCCE", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Text.PreambleSequence", + "sourceSha256": "DBBF1D424C848150A13FB55153B15627C207B5D26DA8E6BFEA4D252697E28041", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.TimeRange", + "sourceSha256": "65792AA41547F253C427C4A2D85FFF73640F62325159F3DFC1F450C12316180D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.TimeUnit", + "sourceSha256": "B6B16025439E8CA757A9807E014F1684B9D7D97A4CABFAB76767064E7D63A981", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.UriScheme", + "sourceSha256": "D50A5E52C1F252F709FAFD84A6EF319C0ECBD8BEA814BE17A1BC18744DD7CCD5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.Serialization.Converters.XmlConverterDecoratorExtensions", + "sourceSha256": "3C55D492470344695B15DC5725A6EFAB4ACAB645B1D1261E9AB3E8772595AF63", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.Serialization.XmlSerializerOptions", + "sourceSha256": "41386D1CFDC7722AA4E3F20D77F966B9435B798EB8031CBB97BEFC60124D0FEA", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.XmlDocumentFactory", + "sourceSha256": "ECA17DF87E9DF86D75DD1EAA971598A6B9B6736DA326595ECFE10F7951830A3D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.XPath.XPathDocumentFactory", + "sourceSha256": "9013FD0073EBF73AB515FB5F95402A714D7309FAB3BB3FBECCC7C560C7815120", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.ActionFactory`1", + "sourceSha256": "4E98085752E0D0B3078F18DA5A54AD53E0EF8DE3C38A653C8BA349F1DC5A406E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Int32DecoratorExtensions", + "sourceSha256": "D05E098698B068272A3DE372620D87027F9869EABEF4EE72AC76A15248B920B1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.Integrity.ChecksumBuilderDecoratorExtensions", + "sourceSha256": "5275CF5E9E070F6EB5DDCB98AA6FCFF5AA8916AB499906C93BB4690EACA64C96", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.TokenBuilder", + "sourceSha256": "85CEC0F2CBE487441FEE558E7153CAB34EC1BCBF317752C3A14F8DF1568A6E13", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Http.Int32Extensions", + "sourceSha256": "0932FA42B32C886E305FC91BD263F79D1457DC4CF72494E8F2921994CA6C7817", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Data.Integrity.ChecksumBuilderExtensions", + "sourceSha256": "2FC27E9C843A26094A9F3257E91F04330ABDE678C413E7DA8567C300EFC4728C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Extensions.Data.Integrity@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Globalization.StatisticalRegionExtensions", + "sourceSha256": "CC17BA51F9A1769F362771FF5DAF218CDF3D75C9637354673E21DB41CDE492D8", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.StringDecoratorExtensions", + "sourceSha256": "93687ED3E471F61088D3FCFD56394B5329391DD7427F746966F5C43BC6FFE9CB", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptor", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptor#1", + "fenceOrdinal": 1, + "sourceSha256": "DBF2A9FF0449240C034E3A3478120C1BC52BBEB61E0F1DA89E412AF5EB05CC97", + "whitespaceSha256": "5FBCB2D6F61DA5467389376137450DCAB7898F4A7F4B7B35F0AB55B398445E72", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Configuration.CacheBustingOptions", + "exampleId": "Cuemon.AspNetCore.Configuration.CacheBustingOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "046BD5971C103EB7D608AEC26E596476256A1C52B2689023336388851686D037", + "whitespaceSha256": "1C7164BBB47F44B14B0DCFDB74E75C27009EA8DFD79AA5FE3B1AE8BBE9F2965E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Configuration.DynamicCacheBustingOptions", + "exampleId": "Cuemon.AspNetCore.Configuration.DynamicCacheBustingOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "FDBB4536F6CAA3C5FA47EDE8E567B4876CDB7725497A552124035DB035732242", + "whitespaceSha256": "C1F932DF440E51EC8EBC84589F28E1F0E630C717D2D151522CA218D2E9E099B1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptions", + "exampleId": "Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "1EF3CD906338F9226A184BFA37506DA90A2701A01DA869180BB124F39B960AB2", + "whitespaceSha256": "A65E3F7B6CF132B0FCB5CA605E9279040D47D3B629BEE0EE447168E487E4BED1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerOptions", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "665805C70D02BE8B508F043D4A480ED34F59A9E9A2ABF44702A2A3B1C110794E", + "whitespaceSha256": "4F29AA2B24D1926897840354AEFB94D0D33AA8813AF674EE30788D2C3B87CEFD", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationMiddleware", + "exampleId": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationMiddleware#1", + "fenceOrdinal": 1, + "sourceSha256": "3CA7BABFDC9C1F4334873B5ED2B93F755345D78E18861720FD777A4120A9A009", + "whitespaceSha256": "AC985AAB99B2C8C00BD316A5611CBF136E80CFD31D6D7368428BDAE0B96F9755", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationMiddleware", + "exampleId": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationMiddleware#1", + "fenceOrdinal": 1, + "sourceSha256": "A8325C52739AB3FAF2EDF4BB49B46B2971E38FAE3E3639DE360E47CAF5C7D22B", + "whitespaceSha256": "7326331D8F0ADD3F32A25B7F8D1282765B6235AA49291E23D3E1706C8450C493", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestFields", + "exampleId": "Cuemon.AspNetCore.Authentication.Digest.DigestFields#1", + "fenceOrdinal": 1, + "sourceSha256": "86235625299DD847F54AFC314B2B5AEB81C531B4A5FD53EE472F5835430D63E8", + "whitespaceSha256": "F222E5760A0E0B0A14DBFA0B0A4EABFD2DF89B960F764C61A8BF8CFE67222A73", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationMiddleware", + "exampleId": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationMiddleware#1", + "fenceOrdinal": 1, + "sourceSha256": "8E645F72FB499AF2F5BE08FBCF102C2A6A996ACB371202878C23C12E2E8B2185", + "whitespaceSha256": "343251E9ECA892118D3B2FB895E2FBE87BC6C1C60D82C458725CD4E189AE0472", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeaderBuilder", + "exampleId": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeaderBuilder#1", + "fenceOrdinal": 1, + "sourceSha256": "1CFE5DB1C8B73D08A3E3AD9091CE49A29062773634A3C8AF07410AF1A9693F83", + "whitespaceSha256": "1D11BB6C627510AA9B55331B4DCBFA3176C115070E8D254B8B1A70590BE2967A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Hmac.HmacFields", + "exampleId": "Cuemon.AspNetCore.Authentication.Hmac.HmacFields#1", + "fenceOrdinal": 1, + "sourceSha256": "43D40A0A2729BE52E443255E174B2B9FC50945F9B565B2D68DD3908C62A02289", + "whitespaceSha256": "8CE0A5357BCFFFB07C8991EDB0EC06A2688B1D90077D542F8DBAF92BA8E8C97D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.NonceTrackerEntry", + "exampleId": "Cuemon.AspNetCore.Authentication.NonceTrackerEntry#1", + "fenceOrdinal": 1, + "sourceSha256": "43D1E0764423F54E6D67F8D8AC708381E5D3A8BDF24CE76345D106C98FEAD5CB", + "whitespaceSha256": "C67D384CFEA3C7F7E2E3FFEB013238260ADED329C78B8FDA0E07CAB6749D57DB", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorDecoratorExtensions", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "9234AEAB2559D7F4C9F29CBA7CA1D5CF1B66DAE4CBE1BAF5E470FEA5DA53AB68", + "whitespaceSha256": "D43A611EBB3566183FD468E3ACF7B1B64900217954C0C4FD2CDFE6D9B29FF570", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseFormatter`1", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseFormatter`1#1", + "fenceOrdinal": 1, + "sourceSha256": "579CCA311D1BB2CD4FDBC468651F53E67C537E28953F2142CF076905449D74CE", + "whitespaceSha256": "E895438D357BFD012C4D960BBBF6ECD528497050C1C9EAFD37C2894B0558CE88", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandler", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandler#1", + "fenceOrdinal": 1, + "sourceSha256": "884514A1D37842DF3DBDB44A14FA393B636C9A3AD0CE8898801FD64611DE529C", + "whitespaceSha256": "A6FE411090035E4FAC71C981C1D8ECC55237EE4CA293A59A60442788D7EF66C5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.HttpFaultResolverDecoratorExtensions", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpFaultResolverDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "79478A09B9F455F176A25F2B39092802B1F9111652F2A6A93D7EBF1D3A98C9EF", + "whitespaceSha256": "63A547D8DD788C426E78297123B49FD3ED822BE7F614D8FE534847896601DF64", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.PreferredFaultDescriptor", + "exampleId": "Cuemon.AspNetCore.Diagnostics.PreferredFaultDescriptor#1", + "fenceOrdinal": 1, + "sourceSha256": "892F075599DFD1FD8EB83519524A78F7B8788148F1007162A76D2F2DEFCB0631", + "whitespaceSha256": "BC56C7DEF9FA037AEA2BC280CA271DE91F64BC783DE386045807A51D0A1D81E4", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.ServerTiming", + "exampleId": "Cuemon.AspNetCore.Diagnostics.ServerTiming#1", + "fenceOrdinal": 1, + "sourceSha256": "CD10C7FE8E3CBB4C947FF93A813DB2E71A064B9D274AAF1D9384BC5776D98099", + "whitespaceSha256": "67B795EC174B35BB1DF0FA66606682BC11DA0ADD612C693BB950ACB80451DA03", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.ServerTimingMetric", + "exampleId": "Cuemon.AspNetCore.Diagnostics.ServerTimingMetric#1", + "fenceOrdinal": 1, + "sourceSha256": "2972DE86E6944FA89D607D2C4BEC23E29C0FE5B9455E19BADC3E9E14C2942248", + "whitespaceSha256": "F157C2621E98B81FEA1B827CCAA6D5731ABEC6FD53EBC05EC4875CA2ECFB041A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Hosting.HostingEnvironmentOptions", + "exampleId": "Cuemon.AspNetCore.Hosting.HostingEnvironmentOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "7410606690ABA93189101D542EA4559D2AF4C2BAF4DA7D23C82F099273C146E3", + "whitespaceSha256": "52A7789EAE4E6D6437B954999DFA906659986C6A86F05EA58E23E443AD3CB2F9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Extensions.Hosting@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.BadRequestException", + "exampleId": "Cuemon.AspNetCore.Http.BadRequestException#1", + "fenceOrdinal": 1, + "sourceSha256": "CD1432A6A9CF2765386C31CA8B0917139F25BD98281975730E04B70395B6B049", + "whitespaceSha256": "84C6B7DDE101E99FCECBEE4786B15AAD09AD5AABBC33663154075613385F487A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.ConflictException", + "exampleId": "Cuemon.AspNetCore.Http.ConflictException#1", + "fenceOrdinal": 1, + "sourceSha256": "FA887C2F11E72A2C1541E2776F3B18934F4CFE74FDE0A19D5E4F21950D25E233", + "whitespaceSha256": "67FE71624BDFFFFA59F6E8CBDEFA3E0F7A549CA94671153B757D336CD570F00B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.GoneException", + "exampleId": "Cuemon.AspNetCore.Http.GoneException#1", + "fenceOrdinal": 1, + "sourceSha256": "617ACACDA0EBD0D88808BDCF157B540E640C7C1C33166691E95FA07CB37C9BA5", + "whitespaceSha256": "652182F615153D8E08B0CB732F73465175398A2754E64559D5AA8DB69CF0D626", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.HeaderDictionaryDecoratorExtensions", + "exampleId": "Cuemon.AspNetCore.Http.HeaderDictionaryDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "78617B8DA1EA8698DE85322EEE3C68CCCB1B08D32F4AF14A8A1C29B55DFF2FC5", + "whitespaceSha256": "370829C10AF4396EAF2A3AADF0CCE7C33D89BC6A199642E7B1F34EF5C86BC44B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.ApiKeyException", + "exampleId": "Cuemon.AspNetCore.Http.Headers.ApiKeyException#1", + "fenceOrdinal": 1, + "sourceSha256": "F774D0BB312F5FF3600FB378C0413DDFE4C6A6FE5F759AEC95EEC497ED355DC4", + "whitespaceSha256": "60A19535929F1C90AD1CFB88C0ECA3FE13D5B6D7BB1098A466FF523CA05BB3B3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.ApiKeySentinelMiddleware", + "exampleId": "Cuemon.AspNetCore.Http.Headers.ApiKeySentinelMiddleware#1", + "fenceOrdinal": 1, + "sourceSha256": "B5660A021ADB8D7A0CFEBA0258C26BB3D1BA33CDC67859CFDB8A540A5C796795", + "whitespaceSha256": "A9C9A74AFEF6D89FF0A2D248B0F17C0500BBA8263A7DE34FBD2EE9CFC3AC0199", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.ApiKeySentinelOptions", + "exampleId": "Cuemon.AspNetCore.Http.Headers.ApiKeySentinelOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "AE08D251F149CC61EDFAD1CDC156BFFB5832080A937F5F470AE008B7EA368556", + "whitespaceSha256": "A9546EAB402AC220665A5BBB270DCCABF2A7CB431C7D4C31C62FAEC44AB017C4", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.CacheableOptions", + "exampleId": "Cuemon.AspNetCore.Http.Headers.CacheableOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "A460881E8A87D1C4C90B2F730DCAC1747D632BF675C925F36AA08C422567263E", + "whitespaceSha256": "79F285B53927BBB458ECD024D582D48FA2ADE8D4F3E5DB28D605A682E5AC58AA", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.ChecksumBuilderDecoratorExtensions", + "exampleId": "Cuemon.AspNetCore.Http.Headers.ChecksumBuilderDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "C9DAE946AD7FA27875FA9F2E8255CB8C425CF04B93DB4B90FF4F450B5DA16BA4", + "whitespaceSha256": "B8D29859F8D09EA9D4FFCFEF4E6FA6064F2D73FBAFC7723A786AF55A7BCD76CB", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierOptions", + "exampleId": "Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "63F4FCAEDFB56BE78708730EA1543A6350298E9987CD28148543945823B70F8F", + "whitespaceSha256": "8458873FF459685D12F6BB3CD092A5DCF380C1B6D3E8DAE40CFFD24E2B63291A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.RequestIdentifierOptions", + "exampleId": "Cuemon.AspNetCore.Http.Headers.RequestIdentifierOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "2017C2F99E88A7257FEE607F02C6F097A5E552C39B1A81D7C231BC674032053C", + "whitespaceSha256": "7C20AEC3132DA06671195BEF1E03FBBFD27E9D42E455C65E22EE3E5B32B28C5E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.RetryConditionScope", + "exampleId": "Cuemon.AspNetCore.Http.Headers.RetryConditionScope#1", + "fenceOrdinal": 1, + "sourceSha256": "18C6C17025118B052BC68297331E3B49F98E876F1AFC57242B94F18DC97CA500", + "whitespaceSha256": "2FD09D7D08392AD4DFAB74F5A9B97AC7480438C26756164C891D2B0DA575DD64", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.UserAgentException", + "exampleId": "Cuemon.AspNetCore.Http.Headers.UserAgentException#1", + "fenceOrdinal": 1, + "sourceSha256": "765E49E638F638EC593B009CEAC0CDD554141A516C7808DC551894A9C81410F8", + "whitespaceSha256": "5DBA73D308D8CC4AA20208136034C9C0CB08DFE27F6D4C487FA58CA8B3035437", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.UserAgentSentinelMiddleware", + "exampleId": "Cuemon.AspNetCore.Http.Headers.UserAgentSentinelMiddleware#1", + "fenceOrdinal": 1, + "sourceSha256": "EFB4B4DF6EC7E9C44D5BBFE0D81A5117E0144C50D5C6CA4DC2110B1AB726FFDF", + "whitespaceSha256": "6796D08D193DC1FEED329FEE208DFA8951DA74E48C3003E45AF4BD8447975935", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.UserAgentSentinelOptions", + "exampleId": "Cuemon.AspNetCore.Http.Headers.UserAgentSentinelOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "4286B2014286B2C7845D4FDA2490DA0272F96FDE56A6EAD6B5B5988F75BB7A7B", + "whitespaceSha256": "5F7E23785B462967693125BB55236C59DA2C7D5180B0CC7A9F63D23D197969CB", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.HttpContextDecoratorExtensions", + "exampleId": "Cuemon.AspNetCore.Http.HttpContextDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "4A82A315AEBDBDD01DCF4F14E857480BE20DC67FED1C5A5686C5E2E5CCD4443F", + "whitespaceSha256": "AE2D16B428F1E2F22C27D069BE4667A7DF7877EB9ABFCA83CD27E8A543132232", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.HttpRequestDecoratorExtensions", + "exampleId": "Cuemon.AspNetCore.Http.HttpRequestDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "8903F2C25BFCA57B5AE134CCED23A33C9F98489341902EA390596436D5556A4D", + "whitespaceSha256": "423F9B0A8413FC7FD35BCDE220A1D3071294DE9DEB8A7FAA59ED54001FCA5408", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.InternalServerErrorException", + "exampleId": "Cuemon.AspNetCore.Http.InternalServerErrorException#1", + "fenceOrdinal": 1, + "sourceSha256": "15C3280CECC99DB6C166EFAC34E5299DF96A9DED3D45511DFC284F0103AF3FA7", + "whitespaceSha256": "6F6CE86D47F4E3977FA32F6F1D8A2A5EB1F6322A5E63EBC624C3C494CB8A254C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.MethodNotAllowedException", + "exampleId": "Cuemon.AspNetCore.Http.MethodNotAllowedException#1", + "fenceOrdinal": 1, + "sourceSha256": "7560A37B9390A871F74A49760139EC9272F3170FD0CC58AB33DA36F85E6CD70D", + "whitespaceSha256": "7B3319C3D5960F78385AD13FAA5742C187793C79BFF93AEB92865AC7C7D151E4", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.NotAcceptableException", + "exampleId": "Cuemon.AspNetCore.Http.NotAcceptableException#1", + "fenceOrdinal": 1, + "sourceSha256": "13EDB6644DCF9620897C454352872942B0283E0361F4DF2CADBEF4D18574F7CB", + "whitespaceSha256": "47492539DB02830804181BF795E74DE08DFB533550EB39CEC39942372108EAE8", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.NotFoundException", + "exampleId": "Cuemon.AspNetCore.Http.NotFoundException#1", + "fenceOrdinal": 1, + "sourceSha256": "6BC840B923F5BD9350BE2F03BF270A011D6E84E5CCBB5B29A2F0583009BD36F6", + "whitespaceSha256": "9201EDF16E50157B4DD6DAF8739EE8DDA6EE34E9CB0769EB72E21441611F5F32", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.PayloadTooLargeException", + "exampleId": "Cuemon.AspNetCore.Http.PayloadTooLargeException#1", + "fenceOrdinal": 1, + "sourceSha256": "31DC76C2AC8F3496108EDC3B7315BCC27740B9E6D67D7F27F55DA34D9FA779D6", + "whitespaceSha256": "37A2CC711A04C491F0147B4A1B304565B1A8C028E82219449D3EF5F15FC9E1E7", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.PreconditionFailedException", + "exampleId": "Cuemon.AspNetCore.Http.PreconditionFailedException#1", + "fenceOrdinal": 1, + "sourceSha256": "1D9F01A65E794F40B72D133FD1136293ACEDE9DC4DAC9ECF3917622677D62C7B", + "whitespaceSha256": "7A66A4776A6A6017A8BCC6BE98B75519DCB9A8A23A8AC19E363664C1C6C26B66", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.PreconditionRequiredException", + "exampleId": "Cuemon.AspNetCore.Http.PreconditionRequiredException#1", + "fenceOrdinal": 1, + "sourceSha256": "70AC180D20BD19BA6597538A19D724C6C8185A59BFD6DA157DD64A50B279AA31", + "whitespaceSha256": "F045F834E29021CC8F6DE6404DE18970C6D7F506EDBD382B511A1C8F62C853E5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Throttling.MemoryThrottlingCache", + "exampleId": "Cuemon.AspNetCore.Http.Throttling.MemoryThrottlingCache#1", + "fenceOrdinal": 1, + "sourceSha256": "B56E430ADB72C48DC9D100626BB6C1CCB64B080EBE98D5524D37CA7E7A0687FC", + "whitespaceSha256": "04980A5FBCD7AAF85845C453CEA7CDB6546E74354C99A1F60E53E16A7ADD4C6D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Throttling.ThrottleQuota", + "exampleId": "Cuemon.AspNetCore.Http.Throttling.ThrottleQuota#1", + "fenceOrdinal": 1, + "sourceSha256": "A815F77554D0E1E8D017655217969D6EA1768056FA5F664A62F04406E9C332B0", + "whitespaceSha256": "F40E83812B0741CC32F1AA9781A8F75473D505B44D46F36E3F67D4AE980BAF86", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Throttling.ThrottleRequest", + "exampleId": "Cuemon.AspNetCore.Http.Throttling.ThrottleRequest#1", + "fenceOrdinal": 1, + "sourceSha256": "B5B7B7B7F6F33CCC0AE4634209BF38502348B8F960CF5072F7679A46DD1594C0", + "whitespaceSha256": "87E7D0CE8A9A2A4DF425965CF1DF585E82630EE4A993206BA6427CF7E5D58050", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Throttling.ThrottlingException", + "exampleId": "Cuemon.AspNetCore.Http.Throttling.ThrottlingException#1", + "fenceOrdinal": 1, + "sourceSha256": "9DF35650303DEFCF6065B2B8937844A1FCA6229BDB34CDE9A2F2F1BC5AE74573", + "whitespaceSha256": "1405B1E0F67566FC7CCEDD0FB63D0873B0C8DA20B08F9082F773DB868EE37C35", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelMiddleware", + "exampleId": "Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelMiddleware#1", + "fenceOrdinal": 1, + "sourceSha256": "63733ADD87875D425DE76DAF30209B96A2BC6D853A420F6B48747F64A29C71EF", + "whitespaceSha256": "6F64D13A72F6A56BE19A2218687145395BCBE38B306AD13600E42E67E9B9F905", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelOptions", + "exampleId": "Cuemon.AspNetCore.Http.Throttling.ThrottlingSentinelOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "CABED1EE806DD02170A836503DE63F5E5776E91BFF580822C0B89AD8DD0B1D52", + "whitespaceSha256": "D261CC5DF010B19A6D7A0F6140BF6EE2F677F01FF11635636D03E3D584DBE987", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.UnauthorizedException", + "exampleId": "Cuemon.AspNetCore.Http.UnauthorizedException#1", + "fenceOrdinal": 1, + "sourceSha256": "CFD610D4B62488AAD8CCE58EAAAD3986915EE8526062A0E8D8B8BC1F53022FF8", + "whitespaceSha256": "6B4996FAB5DB774F7095E2002E1CFA2EAB25758F98AE6B588F43707809E7AA55", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.CacheableFactory", + "exampleId": "Cuemon.AspNetCore.Mvc.CacheableFactory#1", + "fenceOrdinal": 1, + "sourceSha256": "0B5095493083C6FDACCB3703F3167E9AC5C3FE4892BF44B8A1932013EE98FFF9", + "whitespaceSha256": "083B6C5878E49E2F70AFDD2922AF22365F8B9201D13D731C2BE05ED4374E4714", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.CacheableObjectResultOptions`1", + "exampleId": "Cuemon.AspNetCore.Mvc.CacheableObjectResultOptions`1#1", + "fenceOrdinal": 1, + "sourceSha256": "3922C97DAA95B3412D3858D0D6C9CE032245A5A607C1B56E498B7EEA013D659B", + "whitespaceSha256": "D0EE3D52CFB12687E6B05AF8FE6D10FEBA5EB9769A8C4600E84E209BBFC615D9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpEntityTagHeaderOptions", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpEntityTagHeaderOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "04A06BDE9C2F1CF3677796A992E3DE5F4962E0F30E0C8E36677E0D5BD395D56A", + "whitespaceSha256": "AE55B706305E48420E44AC4BBFA4032DA5D19675783323EADF49C6589CA991B7", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpLastModifiedHeaderOptions", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Cacheable.HttpLastModifiedHeaderOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "934B8A9C986B50A186443B1C3D34522107D207713CB0B191B208777EA788A879", + "whitespaceSha256": "BDEBB41F080FDBC1B29C6651B61E6D378BE52F0802194810369B012A1CAB2AD9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingAttribute", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingAttribute#1", + "fenceOrdinal": 1, + "sourceSha256": "561CF282F87E525DBA908DF0B0D4EA05313D976D48A00ADD456FCF3461658FC9", + "whitespaceSha256": "C9AD3CDFB1977482AA44B2A6D52FC7B7265D3480D4F21B0BD5FC1A0883777A3A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingFilter", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Diagnostics.ServerTimingFilter#1", + "fenceOrdinal": 1, + "sourceSha256": "E878E42A96BB0BAF41155AC68C66F98F068AC4B65A5174FF92775DA9F4E9D877", + "whitespaceSha256": "2378721556A6F3B51A126D748D790F9E62B4608EC07DA893693BE84DAF5C3955", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Mvc@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.Hosting@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.Filters.Headers.ApiKeySentinelFilter", + "exampleId": "Cuemon.AspNetCore.Mvc.Filters.Headers.ApiKeySentinelFilter#1", + "fenceOrdinal": 1, + "sourceSha256": "E75B2DE1C5C32E962838F6A2193CE47153C87F804F3BF31DE21236FE2A9C7C49", + "whitespaceSha256": "4C4AFB586959480FD34F02FF1505D47B5520F5321224A80233EB659790D5EA85", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Mvc@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.ForbiddenObjectResult", + "exampleId": "Cuemon.AspNetCore.Mvc.ForbiddenObjectResult#1", + "fenceOrdinal": 1, + "sourceSha256": "2D391AD1B2EBEFE4EA9A1A6C34C0DFC796532F0B51110D308DFCEF4C95270DB7", + "whitespaceSha256": "AD37D93526F867B609DA72B67495759FB2054FF192EB9CE3B57073A036984ACD", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.TooManyRequestsObjectResult", + "exampleId": "Cuemon.AspNetCore.Mvc.TooManyRequestsObjectResult#1", + "fenceOrdinal": 1, + "sourceSha256": "061F31320D3C39165DBF39B7F0AAE023090F99A20B8A07B70C94639C7F9C3097", + "whitespaceSha256": "7A234380057767D33A1CB4355176E0484D172EEF7070FFD5F896E75C46191020", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Mvc.TooManyRequestsResult", + "exampleId": "Cuemon.AspNetCore.Mvc.TooManyRequestsResult#1", + "fenceOrdinal": 1, + "sourceSha256": "32A6969A856FAEE5507A620FA45FFC9C63BF79AEDE66104AF6C7D298EF649FD4", + "whitespaceSha256": "1C48BF6A07B456FC7A0D132D4D2F43DA9659F8898456ED9CC703A4B181F44B3B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.AppImageTagHelper", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.AppImageTagHelper#1", + "fenceOrdinal": 1, + "sourceSha256": "1033113E158C3BE4E635687C590148CF88C143B91F518B3342D6F6D34E147EA6", + "whitespaceSha256": "C8B83AC7C109523D0DF64D392E952ECBF6AD734A3CB38A09CECDC40A7A28CF6C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.AppLinkTagHelper", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.AppLinkTagHelper#1", + "fenceOrdinal": 1, + "sourceSha256": "C3631BEE3782815588179BF9BC11298C50DE69C356193298B0974F6D038BEE36", + "whitespaceSha256": "84AC770A7E9AB19631CFDEF08FDDBAD99A6CE01879945D95DB5EA259E9DCD8DF", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.CdnImageTagHelper", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.CdnImageTagHelper#1", + "fenceOrdinal": 1, + "sourceSha256": "A4D23B43647B9425323C610B184EDB97798B9B67247F386F70948FBE4A4128C4", + "whitespaceSha256": "6F2FF01C40CA6FC783C96E6EDA005417FA51EFCB332EAA498641C0BDEECB8B38", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.CdnLinkTagHelper", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.CdnLinkTagHelper#1", + "fenceOrdinal": 1, + "sourceSha256": "97C2A72222AC1A85772F52504C1725B454C6E523F0349C1AEB15F9231B79B44D", + "whitespaceSha256": "0962122F95F61CDC2483474A43E8A17949C1B953B96760BF1B29B0365E0A9718", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Razor.TagHelpers.CdnScriptTagHelper", + "exampleId": "Cuemon.AspNetCore.Razor.TagHelpers.CdnScriptTagHelper#1", + "fenceOrdinal": 1, + "sourceSha256": "1A32A9A28D33F119C20F3266E50C98882635F19368279317051EBE6A536C054E", + "whitespaceSha256": "D45D20546ED858C352E6AB7512CD7E144E819391E850DE91F31E0C48D5C87699", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AssignmentOperator", + "exampleId": "Cuemon.AssignmentOperator#1", + "fenceOrdinal": 1, + "sourceSha256": "235E093FA4EEA95E6F354176B3BD93AEA390F11964FA8045E26DAE6E0957D7EF", + "whitespaceSha256": "86EF5C2A989884671815934567D6E72BA60E8D9E0C614DD07A90E785BDC4D9BA", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.ByteArrayDecoratorExtensions", + "exampleId": "Cuemon.ByteArrayDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "969311CFA17FDC816FB4104FFAF7DC8042389F2C189CB87588CB09F52B87C435", + "whitespaceSha256": "3FB34DB339BE5030EC98F5AA159C5F9233C1367C3B2C757C96B3798305262FC2", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.CharDecoratorExtensions", + "exampleId": "Cuemon.CharDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "0889A05E01CAA520704BBC0FBA7178420579AD3F6D8F1D1D2E0DBF08169247D7", + "whitespaceSha256": "D5E36AF749C482A98D9159FF8B179E1D10AD06C71EB857B532182C7093B06299", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Collections.Generic.CollectionDecoratorExtensions", + "exampleId": "Cuemon.Collections.Generic.CollectionDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "7623FD5E5A2517831F5469F39619B77820AA429A09F62A25CE036C43D571C7BE", + "whitespaceSha256": "D8209C5AEA91846DFD443139726A0C6EA454B143D597166BF3D30A1F83B56129", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Collections.Generic.DictionaryDecoratorExtensions", + "exampleId": "Cuemon.Collections.Generic.DictionaryDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "30522E76A5045BA69C97CFABB72D3CC721F0B99CD2D3AF9C301B474D0919F895", + "whitespaceSha256": "463F481E1163A6B6DF538F74A2246015585CBA9AE2576572C0EBEBC00D89B848", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Collections.Generic.EnumerableSizeComparer`1", + "exampleId": "Cuemon.Collections.Generic.EnumerableSizeComparer`1#1", + "fenceOrdinal": 1, + "sourceSha256": "2B6B1DCB6331A0A0690FDADC7DD01F4543D755012CA54FC48E9D7DB35FFD0FE9", + "whitespaceSha256": "7890807ED63EABCC8FB9478EADB42FB071B8E34789CA5EFAD5B998FAD380C173", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Collections.Generic.PaginationEnumerable`1", + "exampleId": "Cuemon.Collections.Generic.PaginationEnumerable`1#1", + "fenceOrdinal": 1, + "sourceSha256": "687C59B973184B53821DB7735F4B49BEA8B43272D58E87FBC3103BCBD4FA6643", + "whitespaceSha256": "E38A48DB2968F1B84049EB6BDC974C533CAB199AFF315898F99EF233CF401D7A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Collections.Generic.PaginationList`1", + "exampleId": "Cuemon.Collections.Generic.PaginationList`1#1", + "fenceOrdinal": 1, + "sourceSha256": "AE589BDB9E5D6B58124E010FD6581AF71AF7BD43DEDFD49F6D1FA2DA03017500", + "whitespaceSha256": "F8DE50E196B9F0BC23727DDF467098496862DC5D92A63704E93666583C364898", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Collections.Generic.PartitionerCollection`1", + "exampleId": "Cuemon.Collections.Generic.PartitionerCollection`1#1", + "fenceOrdinal": 1, + "sourceSha256": "791CAC8D09D097E5DFBC5ACD170138D9403C7583C97347CF141DEA6F6104A5B4", + "whitespaceSha256": "5E92F937930C383BF1FBB3B2CE46514FEEA742BDB8615B97A6C69EC67CF222F5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Condition", + "exampleId": "Cuemon.Condition#1", + "fenceOrdinal": 1, + "sourceSha256": "DF5459382824418FF64273226119C48622324F51374F0D43C2947656D1FD37C2", + "whitespaceSha256": "5E3C9383050071FD6BF057F8B11DEC073E10B553F8B6DE4769B76A42FD2A69B9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.DatabaseWatcher", + "exampleId": "Cuemon.Data.DatabaseWatcher#1", + "fenceOrdinal": 1, + "sourceSha256": "8122A4A0C3A1D441BA43CA919F97FB19BE761B3AB23B967D7BB8AAE3B95A6F12", + "whitespaceSha256": "DF8F2165F5F52145F8311AFA44D02D248862336A9866A426F0BEDA7CB05CDC70", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.DataManagerOptions", + "exampleId": "Cuemon.Data.DataManagerOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "5E2BD3A9D0B02BB8AFBAD5CECF7C1D6D2556EBC2656B9D5AC66EC7F1B738CCB1", + "whitespaceSha256": "340E98E4EE483EC40223155BFDC28F0CC6A522C2D72E20F68889113100E4932C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.DataStatement", + "exampleId": "Cuemon.Data.DataStatement#1", + "fenceOrdinal": 1, + "sourceSha256": "17C4036193CC93616DF65A0639F3372D113FFE41463C9C1628A098D86329B9C1", + "whitespaceSha256": "5C44D6916DD6BB479E5F8E7C7C44FA9BD5D11DAB974931998C4822B45A92CB68", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.DataStatementOptions", + "exampleId": "Cuemon.Data.DataStatementOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "85B1DF151861128F653754F21714DEA383BC5F7C9AF2602740A847CB24B9BB33", + "whitespaceSha256": "A06C21804A57D11D8856E805E98365C37D6663FD7E2832530E9B451AC77D84EF", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.DataTransfer", + "exampleId": "Cuemon.Data.DataTransfer#1", + "fenceOrdinal": 1, + "sourceSha256": "E9FE046DF33F89A3499B847159FE6D3B7ADEC57CD1C5F2E37C6C6DC3147796E0", + "whitespaceSha256": "350C9CB63B7E6E2740821E6B6A9A1B150B8DDF3EC17B7EE532A5B38E4900EB84", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.DataTransferColumn", + "exampleId": "Cuemon.Data.DataTransferColumn#1", + "fenceOrdinal": 1, + "sourceSha256": "2A1FAB4D7BF7FE04226A9E4A4394F509C3A3D44B5D6AB5ECDFED99C246056C76", + "whitespaceSha256": "D27AADECCC4E1DF2677FC600793F6B580E5C0C2544CED56DA8FC8F7EFFA46E68", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.DataTransferColumnCollection", + "exampleId": "Cuemon.Data.DataTransferColumnCollection#1", + "fenceOrdinal": 1, + "sourceSha256": "F4A4E289C8A6289BC9AD8D2C15640FCAC81CDECDD2D7FB61FEE4C61456CF5474", + "whitespaceSha256": "9F2D67358229851A80C343DA51D716880F69630F8631E313FA78CC304BEBC5EC", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.DataTransferRow", + "exampleId": "Cuemon.Data.DataTransferRow#1", + "fenceOrdinal": 1, + "sourceSha256": "366030CC93132EA47B9E74A340C56CA780C260BAF0264E2C654CF1EA7728F246", + "whitespaceSha256": "B96CD49B1291F2D383CED2466E2BF795A111051DA7F3E5DA58478100122F3012", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.DataTransferRowCollection", + "exampleId": "Cuemon.Data.DataTransferRowCollection#1", + "fenceOrdinal": 1, + "sourceSha256": "FDC23A87F3572B2D36F46BEEB2F8D43EB1A17E070EB00B63CDC7E3BD5BD11041", + "whitespaceSha256": "715B0ABE62A7D721535BB9E36EEC311402588481A99765954C43971C2798E6ED", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.DsvDataReader", + "exampleId": "Cuemon.Data.DsvDataReader#1", + "fenceOrdinal": 1, + "sourceSha256": "F54C1026001BB786D3064BA4365949FF7119DE398A6F6CA00359FA2A31DE9A17", + "whitespaceSha256": "655C2DD861291413E440EC3EE598F832808E1E82065C8CBFE7EE073426D8EF7C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.Integrity.CacheValidator", + "exampleId": "Cuemon.Data.Integrity.CacheValidator#1", + "fenceOrdinal": 1, + "sourceSha256": "5DDA5F833BF2E68E619EB247D3BA8682C8A7A2FA741F02E270ACEB1BD72BAEE2", + "whitespaceSha256": "5FCDC9EC6C59753195611AA1E2AC0F7C0E1E4BB90A2B555764E63627FF2104F3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.Integrity.CacheValidatorFactory", + "exampleId": "Cuemon.Data.Integrity.CacheValidatorFactory#1", + "fenceOrdinal": 1, + "sourceSha256": "E10009D18F29DFCC15D42072A5DCE2740C8C330AABAA834FF07D16D1AC4D0E76", + "whitespaceSha256": "34CA1D4C0B2E02226C108533B1808D82C6EF0FC601157EAF4BE377A9C01D93E3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.Integrity.ChecksumBuilder", + "exampleId": "Cuemon.Data.Integrity.ChecksumBuilder#1", + "fenceOrdinal": 1, + "sourceSha256": "E871083579D383D18BD300485F45BA05A7523C35E47E0CD16C207887FBBCC4D4", + "whitespaceSha256": "037FA06BACCD297E87864F9524E2CA484243856FC68942E4A222E062CE47968B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.Integrity.DataIntegrityFactory", + "exampleId": "Cuemon.Data.Integrity.DataIntegrityFactory#1", + "fenceOrdinal": 1, + "sourceSha256": "F79D3811E919C605D582D73AEC14A14AAC6E69227ABDB0A318CBA0113B532C8E", + "whitespaceSha256": "1768D166722327F4D25D33C820E61DEBCC03A802D273427686CA8A3FD765E9F6", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.Integrity.EntityDataIntegrityValidation", + "exampleId": "Cuemon.Data.Integrity.EntityDataIntegrityValidation#1", + "fenceOrdinal": 1, + "sourceSha256": "DB5490295AB9F3F57621CE02DA2D685C402C490EE379CF421A2FB6902FB8BD77", + "whitespaceSha256": "2A42A7C4286B185821272C46B7645D8BEC5255A38C87E0F041BA3A00BAF098AE", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.Integrity.EntityInfo", + "exampleId": "Cuemon.Data.Integrity.EntityInfo#1", + "fenceOrdinal": 1, + "sourceSha256": "551D29568A158C1F7AEF51DCDA371FBA5D5B9EF8BD8664955306168288F02C97", + "whitespaceSha256": "E0C41D4BF066444A1624232239B4D3DEF94DF84641749D6840C6322AAE41463E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.Integrity.FileChecksumOptions", + "exampleId": "Cuemon.Data.Integrity.FileChecksumOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "E18A157F53A45283778BEE3A744A01ACDD0FA4521E8CFEDBB7E023351D1E4FC0", + "whitespaceSha256": "46503F1912A7701F77D28C74883B34039D10B3C603A964FDED02EEDA597BD71A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data.Integrity@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.Integrity.FileIntegrityOptions", + "exampleId": "Cuemon.Data.Integrity.FileIntegrityOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "26BE55F567C78CA5A5A5DA20162DF0BCEB463013866EF03F5D24FCB24E80F8C2", + "whitespaceSha256": "F5550A2EC1A8FD673967323F37E967F97CF6A97EF67B560C0EB98C04E4E94E83", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.QueryFormat", + "exampleId": "Cuemon.Data.QueryFormat#1", + "fenceOrdinal": 1, + "sourceSha256": "7D7EDF18BFC674BA4FDF8AD96CA0F9343F097D20710CF25F59EB6C058D792529", + "whitespaceSha256": "525A0E8A16419747FD3099F237DB996E870C153E0F38B103B7A038D2BEC48A14", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.SqlClient.SqlInOperator`1", + "exampleId": "Cuemon.Data.SqlClient.SqlInOperator`1#1", + "fenceOrdinal": 1, + "sourceSha256": "CCF7AF9E8A09D05FB1DB0691933CBBCE3A957596B17382B8A6D683E1C3233B7C", + "whitespaceSha256": "F04E2D7074DCCA6D79B3545FBCD6074B45B1FF448FB05BD5DAA593D116140A46", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0", + "Cuemon.Data.SqlClient@11.0.0", + "Microsoft.Data.SqlClient@7.1.1" + ] + } + }, + { + "uid": "Cuemon.Data.SqlClient.SqlQueryBuilder", + "exampleId": "Cuemon.Data.SqlClient.SqlQueryBuilder#1", + "fenceOrdinal": 1, + "sourceSha256": "BE6D15DFEC02FF16004FAA277F7497E01B65D6E5BD0DD80AC42633DB77B25606", + "whitespaceSha256": "355CCCB8DF3EB083EB492AA253F13D549FC7956F091E6708E320D80424DC9574", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0", + "Cuemon.Data.SqlClient@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.UniqueIndexViolationException", + "exampleId": "Cuemon.Data.UniqueIndexViolationException#1", + "fenceOrdinal": 1, + "sourceSha256": "9A404421022781D0782A6CFF4AF9DFA50BE6275FE466CB9004A31EBF3DE99D17", + "whitespaceSha256": "51C383E4B5A1C5C33B75D680AE84D29FADCB24C5C40D93A52270EA31BC0006F9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.Xml.XmlDataReader", + "exampleId": "Cuemon.Data.Xml.XmlDataReader#1", + "fenceOrdinal": 1, + "sourceSha256": "9AAB887AA49C07206F757AC3E2A6DBF4FCF058A288EEEDD836D1B38E9A3CAE24", + "whitespaceSha256": "001F4A179247A674DE4722A98C7B2395D7577F48B882537D37734C0A4FAA2C77", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.DataPair", + "exampleId": "Cuemon.DataPair#1", + "fenceOrdinal": 1, + "sourceSha256": "1097273977152D74D0262F33CB337A61DDCEF5170FBF37D0907A10C3AC50945E", + "whitespaceSha256": "54EB2B4CB55348841DB4A2F33011BDC6087C2C9AC8FC9A0FDCF5464E047C7637", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.DataPair`1", + "exampleId": "Cuemon.DataPair`1#1", + "fenceOrdinal": 1, + "sourceSha256": "4DD04E90A26782A115046A14FD4AF099BE2ED3F31E856F576C36628F62BFC7D9", + "whitespaceSha256": "553707773F43976004FE29716E84300504663ABB1C63CF7D7FB7610DDF1B1ACB", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.DateSpan", + "exampleId": "Cuemon.DateSpan#1", + "fenceOrdinal": 1, + "sourceSha256": "A2728A13CF32D4390AC7DA00EAC4BF4BB42B5C8FB420C390FCFA96A9E5B8FA0F", + "whitespaceSha256": "B0BBFF82AC422C8751D7E142EEC2FCE1D5CFE7449EBFDFEB4CD8D667C5011586", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.DateTimeDecoratorExtensions", + "exampleId": "Cuemon.DateTimeDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "E15CB5BC4E7D2F5E8809A35FE28B64BAAA609F7611CF0876FD63ED0D2C971C43", + "whitespaceSha256": "93E5C68879D603D0C9EC2C19F60C6A841756C30D7F1206272C4CF47030DB1110", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.DateTimeFormatPattern", + "exampleId": "Cuemon.DateTimeFormatPattern#1", + "fenceOrdinal": 1, + "sourceSha256": "3694EC799C6621E677DA943A06BEB378423A5CECFCDE66A4514C313FD4FA3E78", + "whitespaceSha256": "AD37C001030919FB9B83FC2FE7B8B852553CB7F13C6BB6603C766A8CEB8DEB3C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.DateTimeRange", + "exampleId": "Cuemon.DateTimeRange#1", + "fenceOrdinal": 1, + "sourceSha256": "F915A21F0C9E6D319EA30CFBCEEB3DC04AE824D85227FF99A4FDA790E9EA5A31", + "whitespaceSha256": "40F95F91CEA71FB1EDB1592D3675AA62B3E2AE62956EB4783435F274F38D2D19", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.DayPart", + "exampleId": "Cuemon.DayPart#1", + "fenceOrdinal": 1, + "sourceSha256": "5D0F2A7A8D053C101B79289AE616172AC9513AA0F2ECE30AD62936D170B15BA7", + "whitespaceSha256": "5ACE6E97BE1BBA9E0A5C2330277C306D94827174D16921BF1438639F80A20EEB", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.DelegateDecoratorExtensions", + "exampleId": "Cuemon.DelegateDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "AE9E909F4EC42E59F100BB8BCD92E2C77C170507E6ECB2411B6E7BE6BB997C7E", + "whitespaceSha256": "AC7C64BAEBD0EAA98EDF7774285545B80452EC2F63A84BC9CE0B8BC4C13DCABD", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.DelimitedStringOptions`1", + "exampleId": "Cuemon.DelimitedStringOptions`1#1", + "fenceOrdinal": 1, + "sourceSha256": "F753E6A15C173BEF88E6554529BBB60304917AE39177FB85A0545007CC515BC0", + "whitespaceSha256": "A127A9632D55BA5B03A6CED3C446F10741538BDA5A46501346C8CFEEEC9F8B2D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Diagnostics.ExceptionDescriptorAttribute", + "exampleId": "Cuemon.Diagnostics.ExceptionDescriptorAttribute#1", + "fenceOrdinal": 1, + "sourceSha256": "EA520CF373CE9A0D346174D9180C6A7F599C9C4078EBD3D590203F8ADCD77A23", + "whitespaceSha256": "56B06D1CFDE67A20AE6E3780B686401C7563A7490B2EB8067F4F98DEF706C50F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Diagnostics.FaultResolver", + "exampleId": "Cuemon.Diagnostics.FaultResolver#1", + "fenceOrdinal": 1, + "sourceSha256": "C09ABB9C25EC0F9DA7DD94AC1B20958A6A80698F6FB490D5DA43F3D29DA9EDF3", + "whitespaceSha256": "CD4195D9BBEF8901E8AF2565A4A9C9E48D3816B683F716EEB898FCE108A7B106", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Diagnostics@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Diagnostics.MemberEvidence", + "exampleId": "Cuemon.Diagnostics.MemberEvidence#1", + "fenceOrdinal": 1, + "sourceSha256": "F592931FFB86A4715E209F18CD7F351D7966F137973B9DCC7AD8A44CE1AE0D57", + "whitespaceSha256": "30D79806D7CD11E5EEEA0FF336CCCC657D1A603D457957D397F45ED82FB18109", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Diagnostics.ProfilerOptions", + "exampleId": "Cuemon.Diagnostics.ProfilerOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "293FE533C718253C46BD03942143AA8124B9A6EF7B2F400A6F795E46AE268420", + "whitespaceSha256": "FAEE304C185553EDC888581FD3A65D1D6C7CACB6A589E56BB5A6C4546E5D3472", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Diagnostics@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Diagnostics.TimeMeasure", + "exampleId": "Cuemon.Diagnostics.TimeMeasure#1", + "fenceOrdinal": 1, + "sourceSha256": "FE25C03CBAE37D0F5DF71E246510630F71AC0DC626BFA6C9E5018337048F9DF6", + "whitespaceSha256": "C0329D69EBF281DACC9C6F33EDE4A808C72B88E4DB15C13BB4E3D8E21C5C8254", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Diagnostics@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Diagnostics.TimeMeasureOptions", + "exampleId": "Cuemon.Diagnostics.TimeMeasureOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "A91BE22B20D9C2D2BD1F0D6D5A3DF855345DCCF18D70DDE847BC72E102201615", + "whitespaceSha256": "EB70C45BF24391C1CA6BE6A40FCC9EA7FBA0D0B95C8BDD6550C3CCF48C2772BE", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Diagnostics@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Diagnostics.TimeMeasureProfiler", + "exampleId": "Cuemon.Diagnostics.TimeMeasureProfiler#1", + "fenceOrdinal": 1, + "sourceSha256": "83886F30F53FA63A3C9D264C01862C14212D1B359046F090960FD9AC92475D73", + "whitespaceSha256": "E4D4C9DA6E4849A536A22916B3BCE9C2B10AAA20404E2A02769D874739947E28", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Diagnostics@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Diagnostics.TimeMeasureProfiler`1", + "exampleId": "Cuemon.Diagnostics.TimeMeasureProfiler`1#1", + "fenceOrdinal": 1, + "sourceSha256": "599AD344908BC63F2579AB9EC2D9E2684967395A57617B7D1C0102E3A4BC86F7", + "whitespaceSha256": "E008ED277A16F09A3E9891528E6CC699D0F0CC1C33E82E6FCB060D47D00F132B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Diagnostics@11.0.0" + ] + } + }, + { + "uid": "Cuemon.DisposableOptions", + "exampleId": "Cuemon.DisposableOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "7121C7F3730C5CA22AC3D6D9B28D5CE872BFB982299DE9B32E63470998E95977", + "whitespaceSha256": "E843D03FCEB326B18EC8076D4116C08EE5DBAC5D0BFF944C15A747497C95960A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.DoubleDecoratorExtensions", + "exampleId": "Cuemon.DoubleDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "8DF285C61B3D22AD5CDBDAF9F6273EA17747BA582D9CE544183D98E6363F578D", + "whitespaceSha256": "82EF132BEA4D370458A6C44A612E418A7EDC4BA740C705EE3F44EF075E37A28E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Eradicate", + "exampleId": "Cuemon.Eradicate#1", + "fenceOrdinal": 1, + "sourceSha256": "DA78F96C9195ABD800355D33ED1125CCDAEDA4A0BDE4A4AB0944FDB6EBAA522D", + "whitespaceSha256": "9696785B9343A32395604A0A31F6918B6BD58354526B72DACD0FA887F8AC6BF3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.ExceptionDecoratorExtensions", + "exampleId": "Cuemon.ExceptionDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "0F86DDDF87CAA16DBC3926E6EEDAA195FCDE3F23C444E617A5D05EC6F2527AED", + "whitespaceSha256": "FBFA2219612F907C7F49B584AAF2A96021307024992D348A5FFFE143884AE770", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.ExceptionHandler`2", + "exampleId": "Cuemon.ExceptionHandler`2#1", + "fenceOrdinal": 1, + "sourceSha256": "2F3C6D857F4B1C8D339ABC5052A838817DB3C16E1D27860AD1EA867B2F3329B2", + "whitespaceSha256": "9F5CC4B2CEE6A696D702D092A14D9464B621DE0A13AFB959CD4A5546DB2DF62C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.ExceptionInsights", + "exampleId": "Cuemon.ExceptionInsights#1", + "fenceOrdinal": 1, + "sourceSha256": "CFF5968FF426692801A2A38FE7F86F87D2FD97789D2809CA062494345AD5FDD6", + "whitespaceSha256": "B1AD07AC25DE43619A07686E842BD0DCE221924E4E317C2F6EEDDAE1A6D2AEA7", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.ActionExtensions", + "exampleId": "Cuemon.Extensions.ActionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "34801015E863016596576E0EE94F113952E707B05E70199D3D69A81638B48B36", + "whitespaceSha256": "C2A76F4F23798CFEC1B48D6FAFEDA8AA998CFC4F673170552CFD5F450D4A9C93", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Http.HeaderDictionaryExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.HeaderDictionaryExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "8830FF5E1273B8BE7484FF40909241F420BFC17BA8935D17A978ECFD51DE1FA5", + "whitespaceSha256": "3B418CBAD71D8C06DDAA47394C1529C32D8C3D66A33CFEEEFC464D3AD11D92E5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.CacheableObjectResultExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.CacheableObjectResultExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "7D4175C0284E5AC6AC5D7131F394426504296B217D19FC79600FF20CD4001FCC", + "whitespaceSha256": "4EC77FFBCE6C9726DB9A7605940BDDADA068C56389D2911BC255D01D8A424F10", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable.CacheableAsyncResultFilterExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable.CacheableAsyncResultFilterExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "45568454535F8775AAB03043B357998AD7A60B2E710FF0930EA4C072CD75F5AE", + "whitespaceSha256": "C9BFE71B4BD1D9E91B1D0E8F1E464BE1640F8A7864B85179DFF7A9CFC0304E16", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Filters.Diagnostics.HttpFaultResolverExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Filters.Diagnostics.HttpFaultResolverExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "19CC63A0FE7466FC901043EEC9E71A1A64845FB10D61771D76705023D392B32B", + "whitespaceSha256": "828972676B27CDEE4BC8EC827EA24FFF134607491029D73AF52162B1172DBDEE", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Filters.MvcBuilderExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Filters.MvcBuilderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "889CAA3CF8D106500BBB25979EFBEA205C78E7028F5AF98491C766A3584597BB", + "whitespaceSha256": "0826B5B3C35D06418D7342A747B4A2D6B55206CF71F66EA02A5550703B8964A2", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationMvcOptionsSetup", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.XmlSerializationMvcOptionsSetup#1", + "fenceOrdinal": 1, + "sourceSha256": "E4D085DCBD39031766F3D7BC4D10FAE3FF752A9EDCC4D20376E4D3FB249DD44E", + "whitespaceSha256": "B8FCC35C645A8C71B1084928ACC37544AB2089F588975D3706FB4C647C48FDB4", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml@11.0.0", + "Cuemon.Xml@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Collections.Generic.DictionaryExtensions", + "exampleId": "Cuemon.Extensions.Collections.Generic.DictionaryExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "2278CBDAF1740ABFBBE2E1E735BA18FE9522A0AE59348B5515DD3BD1F6935E59", + "whitespaceSha256": "C725BE4BF2CF56F08C314FFE251981E47A3D54028AB1C64BCF0A7C17C8F7E9C5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Collections.Generic@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Collections.Generic.EnumerableExtensions", + "exampleId": "Cuemon.Extensions.Collections.Generic.EnumerableExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "E56BBC44001E8090A0224A7E3C943E8011AEA843D38692E42DDEB522DC32C2F0", + "whitespaceSha256": "CB8A15F484E1F48DF7CBE5928B05D81937E15B94587479984DB19DA1B0F6906C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Collections.Generic@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Collections.Specialized.DictionaryExtensions", + "exampleId": "Cuemon.Extensions.Collections.Specialized.DictionaryExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "D1EF98E5056C61F29D260DCD8EB3DBA2B026BF3BD74FDD4CA2CFA4A04A67A3E2", + "whitespaceSha256": "9A1781EA402DB6D7AA6339FF295283728214D92F658ADE3985BAFC056F850AF1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Collections.Specialized@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Collections.Specialized.NameValueCollectionExtensions", + "exampleId": "Cuemon.Extensions.Collections.Specialized.NameValueCollectionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "AC8390BD138BB84D660652E0CD61FDBF27CD8737840B652E6F767CD243EBAB0E", + "whitespaceSha256": "A502BB9D55A86792900808AE2E000FAFEF5C313CA4F803AE69F1A57EFF2ABB30", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Collections.Specialized@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Data.DataReaderExtensions", + "exampleId": "Cuemon.Extensions.Data.DataReaderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "A4CD362E1432B23BC87C101EF5463C16694F74511D4C6478B1E3EE02216A2A64", + "whitespaceSha256": "E70BC6A8B245E62BFF51E242071D44E29DA76F1AB44A16AB19DD15E2F3209C05", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data@11.0.0", + "Cuemon.Extensions.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.DependencyInjection.ServiceCollectionExtensions", + "exampleId": "Cuemon.Extensions.DependencyInjection.ServiceCollectionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "0C3BF2373C21D67D352CBEF1EB40A7A633F3699FA4DDEE8DEF0826D14935ACA7", + "whitespaceSha256": "EE1131A21AA746BEC491073806562DEB328B2A0F478D15EF0EFFA159911DC950", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.DependencyInjection@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.DependencyInjection.ServiceOptions", + "exampleId": "Cuemon.Extensions.DependencyInjection.ServiceOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "778135C4429F5CC67520CC2CF06A5119E2211CE413A2378F824B0238AFC45C0E", + "whitespaceSha256": "39BEC788F904984364B60398938F199BDFBE4C2E8CFE891A2ED1FA15EAD5761D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.DependencyInjection@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.DependencyInjection.ServiceProviderExtensions", + "exampleId": "Cuemon.Extensions.DependencyInjection.ServiceProviderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "5D3693A3F68D3C25EC5F2896A5E5F2E3FAAC8105F27E75CDC61638425C88CCD6", + "whitespaceSha256": "511404E2845C743628985AE8DA5D0483CD4FE92E59DF7E626CC2B9065D2B20B8", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.DependencyInjection@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.DependencyInjection.TypeExtensions", + "exampleId": "Cuemon.Extensions.DependencyInjection.TypeExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "AB108F56DA1AAF33806283DE5DD600863BF13BCBF33543644EDB7946C28F118A", + "whitespaceSha256": "6645BCAB57E1518787213E96831AD6E2D65C2A7ACDE7EA9E7B2FD5A59300BB14", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.DependencyInjection.TypeForwardServiceOptions", + "exampleId": "Cuemon.Extensions.DependencyInjection.TypeForwardServiceOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "5C2A5485E203BA50BD17E7E530DFBBA8F14FBE41B8956B16C5FF91FADDD45A43", + "whitespaceSha256": "65BB4E4A847BCB7AFC8A0BC89CE3054C103C43C41AAB5027CBCED55A5250D8F6", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.DependencyInjection@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.ExceptionExtensions", + "exampleId": "Cuemon.Extensions.ExceptionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "44DF14330E6867DF280D0CD42DF79C3482D2132287BC2D0B2D6DD17EC688A88D", + "whitespaceSha256": "EDAC743910A225C7899C8DA87EEDCFF2EF4DE2FCAC25AAF2516AF3720CBD8124", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Globalization.RegionInfoExtensions", + "exampleId": "Cuemon.Extensions.Globalization.RegionInfoExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "44E5A3F46FD5818E0991489AB9E18A9B1D72DAF6DC07A343A79E7B4AABFD500E", + "whitespaceSha256": "77580888EEA8109F86E30A00A316E5E96FD7630D099812B4ADCC650CDB1570F1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.IO.ByteArrayExtensions", + "exampleId": "Cuemon.Extensions.IO.ByteArrayExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "C039F188C1558321E2C6226285452656E65D329562528DB9EEDDA7C74ED5AA8A", + "whitespaceSha256": "6BD8D3A1A66E7AF96217FB122AAAEAD4C3EAEAD1B66D1B651491FB5D405E085C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.IO@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.IO.StringExtensions", + "exampleId": "Cuemon.Extensions.IO.StringExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "4098B72420599B8493E0E4F727CCFDB7119CE1A3FE43F2E3466EE5B15B1953D3", + "whitespaceSha256": "63D159D6473BE155C5FE3A1C747A6FB556E44782470ED0B86984BEAF63BAE3B1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.IO@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.IO.TextReaderExtensions", + "exampleId": "Cuemon.Extensions.IO.TextReaderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "FF8F034894580799A6AC0F2E03C50B58A29E298A47A35A8823863DB72EC003D5", + "whitespaceSha256": "814322EDF4C3EBB1E5259BAA71C3D813151C88669C417667C5851286F88E7DC7", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.IO@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.MethodDescriptorExtensions", + "exampleId": "Cuemon.Extensions.MethodDescriptorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "188E81CC24D0B49F99F32EB5423D6A7601EF62133976DB8BC66B45D6F2F94A69", + "whitespaceSha256": "7E7E46EEA2E152CC838BAB21340898C4974179C4AF26534707CA5F692E0A5ECA", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Net.DictionaryExtensions", + "exampleId": "Cuemon.Extensions.Net.DictionaryExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "BB7F67EDE9E19C6FD1875FE6B20A3292B2B33F83C74F5068C1AF80CAD9D454CF", + "whitespaceSha256": "72D9D30BB64D3F5996760475D1C87987128F4D8B534C42C16EE59946C9B34B4C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Net.Http.HttpManagerFactory", + "exampleId": "Cuemon.Extensions.Net.Http.HttpManagerFactory#1", + "fenceOrdinal": 1, + "sourceSha256": "68550267C8C772966BCB5E506C0CA371F435B9ACDA2428F93858F48EBF5C96EA", + "whitespaceSha256": "DAB5A3D45026EB8FFEB4C1C67C89D1EDB1A3CBFA201462FF4EB54DF65E596C67", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Net.Http.HttpMethodExtensions", + "exampleId": "Cuemon.Extensions.Net.Http.HttpMethodExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "0F1B002EBB77D2DEE093290A5441D31BFB4BDABAE3A9E26FD8EB1E2F2CCC1E6E", + "whitespaceSha256": "CF2361E8D495C156CE24DA0CFC1C080F93502B972F09E9A377471B0B7CAD1836", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0", + "Cuemon.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Net.Http.SlimHttpClientFactory", + "exampleId": "Cuemon.Extensions.Net.Http.SlimHttpClientFactory#1", + "fenceOrdinal": 1, + "sourceSha256": "4462E505DD3825916B28B5DC9E3C96605265E598D5B5D7D3E229E38EB7E65338", + "whitespaceSha256": "84E2874D1133F64886C33D02D0174870C90581C4F37C9EBD192EA08FE17A560E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Net.Http.SlimHttpClientFactoryOptions", + "exampleId": "Cuemon.Extensions.Net.Http.SlimHttpClientFactoryOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "8C45B600FE3025D8235DF189F6E22409EE6B9D3D1D83A55FFA64E1C638766F84", + "whitespaceSha256": "1649D2A4B667452DF42774B0400623461825C347F81AF10C73F95E966FE8B79D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Net.Http.UriExtensions", + "exampleId": "Cuemon.Extensions.Net.Http.UriExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "111BF30748DAA0124FB0497033C7F09D756819FC71F442A7926C9FAF60CBA11E", + "whitespaceSha256": "91E88581507B906D7D8B97BF42D272583F223271E57BF1364D1E13E43707BF26", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Net.NameValueCollectionExtensions", + "exampleId": "Cuemon.Extensions.Net.NameValueCollectionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "3745A7C8A5352EF50FA310E4FEC9B1641D1B1629E647C3BDB09AC38EF68E7734", + "whitespaceSha256": "B6B6B6762F87CBD6F31EF0E78DBA5847CAFC6E78C08063874C59B557793AE37D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Net.Security.StringExtensions", + "exampleId": "Cuemon.Extensions.Net.Security.StringExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "551F2A4756BD6A89E12C16EBC6CB832DF5D8EF5F881B96280F453BB9FAD2F4BD", + "whitespaceSha256": "8816A4E9783DDDDAADCC6D7EE9FBA99AF63774E69D00C5B1C3549ACDC4841F7A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Net.Security.UriExtensions", + "exampleId": "Cuemon.Extensions.Net.Security.UriExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "F0B98672295123E0CCC383F70714FCEDB468CF1CF1A36E133630F4D1D848B400", + "whitespaceSha256": "EFE7C95ABFDAC3BDA9216117AD9985FF7E44D724E41598276AEFF30A882C193A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Net.StringExtensions", + "exampleId": "Cuemon.Extensions.Net.StringExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "BF4C06E519BDED07ADB16BCD2FBA7EA787F4236B11386A433CBFCA5DE0B5C1F8", + "whitespaceSha256": "46C3F8BD07309676022515A592C884656DE49F2A79BA5CAAD11B5B9762CD8D3C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Reflection.PropertyInfoExtensions", + "exampleId": "Cuemon.Extensions.Reflection.PropertyInfoExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "A4A008EA87A0C7A2AFE48378822B28641443326108A83DE32D02F57BD29A5D0A", + "whitespaceSha256": "6058D748B92D0B809E92FB2331596FB8E58BD6D4C33576618F76BD48C8B0EB13", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Reflection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Reflection.TypeExtensions", + "exampleId": "Cuemon.Extensions.Reflection.TypeExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "1F32C25560A184A228126A110883CE20BE8E3A32BB280C90B2A4F0A13FCE673C", + "whitespaceSha256": "A0BE8E3E470DA00A3425887D069DEBE320B7DFC4A8C3AD4ED35AB3188EFA53D4", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Reflection@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Runtime.Caching.CacheEnumerableExtensions", + "exampleId": "Cuemon.Extensions.Runtime.Caching.CacheEnumerableExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "0307F589E42273FBACA2B86D0BF1593358C66235F8C524F9F07628BEBA67992B", + "whitespaceSha256": "D89D06246817661855721B35ECF469C415350DE6EFA73B844CD076C306496258", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Runtime.Caching@11.0.0", + "Cuemon.Runtime.Caching@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Runtime.Serialization.HierarchySerializer", + "exampleId": "Cuemon.Extensions.Runtime.Serialization.HierarchySerializer#1", + "fenceOrdinal": 1, + "sourceSha256": "93E92098DB46724E1F2C30C747361AD19BA9CDDAC6CAE171E6784029AA01B8DA", + "whitespaceSha256": "CFA5DAE9223FF485BEC645BA43F417C231B6F718B8D97BDBE0F6040AF699E683", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.Json.Converters.DateTimeConverter", + "exampleId": "Cuemon.Extensions.Text.Json.Converters.DateTimeConverter#1", + "fenceOrdinal": 1, + "sourceSha256": "8CC2EABB5921B14BB8C3EB45FF99B7C5634D9A27BB3ED12686E2405C5C8CCCE8", + "whitespaceSha256": "539C39B0663742CBF1E287FEAA964681AE7C7828CDE5E94C1FD2FBA7B8A89E74", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.Json.Converters.ExceptionConverter", + "exampleId": "Cuemon.Extensions.Text.Json.Converters.ExceptionConverter#1", + "fenceOrdinal": 1, + "sourceSha256": "9AAFCA09826EB862AC872BE2A097025D12D9C4801903734A7FD995A2059B3CDC", + "whitespaceSha256": "95A4430CA3EE3858AF028DBEA3AC813C28C8B73791DDD83CDFB8C5FBA7AE67B9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.Json.Converters.JsonConverterCollectionExtensions", + "exampleId": "Cuemon.Extensions.Text.Json.Converters.JsonConverterCollectionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "9E0C753E443F9EA677C010D526DDA7AB020765C5F197617080FB4268664B30D7", + "whitespaceSha256": "85722AE5CAE6FB301F9547FBAF2CAF1C3EBD23B41F0B775E299536BF0DD25549", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.Json.Converters.StringEnumConverter", + "exampleId": "Cuemon.Extensions.Text.Json.Converters.StringEnumConverter#1", + "fenceOrdinal": 1, + "sourceSha256": "BA8A0313F49E0A184DD160686F92E815E3334FFAFA29DDCB318CB09F539D441C", + "whitespaceSha256": "365E5B3D58C895C5BBC1957E032A8ADEDC174480D2CEF739ADBFD5ABB5B8D800", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.Json.Converters.StringFlagsEnumConverter", + "exampleId": "Cuemon.Extensions.Text.Json.Converters.StringFlagsEnumConverter#1", + "fenceOrdinal": 1, + "sourceSha256": "5BFB86702585A7BF3A7B95D16499A0B8CE64D33A072632530FEA60684566B8B5", + "whitespaceSha256": "E4505FED72E3666C5472C90BA4EF4DF5AE65016A6DB49739FEDC0E86305C8605", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.Json.Converters.TransientFaultExceptionConverter", + "exampleId": "Cuemon.Extensions.Text.Json.Converters.TransientFaultExceptionConverter#1", + "fenceOrdinal": 1, + "sourceSha256": "C0E886D51566728B3823892A37B668D8AE1F12DE72A748E40B9E012518DEB68C", + "whitespaceSha256": "5823248DE5F77567541ADAE6E674C3594B9177E5708CC5EB38EB59DA4E935BD7", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.Json.DynamicJsonConverter", + "exampleId": "Cuemon.Extensions.Text.Json.DynamicJsonConverter#1", + "fenceOrdinal": 1, + "sourceSha256": "C17A172149D9A76CD227FBD450D223637A6FDFD05DEFA60D878E77A4B3436774", + "whitespaceSha256": "BF2FAA56E3635DFDEAD331F7FFF323722770A2D1E517FAC9192077D35513977B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.Json.Formatters.JsonFormatter", + "exampleId": "Cuemon.Extensions.Text.Json.Formatters.JsonFormatter#1", + "fenceOrdinal": 1, + "sourceSha256": "D4361BCE3784336CD4283F9FA0EC4B3EEF9CEC09D0FE242E2AAEAC30F0AB329F", + "whitespaceSha256": "764AD4B48A4D60AAFCABD6F79DA0F49182576C224BAAAD49DF638C603F86D86C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0", + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.Json.Formatters.JsonFormatterOptions", + "exampleId": "Cuemon.Extensions.Text.Json.Formatters.JsonFormatterOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "CE7F28E8C66D8867BAF5F195A7AE822BCBE7B40780CD5A53F419E0A96CEAAD7F", + "whitespaceSha256": "A062B68BF4CDABB59F0C48F530FCAEDFDF8A46900F40471F8167CEF632E1C372", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.Json.Utf8JsonReaderFunc`1", + "exampleId": "Cuemon.Extensions.Text.Json.Utf8JsonReaderFunc`1#1", + "fenceOrdinal": 1, + "sourceSha256": "0ED5F55C7CF0F34E30ABE86953F931DBB33835B8F7C44318727D777DCA87E19B", + "whitespaceSha256": "94E01D819ADC5BCD46C7342F00B358D8A807EE2D99BACCF7A72F4A3F79551ED6", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.Json.Utf8JsonWriterAction`1", + "exampleId": "Cuemon.Extensions.Text.Json.Utf8JsonWriterAction`1#1", + "fenceOrdinal": 1, + "sourceSha256": "59E0D09FF2CDDC0C27D876901B2E0F748197215A0BBA505274C241AF473AB162", + "whitespaceSha256": "B6847430E76A7606CB72C035F58656547446FB1CCE2D597E49989DFDE270672B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text.Json@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Threading.Tasks.TaskExtensions", + "exampleId": "Cuemon.Extensions.Threading.Tasks.TaskExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "73E84DC9A8DC6EAF65F8118D7DDCDC83450530FF3E1F963C0220D2638301027B", + "whitespaceSha256": "E684FE65C15D44B0431483028624570ABBC1CBB3619B795AFE386AB4F7C77426", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Threading@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.TypeExtensions", + "exampleId": "Cuemon.Extensions.TypeExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "E0C57D16DE18FE274643D8DDA9EE0506030A8A567BF7759E3D8925D832049924", + "whitespaceSha256": "7853C68E42C8B4D76670053450478DA5237A5F4B751A787665A7C483CDB1A033", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Wrapper`1", + "exampleId": "Cuemon.Extensions.Wrapper`1#1", + "fenceOrdinal": 1, + "sourceSha256": "9CC38A4F099775F5C5ADE413AFAC76E987C3E0FBE09DAAC2898A9DB29E448CBC", + "whitespaceSha256": "8F2B8556884CC3BF36185FA8812E7859DE621A0126CF7C9A6DE1D2BD2C49F25A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Xml.DateTimeExtensions", + "exampleId": "Cuemon.Extensions.Xml.DateTimeExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "3420FEEE1723D658D91DF815BE1678991B77E23825258EEAB556B84422E033A0", + "whitespaceSha256": "6C422451FC5C8FFEE5F98593F25D390F22E1564794EB4EAF2B5D006193E46FEA", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Xml.HierarchyExtensions", + "exampleId": "Cuemon.Extensions.Xml.HierarchyExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "8F2710255994FBA2A46063AE85F891E6B64071D9919E5D5268EA342D57C747A3", + "whitespaceSha256": "1F1784562CBAD8D40B4CF8D5F326AEC517C52F873405866EAEF79C63AB26ECB5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0", + "Cuemon.Extensions.Xml@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Xml.Serialization.Converters.XmlConverterExtensions", + "exampleId": "Cuemon.Extensions.Xml.Serialization.Converters.XmlConverterExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "4D5842956E89C8955C23249D617BD91383351D651C748EA0216DE10F4B1C4FA1", + "whitespaceSha256": "795617FB40F487F20BDACF4B0925B22DA054638FCC9C36525EF49E5C30BF2E30", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Xml@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Xml.StringExtensions", + "exampleId": "Cuemon.Extensions.Xml.StringExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "166CD8A57DFD13E9F47416AC6684FF90D16B01CAF7E60397B1A4B029ED18F7D6", + "whitespaceSha256": "50A6200527E2E2EB1383C02265F5C04263401A086AA7AF7A5D538F403CF27AD4", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Xml.UriExtensions", + "exampleId": "Cuemon.Extensions.Xml.UriExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "66AF0321A8C945B9D0E75F53CE1C9C08533372CE64739F9C792F719D3FBA1870", + "whitespaceSha256": "EB4C006AEB893BD613C548A20E0E4018FAA07B1D7208A1AC9BD75C18FFBEFBF0", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Xml.XmlCopyOptions", + "exampleId": "Cuemon.Extensions.Xml.XmlCopyOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "28F5628CD155B09715BA05806579F1AB939F6DDE5E70A205F7205D7D17695465", + "whitespaceSha256": "D544CD0821E70CA6B8641DF11064433E047D97A21BF72BA77490A9BA0EAD5664", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Xml.XmlWriterExtensions", + "exampleId": "Cuemon.Extensions.Xml.XmlWriterExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "0C87FBD5B05C1BBDFD190EA6D999A57E6EEC24370D2AF378DAE69CA24A0EDFC9", + "whitespaceSha256": "3461289D8E3766B2E1439FE01D08BCFC96A4A0EDE2705ED849B4779E5D547D92", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.FuncFactory`2", + "exampleId": "Cuemon.FuncFactory`2#1", + "fenceOrdinal": 1, + "sourceSha256": "2D93B3B1A64A91CF3E7FE15661A248228AA4BF45CC3945BF1EDEA93BB5617D4A", + "whitespaceSha256": "0455E32CA16DFBACB68EAC228EABF577F7BF36A5F462B4CBFEF8EAD1C3A8D648", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Generate", + "exampleId": "Cuemon.Generate#1", + "fenceOrdinal": 1, + "sourceSha256": "63C48655E50651A0CA9CA64E1D7F15DA24349CA42CB525D7F7E46E4D4E924D35", + "whitespaceSha256": "DDFF0EE73FF96BAB4E229762ED79BCE20A141488A9CB2196C7876079DC9FE737", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IntegerDecoratorExtensions", + "exampleId": "Cuemon.IntegerDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "9275D37B9900482308121BBBFAE311837C8B70C4837F0DE76AD9FA5A6210E35A", + "whitespaceSha256": "73A2298606C7B9FF10748987077CAE1E716E8F3A3F0CA28CDAE0A32A4BB50C6D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IO.AsyncStreamCompressionOptions", + "exampleId": "Cuemon.IO.AsyncStreamCompressionOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "DB9CB8D9ED839A6F75E04BE4AFC15D0CAC43788F9E5F25ECBF09C18BFDBCC624", + "whitespaceSha256": "173909B4434B0AA59B774271980E1A5CA70491816C40160A4B46F14AC60F6479", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IO.AsyncStreamCopyOptions", + "exampleId": "Cuemon.IO.AsyncStreamCopyOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "52BC5DE60944AEF28EA51813AEC2C847B20FFAE24CFA6F1B97F1D695380DE865", + "whitespaceSha256": "55601912D0F339333E0F93BAC742B4085FF7349F8CB1AC2582324BC989D2E607", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IO.AsyncStreamReaderOptions", + "exampleId": "Cuemon.IO.AsyncStreamReaderOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "7EB54AD1F5A3A4B73581ED76585DA877B11682784CE80AD52BD141E69A360E6C", + "whitespaceSha256": "8344036C7D5D27085D03CCB0605FA431CECD2FCE4CBB5DE6A64DE5461A8F901F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IO.FileInfoOptions", + "exampleId": "Cuemon.IO.FileInfoOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "7F23071F1E0DEFA86C19026F819344F333774498914CC53AE72C13A3A12C52FF", + "whitespaceSha256": "6BD18BAD43A8B8BF918C8963A755938B78FA5739E44039797AA58D80856C6E79", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IO.StreamCompressionOptions", + "exampleId": "Cuemon.IO.StreamCompressionOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "5328E6B0E973E6A321141521D9B70CEC8872B74EF374214A87AC2219BAFC866D", + "whitespaceSha256": "3531857276742A048AA5673DC1FBC2F6D481E5DC789455C0EB830A842E83E861", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IO.StreamCopyOptions", + "exampleId": "Cuemon.IO.StreamCopyOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "EA41010CDBB2FB6A32692CB6DF2C23DC8502A493F85276979325CA40F881EE1C", + "whitespaceSha256": "110D274C62444ED923BBF9BD76EDB6D10324ED86CACF3634A6217AC5F3726FCC", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IO.StreamEncodingOptions", + "exampleId": "Cuemon.IO.StreamEncodingOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "CFA6843AA0E203B5E54783B9CD5B6262ADC1F680E12C2C66B0C53C3AF4281C40", + "whitespaceSha256": "F23E98CD7E55E8B2302F436A9B18EA9481BBAC930C1E6E68EECC6A1BF07FCB3F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IO.StreamFactory", + "exampleId": "Cuemon.IO.StreamFactory#1", + "fenceOrdinal": 1, + "sourceSha256": "5E8F938D34B48D644F15755DD669D19650EE05E2F91ABCF5EF53A289E52D76C6", + "whitespaceSha256": "B8E525DD556EE8FF7C9635ED5BC1B818A41844F09864BF5B7F3FE710E15CFBC3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IO.StreamReaderOptions", + "exampleId": "Cuemon.IO.StreamReaderOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "DF9FA4C806796D31C7866249E3838D65A5E79DC5096ACF8D2CDD0577E4E4DF00", + "whitespaceSha256": "A2BE17A059CD68C901EDAE17F99746C643C0C89DCC5F54078279FDE7A8F74E91", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IO.StreamWriterOptions", + "exampleId": "Cuemon.IO.StreamWriterOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "C6AB566016C305D4ADDF71C8E6553DD9E09626B12452E0CD46DFF3917DEA166C", + "whitespaceSha256": "F1FBE1734279B0474003EAEDB3052B401FE0A0D839B46DCEC05096456F55CCA6", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IO.TextReaderDecoratorExtensions", + "exampleId": "Cuemon.IO.TextReaderDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "76753F365B29FEBFC297A1109A20AD0018C102A934C96B26158D35F6BED56E9B", + "whitespaceSha256": "F893309327C7BE8B0F4DBB47D0277C58305287C61B315AAB4DC56905D8ED1754", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Messaging.CorrelationToken", + "exampleId": "Cuemon.Messaging.CorrelationToken#1", + "fenceOrdinal": 1, + "sourceSha256": "5DA3E3390F6C8923FEB549E98F764B00B017A3A18EF9456E12DFFE4E480AAFEF", + "whitespaceSha256": "95AB09A4313F076746006C17321841A5C3F9AB035C8892D1971D6DFF231D7378", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.MutableTuple", + "exampleId": "Cuemon.MutableTuple#1", + "fenceOrdinal": 1, + "sourceSha256": "55E7C64D25A49540AAC123A299FB0FC33C2B97212BAE299FA945D684BC167938", + "whitespaceSha256": "9DC0DDFA65928D456973C00685823FA624E776396A51432B433DB3877A3692DA", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.Http.HttpAuthenticationSchemes", + "exampleId": "Cuemon.Net.Http.HttpAuthenticationSchemes#1", + "fenceOrdinal": 1, + "sourceSha256": "BF8F707F4FBB9182AA8270444783FB2F40230B8788F79218FBB98E1B1552D969", + "whitespaceSha256": "E4C873D074AD0399D9582F9D6EB6ECAAA5764D2723EB4E563EAB3E84603B56BB", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.Http.HttpHeaderNames", + "exampleId": "Cuemon.Net.Http.HttpHeaderNames#1", + "fenceOrdinal": 1, + "sourceSha256": "601A88A8FAF37B67674E3FB347444A8031578BE221A9C9CF310F7BEC20A63401", + "whitespaceSha256": "BEDAC639CBDB95F838282D8222784BE103D57BCF622753E1DFC7CF74189544A8", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.Http.HttpManager", + "exampleId": "Cuemon.Net.Http.HttpManager#1", + "fenceOrdinal": 1, + "sourceSha256": "E5702660092898B8E5604723CFCB7CA22DAEE0754EE63721A4A07E3CE26C037C", + "whitespaceSha256": "4DC66232CD4AA65C76058DD445BD7B3D63E5DA446B3FC55DBBB4E23F2E1AC489", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.Http.HttpManagerOptions", + "exampleId": "Cuemon.Net.Http.HttpManagerOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "71F3395CA4FAC6A39BCB19EAB456EAD02B92340B71B878DA345B02FA10CE82BC", + "whitespaceSha256": "FB20968A2C7153BD9E829E4C4B78A83247F09C8D258E64345D8D287669335AE9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.Http.HttpMethodConverter", + "exampleId": "Cuemon.Net.Http.HttpMethodConverter#1", + "fenceOrdinal": 1, + "sourceSha256": "FE90C01757EB8CBDDB3C3F121C5272F1C736A7F958D199046C0868122A085BA8", + "whitespaceSha256": "500C4E308860D4326B62D2F88C9DFB5D28C7921293D5193794E28E2C55970ED1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.Http.HttpMethods", + "exampleId": "Cuemon.Net.Http.HttpMethods#1", + "fenceOrdinal": 1, + "sourceSha256": "4DAEBA64E55694B9FBAAF1C2B7ECF66E02FACBBE31592F4B48F44B23F452AD82", + "whitespaceSha256": "E72C918ED2D1F3D33732EDFD1DB48BAD3B3230E4F1D80AF413BDA98BE396AEAB", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.Http.HttpWatcher", + "exampleId": "Cuemon.Net.Http.HttpWatcher#1", + "fenceOrdinal": 1, + "sourceSha256": "8D3D011B05ED9CFB89FA7278B0B21E888ED2F8FBD5550064762C707BC4A63FE4", + "whitespaceSha256": "B5A4D27241410BD60884EFEDBC438D5205A1EA409F65400063C7E690373C40F3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.Http.HttpWatcherOptions", + "exampleId": "Cuemon.Net.Http.HttpWatcherOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "C942CBE0E79132FB9C1ADD3E07238100B43905EC31C9A13923F565E622677766", + "whitespaceSha256": "4C0A0C8AA8A3EAAC85936A2D0A85A31DB11A41979A015BCF9FED536FF3DD911B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.Mail.MailDistributor", + "exampleId": "Cuemon.Net.Mail.MailDistributor#1", + "fenceOrdinal": 1, + "sourceSha256": "A64CEB6346F3631F0D674BFF1235CECA0A643B7CC54D286F405F6D194BA703B1", + "whitespaceSha256": "F43CD78C0ECFF105846CC6D3C73140FC991E60B0F3AD9C7F9945E8274CA75AFD", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.QueryStringCollection", + "exampleId": "Cuemon.Net.QueryStringCollection#1", + "fenceOrdinal": 1, + "sourceSha256": "8DE34513FF37D4D67883CBBAA58C59BFAB8377E2FF0EF29C869EB3DB1F620695", + "whitespaceSha256": "ADCF1C4D3458C2298671BD60CF1C57FB6C697A3E6B0D2C41ED24D16D3B848F63", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.StringDecoratorExtensions", + "exampleId": "Cuemon.Net.StringDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "76CCD4A89F19EA1D876BF0727A6B19937F3719173615E397A45DD4C50CA68C9B", + "whitespaceSha256": "ACCDA7DE4C80D533CA904C31A2309F69140162C133D32F45D63D1FAA78694674", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0", + "Cuemon.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.ObjectPortrayalOptions", + "exampleId": "Cuemon.ObjectPortrayalOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "40CD97564F3D742BF9A790CE5493217A4DE447D2A8D5396C146A036809F24494", + "whitespaceSha256": "5662C43024C1C3E287178A743A37F62490664F94DCAEB7349A38C17DD7B016E0", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Patterns", + "exampleId": "Cuemon.Patterns#1", + "fenceOrdinal": 1, + "sourceSha256": "E23DB15F5BC44810DD65E54D2A54AAEBDBF556390D2B085802A3F10C86C4F28F", + "whitespaceSha256": "B7A5985E546DC0C0EA493F6C21A3F239F2B540F2214E5DC2BA9A96DFCE7D1433", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.ActivatorOptions", + "exampleId": "Cuemon.Reflection.ActivatorOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "B2BE9D73E6E38C0CD90D3C5D7B386C022126969E9190B6B906BC7F3A5E59556D", + "whitespaceSha256": "B4DA82E12581BBEBAC948942CCA96FAAC510C27D9C47EE5D50D3DD9AAF3AF4BC", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.AssemblyContextOptions", + "exampleId": "Cuemon.Reflection.AssemblyContextOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "6C9E21E2490DBDEF6A7FF7D9DC35C428E34F5FAD0B955A80481785D137EA3A3D", + "whitespaceSha256": "A1AFACD0A7044AABB18791D185944DD3F1F1CFA807EF1384370D2D147BA48F55", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.AssemblyDecoratorExtensions", + "exampleId": "Cuemon.Reflection.AssemblyDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "003F25461BC945A6D94B79CF65E7D83FDA778BADD6B36329D99C9283916F7040", + "whitespaceSha256": "DD228E3EBE50B5E34EAE6E3CE765DD1870D570BCCBC95133D392BF3967633313", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.MemberArgumentDecoratorExtensions", + "exampleId": "Cuemon.Reflection.MemberArgumentDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "9803D5414FC4FC6A5163D2B6D512380AB71ACC4419D591CB3F7AA060B2275BF8", + "whitespaceSha256": "38A94DF676574C1DD3E17DF820BF4EFC76337D758107AFE9DE737CB00E15B348", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.MemberInfoDecoratorExtensions", + "exampleId": "Cuemon.Reflection.MemberInfoDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "88365875310FD10C2682B2256D732E079D76DC2DC179B7EA4035E0F12871E809", + "whitespaceSha256": "D5AA800594B98A27049C295C864353BD602082C131E692CC0C4711D489243D7C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.MemberParser", + "exampleId": "Cuemon.Reflection.MemberParser#1", + "fenceOrdinal": 1, + "sourceSha256": "818C06B62281374D56B3A3E04D8468D769A497830D09A6C562DF9F2772D91141", + "whitespaceSha256": "3700FA3B352E454BDEE5AB04F661C02CC1E98ADC237EDF8BA2DC22D7B3E8001F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.MemberReflection", + "exampleId": "Cuemon.Reflection.MemberReflection#1", + "fenceOrdinal": 1, + "sourceSha256": "644B430DD60434A46B4B9617CAC47FC4C04A365E167CCC577B0F30BF2A084F8E", + "whitespaceSha256": "D1071B23E5F4C5850A2DD638AEFE6A139B0893B4B30794EAC18D1422DC1D016E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.MemberReflectionOptions", + "exampleId": "Cuemon.Reflection.MemberReflectionOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "796012B055B83269D8A4EF5E07221BFC8292DE08A58021A05A69FF4DCFAB0014", + "whitespaceSha256": "4418CD97D0C6C0DC1E6872FB69DB475F32C33D2A430C5B083B1560C9093722CA", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.MethodBaseOptions", + "exampleId": "Cuemon.Reflection.MethodBaseOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "8F33CEC61B4072450E647746BE7C2B82C19A09E75F55F31456ADE16B2CD4C19E", + "whitespaceSha256": "F75314D11CA8AB77E74BC587855DCCDC6A9F03E8849803FB14AD29336FFF0193", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.MethodDescriptor", + "exampleId": "Cuemon.Reflection.MethodDescriptor#1", + "fenceOrdinal": 1, + "sourceSha256": "13413C4BC1886880BF15C47A10E3CCB6358E404375FB4630F2BDFDF7E96A9A59", + "whitespaceSha256": "E88C1B4A90E4398AA3A34A870BFDF645BA08B271DFB1C9B1507ACBB6D60D71C9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.MethodInfoDecoratorExtensions", + "exampleId": "Cuemon.Reflection.MethodInfoDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "39A7D6BB1D89E6974C6DA69BFB817370F83380BD0482DA654EB7503977058DFD", + "whitespaceSha256": "969CB3EACF6342243687A2C34A82EC647D2E1B7EF2728733655195B3EC4EF4D5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.MethodSignature", + "exampleId": "Cuemon.Reflection.MethodSignature#1", + "fenceOrdinal": 1, + "sourceSha256": "E031B7F15BB1DE53F0969E90BEEF615E6457780FF0B1CDA8F820286247C049B9", + "whitespaceSha256": "8D8B85E0B8A26ED0C892C4F5FCEF4681D5DCFB060CED54C1C2A34923BCD0DC86", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.ParameterSignature", + "exampleId": "Cuemon.Reflection.ParameterSignature#1", + "fenceOrdinal": 1, + "sourceSha256": "1C45A6AED79F78A01FEFE69CF43B284E6199C5F0897FC365BCFDF6FFEAC0CCF5", + "whitespaceSha256": "FFCB9156D5E3DB108AD4E796BBC0C5957ACCB1D9AF2EC6E4087CB141117EF84C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.PropertyInfoDecoratorExtensions", + "exampleId": "Cuemon.Reflection.PropertyInfoDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "0ACB65111A0C5E67ABDD0F2474CBB703B9C7B6D81FEF4460108D9802292CE53E", + "whitespaceSha256": "D770963D31C2AACA863C210E5F89876F62753D5BD19A85CB04A94D3CEF17E72F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Resilience.LatencyException", + "exampleId": "Cuemon.Resilience.LatencyException#1", + "fenceOrdinal": 1, + "sourceSha256": "F9A2038DB3E309F2AA69BC40577FA942571D89791F68E8E9BEAE5F80EDC7444E", + "whitespaceSha256": "D2DB708AAA9A9C488BA58B27F08947200976B0C555E6C61001A8C46999906799", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Resilience@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Resilience.TransientFaultEvidence", + "exampleId": "Cuemon.Resilience.TransientFaultEvidence#1", + "fenceOrdinal": 1, + "sourceSha256": "C0B54F35B622FD530F25F6C5538C7BD3786B9F4CA63B9215DAC6BA7D347D986B", + "whitespaceSha256": "D12AA184DF51BC5CD7562E26EB47C82F35C487C77C9806E1E272EABF2738CAEF", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Resilience.TransientFaultException", + "exampleId": "Cuemon.Resilience.TransientFaultException#1", + "fenceOrdinal": 1, + "sourceSha256": "A515C1BE271575996E3C8A586E45F16144B6B3CDB273D7581D6F80ACEEFC6A7E", + "whitespaceSha256": "D8F0C69CBEC70DBE61DA2DAC5DCAB21F3D0151EFCE152CC861FD39A8E6A0EBF5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Resilience.TransientOperation", + "exampleId": "Cuemon.Resilience.TransientOperation#1", + "fenceOrdinal": 1, + "sourceSha256": "851BDCE850F06B64AD9AF6C89E111FACD3B8AEFDA5826237C25B24A093C4FDFC", + "whitespaceSha256": "66C8FC39EED58CA45E7B8A343EBAACA12FCB4E2AA67B18919135B2CB141CC134", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Resilience@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Resilience.TransientOperationOptions", + "exampleId": "Cuemon.Resilience.TransientOperationOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "33922E22887FAA99A22266C06A0D42C98B0F74B0D380D1D628D7EF467C2283B5", + "whitespaceSha256": "AF2D287EA9DFF81BE2186BA873F9711CC95AA602153932EC36B97559729268F9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Resilience@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Runtime.Caching.CacheEntryEventArgs", + "exampleId": "Cuemon.Runtime.Caching.CacheEntryEventArgs#1", + "fenceOrdinal": 1, + "sourceSha256": "585348F382D4CBB14A76201BDDEA0917D0F1C56BE09C1E833B384A182868F541", + "whitespaceSha256": "4A535B6877439332846D2CA49BF180834368F60933F89CD54688A3CBB18FBEF7", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Runtime.Caching@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Runtime.Caching.CachingManager", + "exampleId": "Cuemon.Runtime.Caching.CachingManager#1", + "fenceOrdinal": 1, + "sourceSha256": "EA74EA3F267D980288B51E556D049FAE2C19A7D33FE9B0A44E991E0CFFE98FF4", + "whitespaceSha256": "0A90663D4903974E672AD78903BF04A7613F1DFA8693C37D6FE36938DA0D80E3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Runtime.Caching@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Runtime.Caching.SlimMemoryCache", + "exampleId": "Cuemon.Runtime.Caching.SlimMemoryCache#1", + "fenceOrdinal": 1, + "sourceSha256": "FDCFDE6FB142794239B5F8ECF2E5CFB55AD0AA594D7039B2297CCC4C28DBC655", + "whitespaceSha256": "AA2A4AE1EC335C98740E2CFEE2E4CEC32F8BD1CEB1CD4FECC5EBA494933DF786", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Runtime.Caching@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Runtime.DependencyEventArgs", + "exampleId": "Cuemon.Runtime.DependencyEventArgs#1", + "fenceOrdinal": 1, + "sourceSha256": "9AD30E70310A3BEF1C200150479210A2CEC1B5998198FB5078CB60FC953B6685", + "whitespaceSha256": "9EE597BD9B2C10E5D8460C088EC8DA0046B75A1A1E144F5F6AED88DE4E3D784D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Runtime.FileDependency", + "exampleId": "Cuemon.Runtime.FileDependency#1", + "fenceOrdinal": 1, + "sourceSha256": "826D6F724B3543D22FC2BBDE5E9F352AC31C4967DE21D2608C324098EB5C9A1A", + "whitespaceSha256": "11E0076AB9C1E016E069E37AE6D9BD295FFD1EF53DC1166D6B41291A8A47C815", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Runtime.FileWatcher", + "exampleId": "Cuemon.Runtime.FileWatcher#1", + "fenceOrdinal": 1, + "sourceSha256": "8155290B4B03D57E8B372967F93C2D7F2E71E19C130ED865B752A04039F035E5", + "whitespaceSha256": "CD77CDC3FACE8D85DF25CC82D41F6B38F9DA8CB6AF40EEE2662911C2D9B9EED2", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Runtime.WatcherEventArgs", + "exampleId": "Cuemon.Runtime.WatcherEventArgs#1", + "fenceOrdinal": 1, + "sourceSha256": "8DF318A6DBCD686A24091443388DA0F3FD410809BE098FA578A53F5C674E4305", + "whitespaceSha256": "2203D6A5F320490DEDBECC3C86DD47BBF711C97A62D44A503D77699290385670", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Runtime.WatcherOptions", + "exampleId": "Cuemon.Runtime.WatcherOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "98DAAE1074FB43D957BBE895AA1A6F65B3D0AE3F737642DD1332C1F3103A21C2", + "whitespaceSha256": "453E327A0160A23A4FCCC9E9741CBB61AA88794E3DD343C684705F28B4D0B7A4", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.AesCryptor", + "exampleId": "Cuemon.Security.Cryptography.AesCryptor#1", + "fenceOrdinal": 1, + "sourceSha256": "7971913976064D101C5AE67359653DFD71BB8C23D36B0EE0FF994E9FC439760C", + "whitespaceSha256": "D3347DDE0A70CA99AFB4B74C8375111FFD14D99F7D18EC16C975A8B32500C959", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.AesKeyOptions", + "exampleId": "Cuemon.Security.Cryptography.AesKeyOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "26620299506EDC140C3167A60D024AC4CC0084B1F8E60F148E15CE4700B21210", + "whitespaceSha256": "B07379BE790BF5A2D98B373EFC0003E6CDCEEC3840439FC12543AA603AEEF957", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.HmacMessageDigest5", + "exampleId": "Cuemon.Security.Cryptography.HmacMessageDigest5#1", + "fenceOrdinal": 1, + "sourceSha256": "BDF6BA81E959E9EFC5D86C6B9E14EEBBC2ABB741F11CF1B01A8EF294F2E3B268", + "whitespaceSha256": "5762F2CC4E90B32977033CB50EBF648815823C98ECD244F05015C613B0A747A1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.HmacSecureHashAlgorithm1", + "exampleId": "Cuemon.Security.Cryptography.HmacSecureHashAlgorithm1#1", + "fenceOrdinal": 1, + "sourceSha256": "4917238C5B737A9C3E6967C1794D0973284F08AEF1936391F9572C953F94657B", + "whitespaceSha256": "9B31B877DD260862C90CD7FDC387F86E60F93DE189756A0C7E72474C4D715387", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.KeyedCryptoAlgorithm", + "exampleId": "Cuemon.Security.Cryptography.KeyedCryptoAlgorithm#1", + "fenceOrdinal": 1, + "sourceSha256": "2285839ED31B9C0E1556A883E68F95DD12D3E25FC7536DA12BE401FE6F83FFB9", + "whitespaceSha256": "1FB842F0968B391C6FA317EB360F4D55C0156CDAF5F92E5F39A9EBA2FE9DA9C4", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.Cryptography.UnkeyedCryptoAlgorithm", + "exampleId": "Cuemon.Security.Cryptography.UnkeyedCryptoAlgorithm#1", + "fenceOrdinal": 1, + "sourceSha256": "C5670291A7B7317B3E6F4195C27AA5460B4BC543CDADA51CD87582C84BE20064", + "whitespaceSha256": "F76FB870213A9EF5DBE3C9C04D830158083B17E161A12FF543E263C109D4D7E1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.FowlerNollVo128", + "exampleId": "Cuemon.Security.FowlerNollVo128#1", + "fenceOrdinal": 1, + "sourceSha256": "F0A3250480BC83139F86895D2E382E10C60188CF0C969B963FD7EEEB6710059A", + "whitespaceSha256": "D0CDDAFB3A85DC42AA26EC8F7EC8C3882E315C92951460F7FFC7B0D41A089004", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.FowlerNollVo256", + "exampleId": "Cuemon.Security.FowlerNollVo256#1", + "fenceOrdinal": 1, + "sourceSha256": "D5A9C855FBF55C1F56C200954077B82582025740CDAAA9831451834622CFB3D6", + "whitespaceSha256": "D63EAFCE8D66577A7A70BA52C60BED82B31C481B018A4D8E86B2AD1B122089E6", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Security.FowlerNollVo512", + "exampleId": "Cuemon.Security.FowlerNollVo512#1", + "fenceOrdinal": 1, + "sourceSha256": "E1EC6C90C30388B799F28740FC04CC95A50C84DB20D494E328E479405545520C", + "whitespaceSha256": "A4B31BA758D615F17A3AF594BA28D3240123D042AD92251851EE74945064FAAF", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.SortOrder", + "exampleId": "Cuemon.SortOrder#1", + "fenceOrdinal": 1, + "sourceSha256": "2431BB84716C22B4F963C09B739F07300E291ADA6A579767F0E631FAB8C4F581", + "whitespaceSha256": "90B30A743B1F58AFB2D24E9E44F52B9806B4546412D34372B3AAEF7A59EB099F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.StringFactory", + "exampleId": "Cuemon.StringFactory#1", + "fenceOrdinal": 1, + "sourceSha256": "769868974002C981188550554C25C6C9721CEC0C09E55E1B2F4573269434DB5A", + "whitespaceSha256": "8ABC0913C18B183811E1C24F7988F68FA3493FDA5C746EFCA22B20710B73D97B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.SuccessfulValue", + "exampleId": "Cuemon.SuccessfulValue#1", + "fenceOrdinal": 1, + "sourceSha256": "51F491092F0AFABF7D7ABD4185758897E2DB2BABEBD30634B73D670FC6B96B19", + "whitespaceSha256": "9EB15F9A2593443437D94EAD3F97AF98E91ADA4F6E17D0225B697F790ED246C3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.SuccessfulValue`1", + "exampleId": "Cuemon.SuccessfulValue`1#1", + "fenceOrdinal": 1, + "sourceSha256": "955C55088D980D7FADB2A59CB8D2DBB21DAE96A68431079285283090EEEC5455", + "whitespaceSha256": "DB5B6D20DB730CF63B5021A09F74A8ED725858B2B122F0BE68C4F018B9DFEF5A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.SystemSnapshots", + "exampleId": "Cuemon.SystemSnapshots#1", + "fenceOrdinal": 1, + "sourceSha256": "644EBF27A8D134F9BBA3C88B693ED5FACFD49E45B33F404C7C5FBF230AA28EF3", + "whitespaceSha256": "2E544AE69B45BD61557EAFB1F5D071A6CC9502A3CC2310AC889A7EB79F33F769", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.TesterFuncFactory`3", + "exampleId": "Cuemon.TesterFuncFactory`3#1", + "fenceOrdinal": 1, + "sourceSha256": "678B206CA29830D685C5993B7C2DA142F4F6C22F0EF8191E7591680C3B4DF219", + "whitespaceSha256": "75E1DCE20EFD4EBA70194C199320E5368639AC054BFA5B2DCE122247277EB8D1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Text.ByteOrderMark", + "exampleId": "Cuemon.Text.ByteOrderMark#1", + "fenceOrdinal": 1, + "sourceSha256": "82F80B6C6E45473734701645828CA6E8276E8313AAAF1E887CBC59EDD7504926", + "whitespaceSha256": "0B4A8D352BB3669DD85A0866429D6D97892567BDD48DDEFA74A09263E5F68DC3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Text.ProtocolRelativeUriStringOptions", + "exampleId": "Cuemon.Text.ProtocolRelativeUriStringOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "6682607F474B8149A5B60104199583B7FC7BBB5B4B1C029CEF81B4C941D7400F", + "whitespaceSha256": "000E4FAD412D01D49C2E2D63CEB296B77F02C53942C5DBF8E53375A91AF647D9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Text.UriStringOptions", + "exampleId": "Cuemon.Text.UriStringOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "DA8CC6B3514C770F6414CB24F94AFD1F1EE4AD4ADD48C1B692E498B32C68BDE8", + "whitespaceSha256": "C1E0BCFC48A2D2F9BA9A0640B40E062F1DA5FC75100E6CE5E96E9F1190344962", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Threading.AsyncActionFactory`1", + "exampleId": "Cuemon.Threading.AsyncActionFactory`1#1", + "fenceOrdinal": 1, + "sourceSha256": "AEE7D332084D3878A5BFDAD02CD634D17272CD050E1DC1246001F6A169B64DC3", + "whitespaceSha256": "8038D4BD3662E9795FD3CC50B7BA1FC35977F60CE95B1005DA886D4CAE6D3DF9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Threading.AsyncActionFactory", + "exampleId": "Cuemon.Threading.AsyncActionFactory#1", + "fenceOrdinal": 1, + "sourceSha256": "F7668A0DD7AC0FA54F49A7226E76DE5058657754F8FA70287522AAAF300C59EC", + "whitespaceSha256": "46442C31BECE4AF136AD479F59ADD99F8969546565404371F7289A85B5274F08", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Threading.AsyncFuncFactory", + "exampleId": "Cuemon.Threading.AsyncFuncFactory#1", + "fenceOrdinal": 1, + "sourceSha256": "F8B669453B1428B6FBA2C5A2856E944AB9A643FCCB184BBB7104A11F17D05185", + "whitespaceSha256": "BB117C59C34B05C82B104B427970448CD24E2053D72682B2C594A14B5A0E2436", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Threading.AsyncFuncFactory`2", + "exampleId": "Cuemon.Threading.AsyncFuncFactory`2#1", + "fenceOrdinal": 1, + "sourceSha256": "AD6737F54A69074267D5921161EFF747B091D49389B16DF9553CAE21BCDA5C68", + "whitespaceSha256": "281162A255BE84CFFFDF4D90B6C96D7DF3464263F5003C089FBEECBFADB68B96", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Threading.AsyncOptions", + "exampleId": "Cuemon.Threading.AsyncOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "95796344AE35A89D795F6CD266D2865F22329456326117AA0DDCA3CFDF8D5718", + "whitespaceSha256": "04BA97D4853C0F46FCF44E03FA12A53159C01DA2DA3BBB10515A1E96FAF7A19C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Threading.AsyncPatterns", + "exampleId": "Cuemon.Threading.AsyncPatterns#1", + "fenceOrdinal": 1, + "sourceSha256": "F54A3EB0B5C4E679E51A9DE95F89CA3BAE25EE31A25D5204758213DBDFDDE2EE", + "whitespaceSha256": "81BD19A22282EDC75FE935BEC9D26925BBB72D24BFC4B7FBEE5D8DA6B8F594B3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Threading@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Threading.AsyncRunOptions", + "exampleId": "Cuemon.Threading.AsyncRunOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "F45EB2BD9C969C97D49E7442DE894254ADDF12ECB82B59AC2C2EA35C0F51AD1D", + "whitespaceSha256": "68A689CAF7FC4BB73AA631F985E034CEA95CE51C43EC44784B67444148B5ED11", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Threading.AsyncTaskFactoryOptions", + "exampleId": "Cuemon.Threading.AsyncTaskFactoryOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "FF0CE848A0C683983AF7E4B5C26DD17A54D07476B84F91387DAB90530EFA62E4", + "whitespaceSha256": "41B96D20C8DFFB651D4A237CBEBCE6A34454BC4D00F2D41D76351E4BC5376F1C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Threading.AsyncWorkloadOptions", + "exampleId": "Cuemon.Threading.AsyncWorkloadOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "5C00190F77EA28431DD425BF21E10D20C906F33D1C009E0E4E48C929E2705D60", + "whitespaceSha256": "E5982701BD27FF499E3530FF7FFC036A73D54EC64C1BA6797C4954F0883CE391", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Threading.Awaiter", + "exampleId": "Cuemon.Threading.Awaiter#1", + "fenceOrdinal": 1, + "sourceSha256": "8F759C8E4A09E0F1022DF88268BFFBCD8A88FE64142958790EE2F164A143DC28", + "whitespaceSha256": "0DEA5566C11923A9CD58DD4A71941918CDFDA085ACD4E64B747F0DEC48ECFA03", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Threading.ForLoopRuleset`1", + "exampleId": "Cuemon.Threading.ForLoopRuleset`1#1", + "fenceOrdinal": 1, + "sourceSha256": "99D17B84F6865B67E200E05D45D1A76F71C42778DF9D4AAE7E3679E5647B9F2E", + "whitespaceSha256": "9F82362FED7D5C80CD2C0961AE5F4C720C775CA9A0037B46DCC864ECA149D2CD", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Threading.ParallelFactory", + "exampleId": "Cuemon.Threading.ParallelFactory#1", + "fenceOrdinal": 1, + "sourceSha256": "AF9B98BA8CF6586068EDC1F2F9D6A1B68CB9F7C4C88D6CDA0D961C84F392883B", + "whitespaceSha256": "B06A0B38DFED02BDB8B76ECDA8CEFFE70EA30BA780D5F735701C5FB48098B4A8", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Threading@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Threading.RelationalOperator", + "exampleId": "Cuemon.Threading.RelationalOperator#1", + "fenceOrdinal": 1, + "sourceSha256": "D170AD167C9C8BE279A7F2B4162519BF4BBA839B33FDC1245163CCDEDCA41AAA", + "whitespaceSha256": "998E0036A9FD53788F5F314F0BEF5059BCC234D042D6BD29B88AC6C4CEE64115", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Threading.TimerFactory", + "exampleId": "Cuemon.Threading.TimerFactory#1", + "fenceOrdinal": 1, + "sourceSha256": "0FC6FDD7A7F5AEE181B9234538A53FBD4135AE65834C6BD074B14C0CDD8BD770", + "whitespaceSha256": "D7CC409C8229F59813FDE9E84090259E84AF4614980F348B297F9CF33E1EFA07", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Tweaker", + "exampleId": "Cuemon.Tweaker#1", + "fenceOrdinal": 1, + "sourceSha256": "93F4700B14BA79482080CF80E8107E06F98ABD62F2ECC71FEF856901DAF9C48D", + "whitespaceSha256": "58B0B081C1698180912DF40E82113EBE1E7518F285135F1985968BCC513A1F49", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.TypeArgumentException", + "exampleId": "Cuemon.TypeArgumentException#1", + "fenceOrdinal": 1, + "sourceSha256": "E72D032EDE69011DA73A57696BF61C6AF238B80F2C0341F8575C0F9C40D9875C", + "whitespaceSha256": "6A90F821D00CD6B2503D2E218FB455D216EDD44E890BC4BA1B0653A8C7940109", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.TypeArgumentOutOfRangeException", + "exampleId": "Cuemon.TypeArgumentOutOfRangeException#1", + "fenceOrdinal": 1, + "sourceSha256": "8090F54014E269AC1CA5FEEE44C9127553335F66F08450985157E47DB9FC4954", + "whitespaceSha256": "34011CBA9ED2D273B44DA23EF034CC3699FD1DD3AC7577753153610258824A42", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.TypeDecoratorExtensions", + "exampleId": "Cuemon.TypeDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "4FA2195EBFC6D44DEF93E0B7E757B6C91CC9587243C187520423D3ACA1693431", + "whitespaceSha256": "40B67E861D43E4CCA1B8A4AE0814DB874A3C1BD36300E0C0503705D750DA7F8D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.UnsuccessfulValue", + "exampleId": "Cuemon.UnsuccessfulValue#1", + "fenceOrdinal": 1, + "sourceSha256": "82D62028B5A07A586F4580FD5193614B0091E0425F0B93BC120FAC52F1C00456", + "whitespaceSha256": "79282E46CAF63AAEF48DB89D635631EA0247EAF2336145C5A2A7D1CA502D071F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.UnsuccessfulValue`1", + "exampleId": "Cuemon.UnsuccessfulValue`1#1", + "fenceOrdinal": 1, + "sourceSha256": "2CCA96BCAF8C176159F3D9AA95A5D22F2CBD9BC3988A9681E1DB3B6922454DF5", + "whitespaceSha256": "6AFEEA1689034092FFBE500C1C51F7C4CFB856F5AF51B332547F0FE3E65A0653", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Validator", + "exampleId": "Cuemon.Validator#1", + "fenceOrdinal": 1, + "sourceSha256": "F2DF219EE3B6867CA71E37721805CFE6E21D7D48264B98C8D5379CC66B5B9DD5", + "whitespaceSha256": "384866519B1DDB96CA06C97C932D196E14C1BF7F85A2079A907C905C2008D12E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.HierarchyDecoratorExtensions", + "exampleId": "Cuemon.Xml.HierarchyDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "779B36BBDB13CA1C4D75E47B85461487B3517F6D9EDF3B00005AE4F2DB2E3FEF", + "whitespaceSha256": "53E686FE9C1AF8F18A401B9B27DFC8C9771C81FC69866BAA64CD0C7F261447B3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0", + "Cuemon.Kernel@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.Linq.StringDecoratorExtensions", + "exampleId": "Cuemon.Xml.Linq.StringDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "C6972D9479BC3648BD7D658EB5EF1CE7CD52990AB37E9DFD54AF7F6C2E3689CC", + "whitespaceSha256": "1C09BC4282DB8BCE6830D7EC5DFC171AC60335F7EBDD7E69CB1DF0A7D70B8D77", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.Serialization.Converters.DefaultXmlConverter", + "exampleId": "Cuemon.Xml.Serialization.Converters.DefaultXmlConverter#1", + "fenceOrdinal": 1, + "sourceSha256": "912B92DA2E00CEEB853AB8EFF9744CC904841D6163D224DF7A2CEA14A7EFF01B", + "whitespaceSha256": "74230BA549E99F9779CD8F77B5F854978EBA52D41241C4822E3C348B8DB62C39", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.Serialization.Converters.ExceptionConverter", + "exampleId": "Cuemon.Xml.Serialization.Converters.ExceptionConverter#1", + "fenceOrdinal": 1, + "sourceSha256": "2F643A55415EC18061DF570EF6B7297B8924EA0C05E3DA988FF766B6DDAE8261", + "whitespaceSha256": "73C4A42FB89F1CFFA95074595CD83B37ACFD96F46DC01D2506D8389ECC4238FD", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.Serialization.Converters.FailureConverter", + "exampleId": "Cuemon.Xml.Serialization.Converters.FailureConverter#1", + "fenceOrdinal": 1, + "sourceSha256": "9ECDF6304CF961C5918DC975EED146701BB1BD2731C7A3152BF42CA8C52BC9AD", + "whitespaceSha256": "84D1403764C8F2F7D439E296AE532BD07DA8F0AF47C1D18E20C8C52B70D800AA", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.Serialization.DynamicXmlConverter", + "exampleId": "Cuemon.Xml.Serialization.DynamicXmlConverter#1", + "fenceOrdinal": 1, + "sourceSha256": "806E8704A207D25848D31FB7279A950949951A63C7D9F16DA661F153C3388685", + "whitespaceSha256": "4DE1EDB39A2430B2D12C7A663A768516A326658253C107945C2447F16209CC14", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.Serialization.Formatters.XmlFormatter", + "exampleId": "Cuemon.Xml.Serialization.Formatters.XmlFormatter#1", + "fenceOrdinal": 1, + "sourceSha256": "310D31BC23CED43E67B5081D2396DBFE202765553E380C5218BEBE75D940C5B2", + "whitespaceSha256": "E22D6E2431E6FB57185BBB039DA2C1E533EE24BF2662660A88375223A857F603", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.Serialization.Formatters.XmlFormatterOptions", + "exampleId": "Cuemon.Xml.Serialization.Formatters.XmlFormatterOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "A2BBEAC2D474CF6F3885E03FFFBFB478450780153E9E4A0DE77BD7300CE8AE45", + "whitespaceSha256": "426E8475B7176AC0D50A8FCB113D775E169E44F1C1765D6721DCB785B0DD33BD", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.Serialization.XmlQualifiedEntity", + "exampleId": "Cuemon.Xml.Serialization.XmlQualifiedEntity#1", + "fenceOrdinal": 1, + "sourceSha256": "28AC8CC6ECCD8B2680A48C62E43F914AD0D229FFE093AE3D939D0BBF5916B9CE", + "whitespaceSha256": "29CEC98343DF735198B33231F24125402313D50949164364ECB8236D400ED1FA", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.Serialization.XmlSerializer", + "exampleId": "Cuemon.Xml.Serialization.XmlSerializer#1", + "fenceOrdinal": 1, + "sourceSha256": "3317328217E098410850F0BB9A826F004BDF4F3CF75A5A56BF412C432D587BA8", + "whitespaceSha256": "182E334F96783FA1956B6356386C5EDA8CC6AD7C288AB5ADC49A7775FFE9A447", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.StreamDecoratorExtensions", + "exampleId": "Cuemon.Xml.StreamDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "ED9B7EB4310FECC2BA0514A7896D827C07A62CDACB8EECA8CDC11438276FCE25", + "whitespaceSha256": "305D94C38AC04ED7FCB528D5FE806810873800AD0AF80F6FC58949C46088CD89", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.XmlEncodingOptions", + "exampleId": "Cuemon.Xml.XmlEncodingOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "EC7616F25E88A957A28DCA5677C5C17AC8214F0B27F29BFA14C25C6A5194B95F", + "whitespaceSha256": "4E46F12C5B494D3F62648BC633EF6520032BC9B0240C5AC95BAE5842E284A2E7", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.XmlReaderDecoratorExtensions", + "exampleId": "Cuemon.Xml.XmlReaderDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "5099DE8220BC7549EDF8A3CFAFE16BFB7056F70F80ABF7786831695E0B87474B", + "whitespaceSha256": "1C07E496DD83C41D4025C5881E0F890037F86FCAF0DD7E3B4C0CC69E374FC58E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.XmlStreamFactory", + "exampleId": "Cuemon.Xml.XmlStreamFactory#1", + "fenceOrdinal": 1, + "sourceSha256": "5F89B3D8FB1B6C86B9E076361855F36FC286EC5CB746726E893FA218E2D25D87", + "whitespaceSha256": "DDEF34582B4F05C89F353356026B063627BB64CFE3CAF3BFA511FB037736E5A9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "System.Runtime.CompilerServices.CallerArgumentExpressionAttribute", + "exampleId": "System.Runtime.CompilerServices.CallerArgumentExpressionAttribute#1", + "fenceOrdinal": 1, + "sourceSha256": "A69BE067AC96474490AA46ABA869FAE0961AF0CBB4D82DFDC049FA0425872886", + "whitespaceSha256": "608B00D6EC2306111BADF0A5FA09307FD1F2682B9E9A889C7925E2DE780C6DCD", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net48", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Diagnostics.AsyncTimeMeasureOptions", + "exampleId": "Cuemon.Diagnostics.AsyncTimeMeasureOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "036958A441AEF8CB1A8AD6FF1CDEB802F127505A589AD5CB7B8CEA976078C93F", + "whitespaceSha256": "DC458A22259C44F45B8CBC3DC157F12B91F810CD7B00727A9770C10B3AD912D9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Diagnostics@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Configuration.AssemblyCacheBustingOptions", + "exampleId": "Cuemon.Extensions.AspNetCore.Configuration.AssemblyCacheBustingOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "496E86484F2AD197DF8AE28070446CE5BBBFDCB227F82684D0B708A5FCA3D4BE", + "whitespaceSha256": "DA630C1BC3ABB11F0E29FFC1682EE37B837988C735B1C387EE55AB55B0380CC3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0", + "Cuemon.Security.Cryptography@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Data.Integrity.CacheValidatorExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Data.Integrity.CacheValidatorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "B1B8CC9B9C0AC7C3649248F4ED02CC4167B76356F4AF8812BC181E830DBFF545", + "whitespaceSha256": "E87D72B103CCDDBF779877CFDCE3D7F22747AB264883CD15802167CC3463D52A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Diagnostics.FileVersionInfoExtensions", + "exampleId": "Cuemon.Extensions.Diagnostics.FileVersionInfoExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "A6B1606B0E78AD50BAC01B90F5580ECD45455BD044BF33520E0FFB1B1521BC2F", + "whitespaceSha256": "6D976B4C33108BA4BA1A26D089F6347FFBBC1F34F0784DA43F4F9712AAE5B25B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Diagnostics@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Reflection.AssemblyExtensions", + "exampleId": "Cuemon.Extensions.Reflection.AssemblyExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "5D3696E4CD82CBC93E129C2F46D85060767A32E09304BFB3935CFE73CCFE830A", + "whitespaceSha256": "80A0117B682EA1B197393ACED3C1B1E5D51C45FCB035E1D7180F4DBFA5346174", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Reflection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.MemberArgument", + "exampleId": "Cuemon.Reflection.MemberArgument#1", + "fenceOrdinal": 1, + "sourceSha256": "C1871254408BB673FDDD8C5A415DB3AE2E3338262E5C3278148B1A187F7FDE7A", + "whitespaceSha256": "30749275B01390A9F7EC73B57C91A4B36E60C3E3FA9244447FE2C62CF6056D96", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.TargetFrameworkMoniker", + "exampleId": "Cuemon.Reflection.TargetFrameworkMoniker#1", + "fenceOrdinal": 1, + "sourceSha256": "E34F26487A0047642A9ED94952EE9553872601EBA9677255965282B7A406C4BF", + "whitespaceSha256": "0758EEA0C1FB35E68F71B77C8CFEB4DC55C34F370BC18220445398ABCDBA740F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Threading.AdvancedParallelFactory", + "exampleId": "Cuemon.Threading.AdvancedParallelFactory#1", + "fenceOrdinal": 1, + "sourceSha256": "18D626D8435797A99507A6B832A3AC33D1295BDD356BE8C93664BB1322394B94", + "whitespaceSha256": "D8018CF86AF6F9E23E95A61C03158BAA50E8EABDF8D1AA46D7BAF1E3AC6E06D3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Threading@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Runtime.HierarchyDecoratorExtensions", + "exampleId": "Cuemon.Extensions.Runtime.HierarchyDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "54712C233568FA4C5273644ECC248B56FA069EE34FDDE07A7D71A22C6880A4C3", + "whitespaceSha256": "6E6A2B4EC338DCE8ECD5D0DDB97BEDB90C072ADA27C11DDBD95E017FCF2ADFA1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.Serialization.XmlConvert", + "exampleId": "Cuemon.Xml.Serialization.XmlConvert#1", + "fenceOrdinal": 1, + "sourceSha256": "5112626C6BC1ED9BB18358EE0F9BDCCED5D082373B051EB794AC9A09D3ECF9D4", + "whitespaceSha256": "A8F000961C294C206A8623CDC4B05CC6B27AC985957C617167ACE0A92478F7E5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeaderBuilder", + "exampleId": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthorizationHeaderBuilder#1", + "fenceOrdinal": 1, + "sourceSha256": "F31F3D7CCB8A32A5D3139713A186A24FAF09FCF4130C92E7F4FAE4ACAAB0809B", + "whitespaceSha256": "BD527F1BA091D2433EA5AC345FCB724BD568ADD533CEAEC4A093E2DB9730206D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeader", + "exampleId": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthorizationHeader#1", + "fenceOrdinal": 1, + "sourceSha256": "1AA640FC3F52297606ACB7C7608A32EEB62CBA558FAA605690B25EE63009C3F9", + "whitespaceSha256": "7CAD332189464B442A0BF273350907E8C5F21F7BE8AE04B75EEBEEDE37CA9EBD", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Builder.MiddlewareBuilderFactory", + "exampleId": "Cuemon.AspNetCore.Builder.MiddlewareBuilderFactory#1", + "fenceOrdinal": 1, + "sourceSha256": "8F8B04BFEFB7CA9B7000E11ABAF45F85F14CFA101022C6C76D07519F09DC45D6", + "whitespaceSha256": "AD88223B99CA5D3E8786D27B6403984CCB83EEBF0BD60A6F5F15C1673C78DFBC", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerDecoratorExtensions", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpExceptionDescriptorResponseHandlerDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "1A1671A5E8FE4B956120490359EE92B980AB2A71241CBCA13287E5B4AC87C935", + "whitespaceSha256": "DB0FF0F01AC3BA3A06A6F3FBDB600BE9AC00B851C4B946C74035EC25B39ABFF4", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.ServerTimingOptions", + "exampleId": "Cuemon.AspNetCore.Diagnostics.ServerTimingOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "F9CDDC29F5FEFD76B4EC76F8FE1AB96F53E91D3ABFC4B35348EE9D3431B1F23C", + "whitespaceSha256": "BC9185A2100F60AFAD69BCDDB36FFC3534BB87402757B70DE491EBC12B120D85", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.HttpStatusCodeExceptionDecoratorExtensions", + "exampleId": "Cuemon.AspNetCore.Http.HttpStatusCodeExceptionDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "D14A436159088B2ABCC07BD1E4B3AFFC09897E15DD696E02BA8B63ACB9D03CE8", + "whitespaceSha256": "E517AF69CDE62556F09BFA66CAD0CB6499956A90E362900A190ABFE751B40C88", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.DatabaseDependency", + "exampleId": "Cuemon.Data.DatabaseDependency#1", + "fenceOrdinal": 1, + "sourceSha256": "A2DBE3A169BE1F94CC81AC023E628BBBF0D5B6B3276CC907F87BF5ED418744E4", + "whitespaceSha256": "551354E7D9619BDFF2019B653F2B42E0D9B3258B69DC3A431853C350F8F76378", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data@11.0.0" + ] + } + }, + { + "uid": "Cuemon.ExceptionInvoker`2", + "exampleId": "Cuemon.ExceptionInvoker`2#1", + "fenceOrdinal": 1, + "sourceSha256": "E639CB38E8EF6D4AA8D6E5323974158C4033B39BCFB06721BDC73692D36BFD0E", + "whitespaceSha256": "4694D37555BD2A4B4050D27F1159DB82E695608ECAB816D1F1E61972C0F7401A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Authentication.AuthorizationResponseHandlerOptions", + "exampleId": "Cuemon.Extensions.AspNetCore.Authentication.AuthorizationResponseHandlerOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "3CBC67FAAD6226E58653B07391EC83C9F1095519543B5DA01B3415B5EF114D29", + "whitespaceSha256": "504FD44B6FB3F785F39B1BD8E274C6B3893848C8F5B4FC72BA3DC519D6FB7ACA", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Authentication@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Net.Security.SignedUriOptions", + "exampleId": "Cuemon.Extensions.Net.Security.SignedUriOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "BC083862B57BB808A7726D17CC98A728041E1C0A7CEEE903A34F0197DDB6377E", + "whitespaceSha256": "93895F9715BEED2CFD3AD87B0C66E004286B654EFE0C2A69274AB3321EF0FE67", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Net@11.0.0", + "Cuemon.Security.Cryptography@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Xml.Serialization.XmlSerializerOptionsExtensions", + "exampleId": "Cuemon.Extensions.Xml.Serialization.XmlSerializerOptionsExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "DD83B7B86B98A63F80706761C52E2270BEC56DF8446D75DBED72157288CEB425", + "whitespaceSha256": "0039535F2A8EBFFC839BA7EB7500DB7AE7C1BAC0CC1936C4CE2285E8B48C73E5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Reflection.TypeNameOptions", + "exampleId": "Cuemon.Reflection.TypeNameOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "56B0D2822F07F9BAC8E91ABE97E454EAB7EF2EA5D3DD36A6AD994B8A6C0D412C", + "whitespaceSha256": "E0839CE92A0A7C5EEC0DA5A76EBE4577F0DD4AF8C269E0B559B7133AC920E1B7", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Resilience.AsyncTransientOperationOptions", + "exampleId": "Cuemon.Resilience.AsyncTransientOperationOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "FAD5F6B0375E0D473767EDC1DE4425EB140921F3C3510700C73811035A0DDB75", + "whitespaceSha256": "0F90D49F7AD9D9E84CDB50B4F825677BD3F4525368E3224642754D4A4F0DD48B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Resilience@11.0.0" + ] + } + }, + { + "uid": "Cuemon.StringDecoratorExtensions", + "exampleId": "Cuemon.StringDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "4C2831EC5DF798231FF1432BD8E65B367513489E909B68245B4442AB72159FBF", + "whitespaceSha256": "6AC53E40A2158890A27FF2E27E908D9F42B57972797EC89BF15312289A6BF23E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Text.AsyncEncodingOptions", + "exampleId": "Cuemon.Text.AsyncEncodingOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "5CEEDC4BC4C6B9D25C4A15AFA8A3EB82BC2BC1696F19F79FB58F7FBBDB5B2222", + "whitespaceSha256": "445B5118A3F49630080DC36962A44237A29884C003DAB3E05C79D2F166BC0213", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Text.FallbackEncodingOptions", + "exampleId": "Cuemon.Text.FallbackEncodingOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "72B1096F6ADEAFBE9D97BF5D851855E010A6ECF08F77D70EF0C2C9D7BF7CC725", + "whitespaceSha256": "5034E8BC441176E51FD8F85F257E7434419156081085F288DF11396CEBA11973", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Text.Stem", + "exampleId": "Cuemon.Text.Stem#1", + "fenceOrdinal": 1, + "sourceSha256": "C15DC75E838E1BFDEADF128D034C1C29153C89B05DE20305D08FE5C65C3C8E32", + "whitespaceSha256": "15DC8A59738EA34964AD36F27F9B1F7185080D8207D0BD8F5187EA2562173F89", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.ServerTimingMiddleware", + "exampleId": "Cuemon.AspNetCore.Diagnostics.ServerTimingMiddleware#1", + "fenceOrdinal": 1, + "sourceSha256": "9294D93ECC0092D335AC855A2365F81890FBFE64254754A1B254B41B632A3EA7", + "whitespaceSha256": "0AADEF400FADC0DCDA4FA3C87219D9BBB0A4DC4B7C88A3BA5D785A2C3E7D2A70", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.Hosting@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Hosting.HostingEnvironmentMiddleware", + "exampleId": "Cuemon.AspNetCore.Hosting.HostingEnvironmentMiddleware#1", + "fenceOrdinal": 1, + "sourceSha256": "1E49CFE9A135B19899D51570A2DC9C10A7ED41311F9A48BCDF4F56215D5EE27A", + "whitespaceSha256": "C3E01537E0376E1899BCB430483C4A35EBBA3D67BE6400A7AAA6CDEDCA2A840C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.Hosting@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.RequestIdentifierMiddleware", + "exampleId": "Cuemon.AspNetCore.Http.Headers.RequestIdentifierMiddleware#1", + "fenceOrdinal": 1, + "sourceSha256": "AA05FA1A027BA647BA1C0CE7A9A3556B63E9C7F7FDA5C625BF68B0E6D4CD090C", + "whitespaceSha256": "B1694C6BBF5E0F3615A8A1F3B1FA93A4E488E1B101F0148A8F54D5A9083C626C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.VaryAcceptMiddleware", + "exampleId": "Cuemon.AspNetCore.Http.Headers.VaryAcceptMiddleware#1", + "fenceOrdinal": 1, + "sourceSha256": "82495F9FE70EA4D7A220FDDC0603C415A3277262F27216239B9C7A2C8419C907", + "whitespaceSha256": "6A84ACC8C9D91C61927B43CD821B62CF8BD107A5928050EB0788B874AEC46A40", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationHandler", + "exampleId": "Cuemon.AspNetCore.Authentication.Basic.BasicAuthenticationHandler#1", + "fenceOrdinal": 1, + "sourceSha256": "8A761399E510D4775C771DAD891511C7EEEF0705C9DEA9A756D9C2E78EC8F9CD", + "whitespaceSha256": "A2417134F88AC2B4E2FC19FA00232CA6EA5EA2FF041D2B6AD85E0B3BC202938B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationHandler", + "exampleId": "Cuemon.AspNetCore.Authentication.Digest.DigestAuthenticationHandler#1", + "fenceOrdinal": 1, + "sourceSha256": "61C3CC8217D3E79AE77A455742F4ABBA4F45684BD8388E88B2F32E94AEAE6FAB", + "whitespaceSha256": "2384F483F7653754896722AA8DA448A57CFB35497FA5B57B994E70325E95FBB8", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationHandler", + "exampleId": "Cuemon.AspNetCore.Authentication.Hmac.HmacAuthenticationHandler#1", + "fenceOrdinal": 1, + "sourceSha256": "7430B424AEC48C37CCDC7299F271711F9614071A0D35DC6CEBC6ABE10673E558", + "whitespaceSha256": "B1C2ADE64AB3F6FD03838569911054FAA1EB9C56476E5F68EF62244879599E3F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Authentication.AuthenticationBuilderExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Authentication.AuthenticationBuilderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "D755A033BAA16FFA556B162E6D561BD0794DF22E08227ECE2278B197F1B0E5D2", + "whitespaceSha256": "EB10ADB272948CF73741A50A4A447FA88370DC23A7EEEBD2457D4E0B35238E9F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Extensions.AspNetCore.Authentication@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Authentication.ServiceCollectionExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Authentication.ServiceCollectionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "9F3863FD59AA484B7692F307605DD5B411B8D67ADC603C84AE7993D48B369C01", + "whitespaceSha256": "AA7E90DD39A3AF770BCAF54F73F65A359408A097C4F21150020685B5EF7FE46D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Authentication@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Authentication@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Text.Json.Converters.JsonConverterCollectionExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Text.Json.Converters.JsonConverterCollectionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "67F00FA6B345E20538C5AA9CE4A35B85085346FE9E5A6A586BFD8AD2C727A866", + "whitespaceSha256": "06FBF2919DFE76488EBAF580C57BB3632D8830F0CD317B751CC348588425861A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Text.Json@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.ObjectExtensions", + "exampleId": "Cuemon.Extensions.ObjectExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "8A9836CA004C9C432B18977D9DE76224356242C2A808CB51080747030C6F5074", + "whitespaceSha256": "54C2672598F4BBDC1DFC34E8BEC5781078B20156697E63D4031BFAC28ADB81B4", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Core@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.StringExtensions", + "exampleId": "Cuemon.Extensions.StringExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "7077232D672C932E46E98297B019D64E18DB0C4E244F24389402667FFDB14BB1", + "whitespaceSha256": "65E06DDE9323FD79B48D19CC6C4B0558721A0D93920D690898B501D9DB9BF751", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Text.StringExtensions", + "exampleId": "Cuemon.Extensions.Text.StringExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "8D75BD60BC74528D3FC7D6DE6BE3A7665F7488883C23433D6C15D15E8B5308D8", + "whitespaceSha256": "9D5434612BAA88006E87F3C8154016523F7D4B80ECB252ADE0C29140B43F8ADF", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Text@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.Serialization.DynamicXmlSerializable", + "exampleId": "Cuemon.Xml.Serialization.DynamicXmlSerializable#1", + "fenceOrdinal": 1, + "sourceSha256": "53BE8142BEFD77859EF06729C13691328B3D395322FC29564AA0F8EEA303AB42", + "whitespaceSha256": "1BB6AB8F32E31D9A96EAEA40F4C7B4D5A7D3B9F2CA22BC75EEB8EC9F92F99246", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.HttpRequestEvidence", + "exampleId": "Cuemon.AspNetCore.Diagnostics.HttpRequestEvidence#1", + "fenceOrdinal": 1, + "sourceSha256": "8384A356877548CA5B5C12F2CA64DB898201C7984C7D28DA643634C378EF60C6", + "whitespaceSha256": "80C183604A2A86E1058EDCB302B4924AC072A894F922410470B8F680070DE6F3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0" + ] + } + }, + { + "uid": "Cuemon.ConvertibleConverterDictionary", + "exampleId": "Cuemon.ConvertibleConverterDictionary#1", + "fenceOrdinal": 1, + "sourceSha256": "7E547127C49E79A15BC3AE04EB81A565BCE8770DD7625904B4117F0E7C9CA0A1", + "whitespaceSha256": "6CB72CF32FE90D6B3669F686FCCC59EB42D5BB6077EC22C115B9F6E31A5C298C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.ConvertibleOptions", + "exampleId": "Cuemon.ConvertibleOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "5A5626A35E12B924689B784601CA7C443F20BDC0150AA09B7A9B97CFF70BE9D8", + "whitespaceSha256": "DF7BE77F3383A9F5C7C6A5C39ED19391002DF63118CC6A133979F470CD60AF4F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.SqlClient.SqlDataManager", + "exampleId": "Cuemon.Data.SqlClient.SqlDataManager#1", + "fenceOrdinal": 1, + "sourceSha256": "4860C143F0BD38DC9DFDA3C7CBA0CE14F3D08CD056C62254C3848CB90A20DD86", + "whitespaceSha256": "4068144D2A46C15779763796DED99183AFED33878E79651DA265AAC0AC57491B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Data.SqlClient@11.0.0" + ] + } + }, + { + "uid": "Cuemon.ExceptionCondition`1", + "exampleId": "Cuemon.ExceptionCondition`1#1", + "fenceOrdinal": 1, + "sourceSha256": "51871E3E4A18FEB175FCF717455B7D06C9DB9EAE852C375A763109D8314069CD", + "whitespaceSha256": "B63E652E224AB2057E3C66D62801E51F76D2CCA7F475FD9CA5051A7A69D7B39D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.ExceptionHandler`1", + "exampleId": "Cuemon.ExceptionHandler`1#1", + "fenceOrdinal": 1, + "sourceSha256": "B2A3ABE81DAB38F792FAC8B00D6CB6600A80BA8145503130B27E912D3A95572D", + "whitespaceSha256": "8F8EC147D5A9C8C4BCDFEBBBDB36F97C381309EEAB7BC95F03BF886E3207629B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.ViewDataDictionaryExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.ViewDataDictionaryExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "B94A0E6791E25F6377E16793DAF94EC6916FD8FA50E7EC3EC3BAE2CEE309D641", + "whitespaceSha256": "599B1AE101C5ED24F7EB6787CA079E532B5815762A95275BEC67A59C0F87F99B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Mvc@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.IO.StreamExtensions", + "exampleId": "Cuemon.Extensions.IO.StreamExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "E79CDA3E64CA550B617EF8A1A0124D166874B0A77224F79B01E619DAFFE84DB0", + "whitespaceSha256": "81F037D0485A5698483112ECD51A5839BA3C08E23A5B13D5AC9EDBCF3691CD6D", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.IO@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Net.ByteArrayExtensions", + "exampleId": "Cuemon.Extensions.Net.ByteArrayExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "7A6ABCF81D05A974413137DF3FEA458C6CCE43B98929DD83A4A9BB8EA396461A", + "whitespaceSha256": "BC7A1EF62BF9C279A295AB7C5CB620D3BF4A00F4F59B9BB7A42AA9A29FDADAA5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Xml.StreamExtensions", + "exampleId": "Cuemon.Extensions.Xml.StreamExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "BEF31962749C80A9DBAE4C087883C420CD9B7014324DD1C045015A17EBB8F284", + "whitespaceSha256": "BE1D82D5054B999E41A79F3759331432B202B62DEABC7D17D5D990AED2B7EEC9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.IO.StreamDecoratorExtensions", + "exampleId": "Cuemon.IO.StreamDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "1438E63AD706AE351AB2653A88A1B240709D4A4E8F3501BAD20D0756E625F744", + "whitespaceSha256": "17D4FDECB7F8FD4D2D268DD917423B98A55ECF457174BB952529A42F7F2EAAD2", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.IO@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.ByteArrayDecoratorExtensions", + "exampleId": "Cuemon.Net.ByteArrayDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "776194204A28B83A13E928162C3F3CCD92972F9013F1EFE4FCA0CE127833FB1E", + "whitespaceSha256": "B09998B0D0E430921DEAC0E1C3A6264273AC4C31C2BBA5DA8E0DD631C6A18188", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Kernel@11.0.0", + "Cuemon.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.Http.HttpDependency", + "exampleId": "Cuemon.Net.Http.HttpDependency#1", + "fenceOrdinal": 1, + "sourceSha256": "C5D24D0CCD5EC4FBB5A4B8E096EC7D3D56268B515F40A394352D69203E2F6FEC", + "whitespaceSha256": "FC5914502683EB9CDE59E428144B270549C73A5AE2EDE4F3AD17EE42CF2C02DD", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.Serialization.DynamicXmlConverterCore", + "exampleId": "Cuemon.Xml.Serialization.DynamicXmlConverterCore#1", + "fenceOrdinal": 1, + "sourceSha256": "34FB17BB77AE27E2FC413A4E29312BCB990B41BAA4B5E72DECFACC70A0DC331F", + "whitespaceSha256": "FCE88242B080F810075EC31AD5E130E44EE2A4FD082430AE9664297DBCC09908", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Xml.XmlWriterDecoratorExtensions", + "exampleId": "Cuemon.Xml.XmlWriterDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "67AE4F18D818806699C97E6F12EF5A73FE69C8A042D78196D534E05E72B1B677", + "whitespaceSha256": "B1839D8513A2B49AB820D7DA57D30094EAF928E7689E5B5563804659E1F40789", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0", + "Cuemon.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Data.DataReaderDecoratorExtensions", + "exampleId": "Cuemon.Data.DataReaderDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "222FBC37BCEDA3819B6845FC256A7FBC72F3F5AF1524BF39DA9E4D623A08093B", + "whitespaceSha256": "7E593256815AD07293D43AC03BE3C3D12DB03C8EAE54AC8BADE5021510358159", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Xml.XmlReaderExtensions", + "exampleId": "Cuemon.Extensions.Xml.XmlReaderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "7BA5FB34B5687ACB58C4D07FCAB0871C672A0822BEA758EE6EDF80406EF798CD", + "whitespaceSha256": "FE40A2C56B1536C06A08EF6BA3C315C541D5CA20FCD540683B0D3C214D4166EC", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Xml@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Net.Http.HttpRequestOptions", + "exampleId": "Cuemon.Net.Http.HttpRequestOptions#1", + "fenceOrdinal": 1, + "sourceSha256": "86EBFB782DCFA0158C1E5B3437F2DB9568072B02523AF4B1050BF588CD82CBAC", + "whitespaceSha256": "55A0D26BA9AAD7151145D8663868441ECC21A2ADCB58F6F5FD78091B8BCCBD46", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Net@11.0.0" + ] + } + }, + { + "uid": "Cuemon.ArgumentReservedKeywordException", + "exampleId": "Cuemon.ArgumentReservedKeywordException#1", + "fenceOrdinal": 1, + "sourceSha256": "DBB6EB26B78B1C374194ACEAFF7256E98069FC124C7260AB0E4180049A930DFF", + "whitespaceSha256": "B17174348F864C3EE379C772448FACFDBA27A455C74B64CA8DF57B3DD8CEC8FC", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.HttpResponseDecoratorExtensions", + "exampleId": "Cuemon.AspNetCore.Http.HttpResponseDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "5EDD94A895E83DA3AD9C5412DD0A9F474CE0245B0238442B72B1BAD04763AC61", + "whitespaceSha256": "1DD0144E335E0EE659D18FF850C339E73845BF5C756AC2EAC4F7C4B420E69F90", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Http.HttpRequestExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.HttpRequestExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "FF923B0EF8B037C1FF7F136FAEFFEAD8A16B874896B0A9E5D175AC1471142B3E", + "whitespaceSha256": "521DFB81412BEFEA109368249B57926D7331FC54860ED864A8B6073DDFE03087", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Http.HttpResponseExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.HttpResponseExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "7F89DDF79EBCE00BF18147F1175C7730415F01348722C64C9A796BCC5415D646", + "whitespaceSha256": "E87A60C41A65513CB4F657E48C3DD85007886FAE9B1738EEEB95D8FDBBC896E9", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcCoreBuilderExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcCoreBuilderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "C2F200AD7EF5F0C1131EAED9A531AC43C26660BAB9A87BFC348F18CDBD03843F", + "whitespaceSha256": "5FCAF0D33FB2C32262BE9DAB0DABA220D8D52861A64E284CF056CF379B7CCEB4", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcCoreBuilderExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcCoreBuilderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "7650EF044F5A93BB18AB9D24A07CB69CC8D58A22F1C782FB638C5530ACDDF380", + "whitespaceSha256": "CC1C10B01B4FC0CB472D7167C23A1149FE5DC0CD3599A618A02175C63003B580", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Data.Integrity.ChecksumBuilderExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Data.Integrity.ChecksumBuilderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "E628091C615588E4CEDDDBF087976CC0AE6F64AE4258446B4867CEBEF9F51342", + "whitespaceSha256": "B7178F3803DE7280F761116AF13FB404DB9572291BB65D868C8C7E9CEC9106CF", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Data.Integrity@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Http.HttpExceptionDescriptorResponseFormatterExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.HttpExceptionDescriptorResponseFormatterExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "B2CFE54D411093EAB88A2BB876FAD9AA11061864BE4743AB7A4638DED63105E8", + "whitespaceSha256": "0047704656C19BAC629AEB5E19E87CFC695AF68F9748AD4CAC531AD7D0BA3FA8", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.RazorPages.PageBaseExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.RazorPages.PageBaseExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "A4D404E5719EA92D5BEF8AE569B5D7A0E2854AA6A25742B571B4FF5F835EF924", + "whitespaceSha256": "1C038D0EF6529C48985DC80CAF0C0E78CB4A1F2C91E47C45DB2E7B33507A7A5A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore.Razor.TagHelpers@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc.RazorPages@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Hosting.Environments", + "exampleId": "Cuemon.Extensions.Hosting.Environments#1", + "fenceOrdinal": 1, + "sourceSha256": "136C3050BB20DC2E52A22912C2E59DF235A01CA94DCE635BC311B622BDC266E8", + "whitespaceSha256": "313EC24ECAD68E2E0BF42CF4A6EBE8EE454FD06B066F2EEBD45ED094B41E8EE5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Hosting@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0", + "Microsoft.Extensions.Hosting@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Http.Throttling.ApplicationBuilderExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.Throttling.ApplicationBuilderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "332A2B275968C1380B9616B754CE87FC4C792F55AD17A3D6BAE298A02035D002", + "whitespaceSha256": "ECE645EDACCE5A798824BBC7C84DF01C9172FD49E86414FDE732FBBF7EAA2E3B", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Http.Throttling.ServiceCollectionExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.Throttling.ServiceCollectionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "7B87588093EEF472920F7A1B009518BC1694BCCA9A8937A662163BC81D5BA4D8", + "whitespaceSha256": "2E54C4966F48A2DA3EBBB9D89F558043F4AE3F3F2E28D5080450F7AF24EB8C33", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Filters.FilterCollectionExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Filters.FilterCollectionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "36F2E9446B737B936F1D27DC72A307114D073EA2D037492FEBF359A0F2DEBB66", + "whitespaceSha256": "529AF6D09DF823B6ECCE56EC7D0BAAC261A1A826AD44C0063EB424368AD3FE8C", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Mvc@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationMvcOptionsSetup", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.JsonSerializationMvcOptionsSetup#1", + "fenceOrdinal": 1, + "sourceSha256": "A25443F8A3D1BD62003D8B95A6ABDEAAD943B13AEC1B9B3327A12BF06D8D5BE8", + "whitespaceSha256": "2C48B2A2BB0C1115E707462BF8FFF44158908A50A8EDA7562141EE19E4A4E31E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcBuilderExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.MvcBuilderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "2EDD24E30EAA750AA05278CB62D18C1F5442C49942436530370CE2D81A248F4C", + "whitespaceSha256": "971A256252370F663A4744319F322BE9271D4C3E758E03FD169A93C01DAA51F5", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcBuilderExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.MvcBuilderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "8DA64B2D90C8F1FADC670191930B75E006EF0A3C7D6A83D3BB123694F9B22E5C", + "whitespaceSha256": "D17603F8E6A0347332D881DA8947DEF3CF8A1557C11F9805B2CEE8D3524DB03A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Text.Json.Formatters.ServiceCollectionExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Text.Json.Formatters.ServiceCollectionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "DB3E812063E1D6E8E14AC48C0640A543DD6BF94A628D4161B4C30CDEE39D23BA", + "whitespaceSha256": "F427A56F525B1A3EB2E6E17E7DD330BA6D3919F7D9E5EB6E3BC9CA42396DC515", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Text.Json@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Text.Json.ServiceCollectionExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Text.Json.ServiceCollectionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "337037B6C3C6BDA215736A50E39E6912368E1D2546A6E5CD5D3FFC9D31E6249F", + "whitespaceSha256": "17C20A79788DA1EFA623EC1F4F6AD3316DDF799A98C0C8334140D5DE39E775B2", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore.Text.Json@11.0.0", + "Cuemon.Extensions.Text.Json@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Xml.ServiceCollectionExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Xml.ServiceCollectionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "51CBC6EF4BE07DABA1A648CF359AF201A9E4F7D7D3CC6F095B63296DC39B120D", + "whitespaceSha256": "970244332E2A27815EC6C0EA0CFC28375C3029F734BC8B3DDDD5D7B186C5F595", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Xml@11.0.0", + "Cuemon.Xml@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.Hosting.HostEnvironmentExtensions", + "exampleId": "Cuemon.Extensions.Hosting.HostEnvironmentExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "C707381189BB9EACE92FC95555A66C6DF6A97EBE4DA2CB1DFA708EBFD678B3CA", + "whitespaceSha256": "60CC3F81458B5C77BAFC1F61FC2AD1F77629A6A6F79998EE94765B414440BC50", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.Hosting@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0", + "Microsoft.Extensions.Hosting@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Mvc.Rendering.HtmlHelperExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Mvc.Rendering.HtmlHelperExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "D0FA41909671C662779D397C5F70CD3FC052B72DCA8CFA0F95C6BE33C2B39DAD", + "whitespaceSha256": "2B78ADB75BFE38B3BB119547653F2A9FD47CDB2C4B3FA16E971D722C01418852", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.Extensions.AspNetCore.Mvc@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Xml.Formatters.ServiceCollectionExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Xml.Formatters.ServiceCollectionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "BC0C5D9EDC42C5E310A4F45F912EE8C703FEB90FBFC291BB04CBF4E0F290A6A8", + "whitespaceSha256": "BCDF18F15DEFF755B4B494517826A2FA8C287347D8C9F80316134ADDC49BE4FB", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore.Xml@11.0.0", + "Cuemon.Xml@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptionsDecoratorExtensions", + "exampleId": "Cuemon.AspNetCore.Diagnostics.FaultDescriptorOptionsDecoratorExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "1CFC3AD663FAB76D11998849DA9DA5551E050C636E04BE92544DB73F81C41D7C", + "whitespaceSha256": "595417D93BA9A90C5830F5A33B3D3C63D00CE3183AB472EC319C6E2649BAAD0E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Kernel@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.CacheableMiddleware", + "exampleId": "Cuemon.AspNetCore.Http.Headers.CacheableMiddleware#1", + "fenceOrdinal": 1, + "sourceSha256": "9460EF76582D22FB0F255CC7017CE0401C4962949BF7A1E8B8BF1F1E67793676", + "whitespaceSha256": "DE3011DA3596AAF6F1F83F05535AB45D97403AF5CD56824FB1EF8F5866074B4A", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierMiddleware", + "exampleId": "Cuemon.AspNetCore.Http.Headers.CorrelationIdentifierMiddleware#1", + "fenceOrdinal": 1, + "sourceSha256": "DF24A900CFAF97988EB69D8AA49B7F963E49E1D21A4D000667953CAFDAC52647", + "whitespaceSha256": "DAB7F43B79F2E95494B949F1789E135D8E913C5AF45DD4D555E2B3776DC6D279", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Configuration.ServiceCollectionExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Configuration.ServiceCollectionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "A279A3663EB1318E9C05CD7EF60412C89AAA0DDADFCCC89A05AEB47755512F44", + "whitespaceSha256": "8F5BC839AC44F029F264BCDF8DC28E66CF661E5C7394F00ADF6738BB53076DE1", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Cuemon.Security.Cryptography@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Diagnostics.ApplicationBuilderExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Diagnostics.ApplicationBuilderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "2DC7D2C71744BD5A6AD1D3250851753B4E9827BC33FBEE25D30D2F546E47E7BD", + "whitespaceSha256": "2982946BB20A95F5DF900551CDE657AD89486854A484670D6014D830613A6CBD", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Diagnostics.ServiceCollectionExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Diagnostics.ServiceCollectionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "AF88EA5DDA3771A5D7C325859A03430E268EB9927FBE0CAA4502E0D474788880", + "whitespaceSha256": "4FDA4458DECF00DC5290DF22BE763E8AA9B3B42DE21BF9F939F9D2811455A771", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Hosting.ApplicationBuilderExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Hosting.ApplicationBuilderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "F82CE0F553B6E3AD9F6FEC2C4FF2F7D16F150600438E323CA34A03114B910C86", + "whitespaceSha256": "CFA737FCD92F44E287437AD68912921B45EEC145C08DEB8D2C6AB2083F05F4E7", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0", + "Microsoft.Extensions.Hosting@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Http.Headers.EntityTagCacheableValidator", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.Headers.EntityTagCacheableValidator#1", + "fenceOrdinal": 1, + "sourceSha256": "E5EFA91562A0A05E8D96AABA5997B333DF9DE010FFCC249BA4F140E6BC251824", + "whitespaceSha256": "86EF60D3F4FC6FE86C497AAA04E7645ED833A09224C744CA3A0F06BC88E0A76E", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Http.Headers.ServiceCollectionExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.Headers.ServiceCollectionExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "E686EA65CDF221A36C3D5E14BB66ABD994A5A64517A291626ECB61ECA824F595", + "whitespaceSha256": "A3C39165266C9FC808C492F31343D53ACDD6F3BFAB91D0751FB492CEF0AAD1D3", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Diagnostics.ServiceProviderExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Diagnostics.ServiceProviderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "36F7E6CBED0A0B1D3781FF4B0F30C3324857285591DF39A63C8CF9D1CFDF2BBC", + "whitespaceSha256": "E3ACDF790E4EDEA50BB809B681DF4A25EE303458106C167CEE7903E0BCFF2739", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Core@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + }, + { + "uid": "Cuemon.Extensions.AspNetCore.Http.Headers.ApplicationBuilderExtensions", + "exampleId": "Cuemon.Extensions.AspNetCore.Http.Headers.ApplicationBuilderExtensions#1", + "fenceOrdinal": 1, + "sourceSha256": "E94DE8EDF29577CE8D3D2CD12783A77E65E3EF411B38419538ADA7B596F0B129", + "whitespaceSha256": "336C72B8A3BDDC761E9D074B823C910C490ABF603BFC1AA6F52908E8CAF5BC5F", + "manifest": { + "schemaVersion": 1, + "mode": "console", + "framework": "net10.0", + "dependsOn": [ + "Cuemon.AspNetCore@11.0.0", + "Cuemon.Extensions.AspNetCore@11.0.0", + "Microsoft.Data.Sqlite@11.0.0", + "Microsoft.Extensions.DependencyInjection@11.0.0" + ] + } + } + ] +} diff --git a/.docfx/templates/cuemon/public/main.js b/.docfx/templates/cuemon/public/main.js index 4eb7c680e..cabef87c9 100644 --- a/.docfx/templates/cuemon/public/main.js +++ b/.docfx/templates/cuemon/public/main.js @@ -6,4 +6,5 @@ export default { title: 'GitHub' } ] - } \ No newline at end of file + } +import './run-actions.js'; diff --git a/.docfx/templates/cuemon/public/run-actions.js b/.docfx/templates/cuemon/public/run-actions.js new file mode 100644 index 000000000..6f57db68f --- /dev/null +++ b/.docfx/templates/cuemon/public/run-actions.js @@ -0,0 +1,270 @@ +// Optional modern-template enhancement. The association remains usable without JavaScript. +const icons = { + native: '' + + '', + docker: '' + + '', +}; +const waitingForCopy = new WeakSet(); +// Generated scripts are one complete `& { ... }` paste unit, so execution and verification run together. +const executionScript = /^& \{\r?\n#requires -Version 7\.0\r?\n[\s\S]*\r?\n\}\r?\n?$/; + +async function fetchScript(link) { + const url = new URL(link.href); + if (url.origin !== location.origin) throw new Error('Script must be hosted on this site.'); + // Asset URLs are stable per example, so always revalidate rather than copy a stale cached script. + const response = await fetch(url, { mode: 'same-origin', cache: 'no-cache' }); + if (!response.ok) throw new Error('Script unavailable.'); + const script = await response.text(); + if (!executionScript.test(script)) throw new Error('Response is not an execution script.'); + return script; +} + +function previewScript(script, label) { + const dialog = document.createElement('dialog'); + dialog.className = 'docfx-run-preview'; + dialog.setAttribute('aria-label', label + ' run script'); + const heading = document.createElement('h2'); + heading.textContent = label + ' run script'; + const source = document.createElement('pre'); + source.tabIndex = 0; + source.textContent = script; + const close = document.createElement('button'); + close.type = 'button'; + close.className = 'btn btn-secondary'; + close.textContent = 'Close'; + close.addEventListener('click', () => dialog.close()); + dialog.addEventListener('close', () => dialog.remove(), { once: true }); + dialog.append(heading, source, close); + document.body.append(dialog); + dialog.showModal(); +} + +function createAction(link, report, onCopyFailure) { + const transport = link.dataset.transport; + const label = transport === 'native' ? 'Native' : 'Docker'; + const name = 'Copy ' + label + ' run script'; + const button = document.createElement('button'); + button.type = 'button'; + button.className = 'btn border-0 docfx-run-copy'; + button.title = name + '\nShift-click or right-click to preview'; + button.setAttribute('aria-label', name); + button.setAttribute('aria-description', 'Press Shift+Enter to preview the PowerShell script.'); + button.innerHTML = ''; + const icon = button.firstElementChild; + const check = document.createElement('i'); + check.className = 'bi bi-check-lg'; + check.setAttribute('aria-hidden', 'true'); + + let pending = false; + let resetIcon; + async function act(preview) { + if (pending) return; + pending = true; + report(''); + try { + const script = fetchScript(link); + if (preview) { + previewScript(await script, label); + } else { + // Start the clipboard write during the user's gesture, including while the fetch is pending. + const clipboard = navigator.clipboard; + if (clipboard?.write && typeof ClipboardItem === 'function') { + const text = script.then(value => new Blob([value], { type: 'text/plain' })); + await Promise.all([text, clipboard.write([new ClipboardItem({ 'text/plain': text })])]); + } else { + const text = await script; + await clipboard.writeText(text); + } + clearTimeout(resetIcon); + // Measure DocFX's success markup in the same code block so template overrides apply. + const reference = document.createElement('a'); + reference.className = 'btn border-0 link-success code-action'; + reference.hidden = true; + reference.setAttribute('aria-hidden', 'true'); + reference.style.transition = 'none'; + const referenceIcon = check.cloneNode(false); + referenceIcon.removeAttribute('style'); + reference.append(referenceIcon); + button.closest('pre').prepend(reference); + const appearance = getComputedStyle(referenceIcon, '::before'); + check.style.color = appearance.color; + check.style.fontSize = appearance.fontSize; + reference.remove(); + button.replaceChildren(check); + resetIcon = setTimeout(() => button.replaceChildren(icon), 1000); + report(label + ' script copied.', true); + } + } catch { + if (!preview) onCopyFailure?.(); + report('Could not ' + (preview ? 'preview ' : 'copy ') + label + ' script.'); + } finally { + pending = false; + } + } + + button.addEventListener('click', event => { void act(event.shiftKey); }); + button.addEventListener('contextmenu', event => { + event.preventDefault(); + void act(true); + }); + button.addEventListener('keydown', event => { + if (event.shiftKey && event.key === 'Enter') { + event.preventDefault(); + void act(true); + } + }); + return button; +} + +export function enhanceRunActions(root = document) { + for (const links of root.querySelectorAll('.docfx-run-actions:not([data-enhanced])')) { + const previous = links.previousElementSibling; + const pre = previous?.matches('pre') ? previous : previous?.querySelector('pre'); + if (!pre?.querySelector(':scope > code:is(.lang-csharp, .language-csharp, .lang-cs, .language-cs)')) continue; + const assets = [...links.querySelectorAll('a[data-transport="native"], a[data-transport="docker"]')]; + if (!assets.length) continue; + + // DocFX imports the custom module before rendering its Lit-managed copy anchor. + if (!pre.querySelector(':scope > a.code-action')) { + if (waitingForCopy.has(pre)) continue; + waitingForCopy.add(pre); + const observer = new MutationObserver(() => { + if (!pre.querySelector(':scope > a.code-action')) return; + observer.disconnect(); + waitingForCopy.delete(pre); + attachToolbar(pre, links, assets); + }); + observer.observe(pre, { childList: true }); + continue; + } + + attachToolbar(pre, links, assets); + } +} + +function attachToolbar(pre, links, assets) { + if ('enhanced' in links.dataset) return; + const toolbar = document.createElement('span'); + toolbar.className = 'docfx-run-toolbar'; + toolbar.setAttribute('role', 'group'); + toolbar.setAttribute('aria-label', 'Run scripts'); + const status = document.createElement('span'); + status.setAttribute('role', 'status'); + status.className = 'docfx-run-status'; + let clearStatus; + function report(message, visuallyHidden = false) { + clearTimeout(clearStatus); + status.classList.toggle('visually-hidden', visuallyHidden); + status.textContent = message; + if (message) clearStatus = setTimeout(() => { status.textContent = ''; }, 3000); + } + toolbar.append(...assets.map(link => createAction(link, report, () => { links.hidden = false; }))); + // Keep our nodes before DocFX's Lit render range, which replaces the original anchor on copy. + pre.prepend(toolbar, status); + pre.classList.add('docfx-runnable'); + links.dataset.enhanced = 'true'; + // Keep the recipe explanation visible when the toolbar replaces the fallback links. + links.after(...links.querySelectorAll(':scope > p')); + links.hidden = true; +} + +if (typeof document !== 'undefined') { + const style = document.createElement('style'); + style.textContent = ` +pre.docfx-runnable { + --run-action-size: 2.25rem; +} +.docfx-run-icon-native { + color: #926bbb; +} +.docfx-run-icon-docker { + color: #4d79d7; +} +.docfx-run-play { + color: #628b2f; +} +pre.docfx-runnable > .code-action, +.docfx-run-toolbar { + display: flex; + position: absolute; + top: .25rem; + opacity: 0; + pointer-events: none; + z-index: 1; +} +pre.docfx-runnable > .code-action, +.docfx-run-copy { + align-items: center; + justify-content: center; + inline-size: var(--run-action-size); + block-size: var(--run-action-size); + padding: 0; + background-color: var(--bs-body-bg); +} +.docfx-run-toolbar { + right: calc(.35rem + var(--run-action-size)); + gap: .15rem; +} +.docfx-run-copy { + display: inline-flex; +} +.docfx-run-copy .bi-check-lg { + pointer-events: none; +} +.docfx-run-copy:hover { + background-color: var(--bs-tertiary-bg); +} +pre.docfx-runnable:hover > :is(.code-action, .docfx-run-toolbar), +pre.docfx-runnable:focus-within > :is(.code-action, .docfx-run-toolbar) { + opacity: 1; + pointer-events: auto; +} +pre.docfx-runnable > .code-action:focus-visible, +.docfx-run-copy:focus-visible { + outline: 2px solid currentColor; + outline-offset: -2px; +} +.docfx-run-status { + position: absolute; + z-index: 1; + top: .25rem; + left: .25rem; + max-inline-size: calc(100% - 3 * var(--run-action-size) - 1rem); + white-space: normal; + pointer-events: none; +} +.docfx-run-status:not(:empty) { + padding: .3rem .5rem; + border-radius: .25rem; + background: var(--bs-body-bg); + color: var(--bs-body-color); +} +.docfx-run-preview { + inline-size: min(52rem, 94vw); + padding: 1rem; + color: var(--bs-body-color); + background: var(--bs-body-bg); + border: 1px solid var(--bs-border-color); + border-radius: .5rem; +} +.docfx-run-preview::backdrop { + background: rgb(0 0 0 / 45%); +} +.docfx-run-preview pre { + max-block-size: 65vh; + padding: .75rem; + background: var(--bs-tertiary-bg); +} +@media (hover: none), (any-pointer: coarse) { + pre.docfx-runnable > :is(.code-action, .docfx-run-toolbar) { + opacity: 1; + pointer-events: auto; + } +} +`; + document.head.append(style); + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => enhanceRunActions(), { once: true }); + else enhanceRunActions(); +} diff --git a/.docfx/verify-docfx-site.sh b/.docfx/verify-docfx-site.sh new file mode 100644 index 000000000..ade3ad98d --- /dev/null +++ b/.docfx/verify-docfx-site.sh @@ -0,0 +1,273 @@ +#!/bin/sh +set -eu + +# Verifies Cuemon DocFX run-action assets inside a build context or rendered site directory. +# Uses only POSIX shell + standard BusyBox/Alpine utilities so it runs inside both +# codebeltnet/docfx and nginx runtime containers without extra dependencies. + +usage() { + cat <<'EOF' >&2 +Usage: + verify-docfx-site.sh --context [docfx-root] + verify-docfx-site.sh --site [--source ] [--manifest ] +EOF + exit 2 +} + +mode="" +target="" +source_root="" +manifest_path="" + +while [ "$#" -gt 0 ]; do + case "$1" in + --context) + [ -n "$mode" ] && usage + mode="context" + if [ "$#" -gt 1 ] && [ "${2#-}" = "$2" ]; then + target="$2" + shift 2 + else + target="." + shift 1 + fi + ;; + --site) + [ -n "$mode" ] && usage + [ "$#" -lt 2 ] && usage + mode="site" + target="$2" + shift 2 + ;; + --source) + [ "$#" -lt 2 ] && usage + source_root="$2" + shift 2 + ;; + --manifest) + [ "$#" -lt 2 ] && usage + manifest_path="$2" + shift 2 + ;; + *) + usage + ;; + esac +done + +[ -n "$mode" ] || usage + +fail() { + printf 'ERROR: %s\n' "$1" >&2 + exit 1 +} + +check_manifest_ids() { + mf="$1" + scripts_dir="$2" + [ -s "$mf" ] || fail "Missing or empty run-actions manifest: $mf" + + ids_file=$(mktemp) + trap 'rm -f "$ids_file"' EXIT + + grep -oE '"id"[[:space:]]*:[[:space:]]*"[a-f0-9]{24}"' "$mf" \ + | sed -E 's/.*"([a-f0-9]{24})".*/\1/' \ + | sort -u > "$ids_file" + + [ -s "$ids_file" ] || fail "No valid run-action IDs found in manifest: $mf" + + missing_ids=0 + while IFS= read -r id; do + [ -n "$id" ] || continue + if [ ! -s "$scripts_dir/$id/native.ps1" ] && [ ! -s "$scripts_dir/$id/docker.ps1" ]; then + printf 'ERROR: Missing generated run-action script(s) for manifest id %s in %s\n' "$id" "$scripts_dir" >&2 + missing_ids=$((missing_ids + 1)) + fi + done < "$ids_file" + + rm -f "$ids_file" + trap - EXIT + [ "$missing_ids" -eq 0 ] || fail "$missing_ids manifest example(s) are missing generated scripts in $scripts_dir." +} + +if [ "$mode" = "context" ]; then + docfx_root=$(cd "$target" && pwd) + + [ -s "$docfx_root/run-actions.manifest.json" ] || fail "Missing or empty run-actions.manifest.json in $docfx_root." + [ -s "$docfx_root/templates/cuemon/public/run-actions.js" ] || fail "Missing or empty templates/cuemon/public/run-actions.js in $docfx_root." + + if [ ! -d "$docfx_root/run-actions" ] || [ -z "$(find "$docfx_root/run-actions" -type f -name '*.ps1' 2>/dev/null | head -n 1)" ]; then + cat >&2 </dev/null \ + | sed 's|^~/||' \ + | sort -u > "$refs_file" || true + + [ -s "$refs_file" ] || fail "No run-actions script references found in Markdown under $docfx_root." + + missing_refs=0 + ref_count=0 + while IFS= read -r rel_path; do + [ -n "$rel_path" ] || continue + ref_count=$((ref_count + 1)) + if [ ! -s "$docfx_root/$rel_path" ]; then + printf 'ERROR: Missing or empty referenced run-action script in build context: %s\n' "$rel_path" >&2 + missing_refs=$((missing_refs + 1)) + fi + done < "$refs_file" + + rm -f "$refs_file" + trap - EXIT + [ "$missing_refs" -eq 0 ] || fail "$missing_refs referenced run-action script(s) are missing from Docker build context." + + check_manifest_ids "$docfx_root/run-actions.manifest.json" "$docfx_root/run-actions" + + printf 'Verified Docker build context: %s referenced run-action script(s) present in %s/run-actions.\n' "$ref_count" "$docfx_root" + exit 0 +fi + +# --site mode +[ -d "$target" ] || fail "Published DocFX site directory not found: $target" +site_root=$(cd "$target" && pwd) + +[ -s "$site_root/public/run-actions.js" ] || fail "Missing or empty published template script: $site_root/public/run-actions.js" +[ -d "$site_root/run-actions" ] || fail "Missing published run-actions directory: $site_root/run-actions" + +site_ps1_count=$(find "$site_root/run-actions" -type f -name '*.ps1' | wc -l | tr -d ' ') +[ "$site_ps1_count" -gt 0 ] || fail "Published run-actions directory contains no .ps1 scripts: $site_root/run-actions" + +if [ -n "$source_root" ]; then + source_abs=$(cd "$source_root" && pwd) + [ -d "$source_abs/run-actions" ] || fail "Source run-actions directory not found: $source_abs/run-actions" + + src_list=$(mktemp) + site_list=$(mktemp) + trap 'rm -f "$src_list" "$site_list"' EXIT + + (cd "$source_abs/run-actions" && find . -type f -name '*.ps1' | sed 's|^\./||' | sort) > "$src_list" + (cd "$site_root/run-actions" && find . -type f -name '*.ps1' | sed 's|^\./||' | sort) > "$site_list" + + missing_from_site=$(comm -23 "$src_list" "$site_list") + if [ -n "$missing_from_site" ]; then + printf 'ERROR: Generated run-actions missing from published site %s:\n%s\n' "$site_root" "$missing_from_site" >&2 + exit 1 + fi + + rm -f "$src_list" "$site_list" + trap - EXIT +fi + +if [ -n "$manifest_path" ]; then + check_manifest_ids "$manifest_path" "$site_root/run-actions" +fi + +html_list=$(mktemp) +trap 'rm -f "$html_list"' EXIT +find "$site_root" -type f -name '*.html' | sort > "$html_list" +[ -s "$html_list" ] || fail "No HTML files found in published site: $site_root" + +check_file=$(mktemp) +trap 'rm -f "$html_list" "$check_file"' EXIT + +awk -v site_root="$site_root" ' +function normalize_rel(base_dir, href, full, n, i, seg, out_n, res, stack) { + if (href ~ /^\//) { + full = substr(href, 2) + } else if (base_dir == "" || base_dir == ".") { + full = href + } else { + full = base_dir "/" href + } + n = split(full, seg, "/") + out_n = 0 + for (i = 1; i <= n; i++) { + if (seg[i] == "" || seg[i] == ".") continue + if (seg[i] == "..") { + if (out_n == 0) return "__ESCAPES_ROOT__" + out_n-- + } else { + stack[++out_n] = seg[i] + } + } + res = "" + for (i = 1; i <= out_n; i++) { + res = (i == 1 ? stack[i] : res "/" stack[i]) + } + return res +} +{ + file = $0 + rel_file = substr(file, length(site_root) + 2) + dir = rel_file + if (index(dir, "/") > 0) { + sub(/\/[^\/]+$/, "", dir) + } else { + dir = "" + } + while ((getline line < file) > 0) { + pos = 1 + while (match(substr(line, pos), /href="[^"]*run-actions\/[^"]*"/)) { + m = substr(line, pos + RSTART - 1, RLENGTH) + href = substr(m, 7, length(m) - 7) + links++ + resolved = normalize_rel(dir, href) + if (resolved == "__ESCAPES_ROOT__" || resolved !~ /^run-actions\/[a-f0-9]{24}\/(native|docker)\.ps1$/) { + printf("INVALID|%s|%s|%s\n", rel_file, href, resolved) + bad++ + } else if (!(resolved in seen)) { + seen[resolved] = rel_file + print "CHECK|" resolved "|" rel_file + } + pos += RSTART + RLENGTH - 1 + } + } + close(file) +} +END { + printf("SUMMARY|%d|%d\n", links + 0, bad + 0) +} +' "$html_list" > "$check_file" + +total_links=0 +invalid_links=0 + +while IFS='|' read -r kind col1 col2 col3; do + case "$kind" in + INVALID) + printf 'ERROR: Invalid run-action href "%s" in %s (resolved: "%s")\n' "$col2" "$col1" "$col3" >&2 + invalid_links=$((invalid_links + 1)) + ;; + CHECK) + if [ ! -s "$site_root/$col1" ]; then + printf 'ERROR: Missing or empty published script "%s" referenced by %s\n' "$col1" "$col2" >&2 + invalid_links=$((invalid_links + 1)) + fi + ;; + SUMMARY) + total_links="$col1" + ;; + esac +done < "$check_file" + +rm -f "$html_list" "$check_file" +trap - EXIT + +[ "$total_links" -gt 0 ] || fail "No run-actions links found in rendered HTML under $site_root" +[ "$invalid_links" -eq 0 ] || fail "$invalid_links invalid or missing run-action reference(s) found in $site_root." + +printf 'Verified published DocFX site %s: %s HTML run-action link(s), %s script file(s) in run-actions/.\n' "$site_root" "$total_links" "$site_ps1_count" diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e84f86e77..e85db0202 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,6 +8,10 @@ on: type: boolean description: Run the macOS test matrix despite the additional cost and runtime. default: false + run_docfx_framework_views: + type: boolean + description: Run the experimental DocFX framework-view fixture. + default: false permissions: contents: read @@ -33,19 +37,86 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + docfx_validation: + name: DocFX run-actions + runs-on: ubuntu-26.04 + timeout-minutes: 10 + steps: + - name: Checkout + uses: codebeltnet/git-checkout@v1 + + - name: Generate, validate, and verify deterministic run-action scripts + shell: pwsh + run: | + & ./.docfx/BuildRunActions.ps1 + & ./.docfx/TestRunActions.ps1 -CheckDeterminism + + - name: Verify Docker build context preserves run-action scripts + shell: bash + run: | + set -euo pipefail + tmp_dockerfile="$(mktemp)" + trap 'rm -f "$tmp_dockerfile"' EXIT + cat <<'EOF' > "$tmp_dockerfile" + FROM dhi.io/nginx:1.31-alpine + WORKDIR /build/docfx + COPY . . + RUN test ! -e BuildRunActions.ps1 && test ! -e BuildDocfxImage.ps1 && sh ./verify-docfx-site.sh --context . + EOF + docker build --no-cache -f "$tmp_dockerfile" .docfx + + docfx_framework_views: + name: DocFX framework views (${{ matrix.os }}) + if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_docfx_framework_views }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-26.04, windows-2025] + runs-on: ${{ matrix.os }} + timeout-minutes: 20 + steps: + - name: Checkout + uses: codebeltnet/git-checkout@v1 + + - name: Install .NET + uses: codebeltnet/install-dotnet@v3 + + - name: Build and validate the framework fixture + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $true + $tools = Join-Path $env:RUNNER_TEMP 'framework-tools' + dotnet tool install --tool-path $tools docfx --version 2.81.0 + $env:PATH = "$tools$([IO.Path]::PathSeparator)$env:PATH" + $output = Join-Path $env:RUNNER_TEMP 'framework-views' + & ./tooling/docfx-multi-tfm/Build-DocfxFrameworkViews.ps1 -OutputRoot $output -TestSharedImplementation + if ($IsLinux) { + $browserTools = Join-Path $env:RUNNER_TEMP 'framework-browser' + npm install --prefix $browserTools playwright@1.61.1 + node "$browserTools/node_modules/playwright/cli.js" install --with-deps chromium + $env:NODE_PATH = "$browserTools/node_modules" + & ./tooling/docfx-multi-tfm/Test-DocfxFrameworkViews.ps1 -Workspace $output -Browser + } + # Keep the existing aggregate required-check name for branch protection. pr_quality_gate: if: ${{ always() }} name: PR quality gate - needs: [verification] + needs: [verification, docfx_validation] runs-on: ubuntu-26.04 steps: - name: Evaluate PR proof shell: bash env: VERIFICATION_RESULT: ${{ needs.verification.result }} + DOCFX_VALIDATION_RESULT: ${{ needs.docfx_validation.result }} run: | if [[ "$VERIFICATION_RESULT" != "success" ]]; then echo "::error::PR verification finished with '$VERIFICATION_RESULT'." exit 1 fi + if [[ "$DOCFX_VALIDATION_RESULT" != "success" ]]; then + echo "::error::DocFX run-actions validation finished with '$DOCFX_VALIDATION_RESULT'." + exit 1 + fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 43f6029d3..dc79604a2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -361,6 +361,12 @@ jobs: - name: Install .NET uses: codebeltnet/install-dotnet@v3 + - name: Generate and validate DocFX run-action scripts + shell: pwsh + run: | + & ./.docfx/BuildRunActions.ps1 + & ./.docfx/TestRunActions.ps1 + - name: Build and verify the multi-platform DocFX OCI artifact uses: codebeltnet/docfx-oci-build@v1 with: @@ -370,6 +376,13 @@ jobs: docfx-version: 2.78.5 platforms: linux/amd64,linux/arm64 + - name: Verify DocFX run-action assets in OCI archive + shell: pwsh + env: + OCI_ARCHIVE_PATH: ${{ runner.temp }}/cuemon-docfx-${{ needs.release_preflight.outputs.version }}.oci.tar + run: | + & ./.docfx/TestRunActions.ps1 -OciArchivePath $env:OCI_ARCHIVE_PATH + - name: Persist OCI image between release jobs uses: actions/upload-artifact@v7 with: diff --git a/.gitignore b/.gitignore index e2c9694db..0f5b1646f 100644 --- a/.gitignore +++ b/.gitignore @@ -234,3 +234,4 @@ ModelManifest.xml # Bot workspace (local-only AI agent ideation, PRDs, and agentic loop state) .bot/* !.bot/README.md +/.docfx/run-actions/ diff --git a/AGENTS.md b/AGENTS.md index cea72bbf7..13cb1fbab 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -607,6 +607,17 @@ Agents must never automatically commit code changes or push to remote repositori 5. Run targeted tests when changing logic. 6. Keep changes minimal and consistent with existing local style. +## DocFX Build Entry Points + +For the scripted local build, install PowerShell 7, Git, the .NET 11 SDK, and Docker with Buildx, Linux containers, and the containerd image store enabled. Install the host tools with `dotnet tool install --global docfx --version 2.81.0` and `dotnet tool install --global minver-cli --version 7.0.0`, then make sure `docfx` and `minver` are on `PATH`. The build restores NuGet packages, pulls published container images, and skips assembly signing for metadata generation when the local signing key is absent. + +DocFX run-action scripts under `.docfx/run-actions/` and generated API metadata under `.docfx/api/**/*.yml` are Git-ignored and must be generated before building the site image: + +- **Scripted local image build (recommended):** `pwsh .docfx/BuildDocfxImage.ps1` — generates `.docfx/run-actions/` via `.docfx/BuildRunActions.ps1`, validates manifest/Markdown/scripts via `.docfx/TestRunActions.ps1`, generates or reuses DocFX metadata, builds `Dockerfile.docfx`, and verifies the built container image. +- **Direct Docker build:** Run `pwsh .docfx/BuildRunActions.ps1`, `pwsh .docfx/TestRunActions.ps1`, and `docfx metadata .docfx/docfx.json` first, then run `docker build -f .docfx/Dockerfile.docfx .docfx`. Direct Docker builds validate the build context and rendered `wwwroot` via `.docfx/verify-docfx-site.sh` and fail immediately if run-action scripts are missing or incomplete. +- **CI release build:** `.github/workflows/release.yml` runs `.docfx/BuildRunActions.ps1` and `.docfx/TestRunActions.ps1` before `codebeltnet/docfx-oci-build@v1`, and validates the exported OCI archive with `.docfx/TestRunActions.ps1 -OciArchivePath ...`. +- **PR validation:** `.github/workflows/pr.yml` runs `.docfx/BuildRunActions.ps1`, `.docfx/TestRunActions.ps1 -CheckDeterminism`, and a Docker build context check against `.docfx/.dockerignore`. + ## DocFX Documentation Maintenance @@ -618,7 +629,7 @@ Public non-abstraction types — including enums, structs, records, plain classe For public non-abstraction types, include at least one realistic, copy/paste-ready usage example on the generated type page/overwrite section for that type UID. For example, a public `Class1` requires an example on the `Class1` API page, not only on the namespace page. Prefer deriving examples from existing unit, functional, or integration tests, but convert test code into real-life consumer-oriented usage. -Missing type examples must be added through per-type DocFX overwrite files under `.docfx/api/types/{TypeUid}.md` in Codebelt repositories. Namespace overview text and `Extension Members` tables are not substitutes for type-page examples. +Missing type examples must be added through per-type DocFX overwrite files under `.docfx/api/types/{TypeUid}.md` in Codebelt repositories. Namespace overview text and `Extension Members` tables are not substitutes for type-page examples. When front matter maps the body to `example` (`example: *content`, `example: [*content]`, or `example:\n- *content`), DocFX renders the `Examples` section heading automatically — never add a manual `## Example`, `### Example`, or `### Examples` heading in the body; place the complementary explanatory prose directly before the C# fence instead. Public extension methods must have examples too. Listing an extension method in an `Extension Members` table is required, but it is not enough. @@ -636,7 +647,7 @@ Both namespace overwrite files and type overwrite files are required deliverable `docfx.json` must keep namespace and type overwrite files in separate subdirectories. `build.overwrite` must include both `api/namespaces/**/*.md` (for namespace pages) and `api/types/**/*.md` (for type pages). `build.content` must exclude both `api/namespaces/**` and `api/types/**` to prevent overwrite Markdown from being treated as conceptual content. Do not use `api/**/*.md` under `build.overwrite` or `build.content`. -Availability must be documented by referencing the appropriate include file when one exists, or by adding explicit availability text when no suitable include exists. Availability must reflect the actual target frameworks, conditional compilation, and project configuration. +Availability must be documented on namespace overview pages under `.docfx/api/namespaces/*` by referencing the appropriate `[!INCLUDE ...]` file when one exists, or by adding explicit availability text when no suitable include exists. Under `.docfx/api/`, `[!INCLUDE ...]` directives are only allowed in `.docfx/api/namespaces/*` — never on type pages (`.docfx/api/types/*`), never in other files under `.docfx/api/`, and never after examples. When performing DocFX API documentation maintenance or applying `dotnet-docfx-digest` / `csrun` run-action updates, limit DocFX Markdown edits to `.docfx/api/` and leave unrelated Markdown files outside `.docfx/api/` (such as `README.md`, `CHANGELOG.md`, guides, articles, or conceptual docs) untouched; this DocFX scope rule does not restrict normal repository documentation updates in other changes. Availability must reflect the actual target frameworks, conditional compilation, and project configuration. For conditionally compiled APIs, choose the executable test framework from the asset that contains the API. Inspect the preprocessor condition, project TFMs, package `lib/` assets, and resolved consumer asset before changing a sample. For APIs under `NETSTANDARD2_0` or `NETSTANDARD2_0_OR_GREATER`, when modern `lib/netX.0/` assets also exist, use `net48` (or another supported .NET Framework target from `net462` onward) so the consumer selects `lib/netstandard2.0/`. Never use `netstandard*` as an executable target, and never use a modern `netX.0` target when it selects an asset where the API is absent. For other TFM guards, select a runnable consumer TFM that resolves to the containing asset and confirm that selection from restore or build evidence. @@ -644,7 +655,7 @@ Preserve manual documentation edits. Prefer additive changes, but correct stale Preserve working Markdown links, `Related:` references, and historical URL citations during prose rewrites. Remove or replace a URL only after directly verifying that the current destination returns HTTP 404. Timeouts, 403s, rate limits, DNS failures, and other lookup problems are not removal evidence. -The following restrictions on new working-tree files apply only to files created as part of the DocFX documentation-maintenance process, not to the repository in general. Interim scratch artifacts from this process do not belong in the repository working tree. Store assessment queues, project manifests, review reports, captured validator output, progress notes, and one-off helper scripts in temp or session storage instead. New working-tree files are only legitimate when they are the managed `AGENTS.md` block, the active `docfx.json`, the deterministic `skip-compile-allowlist.json` waiver file when one is truly required, or DocFX-authored namespace/type Markdown that maps to a real public namespace or type. Everything else is blocking cleanup work, not a documentation deliverable. The validator auto-detects generic-arity type families (such as `MutableTuple`1`..`MutableTuple`N`) and skips redundant sibling examples from the public API surface alone, so no family-skip manifest is ever written into the repository. +Interim scratch artifacts do not belong in the repository working tree. Store assessment queues, project manifests, review reports, captured validator output, progress notes, and one-off helper scripts in temp or session storage instead. New working-tree files are only legitimate when they are the managed `AGENTS.md` block, the active `docfx.json`, the deterministic `skip-compile-allowlist.json` waiver file when one is truly required, or DocFX-authored namespace/type Markdown that maps to a real public namespace or type. Everything else is blocking cleanup work, not a documentation deliverable. The validator auto-detects generic-arity type families (such as `MutableTuple`1`..`MutableTuple`N`) and skips redundant sibling examples from the public API surface alone, so no family-skip manifest is ever written into the repository. Skip markers are waivers, not fixes. A skip marker only suppresses compilation when it both existed before the current run and matches an entry in `.docfx/skip-compile-allowlist.json`. Each allowlist entry must include `diagnosticCode`, `filePath`, `uid` or `symbol`, `reason`, `approval`, and `lifetime` (`temporary` or `permanent`). Newly introduced or unallowlisted skip markers remain fail-level diagnostics and do not permit a completion claim. diff --git a/CHANGELOG.md b/CHANGELOG.md index 388e036d0..bb7eccc65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,8 @@ This major release adds .NET 11 targets, removes .NET 9-specific targets, and ch - `SonarAnalyzer.CSharp` 10.35.0.4138 is configured for source projects, - Central transitive pins for `System.Security.Cryptography.Pkcs` use 10.0.15 for .NET 10 and 11.0.0 for .NET 11, - A .NET 11 test workflow accepts preview SDKs and uses absolute project paths as a workaround for an SDK test-runner issue, -- `Resolve-PackageReleaseNotesConflicts.ps1` resolves package release-note conflict markers and stages the resolved files when run. +- `Resolve-PackageReleaseNotesConflicts.ps1` resolves package release-note conflict markers and stages the resolved files when run, +- DocFX run-actions build script, manifest, settings, and template integration for generating native and Docker run scripts for API example pages. ### Changed @@ -32,7 +33,9 @@ This major release adds .NET 11 targets, removes .NET 9-specific targets, and ch - Test tooling updates `Codebelt.Coverlet.MTP` from 10.1.1 to 11.0.0, `Microsoft.Testing.Extensions.HangDump` from 2.5.1 to 2.5.2, and `xunit.v3`, `xunit.v3.extensibility.core`, and `xunit.v3.runner.console` from 4.0.2 to 4.0.3, - The DocFX image uses `dhi.io/nginx`; fingerprinted assets cache successful and revalidation responses but use `no-store` for other responses, and range requests are disabled for those assets, - Test environments retain separate .NET 10 and .NET 11 Docker runners and remove the .NET 9 runner, -- Verification temporarily skips CodeQL and excludes it from post-release service identity checks while the branch targets .NET 11; the workflow does not claim CodeQL assurance. +- Verification temporarily skips CodeQL and excludes it from post-release service identity checks while the branch targets .NET 11; the workflow does not claim CodeQL assurance, +- Updated DocFX API namespace and type overwrite examples, removed redundant availability includes, wired run-actions content and templates into `docfx.json` and `BuildDocfxImage.ps1`, and updated DocFX maintenance guidance in `AGENTS.md`, +- Added `Cuemon.Kernel` to the package table in `README.md` and ignored generated `.docfx/run-actions/` output in `.gitignore`. ### Removed diff --git a/README.md b/README.md index 168bdc76b..67afbd857 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,7 @@ Provides a focused API for building various types of .NET projects. | [Cuemon.Extensions.Threading](https://www.nuget.org/packages/Cuemon.Extensions.Threading/) | ![vNext](https://img.shields.io/nuget/vpre/Cuemon.Extensions.Threading?logo=nuget) | ![Stable](https://img.shields.io/nuget/v/Cuemon.Extensions.Threading?logo=nuget) | ![Downloads](https://img.shields.io/nuget/dt/Cuemon.Extensions.Threading?color=blueviolet&logo=nuget) | | [Cuemon.Extensions.Xml](https://www.nuget.org/packages/Cuemon.Extensions.Xml/) | ![vNext](https://img.shields.io/nuget/vpre/Cuemon.Extensions.Xml?logo=nuget) | ![Stable](https://img.shields.io/nuget/v/Cuemon.Extensions.Xml?logo=nuget) | ![Downloads](https://img.shields.io/nuget/dt/Cuemon.Extensions.Xml?color=blueviolet&logo=nuget) | | [Cuemon.IO](https://www.nuget.org/packages/Cuemon.IO/) | ![vNext](https://img.shields.io/nuget/vpre/Cuemon.IO?logo=nuget) | ![Stable](https://img.shields.io/nuget/v/Cuemon.IO?logo=nuget) | ![Downloads](https://img.shields.io/nuget/dt/Cuemon.IO?color=blueviolet&logo=nuget) | +| [Cuemon.Kernel](https://www.nuget.org/packages/Cuemon.Kernel/) | ![vNext](https://img.shields.io/nuget/vpre/Cuemon.Kernel?logo=nuget) | ![Stable](https://img.shields.io/nuget/v/Cuemon.Kernel?logo=nuget) | ![Downloads](https://img.shields.io/nuget/dt/Cuemon.Kernel?color=blueviolet&logo=nuget) | | [Cuemon.Net](https://www.nuget.org/packages/Cuemon.Net/) | ![vNext](https://img.shields.io/nuget/vpre/Cuemon.Net?logo=nuget) | ![Stable](https://img.shields.io/nuget/v/Cuemon.Net?logo=nuget) | ![Downloads](https://img.shields.io/nuget/dt/Cuemon.Net?color=blueviolet&logo=nuget) | | [Cuemon.Resilience](https://www.nuget.org/packages/Cuemon.Resilience/) | ![vNext](https://img.shields.io/nuget/vpre/Cuemon.Resilience?logo=nuget) | ![Stable](https://img.shields.io/nuget/v/Cuemon.Resilience?logo=nuget) | ![Downloads](https://img.shields.io/nuget/dt/Cuemon.Resilience?color=blueviolet&logo=nuget) | | [Cuemon.Runtime.Caching](https://www.nuget.org/packages/Cuemon.Runtime.Caching/) | ![vNext](https://img.shields.io/nuget/vpre/Cuemon.Runtime.Caching?logo=nuget) | ![Stable](https://img.shields.io/nuget/v/Cuemon.Runtime.Caching?logo=nuget) | ![Downloads](https://img.shields.io/nuget/dt/Cuemon.Runtime.Caching?color=blueviolet&logo=nuget) | diff --git a/tooling/docfx-multi-tfm/Build-DocfxFrameworkViews.ps1 b/tooling/docfx-multi-tfm/Build-DocfxFrameworkViews.ps1 new file mode 100644 index 000000000..6b1e07820 --- /dev/null +++ b/tooling/docfx-multi-tfm/Build-DocfxFrameworkViews.ps1 @@ -0,0 +1,76 @@ +#requires -Version 7.0 +[CmdletBinding()] +param( + [string] $DefaultFramework = 'net11.0', + [string[]] $Framework = @('net11.0', 'net10.0', 'netstandard2.1', 'netstandard2.0'), + [string] $BuilderImage = 'codebeltnet/docfx:2.81.0@sha256:9645aaf2a361f1644585109bdaaa1fc65480b2c4d5d33a4777583eb07f9831af', + [string] $OutputRoot = (Join-Path ([IO.Path]::GetTempPath()) "cuemon-docfx-native-$([guid]::NewGuid().ToString('N'))"), + [string] $MetadataCache, + [string] $MetadataCacheKey, + [switch] $ForceMetadata, + [switch] $BuildInContainer, + [switch] $TestSharedImplementation +) + +$ErrorActionPreference = 'Stop' +$repo = (Resolve-Path -LiteralPath "$PSScriptRoot/../..").Path +$source = "$repo/.docfx" + +function Expand-PinnedArchive([string] $Repository, [string] $Revision, [string] $Workspace) { + $archive = Join-Path $Workspace "$Repository.zip" + Invoke-WebRequest -Uri "https://codeload.github.com/codebeltnet/$Repository/zip/$Revision" -OutFile $archive + Expand-Archive -LiteralPath $archive -DestinationPath $Workspace + Join-Path $Workspace "$Repository-$Revision" +} + +# Use the authored inputs for the two-project fixture. The shared script owns discovery and generation. +$config = Get-Content -LiteralPath "$source/docfx.json" -Raw | ConvertFrom-Json -AsHashtable +$group = @($config.metadata | Where-Object dest -CEQ 'api/dotnet') +if ($group.Count -ne 1 -or $group[0].src.Count -ne 1) { throw 'Expected one api/dotnet metadata group with one source mapping.' } +$config.metadata = $group +$mapping = $group[0].src[0] +$mapping.src = [IO.Path]::GetFullPath($mapping.src, $source) +$mapping.files = @($mapping.files | Where-Object { $_ -cmatch '^Cuemon\.(Kernel|IO)/' }) +if ($mapping.files.Count -ne 2) { throw 'Expected the authored Cuemon.Kernel and Cuemon.IO project mappings.' } +if (!(Test-Path -LiteralPath "$repo/cuemon.snk" -PathType Leaf)) { + $group[0].properties = @{ SkipSignAssembly = 'true' } +} +$config.build.Remove('sitemap') +$config.build.Remove('xref') +$config.build.globalMetadata.Remove('_googleAnalyticsTagId') +$config.build.content = @(@{ files = @('api/dotnet/**/*.yml', 'index.md', 'toc.yml') }) + +$temporary = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()) +$workspace = Join-Path $temporary "cuemon-docfx-input-$([guid]::NewGuid().ToString('N'))" +$inputRoot = Join-Path $workspace 'input' +New-Item -ItemType Directory -Path "$inputRoot/api" -Force | Out-Null +try { + $shared = Expand-PinnedArchive 'docfx-oci-build' 'fc1d3f50550499691b1c0efa35e8795a44028fcb' $workspace + # The published builder has no framework selector yet. Use this override only for the fixture. + $templates = Expand-PinnedArchive 'docfx' '06e35071e26f0a35a876ea963767c6216449532f' $workspace + $sharedTemplatePath = Join-Path $templates 'templates/ms-style' + if ($TestSharedImplementation) { + & "$shared/tests/Test-FrameworkViews.ps1" -SharedTemplatePath $sharedTemplatePath + } + + Copy-Item -LiteralPath "$source/includes", "$source/images", "$source/templates", "$source/index.md", "$source/$($group[0].filter)" -Destination $inputRoot -Recurse + Copy-Item -LiteralPath "$source/api/namespaces", "$source/api/types" -Destination "$inputRoot/api" -Recurse + @' +- name: Concept Reference + href: index.md +- name: .NET API + href: api/dotnet/Cuemon.IO.yml +'@ | Set-Content -LiteralPath "$inputRoot/toc.yml" + ConvertTo-Json -InputObject $config -Depth 100 | Set-Content -LiteralPath "$inputRoot/docfx.json" + & "$source/BuildRunActions.ps1" -OutputRoot "$inputRoot/run-actions" + & "$shared/scripts/Build-DocfxFrameworkViews.ps1" -DocfxConfig "$inputRoot/docfx.json" -OutputRoot $OutputRoot -ApiPath $group[0].dest ` + -DefaultFramework $DefaultFramework -Framework $Framework -AlignAssemblyVersion ` + -SharedTemplatePath $sharedTemplatePath -BuilderImage $BuilderImage -BuildInContainer:$BuildInContainer ` + -MetadataCache $MetadataCache -MetadataCacheKey $MetadataCacheKey -ForceMetadata:$ForceMetadata + & "$source/TestRunActions.ps1" -ScriptsRoot "$inputRoot/run-actions" -SiteRoot (Join-Path $OutputRoot 'site') +} finally { + $resolvedWorkspace = (Resolve-Path -LiteralPath $workspace).Path + if ([IO.Path]::GetRelativePath($temporary, $resolvedWorkspace) -match '^cuemon-docfx-input-[a-f0-9]{32}$') { + Remove-Item -LiteralPath $resolvedWorkspace -Recurse -Force + } +} diff --git a/tooling/docfx-multi-tfm/Consolidate.cs b/tooling/docfx-multi-tfm/Consolidate.cs new file mode 100644 index 000000000..9160e656e --- /dev/null +++ b/tooling/docfx-multi-tfm/Consolidate.cs @@ -0,0 +1,240 @@ +#:package YamlDotNet@18.1.0 +#:property PublishAot=false + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Security; +using System.Text; +using System.Text.Json; +using YamlDotNet.RepresentationModel; + +namespace Cuemon.Tooling.Docfx; + +internal static class Consolidate +{ + private const string ManagedReference = "### YamlMime:ManagedReference"; + private const string TableOfContent = "### YamlMime:TableOfContent"; + + public static void Main(string[] args) + { + if (args.Length < 3 || args.Length % 2 == 0) + { + throw new ArgumentException("Usage: Consolidate.cs [ ...]"); + } + + var inputs = args.Skip(1).Chunk(2).ToDictionary(pair => pair[0], pair => pair[1], StringComparer.Ordinal); + var pages = new Dictionary(StringComparer.Ordinal); + var locations = new SortedDictionary(StringComparer.Ordinal); + var fileNames = new HashSet(StringComparer.OrdinalIgnoreCase) { "toc.yml" }; + var variants = new Dictionary>(StringComparer.Ordinal); + YamlMappingNode? toc = null; + + foreach (var (framework, directory) in inputs) + { + var manifest = JsonSerializer.Deserialize>(File.ReadAllText(Path.Combine(directory, ".manifest")))!; + var inventory = new Dictionary(StringComparer.Ordinal); + foreach (var path in Directory.GetFiles(directory, "*.yml").Order(StringComparer.Ordinal)) + { + var file = Path.GetFileName(path); + if (file == "toc.yml") { continue; } + var page = Read(path, ManagedReference); + var items = Sequence(page, "items"); + var rootItem = (YamlMappingNode)items.First(); + var root = Uid(rootItem); + var rootChildren = Strings(rootItem, "children").ToHashSet(StringComparer.Ordinal); + foreach (YamlMappingNode item in items) + { + var uid = Uid(item); + Require(uid == root || (Value(item, "parent") == root && rootChildren.Contains(uid)), + $"{framework}: {uid} has no owning child entry in {file}."); + inventory.Add(uid, file); + if (!variants.TryGetValue(uid, out var byFramework)) + { + byFramework = new Dictionary(StringComparer.Ordinal); + variants.Add(uid, byFramework); + locations.Add(uid, file); + } + Require(locations[uid] == file, $"{uid}: page changed from {locations[uid]} to {file} ({framework})."); + byFramework.Add(framework, item); + } + + if (!pages.TryGetValue(root, out var existing)) + { + Require(fileNames.Add(file), $"Page filename collision: {file} ({framework})."); + pages.Add(root, (file, page)); + continue; + } + + Compare(existing.Page, page, $"{root} page ({framework})", "items", "references"); + MergeSequence(existing.Page, page, "items", (left, right) => + Compare(left, right, $"{Uid(left)} ({framework})", "children", "inheritedMembers", "derivedClasses")); + MergeSequence(existing.Page, page, "references", (left, right) => + Compare(left, right, $"{file}, reference {Uid(left)} ({framework})")); + } + + Require(inventory.Count > 0 && inventory.Count == manifest.Count && + inventory.All(pair => manifest.TryGetValue(pair.Key, out var file) && file == pair.Value), + $"{framework}: generated pages disagree with the DocFX manifest."); + var sourceToc = Read(Path.Combine(directory, "toc.yml"), TableOfContent); + if (toc is null) { toc = sourceToc; } + else { MergeToc(toc, sourceToc, framework); } + Console.WriteLine($"{framework}: {inventory.Count} UIDs"); + } + + var output = args[0]; + Require(!Directory.Exists(output), $"Output directory already exists: {output}"); + if (inputs.Count == 1) + { + Directory.CreateDirectory(output); + foreach (var file in Directory.GetFiles(inputs.Values.Single())) + { + File.Copy(file, Path.Combine(output, Path.GetFileName(file))); + } + return; + } + + var tocUids = new HashSet(StringComparer.Ordinal); + foreach (var uid in TocUids(toc!)) + { + Require(tocUids.Add(uid), $"Duplicate UID in TOC: {uid}."); + } + foreach (var (file, page) in pages.Values) + { + var root = Uid((YamlMappingNode)Sequence(page, "items").First()); + Require(tocUids.Remove(root), $"Page missing from TOC: {root}."); + var references = Sequence(page, "references").Cast().ToDictionary(Uid, StringComparer.Ordinal); + foreach (YamlMappingNode item in Sequence(page, "items")) + { + var uid = Uid(item); + var byFramework = variants[uid]; + var children = byFramework.Values.SelectMany(node => Strings(node, "children")).Distinct(StringComparer.Ordinal); + SetSequence(item, "children", children); + foreach (var child in Strings(item, "children")) + { + Require(locations.ContainsKey(child) && (locations[child] == file || references.ContainsKey(child)), + $"{uid}: missing child or child reference {child}."); + } + var overload = Value(item, "overload"); + Require(overload is null || references.ContainsKey(overload), $"{uid}: missing overload reference {overload}."); + // DocFX records a machine-relative path in addition to the canonical Git source URL. + if (item.Children.TryGetValue("source", out var source) && source is YamlMappingNode sourceMap && + sourceMap.Children.TryGetValue("remote", out var remote) && remote is YamlMappingNode remoteMap && + Value(remoteMap, "path") is { } repositoryPath) + { + sourceMap.Children["path"] = new YamlScalarNode(repositoryPath); + } + + if (Value(item, "type") == "Namespace") { continue; } + item.Children.Add("platform", new YamlSequenceNode(byFramework.Keys.Select(framework => new YamlScalarNode(framework)))); + var notes = new List { $"**Available in documented targets:** {string.Join(", ", byFramework.Keys.Select(framework => $"`{framework}`"))}." }; + foreach (var (key, label) in new[] { ("inheritedMembers", "Inherited members"), ("derivedClasses", "Derived types") }) + { + var sets = byFramework.ToDictionary(pair => pair.Key, pair => Strings(pair.Value, key).ToArray(), StringComparer.Ordinal); + var first = sets.Values.First(); + if (sets.Values.All(entries => entries.SequenceEqual(first, StringComparer.Ordinal))) { continue; } + + var shared = first.Where(entry => sets.Values.All(entries => entries.Contains(entry, StringComparer.Ordinal))).ToArray(); + SetSequence(item, key, shared); + foreach (var group in sets.GroupBy(pair => string.Join("\n", pair.Value.Except(shared, StringComparer.Ordinal)))) + { + if (group.Key.Length == 0) { continue; } + var links = group.Key.Split('\n').Select(entry => $""); + notes.Add($"**{label} in {string.Join(", ", group.Select(pair => pair.Key))}:** {string.Join(", ", links)}."); + } + Console.WriteLine($"{uid}: framework-specific {key}"); + } + var remarks = Value(item, "remarks"); + if (!string.IsNullOrEmpty(remarks)) { notes.Add(remarks); } + item.Children["remarks"] = new YamlScalarNode(string.Join("\n\n", notes)) { Style = YamlDotNet.Core.ScalarStyle.Literal }; + } + } + Require(tocUids.Count == 0, $"TOC UIDs without pages: {string.Join(", ", tocUids.Order(StringComparer.Ordinal))}"); + + Directory.CreateDirectory(output); + foreach (var (file, page) in pages.Values) + { + Write(Path.Combine(output, file), ManagedReference, page); + } + Write(Path.Combine(output, "toc.yml"), TableOfContent, toc!); + File.WriteAllText(Path.Combine(output, ".manifest"), JsonSerializer.Serialize(locations, new JsonSerializerOptions { WriteIndented = true, NewLine = "\n" })); + Console.WriteLine($"Union: {locations.Count} UIDs in {pages.Count} managed-reference pages."); + } + + private static void MergeToc(YamlMappingNode left, YamlMappingNode right, string framework) + { + Compare(left, right, $"TOC {Value(left, "uid")} ({framework})", "items"); + MergeSequence(left, right, "items", (a, b) => MergeToc(a, b, framework)); + } + + private static IEnumerable TocUids(YamlMappingNode node) + { + foreach (YamlMappingNode child in Sequence(node, "items")) + { + yield return Uid(child); + foreach (var uid in TocUids(child)) { yield return uid; } + } + } + + private static void MergeSequence(YamlMappingNode left, YamlMappingNode right, string key, Action compare) + { + var sequence = Sequence(left, key); + var index = sequence.Cast().ToDictionary(Uid, StringComparer.Ordinal); + foreach (var (uid, node) in Sequence(right, key).Cast().ToDictionary(Uid, StringComparer.Ordinal)) + { + if (index.TryGetValue(uid, out var existing)) { compare(existing, node); } + else { sequence.Add(node); } + } + if (sequence.Children.Count > 0) { left.Children[key] = sequence; } + } + + private static void Compare(YamlMappingNode left, YamlMappingNode right, string context, params string[] handledKeys) + { + foreach (var key in left.Children.Keys.Concat(right.Children.Keys).Distinct()) + { + if (handledKeys.Contains(((YamlScalarNode)key).Value, StringComparer.Ordinal)) { continue; } + left.Children.TryGetValue(key, out var a); + right.Children.TryGetValue(key, out var b); + Require(Equals(a, b), $"{context}: conflicting '{key}'.\nPrimary: {a}\nAlternate: {b}"); + } + } + + private static YamlMappingNode Read(string path, string mime) + { + using (var reader = File.OpenText(path)) + { + Require(reader.ReadLine() == mime, $"Unexpected DocFX MIME: {path}"); + var yaml = new YamlStream(); + yaml.Load(reader); + return (YamlMappingNode)yaml.Documents.Single().RootNode; + } + } + + private static void Write(string path, string mime, YamlMappingNode node) + { + using (var writer = new StringWriter { NewLine = "\n" }) + { + writer.WriteLine(mime); + new YamlStream(new YamlDocument(node)).Save(writer, assignAnchors: false); + File.WriteAllText(path, writer.ToString().Replace("\r\n", "\n", StringComparison.Ordinal), new UTF8Encoding(false)); + } + } + + private static string Uid(YamlMappingNode node) => Value(node, "uid") ?? throw new InvalidDataException("Missing DocFX UID."); + private static string? Value(YamlMappingNode node, string key) => node.Children.TryGetValue(key, out var value) ? ((YamlScalarNode)value).Value : null; + private static YamlSequenceNode Sequence(YamlMappingNode node, string key) => node.Children.TryGetValue(key, out var value) ? (YamlSequenceNode)value : new YamlSequenceNode(); + private static IEnumerable Strings(YamlMappingNode node, string key) => Sequence(node, key).Cast().Select(value => value.Value!); + + private static void SetSequence(YamlMappingNode node, string key, IEnumerable entries) + { + var sequence = new YamlSequenceNode(entries.Select(entry => new YamlScalarNode(entry))); + if (sequence.Children.Count == 0) { node.Children.Remove(key); } + else { node.Children[key] = sequence; } + } + + private static void Require(bool condition, string message) + { + if (!condition) { throw new InvalidDataException(message); } + } +} diff --git a/tooling/docfx-multi-tfm/README.md b/tooling/docfx-multi-tfm/README.md new file mode 100644 index 000000000..f64de350c --- /dev/null +++ b/tooling/docfx-multi-tfm/README.md @@ -0,0 +1,134 @@ +# Native DocFX framework views + +The fixture builds Cuemon.Kernel and Cuemon.IO independently for each framework through `docfx-oci-build` and the shared `ms-style` template. NGINX serves the selected view under the same public API pathname. The default is .NET 11. + +## Run + +Use PowerShell 7, the .NET 11 SDK, and DocFX 2.81.0 installed as a .NET tool and available on `PATH`. The fixture downloads the shared implementation by commit ID. It also downloads a pinned template override while the published builder image lacks the selector. Both downloads are staged in a temporary directory. Metadata runs on the host. Pass `-BuildInContainer` to render HTML in the pinned builder image. The HTTP regression uses Docker with Linux containers. + +```powershell +$work = Join-Path ([IO.Path]::GetTempPath()) "cuemon-framework-views-$([guid]::NewGuid().ToString('N'))" +& tooling/docfx-multi-tfm/Build-DocfxFrameworkViews.ps1 -OutputRoot $work -TestSharedImplementation +& tooling/docfx-multi-tfm/Test-DocfxFrameworkViews.ps1 -Workspace $work +``` + +Pass `-Framework net11.0,netstandard2.0` to build two views, or `-Framework net11.0` to build a single view. Include the default in the matrix. Build again and pass `-CompareWorkspace` with the other artifacts directory to compare isolated metadata and the packaged site. The comparison normalizes line endings, the DocFX build path and manifest file order, search record order, and machine-relative metadata source paths when DocFX supplies a corresponding Git path. `Test-DocfxFrameworkViews.ps1` also accepts `-Origin` for an already running NGINX instance. + +In PR Flow, enable `run_docfx_framework_views` to run the same fixture entry point on Windows and Linux. `-TestSharedImplementation` also exercises the shared builder's synthetic regression for exclusions, group destinations, and cache recovery. The fixture covers the two-project baseline. The production build remains `.\.docfx\BuildDocfxImage.ps1`. + +To run the browser regression, install Playwright and Chromium outside the checkout, make the Playwright module available to Node, and add `-Browser` to the test command. + +```powershell +$deps = Join-Path ([IO.Path]::GetTempPath()) 'cuemon-docfx-browser' +npm install --prefix $deps playwright@1.61.1 +node "$deps/node_modules/playwright/cli.js" install chromium +$env:NODE_PATH = "$deps/node_modules" +& tooling/docfx-multi-tfm/Test-DocfxFrameworkViews.ps1 -Workspace $work -Browser +``` + +For manual browsing, mount the packaged site and generated configuration into a disposable NGINX container. The sample URLs use the actual DocFX member page as well as a shared type pathname. + +```powershell +$mounts = @('--mount', "type=bind,source=$work/site,target=/usr/share/nginx/html,readonly", + '--mount', "type=bind,source=$work/nginx.conf,target=/etc/nginx/conf.d/default.conf,readonly") +docker run --rm -p 127.0.0.1:8080:8080 @mounts dhi.io/nginx:1.31-alpine +``` + +- [Default StreamFactory](http://localhost:8080/api/dotnet/Cuemon.IO.StreamFactory.html) +- [Create overloads on .NET 10](http://localhost:8080/api/dotnet/Cuemon.IO.StreamFactory.Create.html?view=net-10.0) +- [Create overloads on .NET Standard 2.0](http://localhost:8080/api/dotnet/Cuemon.IO.StreamFactory.Create.html?view=netstandard-2.0) +- [BufferWriterOptions on .NET Standard 2.1](http://localhost:8080/api/dotnet/Cuemon.IO.BufferWriterOptions.html?view=netstandard-2.1) + +## Framework discovery and metadata + +| MSBuild TFM | Public view | Staging directory | Metadata UIDs | Buffer writer overloads | +|---|---|---|---:|---:| +| net11.0 | net-11.0 | net11 | 557 | 6 | +| net10.0 | net-10.0 | net10 | 557 | 6 | +| netstandard2.1 | netstandard-2.1 | netstandard2.1 | 76 | 6 | +| netstandard2.0 | netstandard-2.0 | netstandard2.0 | 548 | 0 | + +The shared builder checks the configured framework order against MSBuild's `TargetFrameworks` and `TargetFramework` properties. The fixture narrows the authored `api/dotnet` group to two projects and keeps its destination, filter, separate member-page layout, and namespace and type overwrites. Each metadata extraction and HTML build uses a fresh DocFX process. The fixture includes the authored home page and a two-entry navigation and omits the production sitemap and xref input to keep availability local to the build. DocFX still emits its native Microsoft Learn links. + +Cuemon.IO directly targets .NET Standard 2.1. Cuemon.Kernel has no such target, so it contributes no pages in that view. The ordinary .NET Standard 2.1 IO build resolves compatible .NET Standard 2.0 dependencies through MSBuild. DocFX's project workspace can retain both the design-time Cuemon.Kernel symbol (observed at version 1.0.0.0) and an on-disk dependency (observed at 11.0.0.0), producing CS0433. A normal Release build followed by MSBuild's GetAssemblyVersion gives the PoC the version to pass to DocFX for Cuemon's mixed graph. This retained project-source links, native declarations and all 76 IO UIDs on Windows and Linux. The original Roslyn project-reference diagnostics remain in the logs. Compilation errors fail the build. The workaround relies on Cuemon's common assembly version and needs additional validation for independently versioned project graphs. [DocFX project compilation](https://github.com/dotnet/docfx/blob/ba844df625370a6bd7c1ecab0d0ec4d1d9128ac4/src/Docfx.Dotnet/DotnetApiCatalog.Compile.cs) + +## Routing, links and search + +The default site sits at the web root. Each additional view contributes its native API subtree, xref map and search index under `_frameworks/`. The package verifies that shared public assets, images and run-action scripts are byte-identical before sharing them. It publishes conceptual HTML and the root navigation once. + +NGINX maps exact view IDs to a static root prefix and checks the selected file at the original URI depth. The default applies when view is missing or empty. Unknown IDs receive HTTP 400. A known view with an unavailable page receives HTTP 404. Physical API copies are internal. The visible pathname keeps relative CSS, JavaScript, image, run-action and page links at the depth DocFX generated. Stable responses use the existing no-store policy and fingerprinted public assets keep their immutable policy. [NGINX try_files](https://nginx.org/en/docs/http/ngx_http_core_module.html#try_files) + +The shared template loads `framework-view.js` before the native DocFX module on configured sites. It sets the API TOC metadata to the selected TOC JSON URL and carries the view through same-origin API links, including links rendered later by DocFX. External and conceptual navigation use their regular URLs. Direct requests select the correct HTML before JavaScript runs. + +DocFX 2.81.0 creates a module worker from `docfx:rel`. The template sets that metadata to `/_framework-search//` for explicitly selected API views. NGINX routes the worker and its imports to shared assets and serves the matching native index at the worker's relative path. Search result links and their secondary labels show the public URLs. Unqualified API and conceptual pages use the ordinary DocFX search entry point. Rerun the browser regression when upgrading DocFX because the adapter uses its search metadata, worker URL, and result template. [Modern search code](https://github.com/dotnet/docfx/blob/ba844df625370a6bd7c1ecab0d0ec4d1d9128ac4/templates/modern/src/search.ts) · [Search worker](https://github.com/dotnet/docfx/blob/ba844df625370a6bd7c1ecab0d0ec4d1d9128ac4/templates/modern/src/search-worker.ts) + +## Selector contract + +The versioned `/framework-views.json` manifest exposes `apiPath`, `defaultView`, `viewOrder`, and `views`. Each view records its TFM, directory, projects, and native xref map URL. The selector resolves the exact UID in the requested view or the nearest newer view in `viewOrder`. When no newer view documents the UID, it prefers the currently displayed view if available, then checks older views. It keeps the fragment and other query parameters and shows a short fallback notice. + +## Verification and cost + +The acceptance scripts use the actual HTTP responses for xref inventory, all pages and anchors, unavailable APIs, native overload and inheritance differences, TOCs, search indexes, source links, overwrite examples, MIME types and caching. The browser test exercises generated sidebar links, in-page cross-references, native search results, refresh, and back/forward between API pages. DocFX's raw TOC HTML is a legacy partial. The interactive sidebar uses the view-specific JSON. + +The original PoC measured 53.29 MiB of output. The shared build preserves the same layout and serves one native search index per page. The browser regression also exercises same-UID switching, fallback to an available view, direct 404 responses, an older-only API, and mobile keyboard focus in dark mode. + +The four-view run performs four metadata extractions and four builds, with one Release project build for the mixed graph. The shared metadata cache can reuse verified extraction output. Each API request uses a static NGINX map and file check. + +| Approach | Generation and delivery | Tradeoff | +|---|---|---| +| Native query views | One extraction and one HTML build per view, one shared static site and one small browser adapter | Keeps existing default URLs and a stable shared pathname. Requires query-aware hosting and navigation and search integration. | +| Native TFM-prefixed URLs | Same independent builds, served at physical per-view roots | Relative URLs, native TOC and search follow the path automatically. Keep existing default URLs at the root and expose alternate views under prefixes. Sharing identical assets can remain a packaging optimization. | +| Historical consolidation | Three extractions and one render plus a 240-line C# consolidator | Uses less output space, but holds a primary declaration and explicit relationship deltas. Unexpected same-UID signatures fail the consolidation. | + +--- + +# Historical PoC 1 — 561-UID consolidation + +Run from the repository root with PowerShell 7, the .NET 11 SDK, and DocFX 2.81.0. + +```powershell +pwsh tooling/docfx-multi-tfm/Test-DocfxMultiTfm.ps1 +``` + +The script prints its temporary workspace. Each round contains the original metadata for each target, consolidated metadata in `api/dotnet`, and the rendered site in `wwwroot`. It uses the repository's filter, matching authored overwrites, templates, xref maps, and generated run-action assets. The file-based consolidator uses YamlDotNet 18.1.0 and runs from the temporary workspace to keep its package pin independent of repository-wide central package management. + +## Findings + +DocFX 2.81.0 uses Roslyn MSBuildWorkspace 5.9.0. When no global `TargetFramework` is supplied, Roslyn runs a design-time build for each declared target and loads the resulting projects. `OpenProjectAsync` returns the first one. DocFX calls `GetCompilationAsync` for that project, or for the first matching file path already loaded into the workspace, and exports its assembly symbols. The unpinned Cuemon run produced byte-identical YAML to the explicit `net11.0` run. The two modern targets have identical metadata in this experiment. [Roslyn target iteration](https://github.com/dotnet/roslyn/blob/35d9211b841e7613c1d2f8f5af6d628ace696c4c/src/Workspaces/MSBuild/BuildHost/Build/ProjectBuildManager.cs#L219) · [Roslyn project selection](https://github.com/dotnet/roslyn/blob/35d9211b841e7613c1d2f8f5af6d628ace696c4c/src/Workspaces/MSBuild/Core/MSBuild/MSBuildWorkspace.cs#L260) · [DocFX compilation](https://github.com/dotnet/docfx/blob/ba844df625370a6bd7c1ecab0d0ec4d1d9128ac4/src/Docfx.Dotnet/DotnetApiCatalog.Compile.cs) + +Multiple metadata groups with distinct destinations produced the correct UID counts in a single process. In the .NET 10 → .NET 11 → .NET Standard 2.0 order, 17 additional shared item records had different `derivedClasses` metadata. The grouped .NET Standard 2.0 output listed `BufferWriterOptions` twice under `StreamEncodingOptions.derivedClasses`. The isolated .NET Standard 2.0 output contained neither entry. `SetDerivedClass` accumulates relationships on a resolver instance held in a static pipeline. A fresh workspace per group therefore still needs process isolation for trustworthy TFM attribution. [DocFX resolver pipeline](https://github.com/dotnet/docfx/blob/ba844df625370a6bd7c1ecab0d0ec4d1d9128ac4/src/Docfx.Dotnet/ManagedReference/Resolvers/YamlMetadataResolver.cs) · [Derived-class resolver](https://github.com/dotnet/docfx/blob/ba844df625370a6bd7c1ecab0d0ec4d1d9128ac4/src/Docfx.Dotnet/ManagedReference/Resolvers/SetDerivedClass.cs) + +`docfx merge` exited with a `NullReferenceException` in `HostServiceCreator.LoadModels` for these inputs. Upstream documents the command as broken. Its merge implementation also keeps the first shared declaration and reference payload. Feeding several target assemblies to one metadata job has a similar limitation because the exporter collapses duplicate symbols by UID before writing pages. Copying only missing files would omit framework-specific children and references on existing pages. [Merge CLI documentation](https://dotnet.github.io/docfx/reference/docfx-cli-reference/docfx-merge.html) · [Merge implementation](https://github.com/dotnet/docfx/blob/ba844df625370a6bd7c1ecab0d0ec4d1d9128ac4/src/Docfx.Build.ManagedReference/MergeManagedReferenceDocument.cs) · [Metadata exporter](https://github.com/dotnet/docfx/blob/ba844df625370a6bd7c1ecab0d0ec4d1d9128ac4/src/Docfx.Dotnet/DotnetApiCatalog.ManagedReference.cs) + +## Consolidation contract + +| Target | UIDs, including namespaces | +|---|---:| +| `net10.0` | 557 | +| `net11.0` | 557 | +| `netstandard2.0` | 548 | +| Union | 561 | + +DocFX's managed-reference files group types and their member records, even with `separatePages`. Items, page-local references, and TOC entries all use `uid`. The XML `commentId` is a separate field, and overload group UIDs with a trailing `*` appear as references. The output keeps the first input as the primary representation, retains original UIDs and page filenames, and unions the page items, child lists, page-local references, TOC entries, and UID manifest. DocFX's build step still creates the member and overload HTML pages. Per-item `platform` uses DocFX's existing metadata field. Remarks render the availability in the current templates and carry framework-specific relationship deltas. Source URLs and line numbers are preserved. When Git source metadata exists, its repository-relative path replaces the machine-relative fallback path. + +The compatibility target contributes the `System.Runtime.CompilerServices` namespace, `CallerArgumentExpressionAttribute`, its constructor, and its property. The modern targets contribute `BufferWriterOptions` and two members, four Brotli methods, and six `StreamFactory.Create` overloads. Shared declarations and XML comments matched. Three shared types have framework-specific derived types and three exceptions have framework-specific inherited BCL members. Their common relationships stay in the regular lists and the differences appear with the relevant framework labels. + +An unexpected difference in syntax, XML documentation, reference payload, or any other shared field fails with the UID, framework, field, and both values. If a future input has a genuine same-UID signature variant, the smallest extension is to collect that UID's syntax by TFM and render labeled syntax blocks on its canonical page. The proof also treats ambiguous filenames, duplicate UIDs, missing inventory entries, and unresolvable child or overload references as errors. + +The three documented targets are the milestone scope. MSBuild also reports `netstandard2.1` for Cuemon.IO. An assembly-input probe of a normal .NET Standard 2.1 build confirmed `BufferWriterOptions` and the six overloads there too. The equivalent project-input metadata job hit CS0433 from duplicate Cuemon.Kernel identities, so mixed project target sets need their own validation before integration. The `netstandard2.0` project-input run emits three workspace reference warnings on Windows and Linux. It completes and returns the same filtered UID inventory on both hosts. + +## Verification + +The test runs extraction, consolidation, and `docfx build --warningsAsErrors` twice. It checks the full UID union against all three source manifests and verifies that every UID resolves to a rendered page and to its anchor when present. It also checks the six overload sections, both representative types, namespace and TOC links, Git source links, and authored examples. A single-target fixture passes through byte for byte. A changed declaration and a missing YAML page both fail before an output is written. + +The consolidated metadata uses LF on both hosts. The site comparison normalizes two fields in DocFX's generated `manifest.json`: the absolute `source_base_path` and the order of the `files` records. It compares every record and hashes all other files directly within each host. + +Two runs passed on Windows and Ubuntu 26.04 with SDK 11.0.100 and DocFX 2.81.0. The consolidated trees were byte-identical across hosts. The rendered trees matched across hosts after normalizing line endings and the two manifest fields. All 62 staged type overwrite examples appeared on their pages. The existing `codebeltnet/docfx:2` image also rendered the staged metadata with its shared templates, zero warnings, and the same xref map. + +## Integration boundary + +The local image wrapper currently restores once, fingerprints metadata inputs and outputs, clears generated YAML and manifests, and regenerates all groups in one process on a cache miss. The OCI action installs its pinned CLI on the host, reuses matching restore assets, generates metadata before Docker, and clears generated YAML and manifests after the build in its `finally` block. Docker consumes the generated YAML and runs the site build with the shared templates. [Local wrapper](../../.docfx/BuildDocfxImage.ps1) · [OCI host script](https://github.com/codebeltnet/docfx-oci-build/blob/v1/scripts/build-docfx-oci.ps1) · [Builder Dockerfile](https://github.com/codebeltnet/docfx/blob/main/Dockerfile) + +The proposed production distribution is a .NET tool published by the shared implementation owner. Cuemon and the composite Action should invoke the same explicit tool version. The tool should read project mappings, metadata destinations, and site structure from the consumer's `docfx.json` and use an explicitly pinned published builder image containing the shared template. Include the tool version and selected framework matrix in the local metadata cache fingerprint. + +Keep production opt-in pending an image build that retains run-action preparation, context and rendered-site verification, verified metadata reuse, and both Linux image platforms. Verify full-site API paths and cross-group relationships before enabling it. The current single-process metadata pass retains resolver state across all groups. diff --git a/tooling/docfx-multi-tfm/Test-DocfxFrameworkViews.ps1 b/tooling/docfx-multi-tfm/Test-DocfxFrameworkViews.ps1 new file mode 100644 index 000000000..08efc0fbc --- /dev/null +++ b/tooling/docfx-multi-tfm/Test-DocfxFrameworkViews.ps1 @@ -0,0 +1,227 @@ +#requires -Version 7.0 +[CmdletBinding()] +param( + [Parameter(Mandatory)][string] $Workspace, + [string] $CompareWorkspace, + [string] $Origin, + [string] $NginxImage = 'dhi.io/nginx:1.31-alpine', + [switch] $Browser +) + +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $false +$workspace = (Resolve-Path -LiteralPath $Workspace).Path +$site = "$workspace/site" +$legacy = 'System.Runtime.CompilerServices.CallerArgumentExpressionAttribute' +$buffer = 'Cuemon.IO.BufferWriterOptions' +$factory = 'Cuemon.IO.StreamFactory' +$baselineUids = @{ 'net11.0' = 557; 'net10.0' = 557; 'netstandard2.1' = 76; 'netstandard2.0' = 548 } + +function Assert-True([bool] $Condition, [string] $Message) { + if (!$Condition) { throw $Message } +} + +function Read-Json([string] $Path) { + Get-Content -LiteralPath $Path -Raw | ConvertFrom-Json -AsHashtable +} + +function Get-Fingerprint([string] $Root) { + $entries = [Collections.Generic.Dictionary[string,string]]::new([StringComparer]::Ordinal) + foreach ($file in Get-ChildItem -LiteralPath $Root -Recurse -File -Force) { + $name = [IO.Path]::GetRelativePath($Root, $file.FullName).Replace('\', '/') + if ($name -ceq 'manifest.json') { + $value = Read-Json $file.FullName + $value.Remove('source_base_path') + $value.files = @($value.files | ForEach-Object { ConvertTo-Json -InputObject $_ -Depth 30 -Compress } | Sort-Object -CaseSensitive) + $content = ConvertTo-Json -InputObject $value -Depth 30 -Compress + } elseif ($file.Name -ceq 'index.json') { + $index = Read-Json $file.FullName + $content = ($index.Keys | Sort-Object -CaseSensitive | ForEach-Object { + "$_ " + (ConvertTo-Json -InputObject $index[$_] -Depth 20 -Compress) + }) -join [char]10 + } elseif ($file.Extension -cin '.html', '.yml', '.json', '.js', '.css', '.ps1', '.svg', '.map' -or $file.Name -ceq '.manifest') { + $content = [IO.File]::ReadAllText($file.FullName).Replace([string]([char]13) + [char]10, [string][char]10) + if ($content.StartsWith('### YamlMime:ManagedReference')) { + # Match the repository-relative source path DocFX uses to render the source link. + $content = $content -creplace '(?m)(^ source:\n remote:\n path: (\S+)\n branch: [^\n]+\n repo: [^\n]+\n id: [^\n]+\n path: )(?:[^\n]*/)?\2$', '$1$2' + } + } else { + $entries.Add($name, (Get-FileHash -LiteralPath $file.FullName).Hash) + continue + } + $entries.Add($name, [Convert]::ToHexString([Security.Cryptography.SHA256]::HashData([Text.Encoding]::UTF8.GetBytes($content)))) + } + $entries +} + +function Compare-Trees([string] $Left, [string] $Right) { + $leftHashes = Get-Fingerprint $Left + $rightHashes = Get-Fingerprint $Right + $differences = @($leftHashes.Keys | Where-Object { $leftHashes[$_] -cne $rightHashes[$_] }) + $differences += @($rightHashes.Keys | Where-Object { !$leftHashes.ContainsKey($_) }) + Assert-True (!$differences.Count) "Different files between $Left and $Right ($($differences.Count)): $($differences | Select-Object -First 15)" +} + +function Get-Page([string] $Path, [int] $Status = 200, [string] $Mime) { + $response = $client.GetAsync([uri]::new($baseUri, $Path)).GetAwaiter().GetResult() + try { + Assert-True ([int]$response.StatusCode -eq $Status) "$Path returned $([int]$response.StatusCode), expected $Status." + if ($Mime) { + Assert-True ($response.Content.Headers.ContentType.MediaType -match $Mime) "$Path has unexpected content type." + } + if ($Path -notmatch '/public/') { + Assert-True ($response.Headers.CacheControl.NoStore -and !$response.Headers.ETag) "$Path has unexpected cache headers." + } + $response.Content.ReadAsStringAsync().GetAwaiter().GetResult() + } finally { + $response.Dispose() + } +} + +function Get-Xrefs([string] $Yaml, [string] $Api) { + $xref = [Collections.Generic.Dictionary[string,string]]::new([StringComparer]::Ordinal) + $uid = $null + # The native DocFX xref writer emits simple scalar UIDs and hrefs for this fixture. + foreach ($line in ($Yaml -split '\r?\n')) { + if ($line -cmatch '^- uid: (.+)$') { $uid = $Matches[1] } + if ($uid -and $line -cmatch '^ href: (.+)$') { + $href = $Matches[1] + if (("/$href").StartsWith($Api, [StringComparison]::Ordinal)) { $xref.Add($uid, $href) } + $uid = $null + } + } + $xref +} + +$manifest = Read-Json "$site/framework-views.json" +if ($CompareWorkspace) { + Compare-Trees $site "$CompareWorkspace/site" + foreach ($entry in $manifest.views.Values) { + $directory = $entry.directory + Compare-Trees "$workspace/$directory$($manifest.apiPath)" "$CompareWorkspace/$directory$($manifest.apiPath)" + } + Write-Host 'Isolated metadata and packaged site match the comparison build.' +} + +$container = $null +$handler = [Net.Http.HttpClientHandler]::new() +$handler.AllowAutoRedirect = $false +$client = [Net.Http.HttpClient]::new($handler) +$client.Timeout = [TimeSpan]::FromSeconds(10) +try { + if (!$Origin) { + $mounts = @('--mount', "type=bind,source=$site,target=/usr/share/nginx/html,readonly", + '--mount', "type=bind,source=$workspace/nginx.conf,target=/etc/nginx/conf.d/default.conf,readonly") + $container = & docker run --rm -d -p 127.0.0.1::8080 @mounts $NginxImage + Assert-True ($LASTEXITCODE -eq 0) 'Could not start isolated NGINX.' + $port = (& docker port $container 8080/tcp).Trim() + Assert-True ($LASTEXITCODE -eq 0 -and $port -match '^127\.0\.0\.1:\d+$') 'Could not resolve mapped NGINX port.' + $Origin = "http://$port" + } + $baseUri = [uri]$Origin + Write-Host "Testing $Origin" + for ($i = 0; $i -lt 20; $i++) { + try { Get-Page '/framework-views.json' 200 'application/json' | Out-Null; break } + catch { + if ($i -eq 19) { throw } + Start-Sleep -Milliseconds 250 + } + } + + $api = $manifest.apiPath + $factoryPath = "$api$factory.html" + $defaultHtml = Get-Page $factoryPath 200 'text/html' + Assert-True ($defaultHtml -ceq (Get-Page "$($factoryPath)?view=$($manifest.defaultView)" 200 'text/html')) 'Implicit and explicit default differ.' + Get-Page "$($factoryPath)?view=unknown" 400 | Out-Null + Get-Page "$($factoryPath)?view=$($manifest.defaultView.ToUpperInvariant())" 400 | Out-Null + Get-Page '/index.html?view=unknown' 200 'text/html' | Out-Null + Get-Page '/public/docfx.min.css?view=unknown' 200 'text/css' | Out-Null + Get-Page '/public/docfx.min.js' 200 'javascript' | Out-Null + Get-Page '/images/favicon.ico' 200 'image/' | Out-Null + $font = Get-ChildItem "$site/public" -Filter '*.woff2' | Select-Object -First 1 + $fontResponse = $client.GetAsync([uri]::new($baseUri, "/public/$($font.Name)")).GetAwaiter().GetResult() + try { + Assert-True ($fontResponse.IsSuccessStatusCode -and $fontResponse.Headers.CacheControl.ToString().Contains('immutable')) 'Fingerprinted font caching policy changed.' + } finally { $fontResponse.Dispose() } + + foreach ($view in $manifest.views.Keys) { + $entry = $manifest.views[$view] + $stage = "$workspace/$($entry.directory)" + $inventory = Read-Json "$stage$($api).manifest" + Assert-True ($inventory.Count -eq $baselineUids[$entry.tfm]) "Unexpected baseline UID count for $view." + $xref = Get-Xrefs (Get-Page $entry.xref) $api + $renderedUids = [Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal) + $renderedUids.UnionWith([string[]]@($xref.Keys | Where-Object { !$_.EndsWith('*') })) + Assert-True ($renderedUids.SetEquals([string[]]@($inventory.Keys))) "$view served xrefs differ from the isolated DocFX inventory." + $pages = @{} + foreach ($uid in $xref.Keys) { + $path, $anchor = $xref[$uid].Split('#', 2) + if (!$pages.ContainsKey($path)) { $pages[$path] = Get-Page "/$($path)?view=$view" 200 'text/html' } + if ($anchor) { + $id = [Net.WebUtility]::HtmlEncode([uri]::UnescapeDataString($anchor)) + Assert-True ($pages[$path].Contains("id=""$id""")) "Missing anchor for $uid in $view." + } + } + $example = $pages.GetEnumerator() | Where-Object Value -Match 'href="[^"]*run-actions/[^"]+\.ps1"' | Select-Object -First 1 + Assert-True ($null -ne $example) "No run-action link in $view." + $href = [regex]::Match($example.Value, 'href="([^"]*run-actions/[^"]+\.ps1)"').Groups[1].Value + $publicPage = [uri]::new($baseUri, "/$($example.Key)?view=$view") + $runAction = [uri]::new($publicPage, $href) + Assert-True ($runAction.AbsolutePath.StartsWith('/run-actions/')) "Run-action escaped the shared public path in $view." + Get-Page $runAction.AbsolutePath | Out-Null + + $isLegacy = $entry.tfm -ceq 'netstandard2.0' + $toc = Get-Page "$($api)toc.json?view=$view" 200 'application/json' + $index = Get-Page "/_framework-search/$($entry.directory)/index.json" 200 'application/json' | ConvertFrom-Json -AsHashtable + foreach ($path in $index.Keys) { + if (("/$path").StartsWith($api) -and !$pages.ContainsKey($path)) { throw "Search indexes unavailable page $path in $view." } + } + $overloads = @($xref.Keys | Where-Object { $_.StartsWith("$factory.Create") -and $_.Contains('System.Buffers.IBufferWriter{System.Byte}') }) + $expectedCount = if ($isLegacy) { 0 } else { 6 } + Assert-True ($overloads.Count -eq $expectedCount) "Wrong buffer writer overload count in $view." + $create = $pages[$xref["$factory.Create*"]] + Assert-True ([regex]::Matches($create, 'id="[^"]+_System_Buffers_IBufferWriter_System_Byte_[^"]*"').Count -eq $expectedCount) "Wrong served overload anchors in $view." + Assert-True ($create.Contains('href="Cuemon.IO.BufferWriterOptions.html"') -eq !$isLegacy) "Wrong BufferWriterOptions cross-reference in $view." + $exception = 'Cuemon.ArgumentReservedKeywordException' + if ($xref.ContainsKey($exception)) { + $inheritsSerialization = $pages[$xref[$exception]].Contains('system.argumentoutofrangeexception.getobjectdata') + Assert-True ($inheritsSerialization -eq $isLegacy) "Wrong inherited serialization member in $view." + } + if ($isLegacy) { + $legacyNamespace = $pages[$xref['System.Runtime.CompilerServices']] + Assert-True ($legacyNamespace.Contains('provides polyfill types')) 'Missing compatibility namespace overwrite.' + } + + foreach ($type in $legacy, $buffer, 'Cuemon.Validator') { + $expected = switch ($type) { + $legacy { $isLegacy } + $buffer { !$isLegacy } + default { $entry.tfm -cne 'netstandard2.1' } + } + $path = "$($api.TrimStart('/'))$type.html" + Assert-True ($xref.ContainsKey($type) -eq $expected) "Wrong xref availability for $type in $view." + Assert-True ($toc.Contains("""topicUid"":""$type""") -eq $expected) "Wrong TOC availability for $type in $view." + Assert-True ($index.Contains($path) -eq $expected) "Wrong search availability for $type in $view." + if (!$expected) { + Get-Page "/$($path)?view=$view" 404 | Out-Null + continue + } + Assert-True ($pages[$path] -match 'github\.com/codebeltnet/cuemon/blob/[^"]+\.cs/#L\d+') "Missing source link for $type in $view." + } + foreach ($file in Get-ChildItem "$stage/api/types" -Filter '*.md') { + if (!$xref.ContainsKey($file.BaseName)) { continue } + if ((Get-Content -LiteralPath $file.FullName -Raw) -notmatch '(?m)^example:') { continue } + $html = $pages[$xref[$file.BaseName]] + Assert-True ($html -match '(?s)

Examples

.*?
]*>\s*\S') "Missing authored example for $($file.BaseName) in $view."
+        }
+        Get-Page "/_frameworks/$($entry.directory)$factoryPath" 404 | Out-Null
+        Write-Host "$view passed $($inventory.Count) UID, anchor, TOC and search checks across $($pages.Count) served API pages."
+    }
+    if ($Browser) {
+        & node "$PSScriptRoot/Test-FrameworkNavigation.cjs" $Origin
+        Assert-True ($LASTEXITCODE -eq 0) 'Playwright navigation tests failed.'
+    }
+} finally {
+    $client.Dispose()
+    if ($container) { & docker stop $container | Out-Null }
+}
diff --git a/tooling/docfx-multi-tfm/Test-DocfxMultiTfm.ps1 b/tooling/docfx-multi-tfm/Test-DocfxMultiTfm.ps1
new file mode 100644
index 000000000..667180bb2
--- /dev/null
+++ b/tooling/docfx-multi-tfm/Test-DocfxMultiTfm.ps1
@@ -0,0 +1,221 @@
+#requires -Version 7.0
+[CmdletBinding()]
+param()
+
+$ErrorActionPreference = 'Stop'
+$PSNativeCommandUseErrorActionPreference = $false
+$repo = (Resolve-Path (Join-Path $PSScriptRoot '../..')).Path
+$docfxRoot = Join-Path $repo '.docfx'
+$work = Join-Path ([IO.Path]::GetTempPath()) "cuemon-docfx-poc-$([Guid]::NewGuid().ToString('N'))"
+$frameworks = @('net10.0', 'net11.0', 'netstandard2.0')
+$projects = @('Cuemon.Kernel/Cuemon.Kernel.csproj', 'Cuemon.IO/Cuemon.IO.csproj')
+$legacyType = 'System.Runtime.CompilerServices.CallerArgumentExpressionAttribute'
+$modernType = 'Cuemon.IO.BufferWriterOptions'
+
+function Assert-True([bool] $Condition, [string] $Message) {
+    if (-not $Condition) { throw $Message }
+}
+
+function Invoke-Logged([string] $Log, [string] $Command, [string[]] $Arguments, [string] $ExpectedFailure) {
+    & $Command @Arguments *> $Log
+    $code = $LASTEXITCODE
+    if ($ExpectedFailure) {
+        Assert-True ($code -ne 0 -and (Get-Content -LiteralPath $Log -Raw).Contains($ExpectedFailure)) "Expected failure '$ExpectedFailure'. See $Log"
+    } elseif ($code -ne 0) {
+        Get-Content -LiteralPath $Log -Tail 30 | Write-Host
+        throw "$Command failed with exit code $code. See $Log"
+    }
+}
+
+function Read-Manifest([string] $Directory) {
+    Get-Content -LiteralPath (Join-Path $Directory '.manifest') -Raw | ConvertFrom-Json -AsHashtable
+}
+
+function Get-TreeFingerprint([string] $Directory) {
+    $entries = Get-ChildItem -LiteralPath $Directory -Recurse -File -Force | ForEach-Object {
+        $name = [IO.Path]::GetRelativePath($Directory, $_.FullName).Replace('\', '/')
+        if ($name -ceq 'manifest.json') {
+            # DocFX records the absolute build directory and emits file entries in parallel completion order.
+            $manifest = Get-Content -LiteralPath $_.FullName -Raw | ConvertFrom-Json -AsHashtable
+            $manifest.Remove('source_base_path')
+            [string[]] $files = @($manifest.files | ForEach-Object { ConvertTo-Json -InputObject $_ -Depth 30 -Compress })
+            [Array]::Sort($files, [StringComparer]::Ordinal)
+            $manifest.files = $files
+            $bytes = [Text.Encoding]::UTF8.GetBytes((ConvertTo-Json -InputObject $manifest -Depth 30 -Compress))
+            "$name $([Convert]::ToHexString([Security.Cryptography.SHA256]::HashData($bytes)))"
+        } else {
+            "$name $((Get-FileHash -LiteralPath $_.FullName).Hash)"
+        }
+    }
+    [string[]] $entries = @($entries)
+    [Array]::Sort($entries, [StringComparer]::Ordinal)
+    $entries -join "`n"
+}
+
+function New-Metadata([string] $Directory, [string] $Name, [string] $Source, [string[]] $Files, [string] $Framework) {
+    $job = @{ src = @(@{ src = $Source; files = $Files }); dest = $Name; memberLayout = 'separatePages'; filter = 'filterConfig.yml' }
+    if ($Framework) { $job.properties = @{ TargetFramework = $Framework } }
+    $config = Join-Path $Directory "$Name.json"
+    @{ metadata = @($job) } | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath $config
+    $log = Join-Path $Directory "$Name.log"
+    Invoke-Logged $log docfx @('metadata', $config, '--noRestore')
+    foreach ($line in [IO.File]::ReadLines($log)) {
+        if ($line -notmatch '^warning:') { continue }
+        $known = $Framework -eq 'netstandard2.0' -and
+            $line -match '^warning: \[Warning\] Found project reference without a matching metadata reference: .*[/\\]Cuemon\.(Kernel|Core|Threading)\.csproj$'
+        Assert-True $known "Unexpected DocFX metadata warning in ${log}: $line"
+    }
+}
+
+function Test-RenderedSite([string] $Site, $Inventory, [string[]] $ModernMembers) {
+    $xrefPath = Join-Path $Site 'xrefmap.yml'
+    $xref = [Collections.Generic.Dictionary[string,string]]::new([StringComparer]::Ordinal)
+    # DocFX's XRefMap writes each UID and its href as top-level fields on the same entry.
+    $uid = $null
+    foreach ($line in [IO.File]::ReadLines($xrefPath)) {
+        if ($line -cmatch '^- uid: (.+)$') { $uid = $Matches[1] }
+        if ($line -cmatch '^  href: (.+)$' -and $uid) { $xref.Add($uid, $Matches[1]); $uid = $null }
+    }
+
+    $html = @{}
+    foreach ($uid in @($Inventory.Keys) + @('Cuemon.IO.StreamFactory.Create*')) {
+        Assert-True ($xref.ContainsKey($uid)) "Rendered xref missing: $uid"
+        $page, $anchor = $xref[$uid].Split('#', 2)
+        Assert-True ($page.StartsWith('api/dotnet/')) "Unexpected xref destination for $uid : $page"
+        if (-not $html.ContainsKey($page)) { $html[$page] = Get-Content -LiteralPath (Join-Path $Site $page) -Raw }
+        if ($anchor) {
+            $id = [Net.WebUtility]::HtmlEncode([Uri]::UnescapeDataString($anchor))
+            Assert-True ($html[$page].Contains("id=`"$id`"")) "Broken rendered anchor for $uid : $anchor"
+        }
+    }
+
+    $legacy = $html[$xref[$legacyType]]
+    $modern = $html[$xref[$modernType]]
+    $modernLabel = 'Available in documented targets: net10.0, net11.0.'
+    Assert-True ($legacy.Contains('Available in documented targets: netstandard2.0.')) 'Incorrect rendered compatibility availability.'
+    Assert-True ($modern.Contains($modernLabel)) 'Incorrect rendered modern type availability.'
+    foreach ($uid in $ModernMembers) {
+        $page, $anchor = $xref[$uid].Split('#', 2)
+        $id = [Net.WebUtility]::HtmlEncode([Uri]::UnescapeDataString($anchor))
+        $section = [regex]::Match($html[$page], '(?s)]*id="' + [regex]::Escape($id) + '"[^>]*>.*?(?=]*data-uid=|\z)').Value
+        Assert-True ($section.Contains($modernLabel) -and $section.Contains('href="Cuemon.IO.BufferWriterOptions.html"')) "Modern overload missing its declaration, link or availability: $uid"
+    }
+
+    $toc = Get-Content -LiteralPath (Join-Path $Site 'api/dotnet/toc.html') -Raw
+    foreach ($type in @($legacyType, $modernType)) {
+        $namespace = $type.Substring(0, $type.LastIndexOf('.'))
+        Assert-True ($toc.Contains("href=`"$type.html`"") -and $toc.Contains("href=`"$namespace.html`"")) "Missing rendered TOC entry for $type"
+        Assert-True ($html[$xref[$namespace]].Contains("href=`"$type.html`"")) "Missing namespace link for $type"
+        Assert-True ($html[$xref[$type]].Contains('.cs/#L')) "Missing Git source link for $type"
+    }
+    Assert-True ($legacy.Contains('CallerArgumentExpressionAttributeExample')) 'Compatibility overwrite example is missing.'
+    Assert-True ($modern.Contains('BufferWriterOptionsExample')) 'Modern overwrite example is missing.'
+    Assert-True ($html[$xref['Cuemon.IO.StreamFactory']].Contains('Create a stream by writing to a StreamWriter')) 'StreamFactory overwrite example is missing.'
+    Assert-True ($html[$xref['System.Runtime.CompilerServices']].Contains('provides polyfill types')) 'Compatibility namespace overwrite is missing.'
+    Assert-True ($html[$xref['Cuemon.ArgumentReservedKeywordException']].Contains('Inherited members in netstandard2.0')) 'Legacy inheritance annotation is missing.'
+    $overwrites = Join-Path (Split-Path -Parent $Site) 'api/types'
+    foreach ($file in Get-ChildItem -LiteralPath $overwrites -Filter '*.md') {
+        $markdown = Get-Content -LiteralPath $file.FullName -Raw
+        if ($markdown -notmatch '(?m)^example:') { continue }
+        $page = $xref[$file.BaseName]
+        Assert-True ($html[$page] -match '(?s)

Examples

.*?
]*>\s*\S') "Authored example did not render for $($file.BaseName)."
+    }
+}
+
+New-Item -ItemType Directory -Path $work | Out-Null
+Write-Host "Artifacts: $work"
+$version = & docfx --version
+Assert-True ($LASTEXITCODE -eq 0 -and $version -match '^2\.81\.0(?:\+|$)') "Expected DocFX 2.81.0, got $version"
+foreach ($project in $projects) {
+    $path = Join-Path "$repo/src" $project
+    $targets = & dotnet msbuild $path -getProperty:TargetFrameworks
+    Assert-True ($LASTEXITCODE -eq 0) "MSBuild target framework discovery failed for $project"
+    foreach ($framework in $frameworks) {
+        Assert-True ($framework -cin $targets.Split(';')) "$project does not declare $framework."
+    }
+    Write-Host "$project declares $targets"
+}
+Invoke-Logged "$work/restore.log" dotnet @('restore', (Join-Path "$repo/src" $projects[1]))
+& "$docfxRoot/BuildRunActions.ps1" -OutputRoot "$work/run-actions"
+& "$docfxRoot/TestRunActions.ps1" -ScriptsRoot "$work/run-actions"
+Copy-Item -LiteralPath "$PSScriptRoot/Consolidate.cs" -Destination $work
+
+foreach ($round in 1, 2) {
+    $stage = Join-Path $work "round-$round"
+    New-Item -ItemType Directory -Path "$stage/api" | Out-Null
+    Copy-Item -LiteralPath "$docfxRoot/filterConfig.yml", "$docfxRoot/includes", "$docfxRoot/templates", "$docfxRoot/images", "$work/run-actions" -Destination $stage -Recurse
+    $source = @{}
+    $output = "$stage/api/dotnet"
+    $arguments = @('run', '--file', "$work/Consolidate.cs", '--', $output)
+    foreach ($framework in $frameworks) {
+        New-Metadata $stage $framework "$repo/src" $projects $framework
+        $source[$framework] = Read-Manifest "$stage/$framework"
+        $arguments += @($framework, "$stage/$framework")
+    }
+    Invoke-Logged "$stage/consolidation.log" dotnet $arguments
+    Get-Content -LiteralPath "$stage/consolidation.log" | Write-Host
+    $actual = Read-Manifest $output
+    $expected = [Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal)
+    foreach ($framework in $frameworks) {
+        $expected.UnionWith([string[]] @($source[$framework].Keys))
+        Assert-True ($source[$framework].Contains('Cuemon.Validator') -and $source[$framework].Contains('Cuemon.IO.StreamFactory')) "Expected both projects in $framework metadata."
+        Assert-True ($source[$framework].Contains($legacyType) -eq ($framework -eq 'netstandard2.0')) "Unexpected source availability for $legacyType in $framework."
+        Assert-True ($source[$framework].Contains($modernType) -eq ($framework -ne 'netstandard2.0')) "Unexpected source availability for $modernType in $framework."
+    }
+    Assert-True ($expected.SetEquals([string[]] @($actual.Keys))) 'Consolidated inventory differs from the source union.'
+    $modernMembers = @($actual.Keys.Where({ $_ -clike 'Cuemon.IO.StreamFactory.Create*' -and $_.Contains('System.Buffers.IBufferWriter{System.Byte}') }))
+    Assert-True ($modernMembers.Count -eq 6) 'Expected six IBufferWriter overloads.'
+    foreach ($uid in $modernMembers) {
+        Assert-True ($source['net10.0'].Contains($uid) -and $source['net11.0'].Contains($uid) -and -not $source['netstandard2.0'].Contains($uid)) "Unexpected source availability for $uid"
+    }
+
+    foreach ($kind in 'types', 'namespaces') {
+        New-Item -ItemType Directory -Path "$stage/api/$kind" | Out-Null
+        Get-ChildItem -LiteralPath "$docfxRoot/api/$kind" -Filter '*.md' |
+            Where-Object { $actual.Contains($_.BaseName) } | Copy-Item -Destination "$stage/api/$kind"
+    }
+    $config = Get-Content -LiteralPath "$docfxRoot/docfx.json" -Raw | ConvertFrom-Json -AsHashtable
+    $config.Remove('metadata')
+    $config.build.Remove('sitemap')
+    $config.build.content = @(@{ files = @('api/dotnet/*.yml') })
+    $config | ConvertTo-Json -Depth 30 | Set-Content -LiteralPath "$stage/docfx.json"
+    Invoke-Logged "$stage/build.log" docfx @('build', "$stage/docfx.json", '--warningsAsErrors')
+    Test-RenderedSite "$stage/wwwroot" $actual $modernMembers
+}
+
+foreach ($directory in 'api/dotnet', 'wwwroot') {
+    $first = Get-TreeFingerprint "$work/round-1/$directory"
+    $second = Get-TreeFingerprint "$work/round-2/$directory"
+    if ($first -cne $second) {
+        Compare-Object ($first -split "`n") ($second -split "`n") | Write-Host
+        throw "Fresh runs differ in $directory."
+    }
+    $first | Set-Content -LiteralPath (Join-Path $work ($directory.Replace('/', '-') + '.sha256'))
+}
+
+$single = "$work/single"
+New-Item -ItemType Directory -Path $single | Out-Null
+Copy-Item -LiteralPath "$docfxRoot/filterConfig.yml" -Destination $single
+'net10.0' |
+    Set-Content -LiteralPath "$single/Single.csproj"
+'namespace Fixture; public class Single { public int GetValue() { return 42; } }' | Set-Content -LiteralPath "$single/Single.cs"
+Invoke-Logged "$single/restore.log" dotnet @('restore', "$single/Single.csproj")
+New-Metadata $single 'normal' $single @('Single.csproj')
+Invoke-Logged "$single/copy.log" dotnet @('run', '--file', "$work/Consolidate.cs", '--', "$single/copied", 'net10.0', "$single/normal")
+Assert-True ((Get-TreeFingerprint "$single/normal") -ceq (Get-TreeFingerprint "$single/copied")) 'Single-TFM metadata changed.'
+
+$first = "$work/round-1"
+$bad = "$work/negative"
+Copy-Item -LiteralPath "$first/net11.0" -Destination $bad -Recurse
+$page = "$bad/Cuemon.IO.StreamFactory.yml"
+$original = Get-Content -LiteralPath $page -Raw
+$modified = $original.Replace('content: public static class StreamFactory', 'content: public sealed class StreamFactory')
+Assert-True ($original -cne $modified) 'Signature conflict fixture did not change the syntax.'
+$modified | Set-Content -LiteralPath $page -NoNewline
+$negative = @('run', '--file', "$work/Consolidate.cs", '--', "$work/rejected", 'net10.0', "$first/net10.0", 'net11.0', $bad)
+Invoke-Logged "$work/signature-conflict.log" dotnet $negative "Cuemon.IO.StreamFactory (net11.0): conflicting 'syntax'"
+$original | Set-Content -LiteralPath $page -NoNewline
+Remove-Item -LiteralPath $page
+Invoke-Logged "$work/missing-api.log" dotnet $negative 'generated pages disagree with the DocFX manifest'
+Assert-True (-not (Test-Path -LiteralPath "$work/rejected")) 'Unsafe input produced an output directory.'
+Write-Host 'Passed availability, UID coverage, links, overwrites, reproducibility, single-TFM passthrough and failure checks.'
diff --git a/tooling/docfx-multi-tfm/Test-FrameworkNavigation.cjs b/tooling/docfx-multi-tfm/Test-FrameworkNavigation.cjs
new file mode 100644
index 000000000..4ec09c688
--- /dev/null
+++ b/tooling/docfx-multi-tfm/Test-FrameworkNavigation.cjs
@@ -0,0 +1,201 @@
+const assert = require('node:assert/strict');
+const { chromium } = require('playwright');
+
+async function main() {
+    const origin = process.argv[2];
+    const browser = await chromium.launch();
+    try {
+        const context = await browser.newContext();
+        await context.route('**/*', route => {
+            if (new URL(route.request().url()).origin !== origin) return route.abort();
+            return route.continue();
+        });
+        const page = await context.newPage();
+        const failures = [];
+        context.on('response', response => {
+            if (response.url().startsWith(origin) && response.status() >= 400) {
+                failures.push(response.url() + ' ' + response.status());
+            }
+        });
+        page.on('pageerror', error => failures.push(error.message));
+        const manifest = await (await context.request.get(origin + '/framework-views.json')).json();
+        const api = manifest.apiPath;
+        const factory = api + 'Cuemon.IO.StreamFactory.html';
+        const buffer = api + 'Cuemon.IO.BufferWriterOptions.html';
+        const legacy = api + 'System.Runtime.CompilerServices.CallerArgumentExpressionAttribute.html';
+        const alphanumeric = api + 'Cuemon.Alphanumeric.html';
+
+        const defaultIndex = page.waitForResponse(origin + '/index.json');
+        await page.goto(origin + factory);
+        assert.equal((await defaultIndex).status(), 200);
+        const defaultLink = page.locator('article a[href*="StreamFactory.Create.html"]').first();
+        assert.equal(new URL(await defaultLink.getAttribute('href'), page.url()).searchParams.get('view'), null);
+
+        const selector = page.getByRole('combobox', { name: 'Framework' });
+        if (Object.keys(manifest.views).length === 1) await selector.waitFor({ state: 'hidden' });
+        if (manifest.defaultView === 'net-11.0' && manifest.views['net-10.0']) {
+            await selector.waitFor();
+            assert.equal(await selector.inputValue(), manifest.defaultView);
+            assert.equal(await selector.locator('option:checked').textContent(), '.NET 11');
+            await page.goto(origin + factory + '?VIEW=net-10.0');
+            await selector.waitFor();
+            assert.equal(await selector.inputValue(), 'net-10.0');
+            const anchor = '#' + await page.locator('article h1').getAttribute('id');
+            await page.goto(origin + factory + '?q=StreamFactory' + anchor);
+            await selector.selectOption('net-10.0');
+            await page.waitForURL(origin + factory + '?q=StreamFactory&view=net-10.0' + anchor);
+            await selector.waitFor();
+            assert.equal(await selector.inputValue(), 'net-10.0');
+            await page.goBack();
+            await selector.waitFor();
+            assert.equal(await selector.inputValue(), manifest.defaultView);
+        }
+
+        if (manifest.views['netstandard-2.1'] && manifest.views['netstandard-2.0'] && manifest.views['net-10.0']) {
+            const fallbackStatus = page.locator('#framework-view-status');
+            await page.goto(origin + alphanumeric + '?q=Alphanumeric&view=net-11.0');
+            const apiRequests = [];
+            const recordApiRequest = request => {
+                if (request.isNavigationRequest() && new URL(request.url()).pathname === alphanumeric) apiRequests.push(request);
+            };
+            page.on('request', recordApiRequest);
+            await selector.selectOption('netstandard-2.1');
+            await page.waitForURL(origin + alphanumeric + '?q=Alphanumeric&view=net-10.0');
+            await fallbackStatus.getByText('This API is not documented for .NET Standard 2.1. Showing .NET 10.').waitFor();
+            assert.equal(await selector.inputValue(), 'net-10.0');
+            assert.equal(apiRequests.length, 1);
+            assert.equal(apiRequests[0].redirectedFrom(), null);
+            await selector.selectOption('netstandard-2.1');
+            await fallbackStatus.getByText('This API is not documented for .NET Standard 2.1. Showing .NET 10.').waitFor();
+            assert.equal(await selector.inputValue(), 'net-10.0');
+            assert.equal(apiRequests.length, 1);
+            page.off('request', recordApiRequest);
+
+            const legacyUrl = origin + legacy + '?view=netstandard-2.0';
+            const legacyResponse = await page.goto(legacyUrl);
+            assert.equal(legacyResponse.status(), 200);
+            assert.equal(legacyResponse.request().redirectedFrom(), null);
+            await selector.selectOption('net-11.0');
+            await fallbackStatus.getByText('This API is not documented for .NET 11. Showing .NET Standard 2.0.').waitFor();
+            assert.equal(page.url(), legacyUrl);
+            assert.equal(await selector.inputValue(), 'netstandard-2.0');
+
+            const missing = await context.request.get(origin + alphanumeric + '?view=netstandard-2.1', { maxRedirects: 0 });
+            assert.equal(missing.status(), 404);
+            assert.equal(missing.headers().location, undefined);
+
+            const createPage = api + 'Cuemon.IO.StreamFactory.Create.html';
+            await page.goto(origin + createPage + '?view=net-11.0');
+            const overload = page.locator('article h3[id*="_System_Buffers_IBufferWriter_"]').first();
+            const memberId = await overload.getAttribute('id');
+            await page.goto(origin + createPage + '?view=net-11.0#' + memberId);
+            await selector.selectOption('netstandard-2.0');
+            await page.waitForURL(origin + createPage + '?view=netstandard-2.1#' + memberId);
+            await fallbackStatus.getByText('This API is not documented for .NET Standard 2.0. Showing .NET Standard 2.1.').waitFor();
+            assert.equal(await selector.inputValue(), 'netstandard-2.1');
+            assert.equal(await page.locator('[id="' + memberId + '"]').count(), 1);
+        }
+
+        for (const [view, entry] of Object.entries(manifest.views)) {
+            const query = '?view=' + view;
+            const indexRequest = page.waitForResponse(origin + '/_framework-search/' + entry.directory + '/index.json');
+            const tocRequest = page.waitForResponse(origin + api + 'toc.json' + query);
+            await page.goto(origin + factory + query);
+            assert.equal((await indexRequest).status(), 200);
+            assert.equal((await tocRequest).status(), 200);
+
+            const old = entry.tfm === 'netstandard2.0';
+            const links = page.locator('#toc a[href*="StreamFactory.Create.html"]');
+            await links.first().waitFor({ state: 'attached' });
+            assert.ok((await links.first().getAttribute('href')).includes(query));
+            assert.equal(await page.locator('#toc a[href*="BufferWriterOptions.html"]').count() > 0, !old);
+            assert.equal(await page.locator('#toc a[href*="CallerArgumentExpressionAttribute.html"]').count() > 0, old);
+
+            const create = page.locator('article a[href*="StreamFactory.Create.html"]').first();
+            const createHref = new URL(await create.getAttribute('href'), page.url());
+            await create.press('Enter');
+            await page.waitForURL(createHref.href);
+            const location = new URL(page.url());
+            assert.equal(location.searchParams.get('view'), view);
+            assert.ok(location.hash);
+            const id = decodeURIComponent(location.hash.slice(1));
+            const declaration = page.locator('[id="' + id + '"]');
+            await declaration.waitFor({ state: 'attached' });
+            await page.reload();
+            assert.equal(new URL(page.url()).href, location.href);
+            assert.equal(await page.locator('[id="' + id + '"]').count(), 1);
+
+            // Use the native TOC's page link for ordinary document history.
+            // DocFX also performs same-document navigation to scroll to a fragment.
+            await page.goto(origin + factory + query);
+            await page.getByRole('searchbox', { name: 'Filter by title' }).fill('Create');
+            await links.first().press('Enter');
+            const memberUrl = origin + api + 'Cuemon.IO.StreamFactory.Create.html' + query;
+            await page.waitForURL(memberUrl);
+            await page.goBack();
+            await page.waitForURL(origin + factory + query);
+            await page.goForward();
+            await page.waitForURL(memberUrl);
+
+            if (!old) {
+                await page.locator('article a[href*="BufferWriterOptions.html"]:visible').first().press('Enter');
+                await page.waitForURL(origin + buffer + query);
+            }
+            const external = page.locator('article a[href^="https://"]').first();
+            assert.ok(!(await external.getAttribute('href')).includes(query));
+
+            const search = page.locator('#search-query');
+            await page.waitForFunction(() => !document.getElementById('search-query').disabled, undefined, { polling: 50 });
+            await search.fill(old ? 'CallerArgumentExpressionAttribute' : 'BufferWriterOptions');
+            const result = page.locator('#search-results a[href*="' + (old ? legacy : buffer) + '"]', { hasText: /Class/ });
+            await result.first().waitFor({ state: 'attached' });
+            const resultHref = new URL(await result.first().getAttribute('href'), origin);
+            assert.equal(resultHref.pathname, old ? legacy : buffer);
+            assert.equal(resultHref.searchParams.get('view'), view);
+            assert.ok(resultHref.searchParams.has('q'));
+            const label = await result.first().evaluate(link => getComputedStyle(link, '::after').content);
+            assert.equal(JSON.parse(label), (old ? legacy : buffer) + query);
+            assert.equal(await result.first().locator('xpath=../following-sibling::div[contains(@class,"item-href")]').isVisible(), false);
+            const [popup] = await Promise.all([page.waitForEvent('popup'), result.first().press('Enter')]);
+            await popup.waitForLoadState();
+            assert.equal(popup.url(), resultHref.href);
+            await popup.close();
+
+            await search.fill('Cwalina');
+            const conceptResult = page.locator('#search-results .item-title > a[href^="/index.html?q="]').first();
+            await conceptResult.waitFor({ state: 'attached' });
+            assert.equal(await conceptResult.getAttribute('data-framework-url'), '/index.html');
+
+            await page.goto(origin + factory + query);
+            const filter = page.getByRole('searchbox', { name: 'Filter by title' });
+            await filter.fill('StreamFactory');
+            const scopedTocLink = page.locator('#toc a[href*="StreamFactory.html"]').first();
+            assert.equal(await scopedTocLink.getAttribute('href'), factory + query);
+            const concept = page.locator('#navbar a[href$="index.html"]').first();
+            await concept.waitFor({ state: 'attached' });
+            assert.equal(new URL(await concept.getAttribute('href'), origin).searchParams.get('view'), null);
+            console.log('Browser passed ' + view);
+        }
+        if (Object.keys(manifest.views).length > 1) {
+            const mobile = await browser.newPage({ viewport: { width: 390, height: 844 }, colorScheme: 'dark' });
+            await mobile.route('**/*', route => new URL(route.request().url()).origin === origin ? route.continue() : route.abort());
+            await mobile.goto(origin + factory);
+            await mobile.getByRole('button', { name: 'Show table of contents' }).click();
+            const mobileSelector = mobile.getByRole('combobox', { name: 'Framework' });
+            await mobileSelector.waitFor();
+            await mobileSelector.focus();
+            assert.equal(await mobileSelector.evaluate(element => document.activeElement === element), true);
+            assert.equal(await mobile.locator('html').getAttribute('data-bs-theme'), 'dark');
+            await mobile.close();
+        }
+        assert.deepEqual(failures, []);
+        console.log('Browser passed deep links, dynamic TOC, xrefs, search, refresh and history in every configured view.');
+    } finally {
+        await browser.close();
+    }
+}
+
+main().catch(error => {
+    console.error(error);
+    process.exitCode = 1;
+});