Skip to content

Commit c27853c

Browse files
committed
修改 类名 方法名
1 parent 034b187 commit c27853c

File tree

7 files changed

+31
-28
lines changed

7 files changed

+31
-28
lines changed

csharp/ToolGood.Algorithm2/AlgorithmEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public bool Parse(string exp)
312312
}
313313
//try {
314314

315-
var stream = new CaseChangingCharStream(new AntlrInputStream(exp));
315+
var stream = new AntlrCharStream(new AntlrInputStream(exp));
316316
var lexer = new mathLexer(stream);
317317
var tokens = new CommonTokenStream(lexer);
318318
var parser = new mathParser(tokens);

csharp/ToolGood.Algorithm2/ConditionCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private ProgContext Parse(string exp)
121121
{
122122
if (string.IsNullOrWhiteSpace(exp)) { return null; }
123123
try {
124-
var stream = new CaseChangingCharStream(new AntlrInputStream(exp));
124+
var stream = new AntlrCharStream(new AntlrInputStream(exp));
125125
var lexer = new mathLexer(stream);
126126
var tokens = new CommonTokenStream(lexer);
127127
var parser = new mathParser(tokens);

csharp/ToolGood.Algorithm2/Internals/CaseChangingCharStream.cs renamed to csharp/ToolGood.Algorithm2/Internals/AntlrCharStream.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace ToolGood.Algorithm.Internals
1616
/// 'BEGIN' if constructor parameter upper=true but getText() would return
1717
/// 'BeGiN'.
1818
/// </summary>
19-
class CaseChangingCharStream : ICharStream
19+
class AntlrCharStream : ICharStream
2020
{
2121
private ICharStream stream;
2222

@@ -26,7 +26,7 @@ class CaseChangingCharStream : ICharStream
2626
/// </summary>
2727
/// <param name="stream">The stream to wrap.</param>
2828
/// <param name="upper">If true force each symbol to upper case, otherwise force to lower.</param>
29-
public CaseChangingCharStream(ICharStream stream)
29+
public AntlrCharStream(ICharStream stream)
3030
{
3131
this.stream = stream;
3232
}

csharp/ToolGood.Algorithm2/Internals/LookupAlgorithmEngine.cs renamed to csharp/ToolGood.Algorithm2/Internals/AntlrLookupEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace ToolGood.Algorithm.Internals
88
{
9-
class LookupAlgorithmEngine : AlgorithmEngine
9+
class AntlrLookupEngine : AlgorithmEngine
1010
{
1111
public Operand Json;
1212

csharp/ToolGood.Algorithm2/Internals/Base64.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,6 @@ public static byte[] FromBase64ForUrlString(string base64ForUrlInput)
6060
int padChars = (len % 4) == 0 ? 0 : (4 - (len % 4));
6161
if (padChars > 0) sb.Append(String.Empty.PadRight(padChars, '='));
6262
return Convert.FromBase64String(sb.ToString());
63-
64-
//base64ForUrlInput = Regex.Replace(base64ForUrlInput, @"[^a-zA-Z0-9+/\-_]", "");
65-
66-
//int padChars = (base64ForUrlInput.Length % 4) == 0 ? 0 : (4 - (base64ForUrlInput.Length % 4));
67-
//StringBuilder result = new StringBuilder(base64ForUrlInput, base64ForUrlInput.Length + padChars);
68-
//result.Append(String.Empty.PadRight(padChars, '='));
69-
//result.Replace('-', '+');
70-
//result.Replace('_', '/');
71-
//return Convert.FromBase64String(result.ToString());
7263
}
7364
}
7465
}

csharp/ToolGood.Algorithm2/Internals/CharUtil.cs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,46 @@ public static char StandardChar(char c)
3232
return char.ToUpperInvariant(o);
3333
}
3434

35-
public static bool Equals(string left, string right)
35+
public static bool EqualsOnce(string left, string right)
3636
{
37-
if (left == null) return false;
38-
if (right == null) return false;
3937
if (left.Length != right.Length) return false;
4038
for (int i = 0; i < left.Length; i++) {
41-
var a = StandardChar(left[i]);
42-
var b = StandardChar(right[i]);
43-
if (a != b) {
44-
return false;
39+
if (left[i] != right[i]) {
40+
var a = StandardChar(left[i]);
41+
var b = StandardChar(right[i]);
42+
if (a != b) return false;
4543
}
4644
}
4745
return true;
4846
}
47+
48+
public static bool Equals(string left, string right)
49+
{
50+
if (left == null) return false;
51+
if (right == null) return false;
52+
return EqualsOnce(left, right);
53+
}
4954
public static bool Equals(string left, string arg1, string arg2)
5055
{
51-
if (Equals(left, arg1))
56+
if (left == null) return false;
57+
if (arg1 != null && EqualsOnce(left, arg1))
58+
return true;
59+
if (arg2 != null && EqualsOnce(left, arg2))
5260
return true;
53-
return Equals(left, arg2);
61+
return false;
5462
}
5563

56-
public static bool Equals(string left, string arg1, string arg2,string arg3)
64+
public static bool Equals(string left, string arg1, string arg2, string arg3)
5765
{
58-
if (Equals(left, arg1))
66+
if (left == null) return false;
67+
if (left == null) return false;
68+
if (arg1 != null && EqualsOnce(left, arg1))
69+
return true;
70+
if (arg2 != null && EqualsOnce(left, arg2))
5971
return true;
60-
if (Equals(left, arg2))
72+
if (arg3 != null && EqualsOnce(left, arg3))
6173
return true;
62-
return Equals(left, arg3);
74+
return false;
6375
}
6476

6577
}

csharp/ToolGood.Algorithm2/Internals/ConditionCacheInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private ProgContext Parse(string exp)
4242
{
4343
if (string.IsNullOrWhiteSpace(exp)) { return null; }
4444
try {
45-
var stream = new CaseChangingCharStream(new AntlrInputStream(exp));
45+
var stream = new AntlrCharStream(new AntlrInputStream(exp));
4646
var lexer = new mathLexer(stream);
4747
var tokens = new CommonTokenStream(lexer);
4848
var parser = new mathParser(tokens);

0 commit comments

Comments
 (0)