Skip to content

Repository files navigation

Riven.Modular

Riven.Modular is the base library for a modular implementation.You can use it to create modular applications.

LICENSES

GitHubBadgeLICENSE

Please note: once the use of the open source projects as well as the reference for the project or containing the project code for violating labor laws (including but not limited the illegal layoffs, overtime labor, child labor, etc.) in any legal action against the project, the author has the right to punish the project fee, or directly are not allowed to use any contains the source code of this project!

Build Status

Build Status

Nuget Packages

PackageStatusDownloads
Riven.ModularNuGet versionNuget

Quick start

(1)创建一个控制台项目

(2)安装nuget包

Install-Package Riven.Modular

(3)创建一个模块

usingRiven;usingRiven.Modular;[DependsOn(typeof(依赖的其它模块)))]publicclassMyAppStartupModule:AppModule{publicoverridevoidOnPreConfigureServices(ServiceConfigurationContextcontext){// 注册服务之前}publicoverridevoidOnConfigureServices(ServiceConfigurationContextcontext){// 注册服务}publicoverridevoidOnPostConfigureServices(ServiceConfigurationContextcontext){// 注册服务之后}publicoverridevoidOnPreApplicationInitialization(ApplicationInitializationContextcontext){// 应用初始化之前}publicoverridevoidOnApplicationInitialization(ApplicationInitializationContextcontext){// 应用初始化}publicoverridevoidOnPostApplicationInitialization(ApplicationInitializationContextcontext){// 应用初始化之后}publicoverridevoidOnApplicationShutdown(ApplicationShutdownContextcontext){// 应用停止}}

(4)在 asp.net core 应用程序中使用

usingMicrosoft.Extensions.Configuration;usingMicrosoft.Extensions.DependencyInjection;usingMicrosoft.Extensions.DependencyInjection.Extensions;usingRiven;publicclassStartup{publicIConfigurationConfiguration{get;}publicStartup(IConfigurationconfiguration){Configuration=configuration;}publicvoidConfigureServices(IServiceCollectionservices){services.AddRivenModule<MyAppStartupModule>(Configuration,(options)=>{// 加载模块插件//var rootPath = Path.GetDirectoryName(typeof(Program).Assembly.Location);//// 目录插件源//options.PlugInSources.Add(// new FolderPlugInSource(Path.Join(rootPath, "plugins", "netstandard2.0"))// );////// 文件插件源//options.PlugInSources.Add(// new FilePlugInSource(Path.Join(rootPath, "plugins", "netstandard2.0", "PluginA.dll"))// );////// 类型插件源//options.PlugInSources.Add(// new TypePlugInSource(typeof(TestModuleC))// );});}publicvoidConfigure(IApplicationBuilderapp,IWebHostEnvironmentenv){app.ApplicationServices.UseRivenModule();}}

(5)在控制台或其它应用程序启动

usingMicrosoft.Extensions.Configuration;usingMicrosoft.Extensions.DependencyInjection;usingMicrosoft.Extensions.DependencyInjection.Extensions;usingRiven;publicclassProgram{publicstaticvoidMain(string[]args){IConfigurationConfiguration=null;// 你应用的配置IServiceCollectionservices=newServiceCollection();services.AddSingleton<IConfiguration>(Configuration);services.AddRivenModule<MyAppStartupModule>(Configuration,(options)=>{// 加载模块插件//var rootPath = Path.GetDirectoryName(typeof(Program).Assembly.Location);//// 目录插件源//options.PlugInSources.Add(// new FolderPlugInSource(Path.Join(rootPath, "plugins", "netstandard2.0"))// );////// 文件插件源//options.PlugInSources.Add(// new FilePlugInSource(Path.Join(rootPath, "plugins", "netstandard2.0", "PluginA.dll"))// );////// 类型插件源//options.PlugInSources.Add(// new TypePlugInSource(typeof(TestModuleC))// );});IServiceProviderserviceProvider=services.BuildServiceProvider();serviceProvider.UseRivenModule();}}

(6)启动

Demos

AspNetCore App Demo: link

Console App Demo: link

Q&A

If you have any questions, you can go to Issues to ask them.

Reference project

This project directly or indirectly refers to the following items

Stargazers over time

Stargazers over time

About

A base library for modular implementations.You can use it to create modular applications.

Resources

Stars

33 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages