/// <summary> /// Gets the object of a cached object. /// </summary> /// <param name="value">The object.</param> /// <returns></returns> public static object GetObject(object value) { SCachedObjectType cachedObject = value as SCachedObjectType; if (cachedObject == null) { return(null); } if (cachedObject.Object != null) { return(cachedObject.Object); } if (cachedObject.RawData == null) { throw new InvalidDataException("No object?!"); } byte[] rawData = Encoding.Default.GetBytes((string)cachedObject.RawData); byte[] data = cachedObject.IsCompressed ? SCachedObjectType.Decompress(rawData) : rawData; cachedObject.Object = CachedFileParser.Parse(data); cachedObject.RawData = null; return(cachedObject.Object); }
/// <summary> /// Parses the specified data. /// </summary> /// <param name="data">The data.</param> /// <returns></returns> internal static object Parse(byte[] data) { var reader = new CachedFileReader(data); var parser = new CachedFileParser(reader); parser.Parse(); return(parser.m_stream.Members.Select(member => member.ToObject()).ToList()); }
/// <summary> /// Parses the specified file. /// </summary> /// <param name="file">The file.</param> /// <returns></returns> internal static KeyValuePair <object, object> Parse(FileInfo file) { Console.WriteLine("Parsing..."); SType.Reset(); var cachedFile = new CachedFileReader(file); var parser = new CachedFileParser(cachedFile); parser.Parse(); return(!s_dumpStructure?parser.ToObjects() : new KeyValuePair <object, object>()); }
/// <summary> /// Parses a sub stream. /// </summary> /// <returns></returns> SType ParseSubStream() { SType subStream = new SStreamType(StreamType.SubStream); var length = m_reader.ReadLength(); if (s_dumpStructure) { var subReader = new CachedFileReader(m_reader, length); var subParser = new CachedFileParser(subReader); subParser.Parse(); subStream.AddMember(subParser.m_stream.Clone()); } if (s_cachedObject) { return(new SStringType(m_reader.ReadString(length))); } m_reader.Seek(length); return(subStream); }
/// <summary> /// Parses the specified file. /// </summary> /// <param name="file">The file.</param> /// <returns></returns> public static KeyValuePair <object, object> Parse(FileInfo file) { return(CachedFileParser.Parse(file)); }
/// <summary> /// Reads the specified file and shows it in an ASCII format. /// </summary> /// <param name="file">The file.</param> public static void ShowAsAscii(FileInfo file) { CachedFileParser.ShowAsAscii(file); }
/// <summary> /// Dumps the structure of the file to a file. /// </summary> /// <param name="file">The file.</param> public static void DumpStructure(FileInfo file) { CachedFileParser.DumpStructure(file); }