コード例 #1
0
        public bool ValidateStartElement(out string message)
        {
            message = null;
            XmlSchemaComplexType xmlSchemaComplexType = null;
            ArrayList            arrayList            = null;

            if (this.m_rdlElementStack == null)
            {
                this.m_rdlElementStack = new RdlElementStack();
            }
            if (this.m_reader.SchemaInfo != null && this.m_validationNamespaces.Contains(this.m_reader.NamespaceURI))
            {
                xmlSchemaComplexType = (this.m_reader.SchemaInfo.SchemaType as XmlSchemaComplexType);
            }
            if (xmlSchemaComplexType != null)
            {
                arrayList = new ArrayList();
                RdlValidator.TraverseParticle(xmlSchemaComplexType.ContentTypeParticle, arrayList);
            }
            if (xmlSchemaComplexType != null && 1 < arrayList.Count && "MapLayersType" != xmlSchemaComplexType.Name && "ReportItemsType" != xmlSchemaComplexType.Name)
            {
                Hashtable hashtable = new Hashtable(arrayList.Count);
                hashtable.Add("_ParentName", this.m_reader.LocalName);
                hashtable.Add("_Type", xmlSchemaComplexType);
                this.m_rdlElementStack.Add(hashtable);
            }
            else
            {
                this.m_rdlElementStack.Add(null);
            }
            if (0 < this.m_reader.Depth && this.m_rdlElementStack != null)
            {
                Hashtable hashtable2 = this.m_rdlElementStack[this.m_reader.Depth - 1];
                if (hashtable2 != null)
                {
                    if (hashtable2.ContainsKey(this.m_reader.LocalName))
                    {
                        message = this.ValidationMessage("rdlValidationInvalidElement", (string)hashtable2["_ParentName"], this.m_reader.LocalName);
                        return(false);
                    }
                    hashtable2.Add(this.m_reader.LocalName, null);
                }
            }
            string text = (this.m_reader.GetAttribute("MustUnderstand") ?? string.Empty).Trim();

            if (!string.IsNullOrEmpty(text))
            {
                string[] array = text.Split();
                foreach (string text2 in array)
                {
                    string text3 = this.m_reader.LookupNamespace(text2);
                    if (!this.m_validationNamespaces.Contains(text3))
                    {
                        int          num         = 0;
                        int          num2        = 0;
                        IXmlLineInfo xmlLineInfo = (IXmlLineInfo)this.m_reader;
                        num     = xmlLineInfo.LineNumber;
                        num2    = xmlLineInfo.LinePosition;
                        message = RDLValidatingReaderStrings.rdlValidationUnknownRequiredNamespaces(text2, text3, "Microsoft SQL Server 2017", num.ToString(CultureInfo.InvariantCulture.NumberFormat), num2.ToString(CultureInfo.InvariantCulture.NumberFormat));
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #2
0
        public bool Validate(out string message)
        {
            message = null;
            if (RDLValidatingReader.CompareWithInvariantCulture(this.m_validationNamespace, base.NamespaceURI, false) != 0)
            {
                return(true);
            }
            XmlSchemaComplexType xmlSchemaComplexType = null;
            bool      result    = true;
            ArrayList arrayList = new ArrayList();

            switch (base.NodeType)
            {
            case XmlNodeType.Element:
                if (this.m_rdlElementStack == null)
                {
                    this.m_rdlElementStack = new RdlElementStack();
                }
                xmlSchemaComplexType = (base.SchemaType as XmlSchemaComplexType);
                if (xmlSchemaComplexType != null)
                {
                    RDLValidatingReader.TraverseParticle(xmlSchemaComplexType.ContentTypeParticle, arrayList);
                }
                if (!base.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", base.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(base.LocalName, xmlSchemaElement2.Name, base.LineNumber.ToString(CultureInfo.InvariantCulture.NumberFormat), base.LinePosition.ToString(CultureInfo.InvariantCulture.NumberFormat));
                        }
                    }
                }
                if (0 < base.Depth && this.m_rdlElementStack != null)
                {
                    Hashtable hashtable3 = this.m_rdlElementStack[base.Depth - 1];
                    if (hashtable3 != null)
                    {
                        if (hashtable3.ContainsKey(base.LocalName))
                        {
                            result  = false;
                            message = RDLValidatingReaderStrings.rdlValidationInvalidElement(hashtable3["_ParentName"] as string, base.LocalName, base.LineNumber.ToString(CultureInfo.InvariantCulture.NumberFormat), base.LinePosition.ToString(CultureInfo.InvariantCulture.NumberFormat));
                        }
                        else
                        {
                            hashtable3.Add(base.LocalName, null);
                        }
                    }
                }
                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(base.LocalName, xmlSchemaElement.Name, base.LineNumber.ToString(CultureInfo.InvariantCulture.NumberFormat), base.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);
        }