fix
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
namespace MyOffice.Core.Attributes;
|
||||
|
||||
using System;
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = true)]
|
||||
public class LinkAttribute : Attribute
|
||||
{
|
||||
public LinkAttribute(Type type)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = true)]
|
||||
public class LinkFromAttribute : Attribute
|
||||
{
|
||||
public LinkFromAttribute(Type type)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = true)]
|
||||
public class LinkToAttribute : Attribute
|
||||
{
|
||||
public LinkToAttribute(Type type)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = true)]
|
||||
public class LinkWithAttribute : Attribute
|
||||
{
|
||||
public LinkWithAttribute(Type type)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,26 @@ public static class StringExtensions
|
||||
return str != null && str.Equals(value, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public static string? SafeTrim(this string? str)
|
||||
{
|
||||
return str == null ? str : str!.Trim();
|
||||
}
|
||||
|
||||
public static string? MaxOf(this string? str, int maxLength)
|
||||
{
|
||||
if (str == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (str.Length < maxLength)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
return str.Substring(0, maxLength);
|
||||
}
|
||||
|
||||
public static bool AsBool(this string? str, bool defaultValue = false)
|
||||
{
|
||||
return true.ToString().Equals(str, StringComparison.OrdinalIgnoreCase) || defaultValue;
|
||||
@@ -31,21 +51,11 @@ public static class StringExtensions
|
||||
|
||||
public static Guid AsGuid(this string str)
|
||||
{
|
||||
/*str = str
|
||||
.Replace("_", "/")
|
||||
.Replace("-", "+");
|
||||
byte[] buffer = Convert.FromBase64String(str + "==");
|
||||
return new Guid(buffer);*/
|
||||
return Guid.Parse(str);
|
||||
}
|
||||
|
||||
public static Guid? AsGuidNull(this string str)
|
||||
{
|
||||
/*str = str
|
||||
.Replace("_", "/")
|
||||
.Replace("-", "+");
|
||||
byte[] buffer = Convert.FromBase64String(str + "==");
|
||||
return new Guid(buffer);*/
|
||||
if (Guid.TryParse(str, out var guid))
|
||||
{
|
||||
return guid;
|
||||
|
||||
Reference in New Issue
Block a user