龙腾猫跃 6 месяцев назад
Родитель
Сommit
2b3e6e211a
3 измененных файлов с 16 добавлено и 11 удалено
  1. 1 1
      Extensions/StringExtensions.cs
  2. 5 0
      General/ConcurrentList.cs
  3. 10 10
      Utils/MathUtils.cs

+ 1 - 1
Extensions/StringExtensions.cs

@@ -166,7 +166,7 @@ public static class StringExtensions {
 
     /// <summary>
     /// 将字符串中的换行符统一替换为指定字符。
-    /// 若指定了 <paramref name="mergeMultiple"/>,会将多次换行合并成一次换行。
+    /// 若指定了 <paramref name="mergeMultiple"/>,会将多个连续换行符仅替换为一个目标内容。
     /// </summary>
     public static string ReplaceLineEndings(this string input, string newValue, bool mergeMultiple = false) =>
         Regex.Replace(input,

+ 5 - 0
General/ConcurrentList.cs

@@ -1,4 +1,9 @@
 namespace MeloongCore;
+
+/// <summary>
+/// 线程安全的 <see cref="List{T}"/> 实现。
+/// 在 <see cref="SynchronizedCollection{T}"/> 的基础上,当调用枚举器时返回一个临时副本,以避免列表在枚举过程中被修改导致异常。
+/// </summary>
 public class ConcurrentList<T> : SynchronizedCollection<T>, IEnumerable, IEnumerable<T> {
 
     // 构造函数

+ 10 - 10
Utils/MathUtils.cs

@@ -8,9 +8,9 @@ public static class MathUtils {
     /// <summary>
     /// 将字符串作为数字,转换为指定进制的形式。
     /// 进制数需在 2 到 86 之间,且输入字符串中的每个字符都必须在该进制的字符集中。
-    /// 进制参考:含大写字母 36,含大小写字母 62,含大小写字母和特殊符号 86
+    /// 进制参考:含大写字母 36,含大小写字母 62,含大小写字母和特殊符号 86。
     /// </summary>
-    public static string RadixConvert(this string input, int fromRadix, int toRadix) {
+    public static string ConvertRadix(this string input, int fromRadix, int toRadix) {
         const string digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/+=!?@#$%^&*()[]{}<>;:',";
         if (fromRadix < 2 || fromRadix > digits.Length) throw new ArgumentOutOfRangeException(nameof(fromRadix), $"{nameof(fromRadix)} must be between 2 and 86.");
         // 零与负数的预处理
@@ -24,24 +24,24 @@ public static class MathUtils {
             if (digit == -1 || digit >= fromRadix) throw new ArgumentException($"Character '{c}' in input '{input}' is not a valid digit for radix {fromRadix}.");
             realNum = realNum * fromRadix + digit;
         }
-        return RadixConvert(realNum * (isNegative ? -1 : 1), toRadix);
+        return ConvertRadix(realNum * (isNegative ? -1 : 1), toRadix);
     }
     /// <summary>
     /// 转换为 2 到 86 进制的字符串。
-    /// 进制参考:含大写字母 36,含大小写字母 62,含大小写字母和特殊符号 86
+    /// 进制参考:含大写字母 36,含大小写字母 62,含大小写字母和特殊符号 86。
     /// </summary>
-    public static string RadixConvert(this long input, int toRadix) => RadixConvert((BigInteger) input, toRadix);
+    public static string ConvertRadix(this long input, int toRadix) => ConvertRadix((BigInteger) input, toRadix);
     /// <summary>
     /// 转换为 2 到 86 进制的字符串。
-    /// 进制参考:含大写字母 36,含大小写字母 62,含大小写字母和特殊符号 86
+    /// 进制参考:含大写字母 36,含大小写字母 62,含大小写字母和特殊符号 86。
     /// </summary>
-    public static string RadixConvert(this int input, int toRadix) => RadixConvert((BigInteger) input, toRadix);
+    public static string ConvertRadix(this int input, int toRadix) => ConvertRadix((BigInteger) input, toRadix);
     /// <summary>
     /// 转换为 2 到 86 进制的字符串。
-    /// 进制参考:含大写字母 36,含大小写字母 62,含大小写字母和特殊符号 86
+    /// 进制参考:含大写字母 36,含大小写字母 62,含大小写字母和特殊符号 86。
     /// </summary>
-    public static string RadixConvert(this byte input, int toRadix) => RadixConvert((BigInteger) input, toRadix);
-    private static string RadixConvert(this BigInteger input, int toRadix) {
+    public static string ConvertRadix(this byte input, int toRadix) => ConvertRadix((BigInteger) input, toRadix);
+    private static string ConvertRadix(this BigInteger input, int toRadix) {
         const string digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/+=!?@#$%^&*()[]{}<>;:',";
         if (toRadix < 2 || toRadix > digits.Length) throw new ArgumentOutOfRangeException(nameof(toRadix), $"{nameof(toRadix)} must be between 2 and 86.");
         // 零与负数的预处理