Skip to content

Commit 25e9b65

Browse files
committed
Update the project
1 parent 1aec350 commit 25e9b65

Some content is hidden

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

54 files changed

+1653
-1352
lines changed
+12-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
<Router AppAssembly="@typeof(Program).Assembly">
2-
<Found Context="routeData">
3-
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4-
</Found>
5-
<NotFound>
6-
<LayoutView Layout="@typeof(MainLayout)">
7-
<p>Sorry, there's nothing at this address.</p>
8-
</LayoutView>
9-
</NotFound>
10-
</Router>
1+
<Router AppAssembly="@typeof(App).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
5+
</Found>
6+
<NotFound>
7+
<PageTitle>Not found</PageTitle>
8+
<LayoutView Layout="@typeof(MainLayout)">
9+
<p role="alert">Sorry, there's nothing at this address.</p>
10+
</LayoutView>
11+
</NotFound>
12+
</Router>
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.2" />
11+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.2" PrivateAssets="all" />
12+
<PackageReference Include="Syncfusion.Blazor.Grid" Version="23.1.39" />
13+
<PackageReference Include="Syncfusion.Blazor.Themes" Version="23.1.39" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\Shared\ExpandoDynamicObject.Shared.csproj" />
18+
</ItemGroup>
19+
20+
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
@page "/counter"
2-
3-
<h1>Counter</h1>
4-
5-
<p>Current count: @currentCount</p>
6-
7-
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
8-
9-
@code {
10-
private int currentCount = 0;
11-
12-
private void IncrementCount()
13-
{
14-
currentCount++;
15-
}
16-
}
1+
@page "/counter"
2+
3+
<PageTitle>Counter</PageTitle>
4+
5+
<h1>Counter</h1>
6+
7+
<p role="status">Current count: @currentCount</p>
8+
9+
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
10+
11+
@code {
12+
private int currentCount = 0;
13+
14+
private void IncrementCount()
15+
{
16+
currentCount++;
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,47 @@
1-
@page "/fetchdata"
2-
@inject HttpClient Http
3-
4-
<h1>Weather forecast</h1>
5-
6-
<p>This component demonstrates fetching data from the server.</p>
7-
8-
@if (forecasts == null)
9-
{
10-
<p><em>Loading...</em></p>
11-
}
12-
else
13-
{
14-
<table class="table">
15-
<thead>
16-
<tr>
17-
<th>Date</th>
18-
<th>Temp. (C)</th>
19-
<th>Temp. (F)</th>
20-
<th>Summary</th>
21-
</tr>
22-
</thead>
23-
<tbody>
24-
@foreach (var forecast in forecasts)
25-
{
26-
<tr>
27-
<td>@forecast.Date.ToShortDateString()</td>
28-
<td>@forecast.TemperatureC</td>
29-
<td>@forecast.TemperatureF</td>
30-
<td>@forecast.Summary</td>
31-
</tr>
32-
}
33-
</tbody>
34-
</table>
35-
}
36-
37-
@code {
38-
private WeatherForecast[] forecasts;
39-
40-
protected override async Task OnInitializedAsync()
41-
{
42-
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("sample-data/weather.json");
43-
}
44-
45-
public class WeatherForecast
46-
{
47-
public DateTime Date { get; set; }
48-
49-
public int TemperatureC { get; set; }
50-
51-
public string Summary { get; set; }
52-
53-
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
54-
}
55-
}
1+
@page "/fetchdata"
2+
@using ExpandoDynamicObject.Shared
3+
@inject HttpClient Http
4+
5+
<PageTitle>Weather forecast</PageTitle>
6+
7+
<h1>Weather forecast</h1>
8+
9+
<p>This component demonstrates fetching data from the server.</p>
10+
11+
@if (forecasts == null)
12+
{
13+
<p><em>Loading...</em></p>
14+
}
15+
else
16+
{
17+
<table class="table">
18+
<thead>
19+
<tr>
20+
<th>Date</th>
21+
<th>Temp. (C)</th>
22+
<th>Temp. (F)</th>
23+
<th>Summary</th>
24+
</tr>
25+
</thead>
26+
<tbody>
27+
@foreach (var forecast in forecasts)
28+
{
29+
<tr>
30+
<td>@forecast.Date.ToShortDateString()</td>
31+
<td>@forecast.TemperatureC</td>
32+
<td>@forecast.TemperatureF</td>
33+
<td>@forecast.Summary</td>
34+
</tr>
35+
}
36+
</tbody>
37+
</table>
38+
}
39+
40+
@code {
41+
private WeatherForecast[]? forecasts;
42+
43+
protected override async Task OnInitializedAsync()
44+
{
45+
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("WeatherForecast");
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,88 @@
1-
@page "/"
2-
@using System.Dynamic;
3-
4-
<SfGrid DataSource="@Orders">
5-
<GridColumns>
6-
<GridColumn Field="OrderID"
7-
HeaderText="Order ID"
8-
TextAlign="TextAlign.Right"
9-
Width="120">
10-
</GridColumn>
11-
<GridColumn Field="CustomerID"
12-
HeaderText="Customer Name"
13-
Width="150">
14-
</GridColumn>
15-
<GridColumn Field="OrderDate"
16-
HeaderText=" Order Date"
17-
EditType="EditType.DatePickerEdit"
18-
TextAlign="TextAlign.Right"
19-
Format="d"
20-
Type="ColumnType.Date"
21-
Width="130">
22-
</GridColumn>
23-
<GridColumn Field="Freight"
24-
HeaderText="Freight"
25-
Format="C2"
26-
TextAlign="TextAlign.Right"
27-
Width="120">
28-
</GridColumn>
29-
</GridColumns>
30-
</SfGrid>
31-
32-
@code{
33-
public List<OrderDetails> Orders { get; set; } = new List<OrderDetails>();
34-
35-
protected override void OnInitialized()
36-
{
37-
Orders = Enumerable.Range(1, 12).Select((x) =>
38-
{
39-
dynamic dynamicObj = new OrderDetails();
40-
dynamicObj.OrderID = 1000 + x;
41-
dynamicObj.CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })
42-
[new Random().Next(5)];
43-
dynamicObj.Freight = 2.1 * x;
44-
dynamicObj.OrderDate = DateTime.Now.AddDays(-x);
45-
return dynamicObj;
46-
}).Cast<OrderDetails>().ToList<OrderDetails>();
47-
}
48-
49-
public class OrderDetails : DynamicObject
50-
{
51-
Dictionary<string, object> OrdersDictionary = new Dictionary<string, object>();
52-
53-
public override bool TryGetMember(GetMemberBinder binder, out object result)
54-
{
55-
string name = binder.Name;
56-
return OrdersDictionary.TryGetValue(name, out result);
57-
}
58-
59-
public override bool TrySetMember(SetMemberBinder binder, object value)
60-
{
61-
OrdersDictionary[binder.Name] = value;
62-
return true;
63-
}
64-
65-
public override IEnumerable<string> GetDynamicMemberNames()
66-
{
67-
return this.OrdersDictionary?.Keys;
68-
}
69-
70-
//Expando Object Binding
71-
//public List<ExpandoObject> Orders { get; set; } = new List<ExpandoObject>();
72-
73-
//protected override void OnInitialized()
74-
//{
75-
// Orders = Enumerable.Range(1, 12).Select((x) =>
76-
// {
77-
// dynamic dynamicObj = new ExpandoObject();
78-
// dynamicObj.OrderID = 1000 + x;
79-
// dynamicObj.CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })
80-
// [new Random().Next(5)];
81-
// dynamicObj.Freight = 2.1 * x;
82-
// dynamicObj.OrderDate = DateTime.Now.AddDays(-x);
83-
// return dynamicObj;
84-
// }).Cast<ExpandoObject>().ToList<ExpandoObject>();
85-
//}
86-
}
87-
}
88-
1+
@page "/"
2+
@using System.Dynamic;
3+
4+
<SfGrid DataSource="@Orders">
5+
<GridColumns>
6+
<GridColumn Field="OrderID"
7+
HeaderText="Order ID"
8+
TextAlign="TextAlign.Right"
9+
Width="120">
10+
</GridColumn>
11+
<GridColumn Field="CustomerID"
12+
HeaderText="Customer Name"
13+
Width="150">
14+
</GridColumn>
15+
<GridColumn Field="OrderDate"
16+
HeaderText=" Order Date"
17+
EditType="EditType.DatePickerEdit"
18+
TextAlign="TextAlign.Right"
19+
Format="d"
20+
Type="ColumnType.Date"
21+
Width="130">
22+
</GridColumn>
23+
<GridColumn Field="Freight"
24+
HeaderText="Freight"
25+
Format="C2"
26+
TextAlign="TextAlign.Right"
27+
Width="120">
28+
</GridColumn>
29+
</GridColumns>
30+
</SfGrid>
31+
32+
@code {
33+
public List<OrderDetails> Orders { get; set; } = new List<OrderDetails>();
34+
35+
protected override void OnInitialized()
36+
{
37+
Orders = Enumerable.Range(1, 12).Select((x) =>
38+
{
39+
dynamic dynamicObj = new OrderDetails();
40+
dynamicObj.OrderID = 1000 + x;
41+
dynamicObj.CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })
42+
[new Random().Next(5)];
43+
dynamicObj.Freight = 2.1 * x;
44+
dynamicObj.OrderDate = DateTime.Now.AddDays(-x);
45+
return dynamicObj;
46+
}).Cast<OrderDetails>().ToList<OrderDetails>();
47+
}
48+
49+
public class OrderDetails : DynamicObject
50+
{
51+
Dictionary<string, object> OrdersDictionary = new Dictionary<string, object>();
52+
53+
public override bool TryGetMember(GetMemberBinder binder, out object result)
54+
{
55+
string name = binder.Name;
56+
return OrdersDictionary.TryGetValue(name, out result);
57+
}
58+
59+
public override bool TrySetMember(SetMemberBinder binder, object value)
60+
{
61+
OrdersDictionary[binder.Name] = value;
62+
return true;
63+
}
64+
65+
public override IEnumerable<string> GetDynamicMemberNames()
66+
{
67+
return this.OrdersDictionary?.Keys;
68+
}
69+
70+
//Expando Object Binding
71+
//public List<ExpandoObject> Orders { get; set; } = new List<ExpandoObject>();
72+
73+
//protected override void OnInitialized()
74+
//{
75+
// Orders = Enumerable.Range(1, 12).Select((x) =>
76+
// {
77+
// dynamic dynamicObj = new ExpandoObject();
78+
// dynamicObj.OrderID = 1000 + x;
79+
// dynamicObj.CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })
80+
// [new Random().Next(5)];
81+
// dynamicObj.Freight = 2.1 * x;
82+
// dynamicObj.OrderDate = DateTime.Now.AddDays(-x);
83+
// return dynamicObj;
84+
// }).Cast<ExpandoObject>().ToList<ExpandoObject>();
85+
//}
86+
}
87+
}
88+

Client/Program.cs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using ExpandoDynamicObject.Client;
2+
using Microsoft.AspNetCore.Components.Web;
3+
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
4+
using Syncfusion.Blazor;
5+
6+
var builder = WebAssemblyHostBuilder.CreateDefault(args);
7+
builder.RootComponents.Add<App>("#app");
8+
builder.RootComponents.Add<HeadOutlet>("head::after");
9+
10+
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
11+
builder.Services.AddSyncfusionBlazor();
12+
await builder.Build().RunAsync();

0 commit comments

Comments
 (0)