private void ConvertBand(Band band, string data) { //This method is responsible for initiating parsing of //band section. A new instance of band parser is created //by passing the current data and band information BandParser bandParser; bandParser = new BandParser(dataReader, data, band); //loop till data contains appropriate band identifer while (bandParser.Parse() == true) { //invoke the writer band start method dataWriter.WriteStartBand(band, bandParser.Data); //iterate through individual row of band foreach (Row row in band.Rows) { //a row can be child band //if it is then a recursive call to CovertBand //is triggered if (row.ChildBand != null) { ConvertBand(row.ChildBand, data); } else { ConvertRow(row, data); } //get the next data data = dataReader.Next(); } //invoke the writer band end method dataWriter.WriteEndBand(band); bandParser.Data = data; } }
public void Convert(BooleanCursor reader, IWriter writer) { dataWriter = writer; dataReader = reader; //Parsing kicks off with the invocation of this method. //Parsing code has been packaged inside ConvertBand, ConvertRow and //ConvertCol method. These methods instantiate an appropriate parser and //based on the return value of Parse method it invokes //Writer WriteXXX method. foreach (Band curBand in dceSchema.Bands) { ConvertBand(curBand, dataReader.Next()); } //Close the underlying reader and writer dataReader.BaseReader.Close(); dataWriter.BaseWriter.Close(); }