Skip to content

Commit 5381ac7

Browse files
committed
Undo samples
1 parent 2a42951 commit 5381ac7

File tree

7 files changed

+8
-53
lines changed

7 files changed

+8
-53
lines changed

src/Components/Components/test/ComponentStatePersistenceManagerFilteringTests.cs

Whitespace-only changes.
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using BlazorUnitedApp.Client.Data;
5-
using BlazorUnitedApp.Client.Pages;
64
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
75

86
var builder = WebAssemblyHostBuilder.CreateDefault(args);
97

10-
builder.Services.AddSingleton<ClientWeatherForecastService>();
11-
128
await builder.Build().RunAsync();

src/Components/Samples/BlazorUnitedApp/Data/WeatherForecastService.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ public class WeatherForecastService
1010
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
1111
};
1212

13-
public async Task<WeatherForecast[]> GetForecastAsync(DateOnly startDate)
13+
public Task<WeatherForecast[]> GetForecastAsync(DateOnly startDate)
1414
{
15-
await Task.Yield();
16-
return await Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
15+
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
1716
{
1817
Date = startDate.AddDays(index),
1918
TemperatureC = Random.Shared.Next(-20, 55),
Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
@page "/fetchdata/"
1+
@page "/fetchdata"
22
@using BlazorUnitedApp.Data
33
@inject WeatherForecastService ForecastService
4-
@inject NavigationManager NavigationManager
5-
@rendermode InteractiveServer
64

75
<PageTitle>Weather forecast</PageTitle>
86

97
<h1>Weather forecast</h1>
108

119
<p>This component demonstrates fetching data from a service.</p>
1210

13-
@if (Forecasts == null)
11+
@if (forecasts == null)
1412
{
1513
<p><em>Loading...</em></p>
1614
}
@@ -26,7 +24,7 @@ else
2624
</tr>
2725
</thead>
2826
<tbody>
29-
@foreach (var forecast in Forecasts)
27+
@foreach (var forecast in forecasts)
3028
{
3129
<tr>
3230
<td>@forecast.Date.ToShortDateString()</td>
@@ -39,41 +37,11 @@ else
3937
</table>
4038
}
4139

42-
<p>Current Url = @Page</p>
43-
44-
<ul>
45-
<li>
46-
<a href="fetchdata/?page=0">Page 0</a>
47-
</li>
48-
<li>
49-
<a href="fetchdata/?page=1">Page 1</a>
50-
</li>
51-
<li>
52-
<a href="fetchdata/?page=2">Page 2</a>
53-
</li>
54-
</ul>
55-
5640
@code {
57-
[PersistentState]
58-
[UpdateStateOnEnhancedNavigation(true)]
59-
public WeatherForecast[]? Forecasts { get; set; }
60-
61-
public string Page { get; set; } = "";
41+
private WeatherForecast[]? forecasts;
6242

6343
protected override async Task OnInitializedAsync()
6444
{
65-
// Extract the page from the query string
66-
var uri = NavigationManager.ToAbsoluteUri(NavigationManager.Uri);
67-
var query = System.Web.HttpUtility.ParseQueryString(uri.Query);
68-
var pageParam = query["page"];
69-
int pageIndex = 1 + (int.TryParse(pageParam, out int parsedPage) ? parsedPage : 0);
70-
pageIndex *= 7;
71-
72-
Forecasts ??= await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now).AddDays(pageIndex));
73-
}
74-
75-
protected override void OnParametersSet()
76-
{
77-
Page = NavigationManager.Uri;
45+
forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
7846
}
7947
}

src/Components/Samples/BlazorUnitedApp/Program.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using BlazorUnitedApp;
5-
using BlazorUnitedApp.Client.Data;
65
using BlazorUnitedApp.Data;
76

87
var builder = WebApplication.CreateBuilder(args);
@@ -13,7 +12,6 @@
1312
.AddInteractiveServerComponents();
1413

1514
builder.Services.AddSingleton<WeatherForecastService>();
16-
builder.Services.AddSingleton<ClientWeatherForecastService>();
1715

1816
var app = builder.Build();
1917

@@ -32,7 +30,6 @@
3230

3331
app.MapStaticAssets();
3432
app.MapRazorComponents<App>()
35-
.AddAdditionalAssemblies(typeof(BlazorUnitedApp.Client.Pages.ClientFetchData).Assembly)
3633
.AddInteractiveServerRenderMode()
3734
.AddInteractiveWebAssemblyRenderMode();
3835

src/Components/Samples/BlazorUnitedApp/Routes.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="[typeof(BlazorUnitedApp.Client.Pages.ClientFetchData).Assembly]">
1+
<Router AppAssembly="@typeof(App).Assembly">
22
<Found Context="routeData">
33
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
44
<FocusOnNavigate RouteData="@routeData" Selector="h1" />

src/Components/Samples/BlazorUnitedApp/Shared/NavMenu.razor

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@
2929
<span class="bi bi-list-nested" aria-hidden="true"></span> Web assembly
3030
</NavLink>
3131
</div>
32-
<div class="nav-item px-3">
33-
<NavLink class="nav-link" href="clientfetchdata">
34-
<span class="bi bi-list-nested" aria-hidden="true"></span> Client Fetch Data
35-
</NavLink>
36-
</div>
3732
</nav>
3833
</div>
3934

0 commit comments

Comments
 (0)