TradeWindsBlazor 1.0.0
dotnet add package TradeWindsBlazor --version 1.0.0
NuGet\Install-Package TradeWindsBlazor -Version 1.0.0
<PackageReference Include="TradeWindsBlazor" Version="1.0.0" />
paket add TradeWindsBlazor --version 1.0.0
#r "nuget: TradeWindsBlazor, 1.0.0"
// Install TradeWindsBlazor as a Cake Addin #addin nuget:?package=TradeWindsBlazor&version=1.0.0 // Install TradeWindsBlazor as a Cake Tool #tool nuget:?package=TradeWindsBlazor&version=1.0.0
<img align="left" width="200" src="server_client.png"/>
TradeWindsBlazor
These are some classes I created for my Blazor application.
I will add to this when I identify additional components in my apps that might be of general use.
This is under the MIT license. If you find this useful I ask (not a requirement) that you consider reading my book I DON’T KNOW WHAT I’M DOING!: How a Programmer Became a Successful Startup CEO.
And if you like it, please review it on Amazon and/or GoodReads. The number of legitimate reviews helps a lot. Much appreciated.
ExComponentBase
ExComponentBase.cs is included as an example, not to be used directly. That's why it is internal
instead of public
. I do recommend you copy this over to your application, extend it, and use it instead of ComponentBase
for your components.
To use the ScoppedLoggerEx, you must have the following in your component:
[Inject]
private ScopedLoggerFactoryEx ScopedLoggerFactoryEx { get; set; } = default!;
protected ScopedLoggerEx LoggerEx { get; set; } = default!;
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
LoggerEx = await ScopedLoggerFactoryEx.GetLogger(GetType());
}
ExPageBase
I also recommend you create the class ExPageBase, that is a subclass of ExComponentBase. Use this as your base class for any pages. In this class, add the following:
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
if (LoggerEx.IsEnabled(LogLevel.Trace))
LoggerEx.LogTrace($"Entering {GetType().Name}.OnInitializedAsync(), IsPreRender={IsPreRender}");
}
ILogger
After you have added the above to your ComponentBase
, you now have the member variable LoggerEx
that is an ILogger
for your component. And it is scoped to the component adding username and aspNetId as scopes for all logging by the logger.
Inject everything
I strongly recommend that you add an [Inject]
for every service you use in any component to your ExComponentBase
. And the same for every [CascadingParameter]
. Saves you a lot of copy/paste to each new component.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.Components.Authorization (>= 8.0.8)
- Microsoft.AspNetCore.Http (>= 2.1.34)
- Microsoft.Extensions.Logging (>= 8.0.0)
- System.Text.Encodings.Web (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 87 | 10/4/2024 |