1
1
懒得勤快 2 жил өмнө
parent
commit
4a61304b51

+ 11 - 3
Masuit.Tools.Abstractions/Strings/NumberFormater.cs

@@ -131,7 +131,7 @@ namespace Masuit.Tools.Strings
             {
             {
                 <= 2 => "01",
                 <= 2 => "01",
                 > 2 and < 65 => "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/".Substring(0, @base),
                 > 2 and < 65 => "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/".Substring(0, @base),
-                >= 65 and <= 91 => "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,-.:;<=>?@[]^_`{|}~\"".Substring(0, @base),
+                >= 65 and <= 95 => "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._!@$#%*+?&()/\\,-:;<=>?[]^`{|}~'\"".Substring(0, @base),
                 _ => throw new ArgumentException("默认进制最大支持91进制")
                 _ => throw new ArgumentException("默认进制最大支持91进制")
             };
             };
 
 
@@ -147,7 +147,6 @@ namespace Masuit.Tools.Strings
         /// 数字转换为指定的进制形式字符串
         /// 数字转换为指定的进制形式字符串
         /// </summary>
         /// </summary>
         /// <param name="number"></param>
         /// <param name="number"></param>
-        /// <returns></returns>
         public string ToString(long number)
         public string ToString(long number)
         {
         {
             if (number == 0)
             if (number == 0)
@@ -258,6 +257,7 @@ namespace Masuit.Tools.Strings
                 start = 1;
                 start = 1;
                 resultOffset = _offset - 1;
                 resultOffset = _offset - 1;
             }
             }
+
             int j = 0;
             int j = 0;
             var charArray = str.ToCharArray();
             var charArray = str.ToCharArray();
             Array.Reverse(charArray);
             Array.Reverse(charArray);
@@ -283,7 +283,13 @@ namespace Masuit.Tools.Strings
         // 转换万以下整数
         // 转换万以下整数
         private static string ChangeInt(string x)
         private static string ChangeInt(string x)
         {
         {
-            string[] strArrayLevelNames = { "", "十", "百", "千" };
+            string[] strArrayLevelNames =
+            {
+                "",
+                "十",
+                "百",
+                "千"
+            };
             string ret = "";
             string ret = "";
             int i;
             int i;
             for (i = x.Length - 1; i >= 0; i--)
             for (i = x.Length - 1; i >= 0; i--)
@@ -363,6 +369,7 @@ namespace Masuit.Tools.Strings
                     result += temp;
                     result += temp;
                 }
                 }
             }
             }
+
             int i;
             int i;
             if ((i = result.IndexOf("零万", StringComparison.Ordinal)) != -1)
             if ((i = result.IndexOf("零万", StringComparison.Ordinal)) != -1)
             {
             {
@@ -401,6 +408,7 @@ namespace Masuit.Tools.Strings
                 result = "负";
                 result = "负";
                 x = x.Remove(0, 1);
                 x = x.Remove(0, 1);
             }
             }
+
             if (x[0].ToString() == ".")
             if (x[0].ToString() == ".")
             {
             {
                 x = "0" + x;
                 x = "0" + x;

+ 10 - 1
Masuit.Tools.Abstractions/Systems/SnowFlakeNew.cs

@@ -18,7 +18,7 @@ public class SnowFlakeNew
     private const long SequenceMask = -1L ^ -1L << SequenceBits; //一微秒内可以产生计数,如果达到该值则等到下一微妙在进行生成
     private const long SequenceMask = -1L ^ -1L << SequenceBits; //一微秒内可以产生计数,如果达到该值则等到下一微妙在进行生成
     private static long _lastTimestamp = -1L;
     private static long _lastTimestamp = -1L;
     private static readonly object LockObj = new object();
     private static readonly object LockObj = new object();
-    private readonly NumberFormater _numberFormater = new NumberFormater(36);
+    private static NumberFormater _numberFormater = new NumberFormater(36);
     private static SnowFlakeNew _snowFlake;
     private static SnowFlakeNew _snowFlake;
 
 
     /// <summary>
     /// <summary>
@@ -53,6 +53,15 @@ public class SnowFlakeNew
         _workerId = machineId;
         _workerId = machineId;
     }
     }
 
 
+    /// <summary>
+    /// 设置数制格式化器
+    /// </summary>
+    /// <param name="nf"></param>
+    public static void SetNumberFormater(NumberFormater nf)
+    {
+        _numberFormater = nf;
+    }
+
     public long GetLongId()
     public long GetLongId()
     {
     {
         lock (LockObj)
         lock (LockObj)