-
-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #544 from netty2019/master
增加ValueMappingsBase值映射特性基类,方便从外部(如:Abp框架)继承实现枚举、bool类型的多语言显示
- Loading branch information
Showing
11 changed files
with
211 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/Magicodes.ExporterAndImporter.Core/ValueMappingsBaseAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Text; | ||
|
||
namespace Magicodes.IE.Core | ||
{ | ||
/// <summary> | ||
/// 值映射 | ||
/// </summary> | ||
public abstract class ValueMappingsBaseAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// 根据字段信息获取映射 | ||
/// </summary> | ||
/// <param name="propertyInfo"></param> | ||
/// <returns></returns> | ||
public abstract Dictionary<string, object> GetMappings(PropertyInfo propertyInfo); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/Magicodes.ExporterAndImporter.Tests/Models/Export/Issue544.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Magicodes.ExporterAndImporter.Core; | ||
using Magicodes.ExporterAndImporter.Excel; | ||
using Magicodes.IE.Core; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
|
||
namespace Magicodes.ExporterAndImporter.Tests.Models.Export | ||
{ | ||
[ExcelExporter(Name = "导出结果", TableStyle = OfficeOpenXml.Table.TableStyles.None)] | ||
public class Issue544 | ||
{ | ||
/// <summary> | ||
/// 名称 | ||
/// </summary> | ||
[ExporterHeader(DisplayName = "姓名")] | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// 性别 | ||
/// </summary> | ||
[ExporterHeader(DisplayName = "性别")] | ||
public string Gender { get; set; } | ||
|
||
/// <summary> | ||
/// 是否校友 | ||
/// </summary> | ||
[ExporterHeader(DisplayName = "是否校友")] | ||
[BoolLocal337] | ||
public bool? IsAlumni { get; set; } | ||
|
||
[ExporterHeader(DisplayName = "是否校友2")] | ||
[BoolLocal337] | ||
public bool IsAlumni2 { get; set; } | ||
} | ||
|
||
|
||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)] | ||
public class BoolLocal337Attribute : ValueMappingsBaseAttribute | ||
{ | ||
public override Dictionary<string, object> GetMappings(PropertyInfo propertyInfo) | ||
{ | ||
var res= new Dictionary<string, object>(); | ||
res.Add("是",true); | ||
res.Add("否",false); | ||
return res; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters