Publish from private repository

This commit is contained in:
Gitea Actions
2026-08-01 11:48:55 +00:00
commit 814c39f5ce
617 changed files with 65073 additions and 0 deletions
@@ -0,0 +1,14 @@
namespace MyOffice.Core.Extensions;
public static class BoolExtensions
{
public static string ToLowerCase(this bool value)
{
return value.ToString().ToLower();
}
public static string? ToLowerCase(this bool? value)
{
return value == null ? null : value.ToString()?.ToLower();
}
}
@@ -0,0 +1,31 @@
namespace MyOffice.Core.Extensions;
using System.Security.Claims;
public static class ClaimsExtensions
{
public static string? GetValue(this IEnumerable<Claim> claims, string type)
{
return claims.FirstOrDefault(x => x.Type.Equals(type, StringComparison.OrdinalIgnoreCase))?.Value;
}
public static string? GetValue(this IEnumerable<Claim> claims, string[] types)
{
return claims.FirstOrDefault(x => types.Any(z => x.Type.Equals(z, StringComparison.OrdinalIgnoreCase)))?.Value;
}
public static string? GetEmail(this IEnumerable<Claim> claims)
{
return GetValue(claims, new[] { ClaimTypes.Email, "email" });
}
public static string? GetNameIdentifier(this IEnumerable<Claim> claims)
{
return GetValue(claims, ClaimTypes.NameIdentifier);
}
public static string? GetSID(this IEnumerable<Claim> claims)
{
return GetValue(claims, "sid");
}
}
@@ -0,0 +1,19 @@
namespace MyOffice.Core.Extensions;
public static class DateTimeExtensions
{
public static DateTime StartOfDay(this DateTime dateTime)
{
return dateTime.Date;
}
public static DateTime EndOfDay(this DateTime dateTime)
{
return dateTime.AddDays(1).AddTicks(-1);
}
public static DateTime ToUtc(this DateTime dateTime)
{
return new DateTime(dateTime.Ticks, DateTimeKind.Utc);
}
}
@@ -0,0 +1,19 @@
namespace MyOffice.Core.Extensions;
public static class GuidExtensions
{
public static bool EqualsString(this Guid guid, string str)
{
return guid.ToString().EqualsIgnoreCase(str);
}
public static string ToShort(this Guid guid)
{
return guid.ToString("N");
}
public static string? ToShort(this Guid? guid)
{
return guid?.ToString("N");
}
}
@@ -0,0 +1,65 @@
namespace MyOffice.Core.Extensions;
using Microsoft.Extensions.Logging;
public static class StringExtensions
{
public static bool IsMissing(this string? str)
{
return str == null || string.IsNullOrEmpty(str) || string.IsNullOrEmpty(str.Trim());
}
public static bool IsPresent(this string? str)
{
return !IsMissing(str);
}
public static string? NullIfEmpty(this string? str)
{
return IsMissing(str) ? null : str;
}
public static bool EqualsIgnoreCase(this string? str, string? value)
{
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;
}
public static Guid AsGuid(this string str)
{
return Guid.Parse(str);
}
public static Guid? AsGuidNull(this string? str)
{
if (Guid.TryParse(str, out var guid))
{
return guid;
}
return null;
}
}