public DictionaryItem(string name, string val) { if (name == "") { throw new RuntimeException("Dictionary items must have a name"); } if (name.StartsWith("/")) { m_name = name.Substring(1, name.Length - 1); } else { m_name = name; } Utility.TraceLine("Dictionary item named: " + name + " added"); if (val.StartsWith("[")) { val = val.Substring(1, val.Length - 2); } else if (val.StartsWith("/")) { val = val.Substring(1, val.Length - 1); } Regex reObjects = new Regex("^[ \t]*([0-9]+) ([0-9]+) R[ \t]*(.*)$"); Match mtchObjects = reObjects.Match(val); Regex reNumber = new Regex("^[0-9][ \t]*$"); Match mtchNumber = reNumber.Match(val); if (mtchObjects.Success) { // Object array string tempval = val; while (tempval != "") { mtchObjects = reObjects.Match(tempval); ObjectReference or = new ObjectReference(); try { or.Number = Int32.Parse(mtchObjects.Groups[1].Value); or.Generation = Int32.Parse(mtchObjects.Groups[2].Value); } catch (Exception) { Utility.TraceLine("Gave up on object reference parsing for this dictionary item: " + val); m_objects.Clear(); m_stringval = val; m_type = ValueType.String; return; } m_objects.Add(or); try { tempval = mtchObjects.Groups[3].Value; } catch (Exception) { tempval = ""; } } m_type = ValueType.Objects; } else if (mtchNumber.Success) { m_intval = Int32.Parse(val); m_type = ValueType.Number; } else { m_stringval = val; m_type = ValueType.String; } }
public void Add(ObjectReference obj) { List.Add(obj); }