schangxiang@126.com
2024-09-06 2a19504209e763a7c0e957e4ee265dd419486ef1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
 
namespace iWare.Wms.Core.Util
{
    public static class StringUtil
    {
        /// <summary>
        /// 获取下划线表达式
        /// </summary>
        /// <param name="typeName"></param>
        /// <returns></returns>
        public static string ToUnderLine(string camel)
        {
            return Regex.Replace(camel, "([A-Z])", "_$1").ToLower().TrimStart('_');
        }
 
 
        public static string ParseTrueType(string dataType)
        {
            if (!dataType.StartsWith("System.Nullable")) return dataType;
 
            return new Regex(@"(?i)(?<=\[)(.*)(?=\])").Match(dataType).Value;
 
 
        }
 
        public static string ParseTrueType2(string dataType)
        {
            if (!dataType.StartsWith("System.Nullable")) return dataType;
 
            var str = new Regex(@"(?i)(?<=\[\[)(.*)(?=\]\])").Match(dataType).Value;
 
            var args = str.Split(',');
 
            return args.Length > 0 ? args[0] : "";
        }
 
    }
}