static InfoReader()
        {
            Stream inStream = null;

            try
            {
                string name = string.Format("{0}.Schemas.{1}", typeof(InfoReader).Namespace, "xsInfo.xsd");
                inStream = typeof(InfoReader).Assembly.GetManifestResourceStream(name);
                Schema   = XmlSchemaUtil.GetSchema(inStream);
            }
            finally
            {
                if (inStream != null)
                {
                    try
                    {
                        inStream.Close();
                    }
                    catch
                    {
                    }
                    inStream = null;
                }
            }
        }
 protected virtual void Initialize(XmlReader reader)
 {
     if (reader == null)
     {
         throw new ArgumentNullException("reader");
     }
     this._reader = reader;
     if (this._reader is XmlValidatingReader)
     {
         this._reader2 = (XmlValidatingReader)this._reader;
     }
     else
     {
         this._reader2 = new XmlValidatingReader(this._reader);
         XmlSchemaUtil.AppendSchema(this._reader2, Schema);
     }
     if ((this._reader.NodeType != XmlNodeType.Element) || (this._reader.Name != "infoTable"))
     {
         while (this._reader2.Read())
         {
             if ((this._reader2.NodeType == XmlNodeType.Element) && (this._reader2.Name == "infoTable"))
             {
                 break;
             }
         }
     }
     this._globalCulture = (this._reader.XmlLang == null) ? CultureInfo.CurrentCulture : new CultureInfo(this._reader.GetAttribute("lang"));
     this._current       = null;
 }
    private XmlQualifiedName SplitQName (string name)
    {
        XmlConvert.VerifyName (name);

        Exception ex = null;
        XmlQualifiedName qname = XmlSchemaUtil.ToQName (reader, name, out ex);
        if (ex != null)
            return XmlQualifiedName.Empty;
        else
            return qname;
    }
Пример #4
0
        public override void LoadFromXml(XmlElement el, XmlNamespaceManager nsmgr)
        {
            base.LoadFromXml(el, nsmgr);
            string pr = nsmgr.LookupPrefix(XmlSchemaUtil.WORKFLOW_NAMESPACE);

            if (pr != null && pr.Length > 0)
            {
                pr += ":";
            }
            VariableDir      = (VariableDef.Dir)Enum.Parse(typeof(VariableDef.Dir), el.GetAttribute("dir"));
            DefaultValueExpr = XmlSchemaUtil.GetXmlElementText(el, pr + "defaultValue", nsmgr);
        }
        private XmlQualifiedName SplitQName(string name)
        {
            XmlConvert.VerifyName(name);
            Exception        ex     = null;
            XmlQualifiedName result = XmlSchemaUtil.ToQName(this.reader, name, out ex);

            if (ex != null)
            {
                return(XmlQualifiedName.Empty);
            }
            return(result);
        }
Пример #6
0
        public virtual void ReadXml(XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            XmlValidatingReader reader2 = null;

            try
            {
                if (!this.IsSynchronized)
                {
                    Monitor.Enter(this.SyncRoot);
                }
                this.ptable.Clear();
                if (!(reader is XmlValidatingReader))
                {
                    reader2 = new XmlValidatingReader(reader);
                    XmlSchemaUtil.AppendSchema(reader2, this.GetSchema());
                }
                while (reader.Read())
                {
                    if (((reader.NodeType == XmlNodeType.EndElement) && (reader.Name == "objectTable")) || ((!(reader.Name == string.Empty) && (reader.NodeType == XmlNodeType.Element)) && ((reader.Name == "item") && !this.ReadItem(reader))))
                    {
                        return;
                    }
                }
            }
            finally
            {
                if (!(reader is XmlValidatingReader) && (reader2 != null))
                {
                    try
                    {
                        reader2.Close();
                    }
                    catch
                    {
                    }
                    reader2 = null;
                }
                if (!this.IsSynchronized)
                {
                    Monitor.Exit(this.SyncRoot);
                }
            }
        }
