CSharp examples for System.Xml:XML Serialization
returns true if a simple type is a restriction from XmlSchemaObject
using System.Xml.Schema; using System.Xml; using System.Text; using System.Linq; using System.Diagnostics; using System.Collections.Generic; using System.Collections; using System;/* w w w . j a v a 2 s . c om*/ public class Main{ /// <summary> /// returns true if a simple type is a restriction /// </summary> /// <param name="restrictionType"></param> /// <returns></returns> public static bool IsEnumerationType(XmlSchemaObject restrictionType) { XmlSchemaObjectCollection facets = new XmlSchemaObjectCollection(); if (restrictionType is XmlSchemaSimpleTypeRestriction) facets = ((XmlSchemaSimpleTypeRestriction)restrictionType).Facets; if (restrictionType is XmlSchemaSimpleContentRestriction) facets = ((XmlSchemaSimpleContentRestriction)restrictionType).Facets; foreach (XmlSchemaObject facet in facets) { if (facet is XmlSchemaEnumerationFacet) return true; } return false; } }