System.Data.XSDSchema.FindTypeNode C# (CSharp) Method

FindTypeNode() private method

private FindTypeNode ( XmlSchemaAnnotated node ) : XmlSchemaAnnotated
node System.Xml.Schema.XmlSchemaAnnotated
return System.Xml.Schema.XmlSchemaAnnotated
        internal XmlSchemaAnnotated FindTypeNode(XmlSchemaAnnotated node)
        {
            // this function is returning null
            // if the typeNode for node is in the XSD namespace.

            XmlSchemaAttribute attr = node as XmlSchemaAttribute;
            XmlSchemaElement el = node as XmlSchemaElement;
            bool isAttr = false;
            if (attr != null)
            {
                isAttr = true;
            }

            string _type = isAttr ? attr.SchemaTypeName.Name : el.SchemaTypeName.Name;
            string _typeNs = isAttr ? attr.SchemaTypeName.Namespace : el.SchemaTypeName.Namespace;
            if (_typeNs == Keywords.XSDNS)
                return null;
            XmlSchemaAnnotated typeNode;
            if (_type == null || _type.Length == 0)
            {
                _type = isAttr ? attr.RefName.Name : el.RefName.Name;
                if (_type == null || _type.Length == 0)
                    typeNode = isAttr ? attr.SchemaType : el.SchemaType;
                else
                    typeNode = isAttr ? FindTypeNode((XmlSchemaAnnotated)_attributes[attr.RefName]) : FindTypeNode((XmlSchemaAnnotated)_elementsTable[el.RefName]);
            }
            else
                typeNode = (XmlSchemaAnnotated)_schemaTypes[isAttr ? ((XmlSchemaAttribute)node).SchemaTypeName : ((XmlSchemaElement)node).SchemaTypeName];
            return typeNode;
        }