@foreach (var (option, votes, percentage) in CalculateResults())
@@ -58,15 +58,15 @@ else
}
@code
{
- [Parameter] public string PollId { get; set; }
- private MyPollWatcher _watcher;
- private IAsyncDisposable _subscription;
+ [Parameter] public required string PollId { get; set; }
+ private MyPollWatcher? _watcher;
+ private IAsyncDisposable? _subscription;
private bool _loaded;
private bool _voted;
- private string _errorMessage;
+ private string _errorMessage = string.Empty;
private Guid ownerKey = Guid.NewGuid();
- private PollState _results;
+ private PollState? _results;
protected override async Task OnInitializedAsync()
{
diff --git a/orleans/Voting/Pages/PollEditor.razor b/orleans/Voting/Pages/PollEditor.razor
index 190e9eacef4..47cd40559a1 100644
--- a/orleans/Voting/Pages/PollEditor.razor
+++ b/orleans/Voting/Pages/PollEditor.razor
@@ -18,7 +18,7 @@
@foreach (var (index, option) in options.Select((name, index) => (index, name)))
{
- RenameOption(index, (string)e.Value))">
+ RenameOption(index, (string?)e.Value ?? string.Empty))">
}
@@ -31,8 +31,8 @@
private Guid ownerKey = Guid.NewGuid();
private List
options = new ();
- private string question;
- private string newOption;
+ private string question = string.Empty;
+ private string newOption = string.Empty;
protected override async Task OnInitializedAsync()
{
diff --git a/orleans/Voting/Pages/_Host.cshtml b/orleans/Voting/Pages/_Host.cshtml
index c53e75fe11f..3a02a5c5248 100644
--- a/orleans/Voting/Pages/_Host.cshtml
+++ b/orleans/Voting/Pages/_Host.cshtml
@@ -6,4 +6,4 @@
var clientIp = HttpContext.Connection.RemoteIpAddress?.ToString();
}
-
+
diff --git a/orleans/Voting/Program.cs b/orleans/Voting/Program.cs
index 4f4bacfc3b2..7e5dae752d7 100644
--- a/orleans/Voting/Program.cs
+++ b/orleans/Voting/Program.cs
@@ -1,27 +1,11 @@
+using Orleans.Dashboard;
using Voting.Data;
var builder = WebApplication.CreateBuilder(args);
-builder.Host.UseOrleans((ctx, orleansBuilder) =>
-{
- if (ctx.HostingEnvironment.IsDevelopment())
- {
- // During development time, we don't want to have to deal with
- // storage emulators or other dependencies. Just "Hit F5" to run.
- orleansBuilder
- .UseLocalhostClustering()
- .AddMemoryGrainStorage("votes");
- }
- else
- {
- // In Kubernetes, we use environment variables and the pod manifest
- //orleansBuilder.UseKubernetesHosting();
-
- // Use Redis for clustering & persistence
- //var redisAddress = $"{Environment.GetEnvironmentVariable("REDIS")}:6379";
- //orleansBuilder.UseRedisClustering(options => options.ConnectionString = redisAddress);
- //orleansBuilder.AddRedisGrainStorage("votes", options => options.ConnectionString = redisAddress);
- }
-});
+builder.Host.UseOrleans((ctx, orleansBuilder) => orleansBuilder
+ .UseLocalhostClustering()
+ .AddMemoryGrainStorage("votes")
+ .AddDashboard());
// Add services to the container.
builder.Services.AddRazorPages();
@@ -42,6 +26,9 @@
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
+
app.MapBlazorHub();
+app.MapRazorPages();
+app.MapOrleansDashboard("/dashboard");
app.MapFallbackToPage("/_Host");
app.Run();
diff --git a/orleans/Voting/README.md b/orleans/Voting/README.md
index ea20ce42a22..f4735611308 100644
--- a/orleans/Voting/README.md
+++ b/orleans/Voting/README.md
@@ -22,7 +22,7 @@ The Web app sends HTTP requests which are handled by ASP.NET Core MVC controller
## Sample prerequisites
-This sample is written in C# and targets .NET 7.0. It requires the [.NET 7.0 SDK](https://dotnet.microsoft.com/download/dotnet/7.0) or later.
+This sample is written in C# and targets .NET 10. It requires the [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) or later.
## Building the sample
diff --git a/orleans/Voting/Shared/NavMenu.razor b/orleans/Voting/Shared/NavMenu.razor
index a201e99af25..6da717e1daf 100644
--- a/orleans/Voting/Shared/NavMenu.razor
+++ b/orleans/Voting/Shared/NavMenu.razor
@@ -25,7 +25,7 @@
@code {
private bool collapseNavMenu = true;
- private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
+ private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
private void ToggleNavMenu()
{
diff --git a/orleans/Voting/Voting.csproj b/orleans/Voting/Voting.csproj
index f00afd546fb..efe02441cd3 100644
--- a/orleans/Voting/Voting.csproj
+++ b/orleans/Voting/Voting.csproj
@@ -1,15 +1,15 @@
-
- net7.0
+ net10.0
enable
+ enable
+ true
-
-
-
+
+
+
diff --git a/orleans/Voting/run.cmd b/orleans/Voting/run.cmd
new file mode 100644
index 00000000000..9536012eaa7
--- /dev/null
+++ b/orleans/Voting/run.cmd
@@ -0,0 +1,5 @@
+@echo off
+echo Building and running Voting sample...
+echo Open https://localhost:7178 in your browser
+echo Orleans Dashboard available at https://localhost:7178/dashboard/
+dotnet run --project "%~dp0Voting.csproj"
diff --git a/orleans/Voting/run.sh b/orleans/Voting/run.sh
new file mode 100644
index 00000000000..0c191695f25
--- /dev/null
+++ b/orleans/Voting/run.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+echo "Building and running Voting sample..."
+echo "Open https://localhost:7178 in your browser"
+echo "Orleans Dashboard available at https://localhost:7178/dashboard/"
+dotnet run --project "$(dirname "$0")/Voting.csproj"