-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #378 from runceel/main
Release v8.1.0
- Loading branch information
Showing
111 changed files
with
3,532 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
Samples/Blazor/BlazorSample.Shared/BlazorSample.Shared.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<SupportedPlatform Include="browser" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.4" /> | ||
<PackageReference Include="System.Reactive" Version="5.0.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\Source\ReactiveProperty.Platform.Blazor\ReactiveProperty.Platform.Blazor.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
@using Reactive.Bindings | ||
@using Reactive.Bindings.Extensions | ||
@using Reactive.Bindings.Components | ||
@using System.Reactive.Linq | ||
@using System.Reactive.Disposables | ||
@using System.Reactive.Concurrency | ||
@page "/" | ||
@implements IDisposable | ||
@inject ValidationViewModel _validationViewModel | ||
@inject HelloWorldViewModel _helloWorldViewModel | ||
|
||
<h1>ReactiveProperty samples</h1> | ||
|
||
<h3>Hello world</h3> | ||
|
||
<input class="form-control" type="text" @bind="_helloWorldViewModel.Input.Value" @bind:event="oninput" /> | ||
<div class="alert alert-primary"> | ||
@_helloWorldViewModel.Output.Value | ||
</div> | ||
|
||
<h3>Validation sample</h3> | ||
|
||
<EditForm Model="_validationViewModel" OnInvalidSubmit="InvalidSubmit" OnValidSubmit="ValidSubmit"> | ||
<ReactivePropertiesValidator /> | ||
|
||
<ValidationSummary /> | ||
|
||
<div class="mb-3"> | ||
<label for="firstName">First name</label> | ||
<InputText @bind-Value="_validationViewModel.FirstName.Value" class="form-control" /> | ||
<ValidationMessage For="() => _validationViewModel.FirstName.Value" /> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="firstName">Last name</label> | ||
<InputText @bind-Value="_validationViewModel.LastName.Value" class="form-control" /> | ||
<ValidationMessage For="() => _validationViewModel.LastName.Value" /> | ||
</div> | ||
|
||
<div class="mb-3"> | ||
<span>Full name: @_validationViewModel.FullName.Value</span> | ||
</div> | ||
|
||
<button type="submit" class="btn btn-primary">Submit</button> | ||
</EditForm> | ||
|
||
@if (!string.IsNullOrEmpty(_message)) | ||
{ | ||
<div class="alert alert-primary"> | ||
<span>@_message</span> | ||
</div> | ||
} | ||
|
||
@code { | ||
private readonly CompositeDisposable _disposable = new(); | ||
private string? _message; | ||
|
||
private void InvalidSubmit(EditContext context) | ||
{ | ||
_message = "InvalidSubmit was invoked."; | ||
} | ||
|
||
private void ValidSubmit(EditContext context) | ||
{ | ||
_message = "ValidSubmit was invoked."; | ||
} | ||
|
||
protected override void OnInitialized() | ||
{ | ||
_validationViewModel.AddTo(_disposable); | ||
_helloWorldViewModel.AddTo(_disposable); | ||
|
||
_helloWorldViewModel.Output | ||
.Subscribe(_ => InvokeAsync(StateHasChanged)) | ||
.AddTo(_disposable); | ||
} | ||
|
||
public void Dispose() => _disposable.Dispose(); | ||
} |
26 changes: 26 additions & 0 deletions
26
Samples/Blazor/BlazorSample.Shared/ViewModels/HelloWorldViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Reactive.Disposables; | ||
using System.Reactive.Linq; | ||
using Reactive.Bindings; | ||
using Reactive.Bindings.Extensions; | ||
|
||
namespace BlazorSample.Shared.ViewModels; | ||
|
||
public class HelloWorldViewModel : IDisposable | ||
{ | ||
private readonly CompositeDisposable _disposable = new(); | ||
|
||
public ReactivePropertySlim<string> Input { get; } | ||
public ReadOnlyReactivePropertySlim<string> Output { get; } | ||
|
||
public HelloWorldViewModel() | ||
{ | ||
Input = new ReactivePropertySlim<string>("") | ||
.AddTo(_disposable); | ||
Output = Input | ||
.Select(x => x.ToUpperInvariant()) | ||
.ToReadOnlyReactivePropertySlim("") | ||
.AddTo(_disposable); | ||
} | ||
|
||
public void Dispose() => _disposable.Dispose(); | ||
} |
37 changes: 37 additions & 0 deletions
37
Samples/Blazor/BlazorSample.Shared/ViewModels/ValidationViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Reactive.Disposables; | ||
using System.Reactive.Linq; | ||
using Reactive.Bindings; | ||
using Reactive.Bindings.Extensions; | ||
|
||
namespace BlazorSample.Shared.ViewModels; | ||
|
||
public class ValidationViewModel : IDisposable | ||
{ | ||
private readonly CompositeDisposable _disposables = new(); | ||
|
||
[Required(ErrorMessage = "First name is required.")] | ||
[StringLength(10, ErrorMessage = "First name is under 10 letters.")] | ||
public ReactiveProperty<string> FirstName { get; } | ||
[Required(ErrorMessage = "Last name is required.")] | ||
[StringLength(10, ErrorMessage = "Last name is under 10 letters.")] | ||
public ReactiveProperty<string> LastName { get; } | ||
public ReadOnlyReactivePropertySlim<string> FullName { get; } | ||
|
||
public ValidationViewModel() | ||
{ | ||
var reactivePropertyMode = ReactivePropertyMode.Default | ReactivePropertyMode.IgnoreInitialValidationError; | ||
FirstName = new ReactiveProperty<string>("", mode: reactivePropertyMode) | ||
.SetValidateAttribute(() => FirstName) | ||
.AddTo(_disposables); | ||
LastName = new ReactiveProperty<string>("", mode: reactivePropertyMode) | ||
.SetValidateAttribute(() => LastName) | ||
.AddTo(_disposables); | ||
|
||
FullName = Observable.CombineLatest(new[] { FirstName, LastName }, x => $"{x[0]} {x[1]}") | ||
.ToReadOnlyReactivePropertySlim("") | ||
.AddTo(_disposables); | ||
} | ||
|
||
public void Dispose() => _disposables.Dispose(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@using System.Net.Http | ||
@using System.Net.Http.Json | ||
@using Microsoft.AspNetCore.Components.Forms | ||
@using Microsoft.AspNetCore.Components.Routing | ||
@using Microsoft.AspNetCore.Components.Web | ||
@using Microsoft.AspNetCore.Components.Web.Virtualization | ||
@using BlazorSample.Shared | ||
@using BlazorSample.Shared.ViewModels |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@using BlazorSample.Shared.ViewModels | ||
<Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="@(new[]{ typeof(ValidationViewModel).Assembly })"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> | ||
<FocusOnNavigate RouteData="@routeData" Selector="h1" /> | ||
</Found> | ||
<NotFound> | ||
<PageTitle>Not found</PageTitle> | ||
<LayoutView Layout="@typeof(MainLayout)"> | ||
<p role="alert">Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\BlazorSample.Shared\BlazorSample.Shared.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace BlazorServerApp.Data | ||
{ | ||
public class WeatherForecast | ||
{ | ||
public DateTime Date { get; set; } | ||
|
||
public int TemperatureC { get; set; } | ||
|
||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); | ||
|
||
public string? Summary { get; set; } | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Samples/Blazor/BlazorServerApp/Data/WeatherForecastService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace BlazorServerApp.Data | ||
{ | ||
public class WeatherForecastService | ||
{ | ||
private static readonly string[] Summaries = new[] | ||
{ | ||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" | ||
}; | ||
|
||
public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate) | ||
{ | ||
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast | ||
{ | ||
Date = startDate.AddDays(index), | ||
TemperatureC = Random.Shared.Next(-20, 55), | ||
Summary = Summaries[Random.Shared.Next(Summaries.Length)] | ||
}).ToArray()); | ||
} | ||
} | ||
} |
Oops, something went wrong.