void ParseCategory(string line)
        {
            var values = Regexs.CustomSegmentationSpliter.Split(line);

            var classname = values[0];
            var invoke    = int.Parse(values[1]);
            var group     = int.Parse(values[2]);
            var length    = int.Parse(values[3]);

            CategoryDefinitions.Add(classname, new int[] { invoke, group, length });
        }
Exemple #2
0
 public void Read(string filename)
 {
     try {
         if (!File.Exists(filename))
         {
             return;
         }
         var doc  = XDocument.Load(filename, LoadOptions.None);
         var root = doc.Root;
         if (root.Name == "Exceptions")
         {
             foreach (var categoryDefElem in root.Elements("CategoryDef"))
             {
                 var name             = (string)categoryDefElem.Attribute("Name");
                 var displayName      = (string)categoryDefElem.Attribute("DisplayName");
                 var shortDisplayName = (string)categoryDefElem.Attribute("ShortDisplayName");
                 var flagsAttr        = (string)categoryDefElem.Attribute("Flags");
                 if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(displayName) || string.IsNullOrWhiteSpace(shortDisplayName))
                 {
                     continue;
                 }
                 var flags = ParseCategoryFlags(flagsAttr);
                 CategoryDefinitions.Add(new DbgExceptionCategoryDefinition(flags, name, displayName, shortDisplayName));
             }
             foreach (var exDefCollElem in root.Elements("ExceptionDefs"))
             {
                 var category = (string)exDefCollElem.Attribute("Category");
                 if (string.IsNullOrWhiteSpace(category))
                 {
                     continue;
                 }
                 foreach (var exDefElem in exDefCollElem.Elements("Exception"))
                 {
                     var name        = (string)exDefElem.Attribute("Name");
                     var code        = (string)exDefElem.Attribute("Code");
                     var description = (string)exDefElem.Attribute("Description");
                     if (string.IsNullOrWhiteSpace(description))
                     {
                         description = null;
                     }
                     var            flagsAttr = (string)exDefElem.Attribute("Flags");
                     DbgExceptionId id;
                     if (code == null)
                     {
                         if (string.IsNullOrWhiteSpace(name))
                         {
                             continue;
                         }
                         id = new DbgExceptionId(category, name);
                     }
                     else
                     {
                         code = code.Trim();
                         bool isHex = code.StartsWith("0x", StringComparison.OrdinalIgnoreCase) || code.StartsWith("&H", StringComparison.OrdinalIgnoreCase);
                         if (isHex)
                         {
                             code = code.Substring(2);
                             if (code != code.Trim() || code.StartsWith("-") || code.StartsWith("+"))
                             {
                                 continue;
                             }
                             if (!int.TryParse(code, NumberStyles.HexNumber, null, out int codeValue))
                             {
                                 if (!uint.TryParse(code, NumberStyles.HexNumber, null, out uint codeValueU))
                                 {
                                     continue;
                                 }
                                 codeValue = (int)codeValueU;
                             }
                         }
                         else
                         {
                             if (!int.TryParse(code, out int codeValue))
                             {
                                 if (!uint.TryParse(code, out uint codeValueU))
                                 {
                                     continue;
                                 }
                                 codeValue = (int)codeValueU;
                             }
                         }
                         id = new DbgExceptionId(category, code);
                     }
                     ExceptionDefinitions.Add(new DbgExceptionDefinition(id, ParseExceptionFlags(flagsAttr), description));
                 }
             }
         }
     }
     catch {
     }
 }