A lightweight plugin framework.
Setup infrastructures and plugin-loader in host application
// project: host applicationvarroot=awaitRootBuilder.Boot().Infrastructures((registry,config)=>registry.AddSingleton(...)).UseLoader<AssemblyPluginLoader>()// load plugins from $cwd/plugins, each plugin in a separate folder.UseLoader<TypedPluginLoader>()// use TypedPluginLoader.Register<TPlugin>() to register plugin type.UseLoader<CustomLoader>()// support custom plugin loader.Build();awaitroot.RunAsync(cancellationToken);Setup plugins
// project: plugin// Register your services into denpendency inject containerclassMyPlugin:IPlugin{publicValueTask<IServiceCollection>BuildComponents(CancellationTokencancellationToken=default){varserviceCollection=newServiceCollection();serviceCollection.AddSingleton<MyService>();serviceCollection.AddSingleton<MyServiceConfigurer,IComponentInitializer>();returnserviceCollection;}}// Initialize your servicesclassMyServiceInitializer(MyServicemyService, ...):IComponentInitializer{publicasyncValueTaskInitializeAsync(CancellationTokencancellationToken=default){awaitmyService.Connect(...);}
...}// Run your service!classRunningJob(MyServicemyService):IExecutable{publicasyncValueTaskRunAsync(CancellationTokencancellationToken=default){awaitmyService.ListenAsync(8080,cancenllationToken);}}