懒得勤快 7 年之前
父节点
当前提交
494e591b54

+ 1 - 1
Masuit.Tools.Core/Extensions.cs

@@ -1552,7 +1552,7 @@ namespace Masuit.Tools
                 }
                 }
                 temp = temp.Substring(0, length);
                 temp = temp.Substring(0, length);
             }
             }
-            return temp;
+            return Regex.Replace(temp, @"\p{P}|\+", string.Empty);
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 1 - 1
Masuit.Tools.Core/Masuit.Tools.Core.csproj

@@ -2,7 +2,7 @@
 
 
   <PropertyGroup>
   <PropertyGroup>
     <TargetFramework>netcoreapp2.0</TargetFramework>
     <TargetFramework>netcoreapp2.0</TargetFramework>
-    <Version>2.1.2</Version>
+    <Version>2.1.2.1</Version>
     <Authors>懒得勤快</Authors>
     <Authors>懒得勤快</Authors>
     <Company>masuit.com</Company>
     <Company>masuit.com</Company>
     <Description>包含一些常用的操作类,大都是静态类,加密解密,反射操作,硬件信息,字符串扩展方法,日期时间扩展操作,大文件拷贝,图像裁剪,html处理,验证码、NoSql等常用封装。
     <Description>包含一些常用的操作类,大都是静态类,加密解密,反射操作,硬件信息,字符串扩展方法,日期时间扩展操作,大文件拷贝,图像裁剪,html处理,验证码、NoSql等常用封装。

+ 0 - 1
Masuit.Tools.NoSQL.MongoDBClient.UnitTest/Masuit.Tools.NoSQL.MongoDBClient.UnitTest.csproj

@@ -49,7 +49,6 @@
     <Reference Include="System.Core" />
     <Reference Include="System.Core" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
-    <Compile Include="UnitTest1.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>

+ 0 - 14
Masuit.Tools.NoSQL.MongoDBClient.UnitTest/UnitTest1.cs

@@ -1,14 +0,0 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Masuit.Tools.NoSQL.MongoDBClient.UnitTest
-{
-    [TestClass]
-    public class UnitTest1
-    {
-        [TestMethod]
-        public void TestMethod1()
-        {
-        }
-    }
-}

+ 28 - 0
Masuit.Tools.UnitTest/ExtensionMethodsTest.cs

@@ -0,0 +1,28 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Masuit.Tools.UnitTest
+{
+    [TestClass]
+    public class ExtensionMethodsTest
+    {
+        [TestMethod]
+        public void MatchUrl_True()
+        {
+            bool expect = "https://git.lug.us-tc.edu.cn/masuit/soft".MatchUrl();
+            Assert.AreEqual(true, expect);
+        }
+
+        [TestMethod]
+        public void MatchEmail()
+        {
+            bool expect = "[email protected]".MatchEmail();
+            Assert.AreEqual(true, expect);
+        }
+        [TestMethod]
+        public void MatchIdentifyCard_False()
+        {
+            bool expect = "513901199509120610".MatchIdentifyCard();
+            Assert.AreEqual(false, expect);
+        }
+    }
+}

+ 1 - 0
Masuit.Tools.UnitTest/Masuit.Tools.UnitTest.csproj

@@ -49,6 +49,7 @@
     <Reference Include="System.Core" />
     <Reference Include="System.Core" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <Compile Include="ExtensionMethodsTest.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>

+ 12 - 0
Masuit.Tools.sln

@@ -21,6 +21,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "测试", "测试", "{E0B8FB
 EndProject
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masuit.Tools.NoSQL.MongoDBClient.Core.UnitTest", "Masuit.Tools.NoSQL.MongoDBClient.Core.UnitTest\Masuit.Tools.NoSQL.MongoDBClient.Core.UnitTest.csproj", "{9D2E3A00-9E94-4C3D-AAAE-70B0DA236FE6}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Masuit.Tools.NoSQL.MongoDBClient.Core.UnitTest", "Masuit.Tools.NoSQL.MongoDBClient.Core.UnitTest\Masuit.Tools.NoSQL.MongoDBClient.Core.UnitTest.csproj", "{9D2E3A00-9E94-4C3D-AAAE-70B0DA236FE6}"
 EndProject
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{91954D82-A5FC-417B-8FD9-D9C165C8F16C}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreTest", "NetCoreTest\NetCoreTest.csproj", "{ABEC3F65-6556-44FD-BECE-33F7927FB3AE}"
+EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
 		Debug|Any CPU = Debug|Any CPU
