Ejemplo n.º 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);
        }
Ejemplo n.º 2
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);
        }
        public bool Validate(out string message)
        {
            message = null;
            if (CompareWithInvariantCulture(m_validationNamespace, base.NamespaceURI, ignoreCase: false) != 0)
            {
                return(true);
            }
            XmlSchemaComplexType xmlSchemaComplexType = null;
            bool      result    = true;
            ArrayList arrayList = new ArrayList();

            switch (base.NodeType)
            {
            case XmlNodeType.Element:
            {
                if (m_rdlElementStack == null)
                {
                    m_rdlElementStack = new RdlElementStack();
                }
                xmlSchemaComplexType = (base.SchemaType as XmlSchemaComplexType);
                if (xmlSchemaComplexType != null)
                {
                    TraverseParticle(xmlSchemaComplexType.ContentTypeParticle, arrayList);
                }
                if (!base.IsEmptyElement)
                {
                    if (xmlSchemaComplexType != null && 1 < arrayList.Count && CompareWithInvariantCulture("ReportItemsType", xmlSchemaComplexType.Name, ignoreCase: false) != 0 && CompareWithInvariantCulture("MapLayersType", xmlSchemaComplexType.Name, ignoreCase: false) != 0)
                    {
                        Hashtable hashtable2 = new Hashtable(arrayList.Count);
                        hashtable2.Add("_ParentName", base.LocalName);
                        hashtable2.Add("_Type", xmlSchemaComplexType);
                        m_rdlElementStack.Add(hashtable2);
                    }
                    else
                    {
                        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 || m_rdlElementStack == null)
                {
                    break;
                }
                Hashtable hashtable3 = 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 (m_rdlElementStack == null)
                {
                    break;
                }
                Hashtable hashtable = m_rdlElementStack[m_rdlElementStack.Count - 1];
                if (hashtable != null)
                {
                    xmlSchemaComplexType = (hashtable["_Type"] as XmlSchemaComplexType);
                    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));
                        }
                    }
                    m_rdlElementStack[m_rdlElementStack.Count - 1] = null;
                }
                m_rdlElementStack.RemoveAt(m_rdlElementStack.Count - 1);
                break;
            }
            }
            return(result);
        }
Ejemplo n.º 4
0
        public bool ValidateStartElement(out string message)
        {
            message = null;
            XmlSchemaComplexType xmlSchemaComplexType = null;
            ArrayList            arrayList            = null;

            if (m_rdlElementStack == null)
            {
                m_rdlElementStack = new RdlElementStack();
            }
            if (m_reader.SchemaInfo != null && m_validationNamespaces.Contains(m_reader.NamespaceURI))
            {
                xmlSchemaComplexType = (m_reader.SchemaInfo.SchemaType as XmlSchemaComplexType);
            }
            if (xmlSchemaComplexType != null)
            {
                arrayList = new ArrayList();
                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", m_reader.LocalName);
                hashtable.Add("_Type", xmlSchemaComplexType);
                m_rdlElementStack.Add(hashtable);
            }
            else
            {
                m_rdlElementStack.Add(null);
            }
            if (0 < m_reader.Depth && m_rdlElementStack != null)
            {
                Hashtable hashtable2 = m_rdlElementStack[m_reader.Depth - 1];
                if (hashtable2 != null)
                {
                    if (hashtable2.ContainsKey(m_reader.LocalName))
                    {
                        message = ValidationMessage("rdlValidationInvalidElement", (string)hashtable2["_ParentName"], m_reader.LocalName);
                        return(false);
                    }
                    hashtable2.Add(m_reader.LocalName, null);
                }
            }
            string text = (m_reader.GetAttribute("MustUnderstand") ?? string.Empty).Trim();

            if (!string.IsNullOrEmpty(text))
            {
                string[] array = text.Split();
                foreach (string text2 in array)
                {
                    string text3 = m_reader.LookupNamespace(text2);
                    if (!m_validationNamespaces.Contains(text3))
                    {
                        int          num  = 0;
                        int          num2 = 0;
                        IXmlLineInfo obj  = (IXmlLineInfo)m_reader;
                        num     = obj.LineNumber;
                        message = RDLValidatingReaderStrings.rdlValidationUnknownRequiredNamespaces(position: obj.LinePosition.ToString(CultureInfo.InvariantCulture.NumberFormat), xmlns: text2, prefix: text3, sqlServerVersionName: "Microsoft SQL Server 2019 Community Technology Preview 2.3", linenumber: num.ToString(CultureInfo.InvariantCulture.NumberFormat));
                        return(false);
                    }
                }
            }
            return(true);
        }