Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update #218

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -13,20 +13,15 @@ public class WeatherForecastController : ControllerBase

private readonly ILogger<WeatherForecastController> _logger;

public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
public WeatherForecastController(ILogger<WeatherForecastController> logger) => _logger = logger;

[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
=> Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
Original file line number Diff line number Diff line change
@@ -13,20 +13,15 @@ public class WeatherForecastController : ControllerBase

private readonly ILogger<WeatherForecastController> _logger;

public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
public WeatherForecastController(ILogger<WeatherForecastController> logger) => _logger = logger;

[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
=> Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
17 changes: 4 additions & 13 deletions 3_Web/ASPNETCore/WebSampleApp/CustomHealthCheck.cs
Original file line number Diff line number Diff line change
@@ -4,20 +4,11 @@

namespace WebSampleApp;

public class CustomHealthCheck : IHealthCheck
public class CustomHealthCheck(HealthSample healthSample) : IHealthCheck
{
private readonly HealthSample _healthSample;
public CustomHealthCheck(HealthSample healthSample) => _healthSample = healthSample;
private readonly HealthSample _healthSample = healthSample;

public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
if (_healthSample.IsHealthy)
{
return Task.FromResult(HealthCheckResult.Healthy("healthy"));
}
else
{
return Task.FromResult(HealthCheckResult.Unhealthy("unhealthy"));
}
}
=> _healthSample.IsHealthy ? Task.FromResult(HealthCheckResult.Healthy("healthy"))
: Task.FromResult(HealthCheckResult.Unhealthy("unhealthy"));
}
12 changes: 2 additions & 10 deletions 3_Web/ASPNETCore/WebSampleApp/CustomReadyCheck.cs
Original file line number Diff line number Diff line change
@@ -7,14 +7,6 @@ namespace WebSampleApp;
public class CustomReadyCheck(HealthSample healthSample) : IHealthCheck
{
public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
if (healthSample.IsReady)
{
return Task.FromResult(HealthCheckResult.Healthy("healthy"));
}
else
{
return Task.FromResult(HealthCheckResult.Unhealthy("unhealthy"));
}
}
=> healthSample.IsReady ? Task.FromResult(HealthCheckResult.Healthy("healthy"))
: Task.FromResult(HealthCheckResult.Unhealthy("unhealthy"));
}
5 changes: 1 addition & 4 deletions 3_Web/Blazor/Blazor.ComponentsSample/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -14,8 +14,5 @@
[Parameter]
public int Incrementor { get; set; } = 1;

private void IncrementCount()
{
currentCount += Incrementor;
}
private void IncrementCount() => currentCount += Incrementor;
}
Original file line number Diff line number Diff line change
@@ -11,8 +11,5 @@
[Parameter]
public int Incrementor { get; set; } = 1;

private void IncrementCount()
{
CounterService.Counter += Incrementor;
}
private void IncrementCount() => CounterService.Counter += Incrementor;
}
5 changes: 1 addition & 4 deletions 3_Web/Blazor/Blazor.ComponentsSample/Pages/Editor.razor
Original file line number Diff line number Diff line change
@@ -34,8 +34,5 @@
private BookEditModel bookEditModel = new();
private string validText = string.Empty;

private void HandleValidSubmit(EditContext context)
{
validText = "Input is valid, ready to send it to the server";
}
private void HandleValidSubmit(EditContext context) => validText = "Input is valid, ready to send it to the server";
}
6 changes: 2 additions & 4 deletions 3_Web/Blazor/Blazor.ComponentsSample/Pages/FetchData.razor
Original file line number Diff line number Diff line change
@@ -39,10 +39,8 @@ else
@code {
private WeatherForecast[]? forecasts;

protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
}
protected override async Task OnInitializedAsync()
=> forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");

public class WeatherForecast
{
Original file line number Diff line number Diff line change
@@ -8,12 +8,10 @@ public class WeatherForecastService
};

public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
{
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
=> 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());
}
}
5 changes: 1 addition & 4 deletions 3_Web/Blazor/Blazor.ServerSample/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -11,8 +11,5 @@
@code {
private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
private void IncrementCount() => currentCount++;
}
5 changes: 1 addition & 4 deletions 3_Web/Blazor/Blazor.ServerSample/Pages/FetchData.razor
Original file line number Diff line number Diff line change
@@ -41,8 +41,5 @@ else
@code {
private WeatherForecast[]? forecasts;

protected override async Task OnInitializedAsync()
{
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
}
protected override async Task OnInitializedAsync() => forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
}
5 changes: 1 addition & 4 deletions 3_Web/Blazor/Blazor.WasmSample/Client/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -11,8 +11,5 @@
@code {
private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
private void IncrementCount() => currentCount++;
}
6 changes: 2 additions & 4 deletions 3_Web/Blazor/Blazor.WasmSample/Client/Pages/FetchData.razor
Original file line number Diff line number Diff line change
@@ -40,8 +40,6 @@ else
@code {
private WeatherForecast[]? forecasts;

protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("WeatherForecast");
}
protected override async Task OnInitializedAsync()
=> forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("WeatherForecast");
}
Original file line number Diff line number Diff line change
@@ -14,20 +14,15 @@ public class WeatherForecastController : ControllerBase

private readonly ILogger<WeatherForecastController> _logger;

public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
public WeatherForecastController(ILogger<WeatherForecastController> logger) => _logger = logger;

[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
=> Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}