forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringExtensions.cs
More file actions
104 lines (86 loc) · 3.04 KB
/
StringExtensions.cs
File metadata and controls
104 lines (86 loc) · 3.04 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using System.Collections.Generic;
using Proxy = ServiceStack.Common.StringExtensions;
namespace ServiceStack.Common.Extensions
{
public static class StringExtensions
{
public static T ToEnum<T>(this string value)
{
return Proxy.ToEnum<T>(value);
}
public static T ToEnumOrDefault<T>(this string value, T defaultValue)
{
return Proxy.ToEnumOrDefault<T>(value, defaultValue);
}
public static string SplitCamelCase(this string value)
{
return Proxy.SplitCamelCase(value);
}
public static string ToEnglish(this string camelCase)
{
return Proxy.ToEnglish(camelCase);
}
public static bool IsEmpty(this string value)
{
return Proxy.IsEmpty(value);
}
public static bool IsNullOrEmpty(this string value)
{
return Proxy.IsNullOrEmpty(value);
}
public static bool EqualsIgnoreCase(this string value, string other)
{
return Proxy.EqualsIgnoreCase(value, other);
}
public static string ReplaceFirst(this string haystack, string needle, string replacement)
{
return Proxy.ReplaceFirst(haystack, needle, replacement);
}
public static string ReplaceAll(this string haystack, string needle, string replacement)
{
return Proxy.ReplaceAll(haystack, needle, replacement);
}
public static bool ContainsAny(this string text, params string[] testMatches)
{
return Proxy.ContainsAny(text, testMatches);
}
public static string SafeVarName(this string text)
{
return Proxy.SafeVarName(text);
}
public static string Join(this List<string> items)
{
return Proxy.Join(items);
}
public static string Join(this List<string> items, string delimeter)
{
return Proxy.Join(items, delimeter);
}
public static bool Glob(this string value, string pattern)
{
int pos;
for (pos = 0; pattern.Length != pos; pos++)
{
switch (pattern[pos])
{
case '?':
break;
case '*':
for (int i = value.Length; i >= pos; i--)
{
if (Glob(value.Substring(i), pattern.Substring(pos + 1)))
return true;
}
return false;
default:
if (value.Length == pos || char.ToUpper(pattern[pos]) != char.ToUpper(value[pos]))
{
return false;
}
break;
}
}
return value.Length == pos;
}
}
}