FEqualIdentity() static private method

static private FEqualIdentity ( XmlNode node, string name, string ns ) : bool
node System.Xml.XmlNode
name string
ns string
return bool
 internal void LoadSchema(XmlElement schemaRoot, DataSet ds)
 {
     if (schemaRoot != null)
     {
         this._schemaRoot = schemaRoot;
         this._ds         = ds;
         this._schemaName = schemaRoot.GetAttribute("name");
         this._schemaUri  = "";
         if ((this._schemaName == null) || (this._schemaName.Length == 0))
         {
             this._schemaName = "NewDataSet";
         }
         ds.Namespace = this._schemaUri;
         for (XmlNode node = schemaRoot.FirstChild; node != null; node = node.NextSibling)
         {
             if (node is XmlElement)
             {
                 XmlElement element = (XmlElement)node;
                 if (XMLSchema.FEqualIdentity(element, "ElementType", "urn:schemas-microsoft-com:xml-data"))
                 {
                     this.HandleTable(element);
                 }
             }
         }
         this._schemaName = XmlConvert.DecodeName(this._schemaName);
         if (ds.Tables[this._schemaName] == null)
         {
             ds.DataSetName = this._schemaName;
         }
     }
 }
        internal bool IsXDRField(XmlElement node, XmlElement typeNode)
        {
            int minOccurs = 1;
            int maxOccurs = 1;

            if (!this.IsTextOnlyContent(typeNode))
            {
                return(false);
            }
            for (XmlNode node2 = typeNode.FirstChild; node2 != null; node2 = node2.NextSibling)
            {
                if (XMLSchema.FEqualIdentity(node2, "element", "urn:schemas-microsoft-com:xml-data") || XMLSchema.FEqualIdentity(node2, "attribute", "urn:schemas-microsoft-com:xml-data"))
                {
                    return(false);
                }
            }
            if (XMLSchema.FEqualIdentity(node, "element", "urn:schemas-microsoft-com:xml-data"))
            {
                this.GetMinMax(node, ref minOccurs, ref maxOccurs);
                if ((maxOccurs == -1) || (maxOccurs > 1))
                {
                    return(false);
                }
            }
            return(true);
        }
        internal XmlElement FindTypeNode(XmlElement node)
        {
            if (XMLSchema.FEqualIdentity(node, "ElementType", "urn:schemas-microsoft-com:xml-data"))
            {
                return(node);
            }
            string attribute = node.GetAttribute("type");

            if (XMLSchema.FEqualIdentity(node, "element", "urn:schemas-microsoft-com:xml-data") || XMLSchema.FEqualIdentity(node, "attribute", "urn:schemas-microsoft-com:xml-data"))
            {
                if ((attribute == null) || (attribute.Length == 0))
                {
                    return(null);
                }
                XmlNode firstChild    = node.OwnerDocument.FirstChild;
                XmlNode ownerDocument = node.OwnerDocument;
                while (firstChild != ownerDocument)
                {
                    if (((XMLSchema.FEqualIdentity(firstChild, "ElementType", "urn:schemas-microsoft-com:xml-data") && XMLSchema.FEqualIdentity(node, "element", "urn:schemas-microsoft-com:xml-data")) || (XMLSchema.FEqualIdentity(firstChild, "AttributeType", "urn:schemas-microsoft-com:xml-data") && XMLSchema.FEqualIdentity(node, "attribute", "urn:schemas-microsoft-com:xml-data"))) && ((firstChild is XmlElement) && (((XmlElement)firstChild).GetAttribute("name") == attribute)))
                    {
                        return((XmlElement)firstChild);
                    }
                    if (firstChild.FirstChild != null)
                    {
                        firstChild = firstChild.FirstChild;
                    }
                    else
                    {
                        if (firstChild.NextSibling == null)
                        {
                            goto Label_0115;
                        }
                        firstChild = firstChild.NextSibling;
                    }
                    continue;
Label_00FD:
                    firstChild = firstChild.ParentNode;
                    if (firstChild.NextSibling != null)
                    {
                        firstChild = firstChild.NextSibling;
                        continue;
                    }
Label_0115:
                    if (firstChild != ownerDocument)
                    {
                        goto Label_00FD;
                    }
                }
            }
            return(null);
        }
        internal string GetInstanceName(XmlElement node)
        {
            string attribute;

            if (XMLSchema.FEqualIdentity(node, "ElementType", "urn:schemas-microsoft-com:xml-data") || XMLSchema.FEqualIdentity(node, "AttributeType", "urn:schemas-microsoft-com:xml-data"))
            {
                attribute = node.GetAttribute("name");
                if ((attribute == null) || (attribute.Length == 0))
                {
                    throw ExceptionBuilder.MissingAttribute("Element", "name");
                }
                return(attribute);
            }
            attribute = node.GetAttribute("type");
            if ((attribute == null) || (attribute.Length == 0))
            {
                throw ExceptionBuilder.MissingAttribute("Element", "type");
            }
            return(attribute);
        }
 internal void HandleTypeNode(XmlElement typeNode, DataTable table, ArrayList tableChildren)
 {
     for (XmlNode node = typeNode.FirstChild; node != null; node = node.NextSibling)
     {
         if (node is XmlElement)
         {
             if (XMLSchema.FEqualIdentity(node, "element", "urn:schemas-microsoft-com:xml-data"))
             {
                 DataTable table2 = this.HandleTable((XmlElement)node);
                 if (table2 != null)
                 {
                     tableChildren.Add(table2);
                     continue;
                 }
             }
             if (XMLSchema.FEqualIdentity(node, "attribute", "urn:schemas-microsoft-com:xml-data") || XMLSchema.FEqualIdentity(node, "element", "urn:schemas-microsoft-com:xml-data"))
             {
                 this.HandleColumn((XmlElement)node, table);
             }
         }
     }
 }
        internal void HandleColumn(XmlElement node, DataTable table)
        {
            DataColumn column;
            Type       type;
            string     str3;
            string     str4;
            int        minOccurs = 0;
            int        maxOccurs = 1;

            node.GetAttribute("use");
            if (node.Attributes.Count > 0)
            {
                string str7 = node.GetAttribute("ref");
                if ((str7 != null) && (str7.Length > 0))
                {
                    return;
                }
                str3   = str4 = this.GetInstanceName(node);
                column = table.Columns[str4, this._schemaUri];
                if (column != null)
                {
                    if (column.ColumnMapping == MappingType.Attribute)
                    {
                        if (XMLSchema.FEqualIdentity(node, "attribute", "urn:schemas-microsoft-com:xml-data"))
                        {
                            throw ExceptionBuilder.DuplicateDeclaration(str3);
                        }
                    }
                    else if (XMLSchema.FEqualIdentity(node, "element", "urn:schemas-microsoft-com:xml-data"))
                    {
                        throw ExceptionBuilder.DuplicateDeclaration(str3);
                    }
                    str4 = XMLSchema.GenUniqueColumnName(str3, table);
                }
            }
            else
            {
                str3 = str4 = "";
            }
            XmlElement element = this.FindTypeNode(node);
            SimpleType type2   = null;

            if (element == null)
            {
                throw ExceptionBuilder.UndefinedDatatype(node.GetAttribute("type"));
            }
            string attribute = element.GetAttribute("type", "urn:schemas-microsoft-com:datatypes");
            string dtValues  = element.GetAttribute("values", "urn:schemas-microsoft-com:datatypes");

            if ((attribute == null) || (attribute.Length == 0))
            {
                attribute = "";
                type      = typeof(string);
            }
            else
            {
                type = this.ParseDataType(attribute, dtValues);
                if (attribute == "float")
                {
                    attribute = "";
                }
                if (attribute == "char")
                {
                    attribute = "";
                    type2     = SimpleType.CreateSimpleType(type);
                }
                if (attribute == "enumeration")
                {
                    attribute = "";
                    type2     = SimpleType.CreateEnumeratedType(dtValues);
                }
                if (attribute == "bin.base64")
                {
                    attribute = "";
                    type2     = SimpleType.CreateByteArrayType("base64");
                }
                if (attribute == "bin.hex")
                {
                    attribute = "";
                    type2     = SimpleType.CreateByteArrayType("hex");
                }
            }
            bool isAttribute = XMLSchema.FEqualIdentity(node, "attribute", "urn:schemas-microsoft-com:xml-data");

            this.GetMinMax(node, isAttribute, ref minOccurs, ref maxOccurs);
            string str2 = null;

            str2 = node.GetAttribute("default");
            bool flag2 = false;

            column = new DataColumn(XmlConvert.DecodeName(str4), type, null, isAttribute ? MappingType.Attribute : MappingType.Element);
            XMLSchema.SetProperties(column, node.Attributes);
            column.XmlDataType = attribute;
            column.SimpleType  = type2;
            column.AllowDBNull = (minOccurs == 0) || flag2;
            column.Namespace   = isAttribute ? string.Empty : this._schemaUri;
            if (node.Attributes != null)
            {
                for (int i = 0; i < node.Attributes.Count; i++)
                {
                    if ((node.Attributes[i].NamespaceURI == "urn:schemas-microsoft-com:xml-msdata") && (node.Attributes[i].LocalName == "Expression"))
                    {
                        column.Expression = node.Attributes[i].Value;
                        break;
                    }
                }
            }
            string str5 = node.GetAttribute("targetNamespace");

            if ((str5 != null) && (str5.Length > 0))
            {
                column.Namespace = str5;
            }
            table.Columns.Add(column);
            if ((str2 != null) && (str2.Length != 0))
            {
                try
                {
                    column.DefaultValue = SqlConvert.ChangeTypeForXML(str2, type);
                }
                catch (FormatException)
                {
                    throw ExceptionBuilder.CannotConvert(str2, type.FullName);
                }
            }
            for (XmlNode node2 = node.FirstChild; node2 != null; node2 = node2.NextSibling)
            {
                if (XMLSchema.FEqualIdentity(node2, "description", "urn:schemas-microsoft-com:xml-data"))
                {
                    column.Description(((XmlElement)node2).InnerText);
                }
            }
        }