public static XmlSchemaComplexType GetTypedTableSchema(XmlSchemaSet xs) { XmlSchemaComplexType xmlSchemaComplexType; XmlSchema xmlSchema; XmlSchemaComplexType type = new XmlSchemaComplexType(); XmlSchemaSequence sequence = new XmlSchemaSequence(); guard_profiles_dbDataSet ds = new guard_profiles_dbDataSet(); XmlSchemaAny any1 = new XmlSchemaAny() { Namespace = "http://www.w3.org/2001/XMLSchema", MinOccurs = new decimal(0), MaxOccurs = new decimal(-1, -1, -1, false, 0), ProcessContents = XmlSchemaContentProcessing.Lax }; sequence.Items.Add(any1); XmlSchemaAny any2 = new XmlSchemaAny() { Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1", MinOccurs = new decimal(1), ProcessContents = XmlSchemaContentProcessing.Lax }; sequence.Items.Add(any2); XmlSchemaAttribute attribute1 = new XmlSchemaAttribute() { Name = "namespace", FixedValue = ds.Namespace }; type.Attributes.Add(attribute1); XmlSchemaAttribute attribute2 = new XmlSchemaAttribute() { Name = "tableTypeName", FixedValue = "Tbl_sg_profilesDataTable" }; type.Attributes.Add(attribute2); type.Particle = sequence; XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { MemoryStream s1 = new MemoryStream(); MemoryStream s2 = new MemoryStream(); try { XmlSchema schema = null; dsSchema.Write(s1); IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); while (schemas.MoveNext()) { schema = (XmlSchema)schemas.Current; s2.SetLength((long)0); schema.Write(s2); if (s1.Length != s2.Length) { continue; } s1.Position = (long)0; s2.Position = (long)0; while (s1.Position != s1.Length && s1.ReadByte() == s2.ReadByte()) { } if (s1.Position != s1.Length) { continue; } xmlSchemaComplexType = type; return(xmlSchemaComplexType); } xmlSchema = xs.Add(dsSchema); return(type); } finally { if (s1 != null) { s1.Close(); } if (s2 != null) { s2.Close(); } } return(xmlSchemaComplexType); } xmlSchema = xs.Add(dsSchema); return(type); }
public static XmlSchemaComplexType GetTypedDataSetSchema(XmlSchemaSet xs) { XmlSchemaComplexType xmlSchemaComplexType; XmlSchema xmlSchema; guard_profiles_dbDataSet ds = new guard_profiles_dbDataSet(); XmlSchemaComplexType type = new XmlSchemaComplexType(); XmlSchemaSequence sequence = new XmlSchemaSequence(); XmlSchemaAny any = new XmlSchemaAny() { Namespace = ds.Namespace }; sequence.Items.Add(any); type.Particle = sequence; XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { MemoryStream s1 = new MemoryStream(); MemoryStream s2 = new MemoryStream(); try { XmlSchema schema = null; dsSchema.Write(s1); IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); while (schemas.MoveNext()) { schema = (XmlSchema)schemas.Current; s2.SetLength((long)0); schema.Write(s2); if (s1.Length != s2.Length) { continue; } s1.Position = (long)0; s2.Position = (long)0; while (s1.Position != s1.Length && s1.ReadByte() == s2.ReadByte()) { } if (s1.Position != s1.Length) { continue; } xmlSchemaComplexType = type; return(xmlSchemaComplexType); } xmlSchema = xs.Add(dsSchema); return(type); } finally { if (s1 != null) { s1.Close(); } if (s2 != null) { s2.Close(); } } return(xmlSchemaComplexType); } xmlSchema = xs.Add(dsSchema); return(type); }