Skip to content

Commit

Permalink
发布1.1.0版本,支持net5.0;
Browse files Browse the repository at this point in the history
  • Loading branch information
zqlovejyc committed Nov 11, 2020
1 parent aad908f commit f8cf71a
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 166 deletions.
2 changes: 1 addition & 1 deletion ZqUtils.Core.Console/ZqUtils.Core.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ZqUtils.Core.Web/ZqUtils.Core.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
14 changes: 1 addition & 13 deletions ZqUtils.Core/Extensions/Extensions.DateTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,6 @@ public static int WeekOfYear(this DateTime @this, CultureInfo ci)
/// <param name="identifier">标识符“-”</param>
public static string ToDateTimeString(this DateTime @this, bool isRemoveSecond = false, string identifier = "-")
{
if (@this == null)
return string.Empty;
if (isRemoveSecond)
return @this.ToString($"yyyy{identifier}MM{identifier}dd HH:mm");
return @this.ToString($"yyyy{identifier}MM{identifier}dd HH:mm:ss");
Expand All @@ -268,8 +266,6 @@ public static string ToDateTimeString(this DateTime? @this, bool isRemoveSecond
/// <param name="identifier">标识符“-”</param>
public static string ToDateString(this DateTime @this, string identifier = "-")
{
if (@this == null)
return string.Empty;
return @this.ToString($"yyyy{identifier}MM{identifier}dd");
}

Expand All @@ -291,8 +287,6 @@ public static string ToDateString(this DateTime? @this, string identifier = "-")
/// <param name="this">日期</param>
public static string ToTimeString(this DateTime @this)
{
if (@this == null)
return string.Empty;
return @this.ToString("HH:mm:ss");
}

Expand All @@ -314,8 +308,6 @@ public static string ToTimeString(this DateTime? @this)
/// <param name="identifier">标识符“-”</param>
public static string ToMillisecondString(this DateTime @this, string identifier = "-")
{
if (@this == null)
return string.Empty;
return @this.ToString($"yyyy{identifier}MM{identifier}dd HH:mm:ss.fff");
}

Expand All @@ -337,8 +329,6 @@ public static string ToMillisecondString(this DateTime? @this, string identifier
/// <param name="this">日期</param>
public static string ToChineseDateString(this DateTime @this)
{
if (@this == null)
return string.Empty;
return @this.ToString("yyyy年MM月dd日");
}

Expand All @@ -360,8 +350,6 @@ public static string ToChineseDateString(this DateTime? @this)
/// <param name="isRemoveSecond">是否移除秒</param>
public static string ToChineseDateTimeString(this DateTime @this, bool isRemoveSecond = false)
{
if (@this == null)
return string.Empty;
var result = new StringBuilder(@this.ToString("yyyy年MM月dd日 HH时mm分")); ;
if (isRemoveSecond == false)
result.Append($"{@this.Second}秒");
Expand Down Expand Up @@ -1445,4 +1433,4 @@ public static DateTime Yesterday(this DateTime @this)
}
#endregion
}
}
}
16 changes: 8 additions & 8 deletions ZqUtils.Core/Extensions/Extensions.Object.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5898,13 +5898,13 @@ public static T Chain<T>(this T @this, Action<T> action)
/// <returns>the copied object.</returns>
public static T DeepClone<T>(this T @this)
{
IFormatter formatter = new BinaryFormatter();
using (var stream = new MemoryStream())
{
formatter.Serialize(stream, @this);
stream.Seek(0, SeekOrigin.Begin);
return (T)formatter.Deserialize(stream);
}
// Don't serialize a null object, simply return the default for that object
if (@this == null)
return default;

var deserializeSettings = new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling.Replace };
var serializeSettings = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore };
return JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(@this, serializeSettings), deserializeSettings);
}
#endregion

Expand Down Expand Up @@ -7173,4 +7173,4 @@ public static object GetValue(this object target, MemberInfo member)
}
#endregion
}
}
}
9 changes: 5 additions & 4 deletions ZqUtils.Core/Helpers/CodeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@
#endregion

