Skip to content

Commit 375f071

Browse files
Update cmdlet docs from Kestrun/Kestrun@698a353
1 parent cd22904 commit 375f071

File tree

378 files changed

+2661
-544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

378 files changed

+2661
-544
lines changed

docs/_includes/examples/pwsh/10.23-OpenAPI-Path-Template-Mapping.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<#
1+
<#
22
Sample: OpenAPI 3.2 RFC 6570 Path Template Mapping
33
Purpose: Demonstrate RFC 6570 URI Template mapping from ASP.NET Core route values
44
File: 10.23-OpenAPI-Path-Template-Mapping.ps1
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<#!
2+
Sample: Localization (PowerShell string tables)
3+
File: 21.1-Localization.ps1
4+
#>
5+
6+
param(
7+
[int]$Port = 5000,
8+
[IPAddress]$IPAddress = [IPAddress]::Loopback
9+
)
10+
11+
Initialize-KrRoot -Path $PSScriptRoot
12+
13+
New-KrLogger |
14+
Set-KrLoggerLevel -Value Information |
15+
Add-KrSinkConsole |
16+
Register-KrLogger -Name 'console' -SetAsDefault
17+
18+
New-KrServer -Name 'Localization Demo'
19+
20+
Add-KrEndpoint -Port $Port -IPAddress $IPAddress
21+
22+
Add-KrLocalizationMiddleware -ResourcesBasePath './Assets/i18n' -EnableQuery -EnableCookie
23+
24+
Add-KrMapRoute -Verbs Get -Pattern '/hello' -ScriptBlock {
25+
Expand-KrObject -InputObject $Context.Culture -Label 'Current Culture'
26+
$culture = [System.Globalization.CultureInfo]::CurrentCulture
27+
$now = [DateTime]::ParseExact('20260829', 'yyyyMMdd', [System.Globalization.CultureInfo]::InvariantCulture)
28+
$payload = [ordered]@{
29+
culture = $Context.Culture
30+
hello = Get-KrLocalizedString -Key 'Hello' -Default 'Hello'
31+
save = Get-KrLocalizedString -Key 'Labels.Save' -Default 'Save'
32+
cancel = Get-KrLocalizedString -Key 'Labels.Cancel' -Default 'Cancel'
33+
dateSample = $now.ToString('D', $culture)
34+
currencySample = 1234.56.ToString('C', $culture)
35+
calendar = [System.Globalization.CultureInfo]::GetCultureInfo($Context.Culture).Calendar
36+
calendarName = [System.Globalization.CultureInfo]::GetCultureInfo($Context.Culture).Calendar.GetType().Name
37+
}
38+
39+
Write-KrJsonResponse -InputObject $payload -StatusCode 200
40+
}
41+
42+
Add-KrMapRoute -Verbs Get -Pattern '/cultures' -ScriptBlock {
43+
$cultures = Get-KrLocalizationCulture | Sort-Object Name | ForEach-Object { $_.Name }
44+
Write-KrJsonResponse -InputObject @{ cultures = $cultures } -StatusCode 200
45+
}
46+
47+
Enable-KrConfiguration
48+
49+
Start-KrServer
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<#!
2+
Sample: Razor Pages + Localization
3+
File: 21.2-Razor-Localization.ps1
4+
#>
5+
6+
param(
7+
[int]$Port = 5000,
8+
[IPAddress]$IPAddress = [IPAddress]::Loopback
9+
)
10+
11+
Initialize-KrRoot -Path $PSScriptRoot
12+
13+
New-KrLogger |
14+
Set-KrLoggerLevel -Value Information |
15+
Add-KrSinkConsole |
16+
Register-KrLogger -Name 'console' -SetAsDefault
17+
18+
New-KrServer -Name 'Razor Localization Demo'
19+
20+
Add-KrEndpoint -Port $Port -IPAddress $IPAddress
21+
22+
Add-KrLocalizationMiddleware -ResourcesBasePath './Assets/i18n' -EnableQuery
23+
24+
Add-KrPowerShellRazorPagesRuntime -RootPath './Assets/Pages-Localization' -PathPrefix '/ui'
25+
26+
Enable-KrConfiguration
27+
28+
Start-KrServer
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@page
2+
@model Kestrun.Razor.PwshKestrunModel
3+
@{
4+
ViewData["Title"] = "Localization";
5+
dynamic d = Model.Data ?? new { Title = "Localized", Message = "Hello", Save = "Save", Culture = "", DateSample = "", CurrencySample = "" };
6+
}
7+
8+
<h1>@d.Title</h1>
9+
<p class="muted">Culture: @d.Culture</p>
10+
<p class="muted">Date: @d.DateSample</p>
11+
<p class="muted">Amount: @d.CurrencySample</p>
12+
<p>@d.Message</p>
13+
<button>@d.Save</button>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')]
2+
param()
3+
Write-Host "Rendering localized Razor page for culture: $($Context.Culture)"
4+
$culture = [System.Globalization.CultureInfo]::CurrentCulture
5+
$now = Get-Date
6+
$Model = [pscustomobject]@{
7+
Culture = $Context.Culture
8+
Title = (Get-KrLocalizedString -Key 'Page.Title' -Default 'Localized Razor Page')
9+
Message = (Get-KrLocalizedString -Key 'Hello' -Default 'Hello')
10+
Save = (Get-KrLocalizedString -Key 'Labels.Save' -Default 'Save')
11+
DateSample = $now.ToString('D', $culture)
12+
CurrencySample = 1234.56.ToString('C', $culture)
13+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@using System
2+
@using System.Linq
3+
@using Microsoft.AspNetCore.Http
4+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@{
2+
Layout = null;
3+
}

docs/_includes/examples/pwsh/Assets/Pages/Status.cshtml.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $headersText = ($lines -join "`n")
1515
$Model = [pscustomobject]@{
1616
NowUtc = [DateTime]::UtcNow.ToString('u')
1717
Method = $req.Method
18-
Path = $req.Path.Value
18+
Path = $req.Path
1919
RemoteIp = if ($ip) { $ip.ToString() } else { '' }
2020
Headers = $headersText
2121
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@{
2+
# German localization strings
3+
Hello = "Hallo"
4+
Labels = @{
5+
Save = "Speichern"
6+
Cancel = "Abbrechen"
7+
}
8+
Page = @{
9+
Title = "Lokalisierte Razor-Seite"
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@{
2+
# English localization strings
3+
Hello = "Hello"
4+
Labels = @{
5+
Save = "Save"
6+
Cancel = "Cancel"
7+
}
8+
Page = @{
9+
Title = "Localized Razor Page"
10+
}
11+
}

0 commit comments

Comments
 (0)