/// <summary>
/// Handle loading the data classes.
/// </summary>
/// <param name="section">The section being loaded.</param>
private void HandleDataClasses(EncogFileSection section)
{
var map = new Dictionary <String, List <AnalystClassItem> >();
bool first = true;
foreach (String line in section.Lines)
{
if (!first)
{
IList <String> cols = EncogFileSection.SplitColumns(line);
if (cols.Count < ColumnFour)
{
throw new AnalystError("Invalid data class: " + line);
}
String field = cols[0];
String code = cols[1];
String name = cols[2];
int count = Int32.Parse(cols[3]);
DataField df = _script.FindDataField(field);
if (df == null)
{
throw new AnalystError(
"Attempting to add class to unknown field: " + name);
}
List <AnalystClassItem> classItems;
if (!map.ContainsKey(field))
{
classItems = new List <AnalystClassItem>();
map[field] = classItems;
}
else
{
classItems = map[field];
}
classItems.Add(new AnalystClassItem(code, name, count));
}
else
{
first = false;
}
}
foreach (DataField field in _script.Fields)
{
if (field.Class)
{
List <AnalystClassItem> classList = map[field.Name];
if (classList != null)
{
classList.Sort();
field.ClassMembers.Clear();
foreach (AnalystClassItem item in classList)
{
field.ClassMembers.Add(item);
}
}
}
}
}