WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
TableConfigList.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 
4 namespace DirectOutput.LedControl.Loader
5 {
9  public class TableConfigList:List<TableConfig>
10  {
16  public void ParseLedcontrolData(IEnumerable<string> TableConfigDataFromLedControlIni, bool ThrowExceptions = true)
17  {
18  foreach (string Data in TableConfigDataFromLedControlIni)
19  {
20  if (!Data.IsNullOrWhiteSpace())
21  {
22  ParseLedcontrolData(Data, ThrowExceptions);
23  }
24  }
25  }
26 
27 
38  public void ParseLedcontrolData(string TableConfigDataLineFromLedControlIni, bool ThrowExceptions = true)
39  {
40  TableConfig TC=null;
41  try
42  {
43  TC = new TableConfig(TableConfigDataLineFromLedControlIni, ThrowExceptions);
44 
45  }
46  catch (Exception E)
47  {
48  Log.Exception("Could not load table config from data line: {0}".Build(TableConfigDataLineFromLedControlIni), E);
49  if (ThrowExceptions)
50  {
51  throw new Exception("Could not load table config from data line: {0}".Build(TableConfigDataLineFromLedControlIni),E);
52  }
53 
54  };
55  if (TC != null)
56  {
57  if (Contains(TC.ShortRomName))
58  {
59  Log.Exception("Table with ShortRomName {0} has already been loaded (Exists more than once in ledcontrol file).".Build(TC.ShortRomName));
60  if (ThrowExceptions)
61  {
62  throw new Exception("Table with ShortRomName {0} has already been loaded.".Build(TC.ShortRomName));
63  }
64  }
65  {
66  Add(TC);
67  }
68  }
69  }
70 
78  public bool Contains(string ShortRomName)
79  {
80  foreach (TableConfig TC in this)
81  {
82  if (TC.ShortRomName.Equals(ShortRomName, StringComparison.InvariantCultureIgnoreCase))
83  {
84  return true;
85  }
86  }
87  return false;
88  }
89 
90 
91  }
92 }
A table config from a ini file.
Definition: TableConfig.cs:9
void ParseLedcontrolData(IEnumerable< string > TableConfigDataFromLedControlIni, bool ThrowExceptions=true)
Parses several lines of LedControlData.
bool Contains(string ShortRomName)
Determines whether the list contains the specified short rom name.
A simple logger used to record important events and exceptions.
Definition: Log.cs:14
string ShortRomName
Gets or sets the short name of the rom.
Definition: TableConfig.cs:18
void ParseLedcontrolData(string TableConfigDataLineFromLedControlIni, bool ThrowExceptions=true)
Parses a line of LedControl data contaning the config for a table.
static void Exception(string Message, Exception E=null)
Writes a exception message to the log.
Definition: Log.cs:144
A list of table configs from a ini file.