Exemple #1
0
        public bool Validate(out string message)
        {
            message = null;
            if (!ListUtils.ContainsWithOrdinalComparer(this.m_reader.NamespaceURI, this.m_validationNamespaceList))
            {
                return(true);
            }
            XmlSchemaComplexType xmlSchemaComplexType = null;
            bool      result    = true;
            ArrayList arrayList = new ArrayList();

            switch (this.m_reader.NodeType)
            {
            case XmlNodeType.Element:
                if (this.m_rdlElementStack == null)
                {
                    this.m_rdlElementStack = new RdlElementStack();
                }
                xmlSchemaComplexType = (this.m_reader.SchemaInfo.SchemaType as XmlSchemaComplexType);
                if (xmlSchemaComplexType != null)
                {
                    RDLValidatingReader.TraverseParticle(xmlSchemaComplexType.ContentTypeParticle, arrayList);
                }
                if (!this.m_reader.IsEmptyElement)
                {
                    if (xmlSchemaComplexType != null && 1 < arrayList.Count && RDLValidatingReader.CompareWithInvariantCulture("ReportItemsType", xmlSchemaComplexType.Name, false) != 0 && RDLValidatingReader.CompareWithInvariantCulture("MapLayersType", xmlSchemaComplexType.Name, false) != 0)
                    {
                        Hashtable hashtable2 = new Hashtable(arrayList.Count);
                        hashtable2.Add("_ParentName", this.m_reader.LocalName);
                        hashtable2.Add("_Type", xmlSchemaComplexType);
                        this.m_rdlElementStack.Add(hashtable2);
                    }
                    else
                    {
                        this.m_rdlElementStack.Add(null);
                    }
                }
                else if (xmlSchemaComplexType != null)
                {
                    for (int j = 0; j < arrayList.Count; j++)
                    {
                        XmlSchemaElement xmlSchemaElement2 = arrayList[j] as XmlSchemaElement;
                        if (xmlSchemaElement2.MinOccurs > 0m)
                        {
                            result  = false;
                            message = RDLValidatingReaderStrings.rdlValidationMissingChildElement(this.m_reader.LocalName, xmlSchemaElement2.Name, this.LineNumber.ToString(CultureInfo.InvariantCulture.NumberFormat), this.LinePosition.ToString(CultureInfo.InvariantCulture.NumberFormat));
                        }
                    }
                }
                if (0 < this.m_reader.Depth && this.m_rdlElementStack != null)
                {
                    Hashtable hashtable3 = this.m_rdlElementStack[this.m_reader.Depth - 1];
                    if (hashtable3 != null)
                    {
                        string text = (string)hashtable3[this.m_reader.LocalName];
                        if (text == null)
                        {
                            hashtable3.Add(this.m_reader.LocalName, this.m_reader.NamespaceURI);
                        }
                        else if (RDLValidatingReader.CompareWithInvariantCulture(text, this.m_reader.NamespaceURI, false) == 0)
                        {
                            result  = false;
                            message = RDLValidatingReaderStrings.rdlValidationInvalidElement(hashtable3["_ParentName"] as string, this.m_reader.LocalName, this.LineNumber.ToString(CultureInfo.InvariantCulture.NumberFormat), this.LinePosition.ToString(CultureInfo.InvariantCulture.NumberFormat));
                        }
                        else
                        {
                            string key = this.m_reader.LocalName + "$" + this.m_reader.NamespaceURI;
                            if (hashtable3.ContainsKey(key))
                            {
                                result  = false;
                                message = RDLValidatingReaderStrings.rdlValidationInvalidElement(hashtable3["_ParentName"] as string, this.m_reader.LocalName, this.LineNumber.ToString(CultureInfo.InvariantCulture.NumberFormat), this.LinePosition.ToString(CultureInfo.InvariantCulture.NumberFormat));
                            }
                            else
                            {
                                hashtable3.Add(key, this.m_reader.LocalName);
                            }
                        }
                    }
                }
                break;

            case XmlNodeType.EndElement:
                if (this.m_rdlElementStack != null)
                {
                    Hashtable hashtable = this.m_rdlElementStack[this.m_rdlElementStack.Count - 1];
                    if (hashtable != null)
                    {
                        xmlSchemaComplexType = (hashtable["_Type"] as XmlSchemaComplexType);
                        RDLValidatingReader.TraverseParticle(xmlSchemaComplexType.ContentTypeParticle, arrayList);
                        for (int i = 0; i < arrayList.Count; i++)
                        {
                            XmlSchemaElement xmlSchemaElement = arrayList[i] as XmlSchemaElement;
                            if (xmlSchemaElement.MinOccurs > 0m && !hashtable.ContainsKey(xmlSchemaElement.Name))
                            {
                                result  = false;
                                message = RDLValidatingReaderStrings.rdlValidationMissingChildElement(this.m_reader.LocalName, xmlSchemaElement.Name, this.LineNumber.ToString(CultureInfo.InvariantCulture.NumberFormat), this.LinePosition.ToString(CultureInfo.InvariantCulture.NumberFormat));
                            }
                        }
                        this.m_rdlElementStack[this.m_rdlElementStack.Count - 1] = null;
                    }
                    this.m_rdlElementStack.RemoveAt(this.m_rdlElementStack.Count - 1);
                }
                break;
            }
            return(result);
        }