refactor: 将Framework库和RT、UI放在同一个解决方案中。
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
|
||||
namespace Sicentury.Core.Extensions
|
||||
{
|
||||
public static class EnumExtensionMethods
|
||||
{
|
||||
public static string GetDescription(this Enum genericEnum)
|
||||
{
|
||||
var genericEnumType = genericEnum.GetType();
|
||||
var memberInfo = genericEnumType.GetMember(genericEnum.ToString());
|
||||
if ((memberInfo.Length <= 0))
|
||||
return genericEnum.ToString();
|
||||
|
||||
var attributes = memberInfo[0]
|
||||
.GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false);
|
||||
if ((attributes.Any()))
|
||||
{
|
||||
return ((System.ComponentModel.DescriptionAttribute)attributes.ElementAt(0)).Description;
|
||||
}
|
||||
|
||||
return genericEnum.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Sicentury.Core.Extensions
|
||||
{
|
||||
public static class Sha256Extension
|
||||
{
|
||||
public static string Sha256Encoding(this string strSource)
|
||||
{
|
||||
using (var sha = SHA256.Create())
|
||||
{
|
||||
var hashBytes = sha.ComputeHash(Encoding.UTF8.GetBytes(strSource));
|
||||
var hashStr = BitConverter.ToString(hashBytes).Replace("-", "");
|
||||
return hashStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#nullable enable
|
||||
namespace Sicentury.Core.Extensions
|
||||
{
|
||||
public static class StringExtension
|
||||
{
|
||||
public static string? Truncate(this string? value, int maxLength, string truncationSuffix = "…")
|
||||
{
|
||||
return value?.Length > maxLength
|
||||
? value.Substring(0, maxLength) + truncationSuffix
|
||||
: value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user