Example #1
0
        /// <summary>
        /// Load this Simple type from the .NET schema
        /// </summary>
        /// <param name="type">The type to load</param>
        public void Load(System.Xml.Schema.XmlSchemaSimpleType type)
        {
            if (type == null)
            {
                return;
            }
            this.Name           = type.Name;
            this.Namespace      = type.QualifiedName != null ? type.QualifiedName.Namespace : Schema.TargetNamespace;
            this.SystemType     = type.Datatype.ValueType;
            this.systemTypeCode = type.Datatype.TypeCode;
            this.Type           = SimpleType.Extension;

            // Deal with an enum
            if (type.Content is System.Xml.Schema.XmlSchemaSimpleTypeList)
            {
                Type = SimpleType.Enum;

                System.Xml.Schema.XmlSchemaSimpleTypeList stl = type.Content as System.Xml.Schema.XmlSchemaSimpleTypeList;

                this.SystemType     = stl.BaseItemType.Datatype.ValueType;
                this.systemTypeCode = stl.BaseItemType.Datatype.TypeCode;

                System.Xml.Schema.XmlSchemaObjectCollection listitems = null;

                if (stl.ItemType != null && stl.ItemType.Content is System.Xml.Schema.XmlSchemaSimpleTypeRestriction) // Restriction meaning this is an enum
                {
                    listitems = (stl.ItemType.Content as System.Xml.Schema.XmlSchemaSimpleTypeRestriction).Facets;
                }
                else if (stl.BaseItemType.Content is System.Xml.Schema.XmlSchemaSimpleTypeUnion)
                {
                    listitems = new System.Xml.Schema.XmlSchemaObjectCollection();
                    foreach (System.Xml.Schema.XmlSchemaObject so in (stl.BaseItemType.Content as System.Xml.Schema.XmlSchemaSimpleTypeUnion).BaseMemberTypes)
                    {
                        if (so is System.Xml.Schema.XmlSchemaSimpleType)
                        {
                            foreach (System.Xml.Schema.XmlSchemaObject o in ((so as System.Xml.Schema.XmlSchemaSimpleType).Content as System.Xml.Schema.XmlSchemaSimpleTypeRestriction).Facets)
                            {
                                listitems.Add(o);
                            }
                        }
                    }
                }

                // TODO: Can lists appear somewhere else?

                // Iterate through the restrictions
                if (listitems != null)
                {
                    foreach (System.Xml.Schema.XmlSchemaObject o in listitems)
                    {
                        if (o is System.Xml.Schema.XmlSchemaEnumerationFacet)
                        {
                            Restrictions.Add((o as System.Xml.Schema.XmlSchemaEnumerationFacet).Value);
                        }
                    }
                }
            }

            //Debugger.Break();
        }
 public bool MatchesXmlType(System.Xml.XPath.XPathItem item, System.Xml.Schema.XmlTypeCode code)
 {
 }
 public bool MatchesXmlType(IList <System.Xml.XPath.XPathItem> seq, System.Xml.Schema.XmlTypeCode code)
 {
 }