void DeriveShapeFromRows() { object schemaInfo = null; for (int i = 0; (i < rows.Count) && (null == schemaInfo); i++) { XPathNode nd = rows[i] as XPathNode; Debug.Assert(null != nd && (XPathNodeType.Attribute == nd.NodeType || XPathNodeType.Element == nd.NodeType)); if (null != nd) { if (XPathNodeType.Attribute == nd.NodeType) { schemaInfo = nd.SchemaAttribute; } else { schemaInfo = nd.SchemaElement; } } } if (0 == rows.Count) { // TODO: throw new NotImplementedException("XPath failed to match an elements"); } if (null == schemaInfo) { rows.Clear(); throw new XmlException(SR.XmlDataBinding_NoSchemaType, (string[])null); } ShapeGenerator shapeGen = new ShapeGenerator(this.namespaceResolver); XmlSchemaElement xse = schemaInfo as XmlSchemaElement; if (null != xse) { this.rowShape = shapeGen.GenerateFromSchema(xse); } else { this.rowShape = shapeGen.GenerateFromSchema((XmlSchemaAttribute)schemaInfo); } }
void DeriveShapeFromRows() { object schemaInfo = null; for (int i=0; (i<rows.Count) && (null==schemaInfo); i++) { XPathNode nd = rows[i] as XPathNode; Debug.Assert(null != nd && (XPathNodeType.Attribute == nd.NodeType || XPathNodeType.Element == nd.NodeType)); if (null != nd) { if (XPathNodeType.Attribute == nd.NodeType) schemaInfo = nd.SchemaAttribute; else schemaInfo = nd.SchemaElement; } } if (0 == rows.Count) { throw new NotImplementedException("XPath failed to match an elements"); } if (null == schemaInfo) { rows.Clear(); throw new XmlException(Res.XmlDataBinding_NoSchemaType, (string[])null); } ShapeGenerator shapeGen = new ShapeGenerator(this.namespaceResolver); XmlSchemaElement xse = schemaInfo as XmlSchemaElement; if (null != xse) this.rowShape = shapeGen.GenerateFromSchema(xse); else this.rowShape = shapeGen.GenerateFromSchema((XmlSchemaAttribute)schemaInfo); }