Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        /// <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());
        }
Beispiel #3
0
        /// <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>());
        }
Beispiel #4
0
        /// <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);
        }
Beispiel #5
0
 /// <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));
 }
Beispiel #6
0
 /// <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);
 }
Beispiel #7
0
 /// <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);
 }