forked from paulirwin/JavaToCSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaConversionOptions.cs
More file actions
92 lines (70 loc) · 2.31 KB
/
Copy pathJavaConversionOptions.cs
File metadata and controls
92 lines (70 loc) · 2.31 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace JavaToCSharp
{
public class JavaConversionOptions
{
public JavaConversionOptions()
{
this.IncludeNamespace = true;
this.IncludeUsings = true;
}
private readonly IList<Replacement> _packageReplacements = new List<Replacement>();
public event EventHandler<ConversionWarningEventArgs> WarningEncountered;
public event EventHandler<ConversionStateChangedEventArgs> StateChanged;
private readonly IList<string> _usings = new List<string>
{
"System",
"System.Collections.Generic",
"System.Linq",
"System.Text"
};
public IList<Replacement> PackageReplacements
{
get { return _packageReplacements; }
}
public IList<string> Usings
{
get { return _usings; }
}
public bool IncludeUsings { get; set; }
public bool IncludeNamespace { get; set; }
public bool UseDebugAssertForAsserts { get; set; }
public ConversionState ConversionState { get; set; }
public JavaConversionOptions AddPackageReplacement(string pattern, string replacement, RegexOptions options = RegexOptions.None)
{
_packageReplacements.Add(new Replacement(pattern, replacement, options));
return this;
}
public JavaConversionOptions ClearUsings()
{
_usings.Clear();
return this;
}
public JavaConversionOptions AddUsing(string ns)
{
_usings.Add(ns);
return this;
}
internal void Warning(string message, int javaLineNumber)
{
var e = WarningEncountered;
if (e != null)
{
e(this, new ConversionWarningEventArgs(message, javaLineNumber));
}
}
internal void ConversionStateChanged(ConversionState newState)
{
this.ConversionState = newState;
var e = StateChanged;
if (e != null)
{
e(this, new ConversionStateChangedEventArgs(newState));
}
}
}
}