1515// You should have received a copy of the GNU General Public License
1616// along with Open Rails. If not, see <http://www.gnu.org/licenses/>.
1717
18+ using System ;
1819using System . Collections . Generic ;
1920
20-
2121namespace Menu . Notifications
2222{
2323 public class Notifications
2424 {
2525 public List < Notification > NotificationList = new List < Notification > ( ) ;
2626 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+ }
3332 }
3433
3534 public class Notification
3635 {
3736 public string Date { get ; set ; }
3837 public string Title { get ; set ; }
39- public string UpdateMode { get ; set ; }
4038 public List < string > IncludeIf { get ; set ; }
4139 public List < string > IncludeIfNot { get ; set ; }
4240 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+ }
4347 }
44- class Record : Item
48+ class Record : ValueItem
4549 {
46- public string Value { get ; set ; }
4750 }
4851 class Text : Item
4952 {
@@ -52,42 +55,59 @@ class Heading : Item
5255 {
5356 public new string Color { get ; set ; } = "blue" ;
5457 }
55- class Link : Item
58+ class Link : ValueItem
5659 {
57- public string Value { get ; set ; }
5860 public string Url { get ; set ; }
5961 public string StableUrl { get ; set ; }
6062 public string TestingUrl { get ; set ; }
6163 public string UnstableUrl { get ; set ; }
6264 }
63- class Dialog : Item
65+ class Dialog : ValueItem
6466 {
65- public string Value { get ; set ; }
6667 public string Form { get ; set ; }
6768 }
68- class Update : Item
69+ class Update : ValueItem
70+ {
71+ }
72+ abstract class ValueItem : Item
6973 {
7074 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+ }
7280 }
73- public class Item
81+ public abstract class Item
7482 {
7583 public List < string > IncludeIf { get ; set ; }
7684 public List < string > IncludeIfNot { get ; set ; }
7785 public string Label { get ; set ; }
7886 public string Color { get ; set ; } = "black" ;
7987 public int Indent { get ; set ; } = 140 ;
88+ internal virtual void ReplaceParameters ( Func < string , string > replaceFunc )
89+ {
90+ Label = replaceFunc ( Label ) ;
91+ }
8092 }
8193
8294 public class Check
8395 {
8496 public string Id { get ; set ; }
8597 public List < AnyOf > AnyOfList { get ; set ; }
98+ internal void ReplaceParameters ( Func < string , string > replaceFunc )
99+ {
100+ AnyOfList ? . ForEach ( item => item . ReplaceParameters ( replaceFunc ) ) ;
101+ }
86102 }
87103
88104 public class AnyOf
89105 {
90106 public List < Criteria > AllOfList { get ; set ; }
107+ internal void ReplaceParameters ( Func < string , string > replaceFunc )
108+ {
109+ AllOfList ? . ForEach ( item => item . ReplaceParameters ( replaceFunc ) ) ;
110+ }
91111 }
92112
93113 // These criteria are all doing an actual comparison
@@ -114,15 +134,20 @@ public abstract class Criteria
114134 public string Property { get ; set ; } // installed_version, direct3d, runtime, system, memory, cpu, gpu
115135 public string Value { get ; set ; } // {{new_version}}, {{10_0}}
116136 public abstract bool IsMatch ( ) ;
137+ internal void ReplaceParameters ( Func < string , string > replaceFunc )
138+ {
139+ Property = replaceFunc ( Property ) ;
140+ Value = replaceFunc ( Value ) ;
141+ }
117142 }
118143
119- public class ParameterValue
144+ class ParameterValue
120145 {
121146 public string Parameter { get ; set ; } // installed_version, direct3d, runtime, system, memory, cpu, gpu
122147 public string Value { get ; set ; } // {{new_version}}, {{10_0}}
123148 }
124149
125- public class OverrideParameterList
150+ class OverrideParameterList
126151 {
127152 public List < ParameterValue > ParameterValueList = new List < ParameterValue > ( ) ;
128153 }
0 commit comments