@@ -59,6 +63,14 @@ Global
 		{9D2E3A00-9E94-4C3D-AAAE-70B0DA236FE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{9D2E3A00-9E94-4C3D-AAAE-70B0DA236FE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{9D2E3A00-9E94-4C3D-AAAE-70B0DA236FE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{9D2E3A00-9E94-4C3D-AAAE-70B0DA236FE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{9D2E3A00-9E94-4C3D-AAAE-70B0DA236FE6}.Release|Any CPU.Build.0 = Release|Any CPU
 		{9D2E3A00-9E94-4C3D-AAAE-70B0DA236FE6}.Release|Any CPU.Build.0 = Release|Any CPU
+		{91954D82-A5FC-417B-8FD9-D9C165C8F16C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{91954D82-A5FC-417B-8FD9-D9C165C8F16C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{91954D82-A5FC-417B-8FD9-D9C165C8F16C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{91954D82-A5FC-417B-8FD9-D9C165C8F16C}.Release|Any CPU.Build.0 = Release|Any CPU
+		{ABEC3F65-6556-44FD-BECE-33F7927FB3AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{ABEC3F65-6556-44FD-BECE-33F7927FB3AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{ABEC3F65-6556-44FD-BECE-33F7927FB3AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{ABEC3F65-6556-44FD-BECE-33F7927FB3AE}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 		HideSolutionNode = FALSE

+ 2 - 2
Masuit.Tools/Extensions.cs

@@ -1218,7 +1218,7 @@ namespace Masuit.Tools
         /// <returns>匹配对象</returns>
         /// <returns>匹配对象</returns>
         public static Match MatchUrl(this string s, out bool isMatch)
         public static Match MatchUrl(this string s, out bool isMatch)
         {
         {
-            Match match = Regex.Match(s, @"^((\w*):?//)?((\w+)\.|((\S+):(\S+))@)?((\w+)\.(\w+))(:(\d{1,5}))?(/([a-z0-9A-Z-_@{}!+%/]+(\.\w+)?)?(\?([a-z0-9A-Z-_@{}!+%]+=[a-z0-9A-Z-_@{}!+%]+&?)+)?(/?#[a-z0-9A-Z-_@{}!+%/]+)?(\?([a-z0-9A-Z-_@{}!+%]+=[a-z0-9A-Z-_@{}!+%]*&?)+)?)?$");
+            Match match = Regex.Match(s, @"^((\w*):?//)?([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}(:(\d{1,5}))?(/([a-z0-9A-Z-_@{}!+%/]+(\.\w+)?)?(\?([a-z0-9A-Z-_@{}!+%]+=[a-z0-9A-Z-_@{}!+%]+&?)+)?(/?#[a-z0-9A-Z-_@{}!+%/]+)?(\?([a-z0-9A-Z-_@{}!+%]+=[a-z0-9A-Z-_@{}!+%]*&?)+)?)?$");
             isMatch = match.Success;
             isMatch = match.Success;
             return isMatch ? match : null;
             return isMatch ? match : null;
         }
         }
@@ -1499,7 +1499,7 @@ namespace Masuit.Tools
                 }
                 }
                 temp = temp.Substring(0, length);
                 temp = temp.Substring(0, length);
             }
             }
-            return temp.ToLower();
+            return Regex.Replace(temp, @"\p{P}|\+", string.Empty);
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 2 - 2
Masuit.Tools/Properties/AssemblyInfo.cs

@@ -36,7 +36,7 @@ using System.Runtime.InteropServices;
 // 方法是按如下所示使用“*”: :
 // 方法是按如下所示使用“*”: :
 // [assembly: AssemblyVersion("1.0.*")]
 // [assembly: AssemblyVersion("1.0.*")]
 
 
-[assembly: AssemblyVersion("2.1.1.0")]
-[assembly: AssemblyFileVersion("2.1.1.0")]
+[assembly: AssemblyVersion("2.1.2.0")]
+[assembly: AssemblyFileVersion("2.1.2.0")]
 [assembly: NeutralResourcesLanguage("zh-CN")]
 [assembly: NeutralResourcesLanguage("zh-CN")]
 
 

+ 5 - 2
Test/Program.cs

@@ -1,5 +1,7 @@
-using System.Collections.Concurrent;
+using System;
+using System.Collections.Concurrent;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
+using Masuit.Tools;
 using Masuit.Tools.Systems;
 using Masuit.Tools.Systems;
 
 
 namespace Test
 namespace Test
@@ -8,7 +10,8 @@ namespace Test
     {
     {
         static void Main(string[] args)
         static void Main(string[] args)
         {
         {
-            var redisLock = new RedisLock();
+            Console.WriteLine("".CreateShortToken(26));
+            //var redisLock = new RedisLock();
         }
         }
 
 
         public static ConcurrentDictionary<string, object> LockDic { get; set; } = new ConcurrentDictionary<string, object>();
         public static ConcurrentDictionary<string, object> LockDic { get; set; } = new ConcurrentDictionary<string, object>();