2 using System.Collections.Generic;
5 namespace DirectOutput.LedControl.Loader
24 public void ParseControlData(
string LedControlData,
bool ThrowExceptions =
false)
26 string[] Cols = SplitColumns(LedControlData);
29 Log.
Warning(
"No data to parse found in LedControlData: {0}".Build(LedControlData));
32 throw new Exception(
"No data to parse found in LedControlData: {0}".Build(LedControlData));
36 int FirstOutputNumber = 1;
37 int LastColumnWithData = -1;
38 for (
int i = 1; i < Cols.Length; i++)
40 if (!Cols[i].IsNullOrWhiteSpace())
42 LastColumnWithData = i;
45 for (
int i = 1; i <= LastColumnWithData; i++)
53 Log.
Warning(
"Previous exceptions occured in the line {0} of the ledcontrol file".Build(LedControlData));
56 throw new Exception(
"Exception(s) occured when parsing {0}".Build(LedControlData));
71 private string[] SplitColumns(
string ConfigData)
73 List<string> L =
new List<string>();
79 for (
int P = 0; P < ConfigData.Length; P++)
81 if (ConfigData[P] ==
'(')
85 else if (ConfigData[P] ==
')')
88 }
if (ConfigData[P] ==
',' && BracketCount <= 0)
90 L.Add(ConfigData.Substring(LP, P - LP));
97 if (LP < ConfigData.Length)
99 L.Add(ConfigData.Substring(LP));
109 public new void Sort()
111 base.Sort((a, b) => a.Number.CompareTo(b.Number));
126 ParseControlData(LedControlData, ThrowExceptions);