Fluxera.Extensions.Hosting
I am leaving GitHub. Follow me on Codeberg! -- A library that extends the Microsoft.Extensions.Hosting library with modular host implementations for various application platforms.
Install / Use
/learn @mgernand/Fluxera.Extensions.HostingREADME
I am leaving GitHub
Please follow me on Codeberg!
You can also find the sources of this repository there!
Onwards! ✊
Fluxera.Extensions.Hosting
A library that extends the Microsoft.Extensions.Hosting library with modular host implementations for various application platforms.
The library uses the generic host implementation and build a modular structure upon it. It is possible to split your application into login modules that can be shared between different types of applications.
Available Hosts
The modular host is available for the following applicattion types:
- ASP.NET Core
- Blazor WebAssembly
- Console / Windows Service
- WPF
- MAUI
Usage
Every application needs a host and a startup module class. The application is composed of modules that define dependencies on other modules and optional modules that are loaded as plugins.
public class ConsoleApplicationModule : ConfigureServicesModule
{
public override void ConfigureServices(IServiceConfigurationContext context)
{
context.Services.AddHostedService<ConsoleHostedService>();
context.Services.AddSingleton<IWeatherService, WeatherService>();
context.Services.AddOptions<WeatherSettings>().Bind(context.Configuration.GetSection("Weather"));
}
}
This startup module just configures some services and regiosters them in the service collection. The service confiuration pipelineis split up into three steps: pre-configure-, configure- and post-configure-services. Each methos is executed in every module, before moving to the next method.
If you need to configure the application after the creation of the service provider you can just
use the base class ConfigureApplicationModule which provides a similar three step
pipeline for initializing the application: pre-configure, configure and post-configure. Additionally
this base class provides a methos that is executed on every module when the application shuts down.
In addtition to the two base classes ConfigureServicesModule and ConfigureApplicationModule
you are free to use one of the module interfaces to meet you configuration needs.
- IModule
- IConfigureServicesModule
- IPreConfigureServices
- IConfigureServices
- IPostConfigureServices
- IConfigureApplicationModule
- IPreConfigureApplication
- IConfigureApplication
- IPostConfigureApplication
- IShutdownApplicationModule
- IConfigureServicesModule
You can even just implement the IModule interface on your module class, if you don't need any
configuration and application initialization.
public class ConsoleApplicationHost : ConsoleApplicationHost<ConsoleApplicationModule>
{
}
The simplest application host class just inherits from one of the available base classes for the application type you are running.
Each base class provides several methods you can overide to configure additional plugin modules, or a custom logger to use while bootstrapping the host. Please refer to the samples for more information.
public static class Program
{
public static async Task Main(string[] args)
{
await ApplicationHost.RunAsync<ConsoleApplicationHost>(args);
Console.WriteLine();
Console.WriteLine("Press any key to quit...");
Console.ReadKey(true);
}
}
All what's left to do is to run the host using one of the available static entry-points.
Related Skills
node-connect
349.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.7kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
