Baboon 2.0.0
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Framework 4.6.2
This package targets .NET Framework 4.6.2. The package is compatible with this framework or higher.
dotnet add package Baboon --version 2.0.0
NuGet\Install-Package Baboon -Version 2.0.0
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="Baboon" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Baboon --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Baboon, 2.0.0"
#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 Baboon as a Cake Addin #addin nuget:?package=Baboon&version=2.0.0 // Install Baboon as a Cake Tool #tool nuget:?package=Baboon&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Baboon项目总结
项目简介
Baboon是一个轻量级WPF插件化开发的基础库,内置了模块化加载、模块化日志记录、模块化本地存储、模块化IOC注册,以及开发Mvvm必要的Command和EventTrigger。
安装方法
通过nuget安装Baboon
:
Install-Package Baboon
使用说明
基础配置
安装完成后,需要在App.xaml
和.cs
中修改基类继承,同时在App.xaml.cs
中实现抽象类成员,包括注册容器和创建主窗口。
新建模块
- 创建项目与类:新建一个项目,命名为
SayHello.Module
,添加对Baboon
的引用,新建SayHelloModule
类,继承自AppModuleBase
或实现IAppModule
接口,并实现基本成员。 - 模块描述:
ModuleDescription
可以直接赋值,也可以通过xml文件定义。
模块注册
在App
中重写ConfigureModuleCatalog
方法来注册模块,注册方式有三种:
- 实例注册:直接将模块实例注册到主程序,会立刻加载模块,且主程序需要引用模块。
- 类型注册:将模块类型注册到主程序,会立刻加载模块,且主程序需要引用模块。
- 构建器注册:只注册模块信息,需要时自动加载模块,主程序不需要引用模块。
模块加载与使用
- 加载:模块加载是自动的,包括构建器注册的模块,会在需要时加载。
- 使用:从容器中获得
IModuleCatalog
,使用Contains(id)
方法判断模块是否已注册,通过TryGetAppModuleInfo
获取模块信息,根据appModuleInfo.Loaded
属性判断模块是否已加载到主程序,使用appModuleInfo.GetApp()
获取指定模块。
模块管理器
使用IModuleManagerService
服务可实现对模块的快速管理,包括安装、更新、卸载等。IModuleCatalog
会对存放在Modules
文件夹下的所有模块进行注册,但每个模块必须包含名为Description.xml
的文件。
模块日志
每个模块可以拥有单独的日志记录器,通过IAppModule.Logger
获得。
模块本地数据库
Baboon集成了LiteDB数据库,并封装了KV键值存储,使用IConfigurationStoreService
即可。
Mvvm框架
- Command:
ExecuteCommand
类。 - ViewModel:
ObservableObject
和ViewModelBase
类。 - 容器注册View并绑定:在
App.xaml.cs
的RegisterTypes
方法中使用container.RegisterSingletonView<MainWindow, MainViewModel>();
进行注册。 - 绑定事件触发器:使用
EventAction
实现。
参与贡献
- Fork本仓库
- 新建
Feat_xxx
分支 - 提交代码
- 新建Pull Request
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. net9.0-windows was computed. |
.NET Framework | net462 is compatible. 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.
-
.NETFramework 4.6.2
- CommunityToolkit.Mvvm (>= 8.4.0)
- Microsoft.CodeAnalysis.CSharp (>= 4.12.0)
- Microsoft.Extensions.Hosting (>= 8.0.0)
- TouchSocket.Core (>= 3.0.13)
-
net6.0-windows7.0
- CommunityToolkit.Mvvm (>= 8.4.0)
- Microsoft.CodeAnalysis.CSharp (>= 4.12.0)
- Microsoft.Extensions.Hosting (>= 8.0.0)
- TouchSocket.Core (>= 3.0.13)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.