TradeWindsBlazor 1.0.0

dotnet add package TradeWindsBlazor --version 1.0.0                
NuGet\Install-Package TradeWindsBlazor -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TradeWindsBlazor" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TradeWindsBlazor --version 1.0.0                
#r "nuget: TradeWindsBlazor, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 94 10/4/2024