Skip to content

Commit

Permalink
feat: 添加ExpressMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
joesdu committed Aug 20, 2024
1 parent eefe38c commit 599c51d
Show file tree
Hide file tree
Showing 56 changed files with 3,635 additions and 63 deletions.
24 changes: 12 additions & 12 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,22 @@
.EXAMPLE
exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed"
#>
function Exec
{
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
[Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd)
)
& $cmd
if ($lastexitcode -ne 0) {
throw ("Exec: " + $errorMessage)
}
function Exec {
[CmdletBinding()]
param(
[Parameter(Position = 0, Mandatory = 1)][scriptblock]$cmd,
[Parameter(Position = 1, Mandatory = 0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd)
)
& $cmd
if ($lastexitcode -ne 0) {
throw ("Exec: " + $errorMessage)
}
}

$solution = "EasilyNET.sln"
$artifacts = ".\artifacts"

if(Test-Path $artifacts) { Remove-Item $artifacts -Force -Recurse }
if (Test-Path $artifacts) { Remove-Item $artifacts -Force -Recurse }

exec { & dotnet clean $solution -c Release }
exec { & dotnet build $solution -c Release }
Expand All @@ -40,6 +39,7 @@ exec { & dotnet pack .\src\EasilyNET.WebCore.Swagger\EasilyNET.WebCore.Swagger.c
# Framework
exec { & dotnet pack .\src\EasilyNET.AutoDependencyInjection\EasilyNET.AutoDependencyInjection.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.AutoDependencyInjection.Core\EasilyNET.AutoDependencyInjection.Core.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.ExpressMapper\EasilyNET.ExpressMapper.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.RabbitBus.AspNetCore\EasilyNET.RabbitBus.AspNetCore.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.RabbitBus.Core\EasilyNET.RabbitBus.Core.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.Security\EasilyNET.Security.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
Expand Down
7 changes: 7 additions & 0 deletions EasilyNET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApi.SourceGenerator.Test
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasilyNET.Core.SourceGenerator", "src\EasilyNET.Core.SourceGenerator\EasilyNET.Core.SourceGenerator.csproj", "{64D128C1-919B-4A60-A715-5910D5204251}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasilyNET.ExpressMapper", "src\EasilyNET.ExpressMapper\EasilyNET.ExpressMapper.csproj", "{E87E72BC-9A6D-4D78-86E4-6C65D79B0FC5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -155,6 +157,10 @@ Global
{64D128C1-919B-4A60-A715-5910D5204251}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64D128C1-919B-4A60-A715-5910D5204251}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64D128C1-919B-4A60-A715-5910D5204251}.Release|Any CPU.Build.0 = Release|Any CPU
{E87E72BC-9A6D-4D78-86E4-6C65D79B0FC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E87E72BC-9A6D-4D78-86E4-6C65D79B0FC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E87E72BC-9A6D-4D78-86E4-6C65D79B0FC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E87E72BC-9A6D-4D78-86E4-6C65D79B0FC5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -182,6 +188,7 @@ Global
{9B426136-DC85-603B-94FB-F3C0B2E72713} = {4F9DEAE5-078F-E77A-2E4A-FEB6FFE226FF}
{4A011ECD-3C24-4818-8C42-A9361BF4119A} = {4F9DEAE5-078F-E77A-2E4A-FEB6FFE226FF}
{64D128C1-919B-4A60-A715-5910D5204251} = {8D626EA8-CB54-BC41-363A-217881BEBA6E}
{E87E72BC-9A6D-4D78-86E4-6C65D79B0FC5} = {E0AD1809-C64F-3D39-45E0-E424261CE16D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BF2C0069-ED43-44A1-A66C-2CC1B62E3EA3}
Expand Down
3 changes: 2 additions & 1 deletion Push.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ $artifacts = "./artifacts"

if ([string]::IsNullOrEmpty($Env:NUGET_API_KEY)) {
Write-Host "${scriptName}: NUGET_API_KEY is empty or not set. Skipped pushing package(s)."
} else {
}
else {
Get-ChildItem $artifacts -Filter "*.nupkg" | ForEach-Object {
Write-Host "$($scriptName): Pushing $($_.Name)"
dotnet nuget push $_ --source $Env:NUGET_URL --api-key $Env:NUGET_API_KEY
Expand Down
104 changes: 54 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ EasilyNET Packages
- 对 MongoDB 执行命令添加个性化输出.(EasilyNET.Mongo.ConsoleDebug)
- 部分库的[使用案例](./sample/WebApi.Test.Unit/README.md)

<details>
<summary style="font-size: 14px">English</summary>

- AES,DES,RC4,TripleDES,RSA,SM2,SM3,SM4 encryption, signature verification and other algorithms
- Distributed locks based on MongoDB
- Message bus implementation based on RabbitMQ
- Some encapsulation of MongoDB driver for easy use and some common default configurations
- Snowflake ID, some common data types, enumerations, extension methods, etc.
- Automatic modular injection services, adding support for WPF, WinForm and other projects, using IHost common host mode
- Added support for DateOnly and TimeOnly in MongoDB
- Simple support for MongoDB GridFS usage (common usage) and usage examples.
- Integration of some common filters and middleware in WebAPI
- Added support for grouping, hiding APIs, and displaying default values for some data types in Swagger documents, making it easier for front-end engineers to refer to
- Added personalized output for executing MongoDB commands (EasilyNET.Mongo.ConsoleDebug)
- [Usage examples](./sample/WebApi.Test.Unit/README.md) of some libraries

</details>

#### Core

| NuGet Package | Version | Download | Document |
Expand All @@ -59,19 +77,20 @@ EasilyNET Packages
| NuGet Package | Version | Download | Document |
| --------------------------------------- | ------------ | ------------ | --------------------------------------------------------- |
| [EasilyNET.AutoDependencyInjection][20] | ![Nuget][21] | ![Nuget][22] | [文档](./src/EasilyNET.AutoDependencyInjection/README.md) |
| [EasilyNET.RabbitBus.AspNetCore][23] | ![Nuget][24] | ![Nuget][25] | [文档](./src/EasilyNET.RabbitBus.AspNetCore/README.md) |
| [EasilyNET.Security][26] | ![Nuget][27] | ![Nuget][28] | [文档](./src/EasilyNET.Security/README.md) |
| [EasilyNET.ExpressMapper][23] | ![Nuget][24] | ![Nuget][25] | [文档](./src/EasilyNET.ExpressMapper/README.md) |
| [EasilyNET.RabbitBus.AspNetCore][26] | ![Nuget][27] | ![Nuget][28] | [文档](./src/EasilyNET.RabbitBus.AspNetCore/README.md) |
| [EasilyNET.Security][29] | ![Nuget][30] | ![Nuget][31] | [文档](./src/EasilyNET.Security/README.md) |

#### Mongo

| NuGet Package | Version | Download | Document |
| ----------------------------------------------- | ------------ | ------------ | ----------------------------------------------------------------- |
| [EasilyNET.Mongo.AspNetCore][29] | ![Nuget][30] | ![Nuget][31] | [文档](./src/EasilyNET.Mongo.AspNetCore/README.md) |
| [EasilyNET.Mongo.ConsoleDebug][32] | ![Nuget][33] | ![Nuget][34] | [文档](./src/EasilyNET.Mongo.ConsoleDebug/README.md) |
| [EasilyNET.MongoDistributedLock][35] | ![Nuget][36] | ![Nuget][37] | [文档](./src/EasilyNET.MongoDistributedLock/README.md) |
| [EasilyNET.MongoDistributedLock.AspNetCore][38] | ![Nuget][39] | ![Nuget][40] | [文档](./src/EasilyNET.MongoDistributedLock.AspNetCore/README.md) |
| [EasilyNET.MongoGridFS.AspNetCore][41] | ![Nuget][42] | ![Nuget][43] | [文档](./src/EasilyNET.MongoGridFS.AspNetCore/README.md) |
| [EasilyNET.MongoSerializer.AspNetCore][44] | ![Nuget][45] | ![Nuget][46] | [文档](./src/EasilyNET.MongoSerializer.AspNetCore/README.md) |
| [EasilyNET.Mongo.AspNetCore][32] | ![Nuget][33] | ![Nuget][34] | [文档](./src/EasilyNET.Mongo.AspNetCore/README.md) |
| [EasilyNET.Mongo.ConsoleDebug][35] | ![Nuget][36] | ![Nuget][37] | [文档](./src/EasilyNET.Mongo.ConsoleDebug/README.md) |
| [EasilyNET.MongoDistributedLock][38] | ![Nuget][39] | ![Nuget][40] | [文档](./src/EasilyNET.MongoDistributedLock/README.md) |
| [EasilyNET.MongoDistributedLock.AspNetCore][41] | ![Nuget][42] | ![Nuget][43] | [文档](./src/EasilyNET.MongoDistributedLock.AspNetCore/README.md) |
| [EasilyNET.MongoGridFS.AspNetCore][44] | ![Nuget][45] | ![Nuget][46] | [文档](./src/EasilyNET.MongoGridFS.AspNetCore/README.md) |
| [EasilyNET.MongoSerializer.AspNetCore][47] | ![Nuget][48] | ![Nuget][49] | [文档](./src/EasilyNET.MongoSerializer.AspNetCore/README.md) |

#### 感谢 [JetBrains](https://www.jetbrains.com/shop/eform/opensource) 对本项目的支持!

Expand All @@ -85,24 +104,6 @@ EasilyNET Packages
- 然后到本项目创建一个 PR.
- 等待管理员合并 PR 后即可删除掉你自己的仓库.

### Git 贡献提交规范

- 使用 Emoji [参考](https://gitmoji.dev) | [Emoji 中文含义](gitemoji.md)

| 代号 | 说明 |
| :------- | -------------------------------------------------------- |
| feat | 新功能(feature) |
| fix | 修复 bug,可以是 QA 发现的 BUG,也可以是研发自己发现的 BUG |
| docs | 文档(documentation) |
| style | 格式(不影响代码运行的变动) |
| refactor | 重构(即不是新增功能,也不是修改 bug 的代码变动) |
| perf | 优化相关,比如提升性能、体验 |
| test | 增加测试 |
| chore | 构建过程或辅助工具的变动 |
| revert | 回滚到上一个版本 |
| merge | 代码合并 |
| sync | 同步主线或分支的 Bug |

<!--文档中的各项链接-->

[1]: https://img.shields.io/badge/License-MIT-brightgreen.svg
Expand All @@ -127,27 +128,30 @@ EasilyNET Packages
[20]: https://www.nuget.org/packages/EasilyNET.AutoDependencyInjection
[21]: https://img.shields.io/nuget/v/EasilyNET.AutoDependencyInjection
[22]: https://img.shields.io/nuget/dt/EasilyNET.AutoDependencyInjection
[23]: https://www.nuget.org/packages/EasilyNET.RabbitBus.AspNetCore
[24]: https://img.shields.io/nuget/v/EasilyNET.RabbitBus.AspNetCore
[25]: https://img.shields.io/nuget/dt/EasilyNET.RabbitBus.AspNetCore
[26]: https://www.nuget.org/packages/EasilyNET.Security
[27]: https://img.shields.io/nuget/v/EasilyNET.Security
[28]: https://img.shields.io/nuget/dt/EasilyNET.Security
[29]: https://www.nuget.org/packages/EasilyNET.Mongo.AspNetCore
[30]: https://img.shields.io/nuget/v/EasilyNET.Mongo.AspNetCore
[31]: https://img.shields.io/nuget/dt/EasilyNET.Mongo.AspNetCore
[32]: https://www.nuget.org/packages/EasilyNET.Mongo.ConsoleDebug
[33]: https://img.shields.io/nuget/v/EasilyNET.Mongo.ConsoleDebug
[34]: https://img.shields.io/nuget/dt/EasilyNET.Mongo.ConsoleDebug
[35]: https://www.nuget.org/packages/EasilyNET.MongoDistributedLock
[36]: https://img.shields.io/nuget/v/EasilyNET.MongoDistributedLock
[37]: https://img.shields.io/nuget/dt/EasilyNET.MongoDistributedLock
[38]: https://www.nuget.org/packages/EasilyNET.MongoDistributedLock.AspNetCore
[39]: https://img.shields.io/nuget/v/EasilyNET.MongoDistributedLock.AspNetCore
[40]: https://img.shields.io/nuget/dt/EasilyNET.MongoDistributedLock.AspNetCore
[41]: https://www.nuget.org/packages/EasilyNET.MongoGridFS.AspNetCore
[42]: https://img.shields.io/nuget/v/EasilyNET.MongoGridFS.AspNetCore
[43]: https://img.shields.io/nuget/dt/EasilyNET.MongoGridFS.AspNetCore
[44]: https://www.nuget.org/packages/EasilyNET.MongoSerializer.AspNetCore
[45]: https://img.shields.io/nuget/v/EasilyNET.MongoSerializer.AspNetCore
[46]: https://img.shields.io/nuget/dt/EasilyNET.MongoSerializer.AspNetCore
[23]: https://www.nuget.org/packages/EasilyNET.ExpressMapper
[24]: https://img.shields.io/nuget/v/EasilyNET.ExpressMapper
[25]: https://img.shields.io/nuget/dt/EasilyNET.ExpressMapper
[26]: https://www.nuget.org/packages/EasilyNET.RabbitBus.AspNetCore
[27]: https://img.shields.io/nuget/v/EasilyNET.RabbitBus.AspNetCore
[28]: https://img.shields.io/nuget/dt/EasilyNET.RabbitBus.AspNetCore
[29]: https://www.nuget.org/packages/EasilyNET.Security
[30]: https://img.shields.io/nuget/v/EasilyNET.Security
[31]: https://img.shields.io/nuget/dt/EasilyNET.Security
[32]: https://www.nuget.org/packages/EasilyNET.Mongo.AspNetCore
[33]: https://img.shields.io/nuget/v/EasilyNET.Mongo.AspNetCore
[34]: https://img.shields.io/nuget/dt/EasilyNET.Mongo.AspNetCore
[35]: https://www.nuget.org/packages/EasilyNET.Mongo.ConsoleDebug
[36]: https://img.shields.io/nuget/v/EasilyNET.Mongo.ConsoleDebug
[37]: https://img.shields.io/nuget/dt/EasilyNET.Mongo.ConsoleDebug
[38]: https://www.nuget.org/packages/EasilyNET.MongoDistributedLock
[39]: https://img.shields.io/nuget/v/EasilyNET.MongoDistributedLock
[40]: https://img.shields.io/nuget/dt/EasilyNET.MongoDistributedLock
[41]: https://www.nuget.org/packages/EasilyNET.MongoDistributedLock.AspNetCore
[42]: https://img.shields.io/nuget/v/EasilyNET.MongoDistributedLock.AspNetCore
[43]: https://img.shields.io/nuget/dt/EasilyNET.MongoDistributedLock.AspNetCore
[44]: https://www.nuget.org/packages/EasilyNET.MongoGridFS.AspNetCore
[45]: https://img.shields.io/nuget/v/EasilyNET.MongoGridFS.AspNetCore
[46]: https://img.shields.io/nuget/dt/EasilyNET.MongoGridFS.AspNetCore
[47]: https://www.nuget.org/packages/EasilyNET.MongoSerializer.AspNetCore
[48]: https://img.shields.io/nuget/v/EasilyNET.MongoSerializer.AspNetCore
[49]: https://img.shields.io/nuget/dt/EasilyNET.MongoSerializer.AspNetCore
32 changes: 32 additions & 0 deletions src/EasilyNET.ExpressMapper/Abstractions/Clause/IClause.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace EasilyNET.ExpressMapper.Abstractions.Clause;

/// <summary>
/// Interface for a mapping clause.
/// 映射子句的接口。
/// </summary>
/// <typeparam name="TSource">The source type. 源类型。</typeparam>
/// <typeparam name="TDest">The destination type. 目标类型。</typeparam>
public interface IClause<TSource, TDest>
{
/// <summary>
/// Gets a value indicating whether this clause is valid.
/// 获取一个值,该值指示此子句是否有效。
/// </summary>
bool IsValidClause { get; }
}

/// <summary>
/// Interface for a reversible mapping clause.
/// 可逆映射子句的接口。
/// </summary>
/// <typeparam name="TSource">The source type. 源类型。</typeparam>
/// <typeparam name="TDest">The destination type. 目标类型。</typeparam>
public interface IReverseAbleClause<TSource, TDest> : IClause<TSource, TDest>
{
/// <summary>
/// Gets the reverse clause.
/// 获取反向子句。
/// </summary>
/// <returns>The reverse clause. 反向子句。</returns>
public IClause<TDest, TSource> GetReverseClause();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Reflection;
using EasilyNET.ExpressMapper.Expressions;

namespace EasilyNET.ExpressMapper.Abstractions.Clause;

/// <summary>
/// Interface for constructor clause.
/// 构造函数子句的接口。
/// </summary>
/// <typeparam name="TSource">The source type. 源类型。</typeparam>
/// <typeparam name="TDest">The destination type. 目标类型。</typeparam>
public interface IConstructClause<TSource, TDest> : IClause<TSource, TDest>
{
/// <summary>
/// Gets the constructor information.
/// 获取构造函数信息。
/// </summary>
public ConstructorInfo? ConstructorInfo { get; }

/// <summary>
/// Gets the constructor parameters.
/// 获取构造函数参数。
/// </summary>
public IEnumerable<MappingMember> ConstructorParams { get; }
}
24 changes: 24 additions & 0 deletions src/EasilyNET.ExpressMapper/Abstractions/Clause/IIgnoreClause.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using EasilyNET.ExpressMapper.Expressions;

namespace EasilyNET.ExpressMapper.Abstractions.Clause;

/// <summary>
/// Interface for ignore clause.
/// 忽略子句的接口。
/// </summary>
/// <typeparam name="TSource">The source type. 源类型。</typeparam>
/// <typeparam name="TDest">The destination type. 目标类型。</typeparam>
public interface IIgnoreClause<TSource, TDest> : IClause<TSource, TDest>
{
/// <summary>
/// Gets the source ignore member.
/// 获取源忽略成员。
/// </summary>
public MappingMember? SourceIgnoreMember { get; }

/// <summary>
/// Gets the destination ignore member.
/// 获取目标忽略成员。
/// </summary>
public MappingMember? DestinationIgnoreMember { get; }
}
25 changes: 25 additions & 0 deletions src/EasilyNET.ExpressMapper/Abstractions/Clause/IMapClause.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Linq.Expressions;
using EasilyNET.ExpressMapper.Expressions;

namespace EasilyNET.ExpressMapper.Abstractions.Clause;

/// <summary>
/// Interface for map clause.
/// 映射子句的接口。
/// </summary>
/// <typeparam name="TSource">The source type. 源类型。</typeparam>
/// <typeparam name="TDest">The destination type. 目标类型。</typeparam>
public interface IMapClause<TSource, TDest> : IClause<TSource, TDest>
{
/// <summary>
/// Gets the destination member.
/// 获取目标成员。
/// </summary>
public MappingMember? DestinationMember { get; }

/// <summary>
/// Gets the lambda expression.
/// 获取 lambda 表达式。
/// </summary>
public LambdaExpression? Expression { get; }
}
24 changes: 24 additions & 0 deletions src/EasilyNET.ExpressMapper/Abstractions/IConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using EasilyNET.ExpressMapper.Abstractions.Clause;

namespace EasilyNET.ExpressMapper.Abstractions;

/// <summary>
/// Interface for configuration that includes key keeping functionality.
/// 包含密钥保持功能的配置接口。
/// </summary>
public interface IConfig : IKeyKeeper;

/// <summary>
/// Interface for configuration with source and destination types.
/// 具有源类型和目标类型的配置接口。
/// </summary>
/// <typeparam name="TSource">The source type. 源类型。</typeparam>
/// <typeparam name="TDest">The destination type. 目标类型。</typeparam>
public interface IConfig<TSource, TDest> : IConfig
{
/// <summary>
/// Gets the collection of clauses.
/// 获取子句集合。
/// </summary>
IEnumerable<IClause<TSource, TDest>> Clauses { get; }
}
17 changes: 17 additions & 0 deletions src/EasilyNET.ExpressMapper/Abstractions/IConfigManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace EasilyNET.ExpressMapper.Abstractions;

/// <summary>
/// Interface for configuration manager.
/// 配置管理器接口。
/// </summary>
public interface IConfigManager
{
/// <summary>
/// Gets the configuration for the specified source and destination types.
/// 获取指定源类型和目标类型的配置。
/// </summary>
/// <typeparam name="TSource">The source type. 源类型。</typeparam>
/// <typeparam name="TDest">The destination type. 目标类型。</typeparam>
/// <returns>The configuration if found; otherwise, null. 如果找到配置,则返回配置;否则返回 null。</returns>
IConfig<TSource, TDest>? GetConfig<TSource, TDest>();
}
15 changes: 15 additions & 0 deletions src/EasilyNET.ExpressMapper/Abstractions/IConfigProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace EasilyNET.ExpressMapper.Abstractions;

/// <summary>
/// Interface for configuration provider.
/// 配置提供程序接口。
/// </summary>
public interface IConfigProvider
{
/// <summary>
/// Gets the configuration units.
/// 获取配置单元。
/// </summary>
/// <returns>Enumeration of configuration units. 配置单元的枚举。</returns>
public IEnumerable<IConfig> GetConfigUnits();
}
Loading

0 comments on commit 599c51d

Please sign in to comment.