public void ProcessKgrp(int length) { var keygroup = new Keygroup(); int fourCc; int size; int countEnv = 0; int countZone = 0; int zoneNumber = 1; while (length > 0) { ReadTwoInts(out fourCc, out size); length -= Twodwordssize; var type = FromFourCc(fourCc); //Console.WriteLine("Found element called \"" + type + "\" and length " + size.ToString()); List <string> list = new List <string>(); list = SetList(type, list, keygroup, ref countEnv, ref countZone); if (type == "zone") { string sampleName = ""; var valueByte = ReadByte(); var charFromByte = FromOneCc(valueByte); var numberOfChars = ReadByte(); sampleName = SampleName(numberOfChars); if (zoneNumber == 1) { // on 1st zone } //Console.WriteLine("Sample Name: " + sampleName); list.Add(sampleName); ReadBytes(14, list); length -= 48; zoneNumber++; } else { ReadBytes(size, list); length -= size; } } program.Keygroups.Add(keygroup); }
private static List <string> SetList(string type, List <string> list, Keygroup keygroup, ref int countEnv, ref int countZone) { switch (type) { case "kloc": list = keygroup.Klocation; break; case "env ": switch (countEnv) { case 0: list = keygroup.AmpEnv; countEnv++; break; case 1: list = keygroup.FilterEnv; countEnv++; break; case 2: list = keygroup.AuxEnv; countEnv++; break; } break; case "filt": list = keygroup.Filter; break; case "zone": switch (countZone) { case 0: list = keygroup.Zone1; countZone++; break; case 1: list = keygroup.Zone2; countZone++; break; case 2: list = keygroup.Zone3; countZone++; break; case 3: list = keygroup.Zone4; countZone++; break; } break; } return(list); }