forked from paulirwin/JavaToCSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReplacement.cs
More file actions
57 lines (45 loc) · 1.3 KB
/
Copy pathReplacement.cs
File metadata and controls
57 lines (45 loc) · 1.3 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace JavaToCSharp
{
public class Replacement
{
private readonly Regex _regex;
private readonly string _replacement;
public Replacement(string pattern, string replacement, RegexOptions options = RegexOptions.None)
{
_regex = new Regex(pattern, options);
_replacement = replacement;
}
public Regex Regex
{
get { return _regex; }
}
public string ReplacementValue
{
get { return _replacement; }
}
public string Replace(string input)
{
return _regex.Replace(input, _replacement);
}
public override bool Equals(object obj)
{
Replacement r = obj as Replacement;
if (obj == null) return false;
return r.Regex.Equals(_regex) && string.Equals(r.ReplacementValue, _replacement);
}
public override int GetHashCode()
{
const int prime = 23;
int i = 17;
i += prime * _regex.GetHashCode();
i += prime * _replacement.GetHashCode();
return i;
}
}
}