public void AddReaders(string directory) { foreach (var D2oFile in Directory.EnumerateFiles(directory).Where(entry => entry.EndsWith(".d2o"))) { var reader = new D2oReader(D2oFile); AddReader(reader); } }
private void ResetMembersByReading() { var reader = new D2oReader(File.OpenRead(Filename)); indexTable = reader.Indexes; classes = reader.Classes; allocatedClassId = classes.ToDictionary(entry => entry.Value.ClassType, entry => entry.Key); objects = reader.ReadObjects(); reader.Close(); }
private void ReadClassesTable() { this._classcount = _reader.ReadInt(); this.Classes = new Dictionary <int, D2oClassDefinition>(this._classcount); for (int i = 0; i < this._classcount; i++) { int num = this._reader.ReadInt(); string text = this._reader.ReadUTF(); string packagename = this._reader.ReadUTF(); Type type = D2oReader.FindType(text); if (type == null) { type = D2oReader.FindType(text + "s"); if (type == null) { throw new ArgumentException(text); } } int num2 = this._reader.ReadInt(); List <D2oFieldDefinition> list = new List <D2oFieldDefinition>(num2); for (int j = 0; j < num2; j++) { string text2 = this._reader.ReadUTF().Replace("_", ""); text2 = char.ToUpper(text2[0]).ToString() + text2.Substring(1); D2oFieldType d2oFieldType = (D2oFieldType)this._reader.ReadInt(); List <Tuple <D2oFieldType, string> > list2 = new List <Tuple <D2oFieldType, string> >(); if (d2oFieldType == D2oFieldType.List) { D2oFieldType d2oFieldType2; do { string item = this._reader.ReadUTF(); d2oFieldType2 = (D2oFieldType)this._reader.ReadInt(); list2.Add(Tuple.Create <D2oFieldType, string>(d2oFieldType2, item)); }while (d2oFieldType2 == D2oFieldType.List); } FieldInfo field = type.GetField(text2); if (field == null) { field = type.GetField(char.ToLower(text2[0]).ToString() + text2.Substring(1)); if (field == null) { throw new Exception(string.Format("Missing field '{0}' ({1}) in class '{2}'", text2, d2oFieldType, type.Name)); } } list.Add(new D2oFieldDefinition(text2, d2oFieldType, field, this._reader.Position, list2.ToArray())); } this.Classes.Add(num, new D2oClassDefinition(num, text, packagename, type, list, this._reader.Position)); } }
private void AddReader(D2oReader D2oFile) { var classes = D2oFile.Classes; foreach (var @class in classes) { if (ignoredTypes.Contains(@class.Value.ClassType)) { continue; } if (readers.ContainsKey(@class.Value.ClassType)) { // this classes are not bound to a single file, so we ignore them ignoredTypes.Add(@class.Value.ClassType); readers.Remove(@class.Value.ClassType); } else { readers.Add(@class.Value.ClassType, D2oFile); } } }