This commit is contained in:
2023-07-29 16:25:16 +03:00
parent 90f0386bfe
commit 4312a5c084
34 changed files with 1998 additions and 61 deletions
+35
View File
@@ -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)
{
}
}
+20 -10
View File
@@ -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;