Пример #1
0
        public static XmlSchemaDerivationMethod ReadDerivationAttribute(XmlReader reader, out Exception innerExcpetion, string name, XmlSchemaDerivationMethod allowed)
        {
            innerExcpetion = null;
            XmlSchemaDerivationMethod result;

            try
            {
                string value = reader.Value;
                string text  = string.Empty;
                XmlSchemaDerivationMethod xmlSchemaDerivationMethod = XmlSchemaDerivationMethod.Empty;
                if (value.IndexOf("#all") != -1 && value.Trim() != "#all")
                {
                    innerExcpetion = new Exception(value + " is not a valid value for " + name + ". #all if present must be the only value");
                    result         = XmlSchemaDerivationMethod.All;
                }
                else
                {
                    string[] array = XmlSchemaUtil.SplitList(value);
                    int      i     = 0;
                    while (i < array.Length)
                    {
                        string text2 = array[i];
                        string text3 = text2;
                        if (text3 == null)
                        {
                            goto IL_192;
                        }
                        if (XmlSchemaUtil.< > f__switch$map38 == null)
                        {
                            XmlSchemaUtil.< > f__switch$map38 = new Dictionary <string, int>(7)
                            {
                                {
                                    string.Empty,
                                    0
                                },
                                {
                                    "#all",
                                    1
                                },
                                {
                                    "substitution",
                                    2
                                },
                                {
                                    "extension",
                                    3
                                },
                                {
                                    "restriction",
                                    4
                                },
                                {
                                    "list",
                                    5
                                },
                                {
                                    "union",
                                    6
                                }
                            };
                        }
                        int num;
                        if (!XmlSchemaUtil.< > f__switch$map38.TryGetValue(text3, out num))
                        {
                            goto IL_192;
                        }
                        switch (num)
                        {
                        case 0:
                            xmlSchemaDerivationMethod = XmlSchemaUtil.AddFlag(xmlSchemaDerivationMethod, XmlSchemaDerivationMethod.Empty, allowed);
                            break;

                        case 1:
                            xmlSchemaDerivationMethod = XmlSchemaUtil.AddFlag(xmlSchemaDerivationMethod, XmlSchemaDerivationMethod.All, allowed);
                            break;

                        case 2:
                            xmlSchemaDerivationMethod = XmlSchemaUtil.AddFlag(xmlSchemaDerivationMethod, XmlSchemaDerivationMethod.Substitution, allowed);
                            break;

                        case 3:
                            xmlSchemaDerivationMethod = XmlSchemaUtil.AddFlag(xmlSchemaDerivationMethod, XmlSchemaDerivationMethod.Extension, allowed);
                            break;

                        case 4:
                            xmlSchemaDerivationMethod = XmlSchemaUtil.AddFlag(xmlSchemaDerivationMethod, XmlSchemaDerivationMethod.Restriction, allowed);
                            break;

                        case 5:
                            xmlSchemaDerivationMethod = XmlSchemaUtil.AddFlag(xmlSchemaDerivationMethod, XmlSchemaDerivationMethod.List, allowed);
                            break;

                        case 6:
                            xmlSchemaDerivationMethod = XmlSchemaUtil.AddFlag(xmlSchemaDerivationMethod, XmlSchemaDerivationMethod.Union, allowed);
                            break;

                        default:
                            goto IL_192;
                        }
IL_1A4:
                        i++;
                        continue;
IL_192:
                        text = text + text2 + " ";
                        goto IL_1A4;
                    }
                    if (text != string.Empty)
                    {
                        innerExcpetion = new Exception(text + "is/are not valid values for " + name);
                    }
                    result = xmlSchemaDerivationMethod;
                }
            }
            catch (Exception ex)
            {
                innerExcpetion = ex;
                result         = XmlSchemaDerivationMethod.None;
            }
            return(result);
        }