/// <summary> /// Parse a table from the xml. /// </summary> /// <param name="reader">XmlReader where the intermediate is persisted.</param> /// <param name="tableDefinitions">TableDefinitions to use in the intermediate.</param> /// <returns>The parsed table.</returns> internal static Table Read(XmlReader reader, TableDefinitionCollection tableDefinitions) { Debug.Assert("table" == reader.LocalName); bool empty = reader.IsEmptyElement; TableOperation operation = TableOperation.None; string name = null; while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "name": name = reader.Value; break; case "op": switch (reader.Value) { case "add": operation = TableOperation.Add; break; case "drop": operation = TableOperation.Drop; break; default: throw new XmlException(); } break; } } if (null == name) { throw new XmlException(); } TableDefinition tableDefinition = tableDefinitions[name]; Table table = new Table(tableDefinition); table.Operation = operation; if (!empty) { bool done = false; // loop through all the rows in a table while (!done && reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: switch (reader.LocalName) { case "row": Row.Read(reader, table); break; default: throw new XmlException(); } break; case XmlNodeType.EndElement: done = true; break; } } if (!done) { throw new XmlException(); } } return(table); }
/// <summary> /// Creates a table. /// </summary> /// <param name="tableDefinition">Definition of the table.</param> public Table(TableDefinition tableDefinition) { this.Definition = tableDefinition; this.Rows = new List <Row>(); }