Skip to content

Commit

Permalink
添加枚举helper
Browse files Browse the repository at this point in the history
  • Loading branch information
1764564459 committed Apr 23, 2019
1 parent a7f856a commit c6771a0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions EntityFrameWork.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<Compile Include="Entity\Auth\AppUserClaim.cs" />
<Compile Include="Entity\Auth\AppUserLogin.cs" />
<Compile Include="Entity\Auth\AppUserRole.cs" />
<Compile Include="Helper\EnumHelper.cs" />
<Compile Include="Helper\ExcelAndWordHelper.cs" />
<Compile Include="Helper\GPS_To_Baidu.cs" />
<Compile Include="Helper\MongoDbHelper.cs" />
Expand Down
32 changes: 32 additions & 0 deletions Helper/EnumHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EntityFrameWork.Server.Helper
{
/// <summary>
/// 获取枚举键、值
/// </summary>
public class EnumHelper
{

public IEnumerable<EnumReault> Get<T>(T enum_item)
{
List<EnumReault> enum_list = new List<EnumReault>();
var values = Enum.GetValues(typeof(T));
foreach (var item in values)
{
enum_list.Add(new EnumReault { text = Enum.GetName(typeof(T), item), value =item });
}
return enum_list;
}
}
public class EnumReault
{
public string text { get; set; }

public object value { get; set; }
}
}

0 comments on commit c6771a0

Please sign in to comment.