15
15
// You should have received a copy of the GNU General Public License
16
16
// along with Open Rails. If not, see <http://www.gnu.org/licenses/>.
17
17
18
+ using System ;
18
19
using System . Collections . Generic ;
19
20
20
-
21
21
namespace Menu . Notifications
22
22
{
23
23
public class Notifications
24
24
{
25
25
public List < Notification > NotificationList = new List < Notification > ( ) ;
26
26
public List < Check > CheckList = new List < Check > ( ) ;
27
- }
28
-
29
- class JsonInput
30
- {
31
- public List < Notification > NotificationList { get ; set ; }
32
- public List < Check > CheckList { get ; set ; }
27
+ internal void ReplaceParameters ( Func < string , string > replaceFunc )
28
+ {
29
+ NotificationList ? . ForEach ( item => item . ReplaceParameters ( replaceFunc ) ) ;
30
+ CheckList ? . ForEach ( item => item . ReplaceParameters ( replaceFunc ) ) ;
31
+ }
33
32
}
34
33
35
34
public class Notification
36
35
{
37
36
public string Date { get ; set ; }
38
37
public string Title { get ; set ; }
39
- public string UpdateMode { get ; set ; }
40
38
public List < string > IncludeIf { get ; set ; }
41
39
public List < string > IncludeIfNot { get ; set ; }
42
40
public List < Item > ItemList { get ; set ; }
41
+ internal void ReplaceParameters ( Func < string , string > replaceFunc )
42
+ {
43
+ Date = replaceFunc ( Date ) ;
44
+ Title = replaceFunc ( Title ) ;
45
+ ItemList ? . ForEach ( item => item . ReplaceParameters ( replaceFunc ) ) ;
46
+ }
43
47
}
44
- class Record : Item
48
+ class Record : ValueItem
45
49
{
46
- public string Value { get ; set ; }
47
50
}
48
51
class Text : Item
49
52
{
@@ -52,42 +55,59 @@ class Heading : Item
52
55
{
53
56
public new string Color { get ; set ; } = "blue" ;
54
57
}
55
- class Link : Item
58
+ class Link : ValueItem
56
59
{
57
- public string Value { get ; set ; }
58
60
public string Url { get ; set ; }
59
61
public string StableUrl { get ; set ; }
60
62
public string TestingUrl { get ; set ; }
61
63
public string UnstableUrl { get ; set ; }
62
64
}
63
- class Dialog : Item
65
+ class Dialog : ValueItem
64
66
{
65
- public string Value { get ; set ; }
66
67
public string Form { get ; set ; }
67
68
}
68
- class Update : Item
69
+ class Update : ValueItem
70
+ {
71
+ }
72
+ abstract class ValueItem : Item
69
73
{
70
74
public string Value { get ; set ; }
71
- public string UpdateMode { get ; set ; }
75
+ internal override void ReplaceParameters ( Func < string , string > replaceFunc )
76
+ {
77
+ base . ReplaceParameters ( replaceFunc ) ;
78
+ Value = replaceFunc ( Value ) ;
79
+ }
72
80
}
73
- public class Item
81
+ public abstract class Item
74
82
{
75
83
public List < string > IncludeIf { get ; set ; }
76
84
public List < string > IncludeIfNot { get ; set ; }
77
85
public string Label { get ; set ; }
78
86
public string Color { get ; set ; } = "black" ;
79
87
public int Indent { get ; set ; } = 140 ;
88
+ internal virtual void ReplaceParameters ( Func < string , string > replaceFunc )
89
+ {
90
+ Label = replaceFunc ( Label ) ;
91
+ }
80
92
}
81
93
82
94
public class Check
83
95
{
84
96
public string Id { get ; set ; }
85
97
public List < AnyOf > AnyOfList { get ; set ; }
98
+ internal void ReplaceParameters ( Func < string , string > replaceFunc )
99
+ {
100
+ AnyOfList ? . ForEach ( item => item . ReplaceParameters ( replaceFunc ) ) ;
101
+ }
86
102
}
87
103
88
104
public class AnyOf
89
105
{
90
106
public List < Criteria > AllOfList { get ; set ; }
107
+ internal void ReplaceParameters ( Func < string , string > replaceFunc )
108
+ {
109
+ AllOfList ? . ForEach ( item => item . ReplaceParameters ( replaceFunc ) ) ;
110
+ }
91
111
}
92
112
93
113
// These criteria are all doing an actual comparison
@@ -114,15 +134,20 @@ public abstract class Criteria
114
134
public string Property { get ; set ; } // installed_version, direct3d, runtime, system, memory, cpu, gpu
115
135
public string Value { get ; set ; } // {{new_version}}, {{10_0}}
116
136
public abstract bool IsMatch ( ) ;
137
+ internal void ReplaceParameters ( Func < string , string > replaceFunc )
138
+ {
139
+ Property = replaceFunc ( Property ) ;
140
+ Value = replaceFunc ( Value ) ;
141
+ }
117
142
}
118
143
119
- public class ParameterValue
144
+ class ParameterValue
120
145
{
121
146
public string Parameter { get ; set ; } // installed_version, direct3d, runtime, system, memory, cpu, gpu
122
147
public string Value { get ; set ; } // {{new_version}}, {{10_0}}
123
148
}
124
149
125
- public class OverrideParameterList
150
+ class OverrideParameterList
126
151
{
127
152
public List < ParameterValue > ParameterValueList = new List < ParameterValue > ( ) ;
128
153
}
0 commit comments