Пример #7
0
 public bool CompareIdentity(XsdKeyEntry other)
 {
     for (int i = 0; i < this.KeyFields.Count; i++)
     {
         XsdKeyEntryField xsdKeyEntryField  = this.KeyFields[i];
         XsdKeyEntryField xsdKeyEntryField2 = other.KeyFields[i];
         if ((xsdKeyEntryField.IsXsiNil && !xsdKeyEntryField2.IsXsiNil) || (!xsdKeyEntryField.IsXsiNil && xsdKeyEntryField2.IsXsiNil))
         {
             return(false);
         }
         if (!XmlSchemaUtil.AreSchemaDatatypeEqual(xsdKeyEntryField2.FieldType, xsdKeyEntryField2.Identity, xsdKeyEntryField.FieldType, xsdKeyEntryField.Identity))
         {
             return(false);
         }
     }
     return(true);
 }
Пример #8
0
 public bool CompareIdentity(XsdKeyEntry other)
 {
     for (int i = 0; i < KeyFields.Count; i++)
     {
         XsdKeyEntryField f  = this.KeyFields [i];
         XsdKeyEntryField of = other.KeyFields [i];
         if (f.IsXsiNil && !of.IsXsiNil || !f.IsXsiNil && of.IsXsiNil)
         {
             return(false);
         }
         if (!XmlSchemaUtil.AreSchemaDatatypeEqual(
                 of.FieldType, of.Identity, f.FieldType, f.Identity))
         {
             return(false);                      // does not match
         }
     }
     return(true);               // matches
 }
        public void Compile(string nss,
                            ValidationEventHandler h, XmlSchema schema)
        {
            if (SkipCompile)
            {
                return; // used by XmlSchemaAny.AnyTypeContent.
            }
            Reset();
            int    nscount         = 0;
            string actualNamespace = nss == null ? "##any" : nss;

            string[] nslist = XmlSchemaUtil.SplitList(actualNamespace);
            for (int i = 0; i < nslist.Length; i++)
            {
                string ns = nslist [i];
                switch (ns)
                {
                case "##any":
                    if (HasValueAny)
                    {
                        xsobj.error(h, "Multiple specification of ##any was found.");
                    }
                    nscount    |= 1;
                    HasValueAny = true;
                    break;

                case "##other":
                    if (HasValueOther)
                    {
                        xsobj.error(h, "Multiple specification of ##other was found.");
                    }
                    nscount      |= 2;
                    HasValueOther = true;
                    break;

                case "##targetNamespace":
                    if (HasValueTargetNamespace)
                    {
                        xsobj.error(h, "Multiple specification of ##targetNamespace was found.");
                    }
                    nscount |= 4;
                    HasValueTargetNamespace = true;
                    break;

                case "##local":
                    if (HasValueLocal)
                    {
                        xsobj.error(h, "Multiple specification of ##local was found.");
                    }
                    nscount      |= 8;
                    HasValueLocal = true;
                    break;

                default:
                    if (!XmlSchemaUtil.CheckAnyUri(ns))
                    {
                        xsobj.error(h, "the namespace is not a valid anyURI");
                    }
                    else if (ResolvedNamespaces.Contains(ns))
                    {
                        xsobj.error(h, "Multiple specification of '" + ns + "' was found.");
                    }
                    else
                    {
                        nscount |= 16;
                        ResolvedNamespaces.Add(ns);
                    }
                    break;
                }
            }
            if ((nscount & 1) == 1 && nscount != 1)
            {
                xsobj.error(h, "##any if present must be the only namespace attribute");
            }
            if ((nscount & 2) == 2 && nscount != 2)
            {
                xsobj.error(h, "##other if present must be the only namespace attribute");
            }
        }
