namespace PlcSiemens.Core.Extension
{
public static class GuidExtension
{
///
/// GuidÊÕËõµ½string
///
///
///
public static string Shrink(this Guid target)
{
if (target.IsEmpty()) return "";
var base64 = Convert.ToBase64String(target.ToByteArray());
var encoded = base64.Replace("/", "_").Replace("+", "-");
return encoded.Substring(0, 22);
}
///
/// GuidÊÇ·ñΪ¿Õ
///
///
///
public static bool IsEmpty(this Guid target)
{
return target == Guid.Empty;
}
}
}