Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit c09c826

Browse files
authored
Unseal lifecycle methods on MvvmComponentBase (#50)
* unsealed lifecycle methods on componentbase
1 parent 3bdf08a commit c09c826

File tree

31 files changed

+276
-323
lines changed

31 files changed

+276
-323
lines changed

samples/BlazorClientsideSample.Client/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
using BlazorClientsideSample.Client.Services;
1+
using System;
2+
using System.Net.Http;
3+
using System.Threading.Tasks;
4+
using BlazorClientsideSample.Client.Services;
25
using BlazorSample.Components.Extensions;
36
using BlazorSample.Domain.Extensions;
47
using BlazorSample.Domain.Services;
58
using BlazorSample.ViewModels.Extensions;
69
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
710
using Microsoft.Extensions.DependencyInjection;
811
using MvvmBlazor.Extensions;
9-
using System;
10-
using System.Net.Http;
11-
using System.Threading.Tasks;
1212

1313
namespace BlazorClientsideSample.Client
1414
{

samples/BlazorClientsideSample.Client/Services/WeatherForecastGetter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
using System.Threading.Tasks;
55
using BlazorSample.Domain.Entities;
66
using BlazorSample.Domain.Services;
7-
using Microsoft.AspNetCore.Components;
87

98
namespace BlazorClientsideSample.Client.Services
109
{
11-
public class WeatherForecastGetter: IWeatherForecastGetter
10+
public class WeatherForecastGetter : IWeatherForecastGetter
1211
{
1312
private readonly HttpClient _httpClient;
1413

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta charset="utf-8" />
5-
<meta name="viewport" content="width=device-width" />
4+
<meta charset="utf-8"/>
5+
<meta name="viewport" content="width=device-width"/>
66
<title>BlazorSample</title>
7-
<base href="/" />
8-
<link href="_content/BlazorSample.Components/site.css" rel="stylesheet" />
7+
<base href="/"/>
8+
<link href="_content/BlazorSample.Components/site.css" rel="stylesheet"/>
99
<script src="_content/MatBlazor/dist/matBlazor.js"></script>
10-
<link href="_content/MatBlazor/dist/matBlazor.css" rel="stylesheet" />
10+
<link href="_content/MatBlazor/dist/matBlazor.css" rel="stylesheet"/>
1111
</head>
1212
<body>
1313
<div id="app">Loading...</div>
1414

15-
<script src="_framework/blazor.webassembly.js"></script>
15+
<script src="_framework/blazor.webassembly.js"></script>
1616
</body>
1717
</html>

samples/BlazorSample.Components/Extensions/ServiceCollectionExtensions.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
using Microsoft.Extensions.DependencyInjection;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Net.Http;
5-
using System.Text;
6-
using BlazorSample.Components.Pages;
1+
using BlazorSample.Components.Pages;
72
using BlazorSample.Domain.Extensions;
83
using MatBlazor;
9-
using Index = BlazorSample.Components.Pages.Index;
4+
using Microsoft.Extensions.DependencyInjection;
105

116
namespace BlazorSample.Components.Extensions
127
{
@@ -23,4 +18,4 @@ public static IServiceCollection AddComponents(this IServiceCollection serviceCo
2318
return serviceCollection;
2419
}
2520
}
26-
}
21+
}

samples/BlazorSample.Components/Pages/Clock.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<MatBody2>
1616
This component demonstrates updating from a background task without user interaction.
1717
</MatBody2>
18-
<br />
18+
<br/>
1919
<MatBody2>
2020
Current time: @Bind(x => x.DateTime)
2121
</MatBody2>

samples/BlazorSample.Components/Pages/Counter.razor

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
</MatSubtitle1>
1111
</MatCardContent>
1212
</MatCard>
13-
<br />
13+
<br/>
1414

1515

1616
<MatBody2>Current count: @Bind(x => x.CurrentCount)</MatBody2>
1717

1818
<MatButton OnClick="@BindingContext.IncrementCount" Raised="true">Click me</MatButton>
1919

20-
<br />
21-
<br />
22-
<br />
20+
<br/>
21+
<br/>
22+
<br/>
2323

2424
<MatCard>
2525
<MatCardContent>
@@ -29,6 +29,6 @@
2929
</MatSubtitle1>
3030
</MatCardContent>
3131
</MatCard>
32-
<br />
32+
<br/>
3333

3434
<MatBody2>Current time: @Bind(ClockViewModel, x => x.DateTime)</MatBody2>

samples/BlazorSample.Components/Pages/Parameters.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
</MatSubtitle1>
1212
</MatCardContent>
1313
</MatCard>
14-
<br />
14+
<br/>
1515

1616
<MatBody2>My Name is @Bind(x => x.Name)</MatBody2>
17-
<br />
17+
<br/>
1818

1919
<MatTextField @bind-Value="@BindingContext.NewName" Label="New name"></MatTextField>
2020
<MatButton OnClick="@BindingContext.NavigateToNewName" Raised="true">Navigate</MatButton>

samples/BlazorSample.Components/Pages/WeatherForecasts.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
</MatSubtitle1>
1313
</MatCardContent>
1414
</MatCard>
15-
<br />
15+
<br/>
1616

1717
<MatCard>
1818
<MatCardContent>
1919
<MatSubtitle1>
2020
In list scenarios you often nest view models to achieve bindings on the list items. This is especially needed when the data of the item changes.
21-
You can click the randomize button and see that the list gets updated.
21+
You can click the randomize button and see that the list gets updated.
2222
</MatSubtitle1>
2323
</MatCardContent>
2424
</MatCard>
25-
<br />
25+
<br/>
2626

2727
@if (Bind(x => x.Forecasts) == null)
2828
{

samples/BlazorSample.Components/Shared/Navbar.razor

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
<MatNavMenu>
66
@foreach (var item in Bind(x => x.NavbarItems))
77
{
8-
<MatNavItem Href="@item.Template" Selected="@Bind(item, x => x.IsActive)">
9-
@if (!string.IsNullOrEmpty(item.Icon))
10-
{
11-
<MatIcon Icon="@item.Icon" class="icon"></MatIcon>
12-
}
8+
<MatNavItem Href="@item.Template" Selected="@Bind(item, x => x.IsActive)">
9+
@if (!string.IsNullOrEmpty(item.Icon))
10+
{
11+
<MatIcon Icon="@item.Icon" class="icon"></MatIcon>
12+
}
1313

14-
@item.DisplayName
15-
</MatNavItem>
14+
@item.DisplayName
15+
</MatNavItem>
1616
}
1717
</MatNavMenu>
1818
</MatDrawer>

samples/BlazorSample.Components/wwwroot/site.css

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -16,79 +16,57 @@ article, aside, canvas, details, embed,
1616
figure, figcaption, footer, header, hgroup,
1717
main, menu, nav, output, ruby, section, summary,
1818
time, mark, audio, video {
19-
margin: 0;
20-
padding: 0;
2119
border: 0;
22-
font-size: 100%;
2320
font: inherit;
21+
font-size: 100%;
22+
margin: 0;
23+
padding: 0;
2424
vertical-align: baseline;
2525
}
26+
2627
/* HTML5 display-role reset for older browsers */
28+
2729
article, aside, details, figcaption, figure,
28-
footer, header, hgroup, main, menu, nav, section {
29-
display: block;
30-
}
30+
footer, header, hgroup, main, menu, nav, section { display: block; }
31+
3132
/* HTML5 hidden-attribute fix for newer browsers */
32-
*[hidden] {
33-
display: none;
34-
}
3533

36-
body {
37-
line-height: 1;
38-
}
34+
*[hidden] { display: none; }
3935

40-
ol, ul {
41-
list-style: none;
42-
}
36+
body { line-height: 1; }
4337

44-
blockquote, q {
45-
quotes: none;
46-
}
38+
ol, ul { list-style: none; }
4739

48-
blockquote:before, blockquote:after,
49-
q:before, q:after {
50-
content: '';
51-
content: none;
52-
}
40+
blockquote, q { quotes: none; }
41+
42+
blockquote:before, blockquote:after,
43+
q:before, q:after {
44+
content: '';
45+
content: none;
46+
}
5347

5448
table {
5549
border-collapse: collapse;
5650
border-spacing: 0;
5751
}
5852

59-
html, body, app {
60-
height: 100%;
61-
}
53+
html, body, app { height: 100%; }
6254

63-
.mdc-text-field {
64-
width: 100% !important;
65-
}
55+
.mdc-text-field { width: 100% !important; }
6656

67-
.mdc-card__primary-action {
68-
padding: 0.5rem;
69-
}
57+
.mdc-card__primary-action { padding: 0.5rem; }
7058

7159
.navbar {
72-
width: 100vw;
7360
height: 100vh;
61+
width: 100vw;
7462
}
7563

76-
.navbar .left-sidebar {
77-
user-select: none;
78-
}
64+
.navbar .left-sidebar { user-select: none; }
7965

80-
.navbar .icon {
81-
margin-right: 0.5rem;
82-
}
66+
.navbar .icon { margin-right: 0.5rem; }
8367

84-
.navbar .content-container {
85-
margin: 1rem;
86-
}
68+
.navbar .content-container { margin: 1rem; }
8769

88-
.navbar aside:focus {
89-
outline: none;
90-
}
70+
.navbar aside:focus { outline: none; }
9171

92-
.navbar .mdc-drawer__content:focus {
93-
outline: none;
94-
}
72+
.navbar .mdc-drawer__content:focus { outline: none; }

0 commit comments

Comments
 (0)