forked from paulirwin/JavaToCSharp
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJavaConversionOptions.cs
More file actions
72 lines (50 loc) · 1.95 KB
/
Copy pathJavaConversionOptions.cs
File metadata and controls
72 lines (50 loc) · 1.95 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
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace JavaToCSharp;
public class JavaConversionOptions
{
public event EventHandler<ConversionWarningEventArgs>? WarningEncountered;
public event EventHandler<ConversionStateChangedEventArgs>? StateChanged;
public IList<Replacement> PackageReplacements { get; } = new List<Replacement>();
public IList<string> Usings { get; } = new List<string>
{
"System",
"System.Collections.Generic",
"System.Collections.ObjectModel",
"System.Linq",
"System.Text"
};
public bool IncludeUsings { get; set; } = true;
public bool IncludeNamespace { get; set; } = true;
public bool UseDebugAssertForAsserts { get; set; }
public bool StartInterfaceNamesWithI { get; set; }
/// <summary>
/// Unrecognized code is translated into comments
/// </summary>
public bool UseUnrecognizedCodeToComment { get; set; } = true;
public bool ConvertSystemOutToConsole { get; set; }
public bool IncludeComments { get; set; } = true;
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) => WarningEncountered?.Invoke(this, new ConversionWarningEventArgs(message, javaLineNumber));
internal void ConversionStateChanged(ConversionState newState)
{
ConversionState = newState;
StateChanged?.Invoke(this, new ConversionStateChangedEventArgs(newState));
}
}