Reface.AppStarter 0.5.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Reface.AppStarter --version 0.5.2
NuGet\Install-Package Reface.AppStarter -Version 0.5.2
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="Reface.AppStarter" Version="0.5.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Reface.AppStarter --version 0.5.2
#r "nuget: Reface.AppStarter, 0.5.2"
#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 Reface.AppStarter as a Cake Addin
#addin nuget:?package=Reface.AppStarter&version=0.5.2

// Install Reface.AppStarter as a Cake Tool
#tool nuget:?package=Reface.AppStarter&version=0.5.2

摘要

这是一个用来快速初始化系统依赖模块的启动器。 通过在启动项中 Use 模块,再在模块中 Use 子模块的方式,将整个应用系统中的各种组件和配置初始化。

背景

Autofac 已经成为了大部分应用系统在开发时作为容器的标配了,可是系统往往由很多 Library 组成,要在系统启动时,向 Autofac 容器中注册所有 Library 的组件将意味着,启动项需要引用几乎所有的库。 这明显是不合理的,假定启动项目是 WebApi ,那它只需要知道 Service 在哪儿就行了,至于数据层什么的,那是 Service层 的事了。

AppStarter 就是为了解决将所有的配置都集中在启动项配置的问题。

解决方案

主要成员

ApplicationEnvironment

该类是应用程序环境,在运行时可以使用它访问应用程序的一些参数

ApplicationEnvironmentSetup

ApplicationEnvironment 安装类,在系统启动阶段,使用它来安装应用程序的环境,是一个非常重要的成员

BaseApplicationStarter

应用程序启动类,通过接受一个 ApplicationEnvironmentSetup 实例进行系统的启动,每个应用系统都应当实现一个该类型,并重写它的 OnStarting 方法,在该方法中,可以通过使用 applicationEnvironmentSetup.Use(Module) 的方法来加载启动项所依赖的其它模块

BaseModuleStarter

模块启动基础类,每个 模块 / 中都应当有一个该类的子类,用于定义了如何启动当前的库,和 BaseApplicationStarter 一样,在有需要时可以通过重写 Start 方法进行一些额外的初始化

ComponentAttribute

这个可以算是最重要的一个特征,被加了该特征的类,会在模块对应的 Starter 被 Use 时,自动以接口作为服务注册到 Autofac 容器中去。

Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on Reface.AppStarter:

Package Downloads
Reface.AppStarter.Proxy

基于 Reface.AppStarter 的模块,允许用户简单的创建类或接口的代理类,实现 AOP 、动态实现等功能

Reface.AppStarter.WebApi

启动 WebApi 项目

Reface.AppStarter.NPI

作为 Reface.AppStarter 实现的 NPI 核心功能

Reface.AppStarter.UnitTests

基于 Reface.AppStarter 单元测试

Reface.EventBus.Starter

启动事件总线

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.26.2 1,034 7/14/2020
2.1.26.1 444 7/13/2020
2.1.25.1 500 7/13/2020
2.1.20 471 6/27/2020
2.1.11 567 6/15/2020
2.1.7 776 6/9/2020
2.1.6 608 6/4/2020
2.0.5 437 4/26/2020
2.0.4 967 4/21/2020
2.0.3 688 4/21/2020
1.7.2 424 4/16/2020
1.7.1 408 4/16/2020
1.7.0 468 4/12/2020
1.6.0 805 4/9/2020
1.5.1 644 4/1/2020
1.5.0 862 3/31/2020
1.2.1 998 3/28/2020
1.2.0-beta.1 371 3/26/2020
1.1.0 1,117 3/23/2020
0.13.0-alpha1 347 9/4/2019
0.12.0 484 9/3/2019
0.5.2 931 5/10/2019

+ 模块添加应用程序启动事后的执行点
       + 应用程序环境添加运行时的 Properties 属性
       + IModule 中加了一些钩子可以进行二次扩展 [x]
       + 优化了对 Module 钩子的实现方法