mirror of
https://github.com/nsnail/ns-ext.git
synced 2025-04-29 13:52:50 +08:00
Compare commits
No commits in common. "fdaf7518c600240c132939d3817b14c134b5784d" and "b6279bb0bb0dd0a3b98e8253e7969b6080240dea" have entirely different histories.
fdaf7518c6
...
b6279bb0bb
@ -0,0 +1 @@
|
|||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
|
@ -86,4 +86,4 @@ resharper_wrap_object_and_collection_initializer_style = chop_always
|
|||||||
[*.cs]
|
[*.cs]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
tab_width = 4
|
tab_width = 4
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Authors>nsnail</Authors>
|
<Authors>nsnail</Authors>
|
||||||
<Product>NSExt</Product>
|
<Product>NSExt</Product>
|
||||||
<Copyright>© 2006-2022 nsnail</Copyright>
|
<Copyright>© 2006-2022 nsnail</Copyright>
|
||||||
<RepositoryUrl>https://github.com/nsnail/ns-ext.git</RepositoryUrl>
|
<RepositoryUrl>https://github.com/nsnail/ns-ext.git</RepositoryUrl>
|
||||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||||
<EmbedUntrackedSource>true</EmbedUntrackedSource>
|
<EmbedUntrackedSource>true</EmbedUntrackedSource>
|
||||||
<EmbedAllSources>true</EmbedAllSources>
|
<EmbedAllSources>true</EmbedAllSources>
|
||||||
<RepositoryType>Git</RepositoryType>
|
<RepositoryType>Git</RepositoryType>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<IncludeSymbols>true</IncludeSymbols>
|
<IncludeSymbols>true</IncludeSymbols>
|
||||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageProjectUrl>https://github.com/nsnail/ns-ext.git</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/nsnail/ns-ext.git</PackageProjectUrl>
|
||||||
<PackageOutputPath>../../build/nupkgs</PackageOutputPath>
|
<PackageOutputPath>../../build/nupkgs</PackageOutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NSExt", "NSExt\NSExt.csproj", "{54814D1B-C587-4D90-A7BE-4BE1E170D5FC}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NSExt", "NSExt\NSExt.csproj", "{54814D1B-C587-4D90-A7BE-4BE1E170D5FC}"
|
||||||
EndProject
|
EndProject
|
||||||
@ -13,4 +13,4 @@ Global
|
|||||||
{54814D1B-C587-4D90-A7BE-4BE1E170D5FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{54814D1B-C587-4D90-A7BE-4BE1E170D5FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{54814D1B-C587-4D90-A7BE-4BE1E170D5FC}.Release|Any CPU.Build.0 = Release|Any CPU
|
{54814D1B-C587-4D90-A7BE-4BE1E170D5FC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
|||||||
namespace NSExt.Extensions;
|
namespace NSExt.Extensions;
|
||||||
|
|
||||||
public static class ByteExtensions
|
public static class ByteExtensions
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace NSExt.Extensions;
|
namespace NSExt.Extensions;
|
||||||
|
|
||||||
public static class CharExtensions
|
public static class CharExtensions
|
||||||
{
|
{
|
||||||
@ -21,4 +21,6 @@ public static class CharExtensions
|
|||||||
{
|
{
|
||||||
return IsAsciiLetterOrDigit(me) || me is '+' or '/' or '=';
|
return IsAsciiLetterOrDigit(me) || me is '+' or '/' or '=';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
namespace NSExt.Extensions;
|
namespace NSExt.Extensions;
|
||||||
|
|
||||||
@ -86,4 +86,4 @@ public static class DateTimeExtensions
|
|||||||
{
|
{
|
||||||
return me.ToString("yyyyMMdd");
|
return me.ToString("yyyyMMdd");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace NSExt.Extensions;
|
namespace NSExt.Extensions;
|
||||||
|
|
||||||
public static class DbCommandExtensions
|
public static class DbCommandExtensions
|
||||||
{
|
{
|
||||||
@ -26,4 +26,5 @@ public static class DbCommandExtensions
|
|||||||
|
|
||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace NSExt.Extensions;
|
namespace NSExt.Extensions;
|
||||||
|
|
||||||
public static class DecimalExtensions
|
public static class DecimalExtensions
|
||||||
{
|
{
|
||||||
@ -13,4 +13,6 @@ public static class DecimalExtensions
|
|||||||
var dec = Math.Round(me, place);
|
var dec = Math.Round(me, place);
|
||||||
return dec;
|
return dec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace NSExt.Extensions;
|
namespace NSExt.Extensions;
|
||||||
|
|
||||||
public static class EnumExtensions
|
public static class EnumExtensions
|
||||||
{
|
{
|
||||||
@ -14,4 +14,6 @@ public static class EnumExtensions
|
|||||||
var attrs = (DescriptionAttribute[])fi!.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
var attrs = (DescriptionAttribute[])fi!.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||||
return (attrs.Length != 0 ? attrs[0].Description : Enum.GetName(t, e)) ?? "";
|
return (attrs.Length != 0 ? attrs[0].Description : Enum.GetName(t, e)) ?? "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace NSExt.Extensions;
|
namespace NSExt.Extensions;
|
||||||
|
|
||||||
public static class EnumerableExtensions
|
public static class EnumerableExtensions
|
||||||
{
|
{
|
||||||
@ -23,4 +23,6 @@ public static class EnumerableExtensions
|
|||||||
{
|
{
|
||||||
return me is null || !me.Any();
|
return me is null || !me.Any();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace NSExt.Extensions;
|
namespace NSExt.Extensions;
|
||||||
|
|
||||||
public static class GenericExtensions
|
public static class GenericExtensions
|
||||||
{
|
{
|
||||||
@ -40,4 +40,6 @@ public static class GenericExtensions
|
|||||||
{
|
{
|
||||||
return me.Equals(compare) ? ret : me;
|
return me.Equals(compare) ? ret : me;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace NSExt.Extensions;
|
namespace NSExt.Extensions;
|
||||||
|
|
||||||
public static class IntExtensions
|
public static class IntExtensions
|
||||||
{
|
{
|
||||||
@ -33,4 +33,6 @@ public static class IntExtensions
|
|||||||
{
|
{
|
||||||
return string.Join(".", BitConverter.GetBytes(me).Reverse());
|
return string.Join(".", BitConverter.GetBytes(me).Reverse());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// ReSharper disable TemplateIsNotCompileTimeConstantProblem
|
// ReSharper disable TemplateIsNotCompileTimeConstantProblem
|
||||||
|
|
||||||
namespace NSExt.Extensions;
|
namespace NSExt.Extensions;
|
||||||
|
|
||||||
@ -63,4 +63,6 @@ public static class LoggerExtensions
|
|||||||
{
|
{
|
||||||
me.LogWarning(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber));
|
me.LogWarning(CallerInfoMessage(message, callerName, callerFilePath, callerLineNumber));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace NSExt.Extensions;
|
namespace NSExt.Extensions;
|
||||||
|
|
||||||
public static class LongExtensions
|
public static class LongExtensions
|
||||||
{
|
{
|
||||||
@ -24,4 +24,7 @@ public static class LongExtensions
|
|||||||
{
|
{
|
||||||
return new DateTime(1970, 1, 1).AddMilliseconds(msFrom1970).ToLocalTime();
|
return new DateTime(1970, 1, 1).AddMilliseconds(msFrom1970).ToLocalTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace NSExt.Extensions;
|
namespace NSExt.Extensions;
|
||||||
|
|
||||||
@ -18,4 +18,4 @@ public static class ObjectExtensions
|
|||||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
namespace NSExt.Extensions;
|
|
||||||
|
|
||||||
public static class StreamExtensions
|
|
||||||
{
|
|
||||||
public static long FirstByteIndex(this Stream me, byte[] findBytes)
|
|
||||||
{
|
|
||||||
int data;
|
|
||||||
while ((data = me.ReadByte()) != -1)
|
|
||||||
if (findBytes.Contains((byte)data))
|
|
||||||
return me.Position;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsTextStream(this Stream me)
|
|
||||||
{
|
|
||||||
return me.FirstByteIndex(new byte[] {
|
|
||||||
0x00,
|
|
||||||
0xff
|
|
||||||
}) < 0;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
@ -11,21 +11,6 @@ public static class StringExtensions
|
|||||||
private static readonly JsonSerializerOptions _DEFAULT_JSON_SERIALIZER_OPTIONS =
|
private static readonly JsonSerializerOptions _DEFAULT_JSON_SERIALIZER_OPTIONS =
|
||||||
default(JsonSerializerOptions).NewJsonSerializerOptions();
|
default(JsonSerializerOptions).NewJsonSerializerOptions();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// MD5 hmac编码
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="me">字符串</param>
|
|
||||||
/// <param name="key">密钥</param>
|
|
||||||
/// <param name="e">字符串使用的编码</param>
|
|
||||||
/// <returns>hash摘要的16进制文本形式(无连字符小写)</returns>
|
|
||||||
private static string Md5Hmac(this string me, string key, Encoding e)
|
|
||||||
{
|
|
||||||
using var md5Hmac = new HMACMD5(e.GetBytes(key));
|
|
||||||
return BitConverter.ToString(md5Hmac.ComputeHash(e.GetBytes(me)))
|
|
||||||
.Replace("-", string.Empty)
|
|
||||||
.ToLower(CultureInfo.CurrentCulture);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// aes加密
|
/// aes加密
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -569,4 +554,19 @@ public static class StringExtensions
|
|||||||
{
|
{
|
||||||
return Uri.UnescapeDataString(me);
|
return Uri.UnescapeDataString(me);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// MD5 hmac编码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="me">字符串</param>
|
||||||
|
/// <param name="key">密钥</param>
|
||||||
|
/// <param name="e">字符串使用的编码</param>
|
||||||
|
/// <returns>hash摘要的16进制文本形式(无连字符小写)</returns>
|
||||||
|
private static string Md5Hmac(this string me, string key, Encoding e)
|
||||||
|
{
|
||||||
|
using var md5Hmac = new HMACMD5(e.GetBytes(key));
|
||||||
|
return BitConverter.ToString(md5Hmac.ComputeHash(e.GetBytes(me)))
|
||||||
|
.Replace("-", string.Empty)
|
||||||
|
.ToLower(CultureInfo.CurrentCulture);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
namespace NSExt.Extensions;
|
namespace NSExt.Extensions;
|
||||||
|
|
||||||
public static class TypeExtensions
|
public static class TypeExtensions
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace NSExt.Extensions;
|
namespace NSExt.Extensions;
|
||||||
|
|
||||||
public static class UriExtensions
|
public static class UriExtensions
|
||||||
{
|
{
|
||||||
@ -11,4 +11,7 @@ public static class UriExtensions
|
|||||||
{
|
{
|
||||||
return "//" + me.Authority + me.PathAndQuery;
|
return "//" + me.Authority + me.PathAndQuery;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
global using System.Data;
|
global using System.Data;
|
||||||
global using System.Data.Common;
|
global using System.Data.Common;
|
||||||
global using System.Runtime.CompilerServices;
|
global using System.Runtime.CompilerServices;
|
||||||
global using Microsoft.Extensions.Logging;
|
global using Microsoft.Extensions.Logging;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
|
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<VersionPrefix>1.0.3</VersionPrefix>
|
<VersionPrefix>1.0.2</VersionPrefix>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
|
Loading…
x
Reference in New Issue
Block a user