DirectOutputR1
DirectOutput framework R1 for virtual pinball cabinets.
Go to:
Overview 
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros Pages
TableConfigColumnList.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 
4 namespace DirectOutput.LedControl.Loader
5 {
10  public class TableConfigColumnList : List<TableConfigColumn>
11  {
12 
25  public void ParseControlData(string LedControlData, bool ThrowExceptions = false)
26  {
27  string[] Cols = LedControlData.Split(new char[] { ',' });
28  if (Cols.Length < 2)
29  {
30  Log.Warning("No data to parse found in LedControlData: {0}".Build(LedControlData));
31  if (ThrowExceptions)
32  {
33  throw new Exception("No data to parse found in LedControlData: {0}".Build(LedControlData));
34  }
35  return;
36  }
37  int FirstOutputNumber = 1;
38  int LastColumnWithData = -1;
39  for (int i = 1; i < Cols.Length; i++)
40  {
41  if (!Cols[i].IsNullOrWhiteSpace())
42  {
43  LastColumnWithData = i;
44  }
45  }
46  for (int i = 1; i <= LastColumnWithData; i++)
47  {
49  C.Number = i;
50  C.FirstOutputNumber = FirstOutputNumber;
51  bool ParseOK=C.ParseColumnData(Cols[i], false);
52  if (!ParseOK)
53  {
54  Log.Warning("Previous exceptions occured in the line {0} of the ledcontrol file".Build(LedControlData));
55  if (ThrowExceptions)
56  {
57  throw new Exception("Exception(s) accorud when parsing {0}".Build(LedControlData));
58  }
59  }
60 
61  if (FirstOutputNumber + C.RequiredOutputCount > 33)
62  {
63  Log.Warning("To many outputs (>32) are configured in the following line {0}".Build(LedControlData));
64  if (ThrowExceptions)
65  {
66  throw new Exception("To many outputs (>32) are configured in the following line {0}".Build(LedControlData));
67  }
68  return;
69  }
70 
71  Add(C);
72 
73  FirstOutputNumber += C.RequiredOutputCount;
74 
75  }
76 
77  }
78 
82  public new void Sort()
83  {
84  base.Sort((a, b) => a.Number.CompareTo(b.Number));
85  }
86 
87 
91  public TableConfigColumnList() { }
98  public TableConfigColumnList(string LedControlData, bool ThrowExceptions = false) {
99  ParseControlData(LedControlData, ThrowExceptions);
100  }
101 
102  }
103 }