-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormatHandler.cs
86 lines (76 loc) · 2.63 KB
/
FormatHandler.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace MO2ExportImport
{
public class FormatHandler
{
public static string TrimModActivationStatus(string modListName)
{
return modListName.TrimStart('+', '-', '*');
}
public static bool? GetModActivationStatus(string modListName)
{
bool hasActivationStatus = modListName.StartsWith('+') || modListName.StartsWith('*') || modListName.StartsWith('-');
if (!hasActivationStatus)
{
return null;
}
return modListName.StartsWith('+') || modListName.StartsWith('*');
}
public static string GetModActivationStatusCharStr(string modListName)
{
bool hasActivationStatus = modListName.StartsWith('+') || modListName.StartsWith('*') || modListName.StartsWith('-');
if (hasActivationStatus)
{
return modListName[0].ToString();
}
else
{
return string.Empty;
}
}
public static IEnumerable<string> TrimModActivationStatus(IEnumerable<string> modNames)
{
return modNames.Select(x => TrimModActivationStatus(x));
}
public static string TrimPluginActivationStatus(string pluginName)
{
return pluginName.TrimStart('*');
}
public static IEnumerable<string> TrimPluginActivationStatus(IEnumerable<string> pluginNames)
{
return pluginNames.Select(x => TrimPluginActivationStatus(x));
}
public static bool GetPluginActivationStatus(string pluginEntry)
{
return pluginEntry.StartsWith('*');
}
public static string TrimActivationStatus(string str, StringType stringType)
{
switch(stringType)
{
case StringType.Mod: return TrimModActivationStatus(str);
case StringType.Plugin: return TrimPluginActivationStatus(str);
}
return str;
}
public static IEnumerable<string> TrimActivationStatus(IEnumerable<string> strings, StringType stringType)
{
switch (stringType)
{
case StringType.Mod: return TrimModActivationStatus(strings);
case StringType.Plugin: return TrimPluginActivationStatus(strings);
}
return strings;
}
public enum StringType
{
Mod,
Plugin
}
}
}