using System;
using System.IO;
using System.Collections.Generic;
using System.DrawingCore;
using System.DrawingCore.Imaging;
using System.DrawingCore.Drawing2D;
using System.DrawingCore.Imaging;
using System.IO;
using ZXing;
using ZXing.Common;
using ZXing.QrCode;
using ZXing.QrCode.Internal;
using ZXing.ZKWeb;
/****************************
* [Author] 张强
* [Date] 2015-10-26
* [Describe] 二维码/条形码/验证码工具类
* **************************/
namespace ZqUtils.Core.Helpers
{
using ZXing.ZKWeb;

/// <summary>
/// 二维码/条形码/验证码工具类
/// </summary>
Expand Down Expand Up @@ -406,4 +407,4 @@ public static byte[] CreateValidateGraphic(string validateCode)
}
#endregion
}
}
}
35 changes: 17 additions & 18 deletions ZqUtils.Core/Helpers/EncodingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ public static Encoding DetectBOM(this byte[] boms)
if (boms[0] == 0xfe && boms[1] == 0xff) return Encoding.BigEndianUnicode;
if (boms.Length < 3) return null;
if (boms[0] == 0xef && boms[1] == 0xbb && boms[2] == 0xbf) return Encoding.UTF8;
#if !NET5_0
if (boms[0] == 0x2b && boms[1] == 0x2f && boms[2] == 0x76) return Encoding.UTF7;
#endif
if (boms.Length < 4) return null;
if (boms[0] == 0xff && boms[1] == 0xfe && boms[2] == 0 && boms[3] == 0) return Encoding.UTF32;
if (boms[0] == 0 && boms[1] == 0 && boms[2] == 0xfe && boms[3] == 0xff) return Encoding.GetEncoding(12001);
Expand All @@ -174,27 +176,24 @@ static Encoding DetectASCII(byte[] data)

static bool IsMatch(byte[] data, Encoding encoding)
{
if (encoding == null) encoding = Encoding.UTF8;
try
if (encoding == null)
encoding = Encoding.UTF8;

var str = encoding.GetString(data);
var buf = encoding.GetBytes(str);
// 考虑到噪声干扰,只要0.9
var score = buf.Length * 9 / 10;
var match = 0;
for (var i = 0; i < buf.Length; i++)
{
var str = encoding.GetString(data);
var buf = encoding.GetBytes(str);
// 考虑到噪声干扰,只要0.9
var score = buf.Length * 9 / 10;
var match = 0;
for (var i = 0; i < buf.Length; i++)
if (data[i] == buf[i])
{
if (data[i] == buf[i])
{
match++;
if (match >= score) return true;
}
match++;
if (match >= score)
return true;
}
}
catch (Exception ex)
{
throw ex;
}

return false;
}

Expand Down Expand Up @@ -383,4 +382,4 @@ private static int DetectSuspiciousUTF8SequenceLength(byte[] buf, long pos)
}
#endregion
}
}
}
42 changes: 21 additions & 21 deletions ZqUtils.Core/Helpers/FileHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ public static void GetFile(string filePath, string fileName, bool isDeleteFile =
}
}
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
finally
{
Expand Down Expand Up @@ -235,9 +235,9 @@ public static void GetFile(string fileName, string fullPath, long speed, bool is
}
}
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
finally
{
Expand Down Expand Up @@ -302,9 +302,9 @@ public static void GetFile(string filePath, string fileName, string contentType,
HttpContextHelper.Current.Response.Body.Write(bytes);
HttpContextHelper.Current.Response.Body.Flush();//输出缓存,此部不可少
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
finally
{
Expand Down Expand Up @@ -352,9 +352,9 @@ public static void GetFileOfZip(string[] filePaths, string zipName, bool isDelet
}
}
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
finally
{
Expand Down Expand Up @@ -411,9 +411,9 @@ public static byte[] GetFileOfZip(string[] filePaths, bool isDeleteFiles = false
}
return null;
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
finally
{
Expand Down Expand Up @@ -470,9 +470,9 @@ public static async Task GetFileAsync(string filePath, string fileName, bool isD
}
}
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
finally
{
Expand Down Expand Up @@ -531,9 +531,9 @@ public static async Task GetFileAsync(string fileName, string fullPath, long spe
}
}
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
finally
{
Expand Down Expand Up @@ -566,9 +566,9 @@ public static async Task GetFileAsync(string filePath, string fileName, string c
await HttpContextHelper.Current.Response.Body.WriteAsync(bytes, 0, bytes.Length);
await HttpContextHelper.Current.Response.Body.FlushAsync();//输出缓存,此部不可少
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
finally
{
Expand Down Expand Up @@ -648,9 +648,9 @@ public static async Task GetFileOfZipAsync(string[] filePaths, string zipName, b
}
}
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
finally
{
Expand Down Expand Up @@ -707,9 +707,9 @@ public static async Task<byte[]> GetFileOfZipAsync(string[] filePaths, bool isDe
}
return null;
}
catch (Exception ex)
catch (Exception)
{
throw ex;
throw;
}
finally
{
Expand Down Expand Up @@ -1114,4 +1114,4 @@ public static string GetContentType(this string fileName)
#endregion
}
#endregion
}
}
Loading

0 comments on commit f8cf71a

Please sign in to comment.