sync public allowlist from private myoffice
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user