From 676e80f901500519ed29de1e97a0936cf1b7340b Mon Sep 17 00:00:00 2001
From: SmallChi <564952747@qq.com>
Date: Fri, 22 Feb 2019 15:10:31 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9E=9A=E4=B8=BE=E8=BD=AC?=
=?UTF-8?q?=E6=95=B0=E5=80=BC=E7=B1=BB=E5=9E=8B=E6=89=A9=E5=B1=95=E6=96=B9?=
=?UTF-8?q?=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Extensions/JT809EnumExtensions.cs | 31 +++++++++----------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/src/JT809.Protocol/Extensions/JT809EnumExtensions.cs b/src/JT809.Protocol/Extensions/JT809EnumExtensions.cs
index 6e3f45c..e774843 100644
--- a/src/JT809.Protocol/Extensions/JT809EnumExtensions.cs
+++ b/src/JT809.Protocol/Extensions/JT809EnumExtensions.cs
@@ -22,6 +22,17 @@ namespace JT809.Protocol.Extensions
return Convert.ToInt32(t);
}
+ ///
+ /// 转为 u16 整型
+ ///
+ ///
+ ///
+ ///
+ public static ushort ToUInt16Value(this T t) where T : struct
+ {
+ return Convert.ToUInt16(t);
+ }
+
///
/// 转为Byte
///
@@ -89,7 +100,7 @@ namespace JT809.Protocol.Extensions
///
/// 获取DescriptionAttribute特性枚举及描述
///
- ///
+ ///
///
public static Dictionary GetDescriptionAttributeDictionary(this Enum value)
{
@@ -106,7 +117,7 @@ namespace JT809.Protocol.Extensions
///
/// 获取DisplayNameAttribute特性枚举值的描述
///
- /// 枚举值
+ /// 枚举值
///
public static string GetDisplayName(this Enum value)
{
@@ -117,7 +128,7 @@ namespace JT809.Protocol.Extensions
///
/// 获取DisplayNameAttribute特性枚举及描述
///
- ///
+ ///
///
public static Dictionary GetDisplayNameAttributeDictionary(this Enum value)
{
@@ -152,18 +163,6 @@ namespace JT809.Protocol.Extensions
}
}
- ///
- /// 根据值获取对应枚举类型集合
- ///
- /// 具体枚举类型
- /// 枚举值
- /// 位数(8,16,32)
- ///
- public static IEnumerable GetEnumTypes(this int value,int digit) where T : Enum
- {
- return GetEnumTypes(value, digit,true);
- }
-
///
/// 根据值获取对应枚举类型集合
///
@@ -172,7 +171,7 @@ namespace JT809.Protocol.Extensions
/// 位数(8,16,32)
/// 是否忽略未知数据
///
- public static IEnumerable GetEnumTypes(this int value, int digit,bool ignoreUnknown) where T : Enum
+ public static IEnumerable GetEnumTypes(this int value, int digit, bool ignoreUnknown = false) where T : Enum
{
List values = new List();
for (int i = 0; i < digit; i++)