mirror of
				https://github.com/nsnail/ns-ext.git
				synced 2025-11-01 06:15:28 +08:00 
			
		
		
		
	Merge branch 'main' of https://github.com/nsnail/ns-ext
This commit is contained in:
		| @@ -1,10 +1,4 @@ | |||||||
| // @program: NSExt | using System.Text; | ||||||
| // @file: ByteExtensions.cs |  | ||||||
| // @author: tao ke |  | ||||||
| // @mailto: taokeu@gmail.com |  | ||||||
| // @created: 07/26/2022 21:57 |  | ||||||
|  |  | ||||||
| using System.Text; |  | ||||||
|  |  | ||||||
| namespace NSExt; | namespace NSExt; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,10 +1,4 @@ | |||||||
| // @program: NSExt | // ReSharper disable UnusedMember.Global | ||||||
| // @file: DateTimeExtensions.cs |  | ||||||
| // @author: tao ke |  | ||||||
| // @mailto: taokeu@gmail.com |  | ||||||
| // @created: 07/26/2022 21:57 |  | ||||||
|  |  | ||||||
| // ReSharper disable UnusedMember.Global |  | ||||||
|  |  | ||||||
| namespace NSExt; | namespace NSExt; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,10 +1,4 @@ | |||||||
| // @program: NSExt | using System.Data; | ||||||
| // @file: DbCommandExtensions.cs |  | ||||||
| // @author: tao ke |  | ||||||
| // @mailto: taokeu@gmail.com |  | ||||||
| // @created: 08/06/2022 19:48 |  | ||||||
|  |  | ||||||
| using System.Data; |  | ||||||
| using System.Data.Common; | using System.Data.Common; | ||||||
|  |  | ||||||
| namespace NSExt; | namespace NSExt; | ||||||
|   | |||||||
| @@ -1,10 +1,4 @@ | |||||||
| // @program: NSExt | namespace NSExt; | ||||||
| // @file: DecimalExtensions.cs |  | ||||||
| // @author: tao ke |  | ||||||
| // @mailto: taokeu@gmail.com |  | ||||||
| // @created: 07/26/2022 21:57 |  | ||||||
|  |  | ||||||
| namespace NSExt; |  | ||||||
|  |  | ||||||
| public static class DecimalExtensions | public static class DecimalExtensions | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,10 +1,4 @@ | |||||||
| // @program: NSExt | using System.ComponentModel; | ||||||
| // @file: EnumExtensions.cs |  | ||||||
| // @author: tao ke |  | ||||||
| // @mailto: taokeu@gmail.com |  | ||||||
| // @created: 07/26/2022 21:57 |  | ||||||
|  |  | ||||||
| using System.ComponentModel; |  | ||||||
|  |  | ||||||
| namespace NSExt; | namespace NSExt; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,10 +1,4 @@ | |||||||
| // @program: NSExt | namespace NSExt; | ||||||
| // @file: EnumerableExtensions.cs |  | ||||||
| // @author: tao ke |  | ||||||
| // @mailto: taokeu@gmail.com |  | ||||||
| // @created: 07/26/2022 21:57 |  | ||||||
|  |  | ||||||
| namespace NSExt; |  | ||||||
|  |  | ||||||
| public static class EnumerableExtensions | public static class EnumerableExtensions | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,10 +1,4 @@ | |||||||
| // @program: NSExt | namespace NSExt; | ||||||
| // @file: GenericExtensions.cs |  | ||||||
| // @author: tao ke |  | ||||||
| // @mailto: taokeu@gmail.com |  | ||||||
| // @created: 07/26/2022 21:57 |  | ||||||
|  |  | ||||||
| namespace NSExt; |  | ||||||
|  |  | ||||||
| public static class GenericExtensions | public static class GenericExtensions | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,10 +1,4 @@ | |||||||
| // @program: NSExt | namespace NSExt; | ||||||
| // @file: IntExtensions.cs |  | ||||||
| // @author: tao ke |  | ||||||
| // @mailto: taokeu@gmail.com |  | ||||||
| // @created: 07/26/2022 21:57 |  | ||||||
|  |  | ||||||
| namespace NSExt; |  | ||||||
|  |  | ||||||
| public static class IntExtensions | public static class IntExtensions | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,10 +1,4 @@ | |||||||
| // @program: NSExt | using System.Runtime.CompilerServices; | ||||||
| // @file: LoggerExtensions.cs |  | ||||||
| // @author: tao ke |  | ||||||
| // @mailto: taokeu@gmail.com |  | ||||||
| // @created: 07/26/2022 21:57 |  | ||||||
|  |  | ||||||
| using System.Runtime.CompilerServices; |  | ||||||
| using Microsoft.Extensions.Logging; | using Microsoft.Extensions.Logging; | ||||||
|  |  | ||||||
| // ReSharper disable TemplateIsNotCompileTimeConstantProblem | // ReSharper disable TemplateIsNotCompileTimeConstantProblem | ||||||
|   | |||||||
| @@ -1,10 +1,4 @@ | |||||||
| // @program: NSExt | namespace NSExt; | ||||||
| // @file: LongExtensions.cs |  | ||||||
| // @author: tao ke |  | ||||||
| // @mailto: taokeu@gmail.com |  | ||||||
| // @created: 07/26/2022 21:57 |  | ||||||
|  |  | ||||||
| namespace NSExt; |  | ||||||
|  |  | ||||||
| public static class LongExtensions | public static class LongExtensions | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,10 +1,4 @@ | |||||||
| // @program: NSExt | using Newtonsoft.Json; | ||||||
| // @file: ObjectExtensions.cs |  | ||||||
| // @author: tao ke |  | ||||||
| // @mailto: taokeu@gmail.com |  | ||||||
| // @created: 07/26/2022 21:57 |  | ||||||
|  |  | ||||||
| using Newtonsoft.Json; |  | ||||||
|  |  | ||||||
| namespace NSExt; | namespace NSExt; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,17 +1,10 @@ | |||||||
| // @program: NSExt | using System.Globalization; | ||||||
| // @file: StringExtensions.cs |  | ||||||
| // @author: tao ke |  | ||||||
| // @mailto: taokeu@gmail.com |  | ||||||
| // @created: 07/26/2022 21:57 |  | ||||||
|  |  | ||||||
| using System.Globalization; |  | ||||||
| using System.Security.Cryptography; | using System.Security.Cryptography; | ||||||
| using System.Text; | using System.Text; | ||||||
| using System.Text.RegularExpressions; | using System.Text.RegularExpressions; | ||||||
| using System.Web; | using System.Web; | ||||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||||
| using Newtonsoft.Json.Linq; | using Newtonsoft.Json.Linq; | ||||||
| using HMACMD5 = System.Security.Cryptography.HMACMD5; |  | ||||||
| using MD5 = SshNet.Security.Cryptography.MD5; | using MD5 = SshNet.Security.Cryptography.MD5; | ||||||
|  |  | ||||||
| // ReSharper disable UnusedMember.Global | // ReSharper disable UnusedMember.Global | ||||||
| @@ -82,6 +75,18 @@ public static class StringExtensions | |||||||
|         return System.DateTime.Parse(me, CultureInfo.CurrentCulture); |         return System.DateTime.Parse(me, CultureInfo.CurrentCulture); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /// <summary> | ||||||
|  |     ///     将字符串转换成日期对象 | ||||||
|  |     /// </summary> | ||||||
|  |     /// <param name="me">待转换字符串</param> | ||||||
|  |     /// <param name="format">日期格式</param> | ||||||
|  |     /// <returns>转换后的日期对象</returns> | ||||||
|  |     public static DateTime DateTimeExact(this string me, string format) | ||||||
|  |     { | ||||||
|  |         return System.DateTime.ParseExact(me, format, CultureInfo.CurrentCulture); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     ///     将字符串转换成日期对象 |     ///     将字符串转换成日期对象 | ||||||
|     /// </summary> |     /// </summary> | ||||||
| @@ -93,6 +98,20 @@ public static class StringExtensions | |||||||
|         return !System.DateTime.TryParse(me, out var ret) ? def : ret; |         return !System.DateTime.TryParse(me, out var ret) ? def : ret; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /// <summary> | ||||||
|  |     ///     将字符串转换成日期对象 | ||||||
|  |     /// </summary> | ||||||
|  |     /// <param name="me">待转换字符串</param> | ||||||
|  |     /// <param name="format">日期格式</param> | ||||||
|  |     /// <param name="def">转换失败时返回的日期对象</param> | ||||||
|  |     /// <returns>转换后的日期对象</returns> | ||||||
|  |     public static DateTime DateTimeExactTry(this string me, string format, DateTime def) | ||||||
|  |     { | ||||||
|  |         return !System.DateTime.TryParseExact(me, format, CultureInfo.CurrentCulture, DateTimeStyles.None, out var ret) | ||||||
|  |                    ? def | ||||||
|  |                    : ret; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     ///     string to decimal |     ///     string to decimal | ||||||
|     /// </summary> |     /// </summary> | ||||||
| @@ -123,7 +142,7 @@ public static class StringExtensions | |||||||
|     /// <returns></returns> |     /// <returns></returns> | ||||||
|     public static T Enum<T>(this string name) where T : Enum |     public static T Enum<T>(this string name) where T : Enum | ||||||
|     { |     { | ||||||
|         return (T)System.Enum.Parse(typeof(T), name); |         return (T)System.Enum.Parse(typeof(T), name, true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -271,7 +290,7 @@ public static class StringExtensions | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// 对一个字符串进行sha1 hash运算 |     ///     对一个字符串进行sha1 hash运算 | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <param name="me">对一个字符串进行sha1 hash运算</param> |     /// <param name="me">对一个字符串进行sha1 hash运算</param> | ||||||
|     /// <param name="secret">密钥</param> |     /// <param name="secret">密钥</param> | ||||||
| @@ -301,8 +320,6 @@ public static class StringExtensions | |||||||
|                            .ToLower(CultureInfo.CurrentCulture); |                            .ToLower(CultureInfo.CurrentCulture); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     ///     MD5 hmac编码 |     ///     MD5 hmac编码 | ||||||
|   | |||||||
| @@ -1,10 +1,4 @@ | |||||||
| // @program: NSExt | namespace NSExt; | ||||||
| // @file: UriExtensions.cs |  | ||||||
| // @author: tao ke |  | ||||||
| // @mailto: taokeu@gmail.com |  | ||||||
| // @created: 07/26/2022 21:57 |  | ||||||
|  |  | ||||||
| namespace NSExt; |  | ||||||
|  |  | ||||||
| public static class UriExtensions | public static class UriExtensions | ||||||
| { | { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user