The package contains server side Blazor plugin extensions used by other CodeGator packages.
- Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions
- CG.Blazor.Plugins.Plugins.IModule
- CG.Blazor.Plugins.Plugins.ModuleBase
- CG.Blazor.Plugins.Options.BlazorPluginOptions
- CG.Blazor.Plugins.Options.BlazorModuleOptions
- .NET 6.x or higher
The binary is hosted on NuGet. To install the package using the NuGet package manager:
PM> Install-Package CG.Blazor.Plugins
If you've spotted a bug in the code please use the project Issues HERE
We have a discussion group HERE
There is developer documentation HERE
We also blog about projects like this one on our website, HERE
There is a working quick start sample HERE
Steps to add plugins to a Blazor project:
-
Create a Blazor project to suit your taste.
-
Add the CG.Blazor.Plugins NUGET package to the project.
-
Add the
@using CG.Blazor.Plugins
statement to the _Imports.razor file. -
Add the line:
services.AddBlazorPlugins(Configuration.GetSection("Plugins"));
to theConfigureServices
method of theStartup
class. -
Add the line:
app.UseBlazorPlugins(env);
to theConfigure
method of theStartup
class. -
Add the following to your appsettings.json file:
{
"Plugins": {
"Modules": [
{
"AssemblyNameOrPath": "YourPlugin",
"Routed": true // <- true if you have pages that need routing support.
}
]
}
}
Where you will, of course, use the name of your plugin assembly in place of YourPlugin
- Edit the App.razor file like so:
<Router AppAssembly="@typeof(Program).Assembly"
PreferExactMatches="@true"
[email protected]> // <-- this line
// code removed for clarity.
</Router>
The indicated line should be added, so the framework will route properly for the plugins.
- Edit the _Host.cshtml file like so:
8A. Add the @using CG.Blazor.Plugins
statement near the top of the file.
8B. Add the @(Html.Raw(BlazorResources.RenderStyleSheetLinks()))
statement at the bottom of the head
tag
8C. Add the @(Html.Raw(BlazorResources.RenderScriptTags()))
statement at the bottom of the body
tag.
- Create your plugin project and add a reference to that project to your Blazor project.
That's it! Of course, you could get fancier with things, if you like. But, this is enough to get started.
This package and it's contents are experimental in nature. There is no official support. Use at your own risk.