public static BinaryPacker.Element FromBinary(string filename) { BinaryPacker.Element element; using (FileStream fileStream = File.OpenRead(filename)) { BinaryReader reader = new BinaryReader((Stream)fileStream); reader.ReadString(); string str = reader.ReadString(); short num = reader.ReadInt16(); BinaryPacker.stringLookup = new string[(int)num]; for (int index = 0; index < (int)num; ++index) { BinaryPacker.stringLookup[index] = reader.ReadString(); } element = BinaryPacker.ReadElement(reader); element.Package = str; } return(element); }
private static BinaryPacker.Element ReadElement(BinaryReader reader) { BinaryPacker.Element element = new BinaryPacker.Element(); element.Name = BinaryPacker.stringLookup[(int)reader.ReadInt16()]; byte num1 = reader.ReadByte(); if (num1 > (byte)0) { element.Attributes = new Dictionary <string, object>(); } for (int index = 0; index < (int)num1; ++index) { string key = BinaryPacker.stringLookup[(int)reader.ReadInt16()]; byte num2 = reader.ReadByte(); object obj = (object)null; switch (num2) { case 0: obj = (object)reader.ReadBoolean(); break; case 1: obj = (object)Convert.ToInt32(reader.ReadByte()); break; case 2: obj = (object)Convert.ToInt32(reader.ReadInt16()); break; case 3: obj = (object)reader.ReadInt32(); break; case 4: obj = (object)reader.ReadSingle(); break; case 5: obj = (object)BinaryPacker.stringLookup[(int)reader.ReadInt16()]; break; case 6: obj = (object)reader.ReadString(); break; case 7: short num3 = reader.ReadInt16(); obj = (object)RunLengthEncoding.Decode(reader.ReadBytes((int)num3)); break; } element.Attributes.Add(key, obj); } short num4 = reader.ReadInt16(); if (num4 > (short)0) { element.Children = new List <BinaryPacker.Element>(); } for (int index = 0; index < (int)num4; ++index) { element.Children.Add(BinaryPacker.ReadElement(reader)); } return(element); }