Пример #10
0
        public void Compile(string nss, ValidationEventHandler h, XmlSchema schema)
        {
            if (this.SkipCompile)
            {
                return;
            }
            this.Reset();
            int    num  = 0;
            string list = (nss != null) ? nss : "##any";

            string[] array = XmlSchemaUtil.SplitList(list);
            int      i     = 0;

            while (i < array.Length)
            {
                string text  = array[i];
                string text2 = text;
                if (text2 == null)
                {
                    goto IL_170;
                }
                if (XsdWildcard.< > f__switch$map6 == null)
                {
                    XsdWildcard.< > f__switch$map6 = new Dictionary <string, int>(4)
                    {
                        {
                            "##any",
                            0
                        },
                        {
                            "##other",
                            1
                        },
                        {
                            "##targetNamespace",
                            2
                        },
                        {
                            "##local",
                            3
                        }
                    };
                }
                int num2;
                if (!XsdWildcard.< > f__switch$map6.TryGetValue(text2, out num2))
                {
                    goto IL_170;
                }
                switch (num2)
                {
                case 0:
                    if (this.HasValueAny)
                    {
                        this.xsobj.error(h, "Multiple specification of ##any was found.");
                    }
                    num |= 1;
                    this.HasValueAny = true;
                    break;

                case 1:
                    if (this.HasValueOther)
                    {
                        this.xsobj.error(h, "Multiple specification of ##other was found.");
                    }
                    num |= 2;
                    this.HasValueOther = true;
                    break;

                case 2:
                    if (this.HasValueTargetNamespace)
                    {
                        this.xsobj.error(h, "Multiple specification of ##targetNamespace was found.");
                    }
                    num |= 4;
                    this.HasValueTargetNamespace = true;
                    break;

                case 3:
                    if (this.HasValueLocal)
                    {
                        this.xsobj.error(h, "Multiple specification of ##local was found.");
                    }
                    num |= 8;
                    this.HasValueLocal = true;
                    break;

                default:
                    goto IL_170;
                }
IL_1DE:
                i++;
                continue;
IL_170:
                if (!XmlSchemaUtil.CheckAnyUri(text))
                {
                    this.xsobj.error(h, "the namespace is not a valid anyURI");
                }
                else if (this.ResolvedNamespaces.Contains(text))
                {
                    this.xsobj.error(h, "Multiple specification of '" + text + "' was found.");
                }
                else
                {
                    num |= 16;
                    this.ResolvedNamespaces.Add(text);
                }
                goto IL_1DE;
            }
            if ((num & 1) == 1 && num != 1)
            {
                this.xsobj.error(h, "##any if present must be the only namespace attribute");
            }
            if ((num & 2) == 2 && num != 2)
            {
                this.xsobj.error(h, "##other if present must be the only namespace attribute");
            }
        }
Пример #11
0
        public void ReadXml(XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            ArrayList           list    = null;
            XmlValidatingReader reader2 = null;

            try
            {
                if (!this.IsSynchronized)
                {
                    if (this._reading)
                    {
                        return;
                    }
                    Monitor.TryEnter(this.SyncRoot);
                }
                if (this._reading)
                {
                    return;
                }
                this._reading = true;
                if (!(reader is XmlValidatingReader))
                {
                    reader2 = new XmlValidatingReader(reader);
                    XmlSchemaUtil.AppendSchema(reader2, this.GetSchema());
                }
                string section = string.Empty;
                string key     = string.Empty;
                list = new ArrayList();
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        switch (reader.Name)
                        {
                        case "section":
                            section = reader.GetAttribute("name");
                            break;

                        case "key":
                            key = reader.GetAttribute("name");
                            if ((section != string.Empty) && (key != string.Empty))
                            {
                                if (reader.IsEmptyElement)
                                {
                                    list.Add(new SettingItem(section, key, string.Empty));
                                }
                                else
                                {
                                    list.Add(new SettingItem(section, key, reader.ReadElementString()));
                                }
                            }
                            break;
                        }
                    }
                }
            }
            finally
            {
                if (!(reader is XmlValidatingReader) && (reader2 != null))
                {
                    try
                    {
                        reader2.Close();
                    }
                    catch
                    {
                    }
                    reader2 = null;
                }
                if (!this.IsSynchronized)
                {
                    Monitor.Exit(this.SyncRoot);
                }
                this._reading = false;
            }
            if (list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    try
                    {
                        SettingItem item = (SettingItem)list[i];
                        this.SetValue(item.Section, item.Key, item.Value);
                    }
                    catch
                    {
                    }
                }
            }
        }