Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed Nov 16, 2022
1 parent d5650f7 commit a7ce444
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Common.CoreLib/Extensions/EnumExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ public static partial class EnumExtensions
/// <summary>
/// 返回一个布尔值,该值指示给定的整数值或其名称字符串是否存在于指定的枚举中
/// </summary>
/// <typeparam name="TEnum"></typeparam>
/// <param name="value"></param>
/// <returns>如果 enumType 中的某个常量的值等于 value,则为 <see langword="true"/>;否则为 <see langword="false"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsDefined(this Enum value) => Enum.IsDefined(value.GetType(), value);
public static bool IsDefined<TEnum>(this TEnum value) where TEnum : struct, Enum
#if NET5_0_OR_GREATER
=> Enum.IsDefined(value);
#else
=> Enum.IsDefined(typeof(TEnum), value);
#endif

public static TEnum ConvertToEnum<TEnum>(this sbyte value)
where TEnum : Enum
Expand Down
2 changes: 1 addition & 1 deletion src/ST/Properties/SR.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a7ce444

Please sign in to comment.