mirror of
https://github.com/nsnail/ns-ext.git
synced 2025-04-18 23:22:51 +08:00
Merge branch 'main' of https://github.com/nsnail/ns-ext
This commit is contained in:
commit
847012041a
@ -1,6 +1,4 @@
|
||||
using System.Text;
|
||||
|
||||
namespace NSExt;
|
||||
namespace NSExt;
|
||||
|
||||
public static class ByteExtensions
|
||||
{
|
||||
|
@ -1,7 +1,4 @@
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace NSExt;
|
||||
namespace NSExt;
|
||||
|
||||
public static class DbCommandExtensions
|
||||
{
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace NSExt;
|
||||
namespace NSExt;
|
||||
|
||||
public static class EnumExtensions
|
||||
{
|
||||
|
12
src/NSExt/GlobalUsings.cs
Normal file
12
src/NSExt/GlobalUsings.cs
Normal file
@ -0,0 +1,12 @@
|
||||
global using System.Data;
|
||||
global using System.Data.Common;
|
||||
global using System.Runtime.CompilerServices;
|
||||
global using Microsoft.Extensions.Logging;
|
||||
global using System.Globalization;
|
||||
global using System.Text;
|
||||
global using System.Text.RegularExpressions;
|
||||
global using System.Web;
|
||||
global using Newtonsoft.Json;
|
||||
global using Newtonsoft.Json.Linq;
|
||||
global using System.ComponentModel;
|
||||
global using SshNet.Security.Cryptography;
|
@ -1,8 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
// ReSharper disable TemplateIsNotCompileTimeConstantProblem
|
||||
|
||||
// ReSharper disable TemplateIsNotCompileTimeConstantProblem
|
||||
|
||||
namespace NSExt;
|
||||
|
||||
@ -29,15 +25,11 @@ public static class LoggerExtensions
|
||||
|
||||
public static void Error(this ILogger me,
|
||||
object message,
|
||||
Exception ex = null,
|
||||
[CallerMemberName] string callerName = null,
|
||||
[CallerFilePath] string callerFilePath = null,
|
||||
[CallerLineNumber] int callerLineNumber = 0)
|
||||
{
|
||||
if (ex is null)
|
||||
me.LogError(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber));
|
||||
else
|
||||
me.LogError(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber), ex);
|
||||
me.LogError(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber));
|
||||
}
|
||||
|
||||
public static void Fatal(this ILogger me,
|
||||
|
@ -1,6 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NSExt;
|
||||
namespace NSExt;
|
||||
|
||||
public static class ObjectExtensions
|
||||
{
|
||||
|
@ -1,13 +1,10 @@
|
||||
using System.Globalization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using MD5 = SshNet.Security.Cryptography.MD5;
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using System.Security.Cryptography;
|
||||
using HMACMD5 = SshNet.Security.Cryptography.HMACMD5;
|
||||
using HMACSHA1 = SshNet.Security.Cryptography.HMACSHA1;
|
||||
using MD5 = SshNet.Security.Cryptography.MD5;
|
||||
|
||||
namespace NSExt;
|
||||
|
||||
@ -283,7 +280,7 @@ public static class StringExtensions
|
||||
/// <returns>hash摘要的16进制文本形式(无连字符小写)</returns>
|
||||
public static string Sha1(this string me, Encoding e)
|
||||
{
|
||||
using var sha1 = SHA1.Create();
|
||||
using var sha1 = HashAlgorithm.Create();
|
||||
return BitConverter.ToString(sha1.ComputeHash(e.GetBytes(me)))
|
||||
.Replace("-", string.Empty)
|
||||
.ToLower(CultureInfo.CurrentCulture);
|
||||
@ -438,4 +435,10 @@ public static class StringExtensions
|
||||
{
|
||||
return BitConverter.ToInt32(me.Split('.').Select(byte.Parse).Reverse().ToArray(), 0);
|
||||
}
|
||||
|
||||
|
||||
public static bool NullOrWhiteSpace(this string me)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(me);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user