示例#1
0
        static IEnumerable <Object> ReadAnonymousArray(Stream input)
        {
            var entries = BinaryFile.ReadCompressedInteger(input);
            var objects = new List <Object>();

            for (var i = 0; i < entries; i++)
            {
                var subType = input.ReadByte();
                switch (subType)
                {
                case 0:
                    objects.Add(BinaryFile.ReadString(input));
                    break;

                case 1:
                    objects.Add(BinaryFile.ReadFloat32(input));
                    break;

                case 2:
                    objects.Add(BinaryFile.ReadInt32(input));
                    break;

                case 3:
                    objects.Add(ReadAnonymousArray(input));
                    break;

                //TODO - need to do something with this !
                //case 4: objects.Add(BinaryFile.ReadString(input)); break;
                default:
                    throw new RapFormatException("Unexpected array element type " + subType + " found in rap file");
                }
            }
            return(objects);
        }
示例#2
0
        // reads a class body
        ConfigClass ReadClassBody(string name, long bodyOffset)
        {
            // Class bodies are distributed separately from their definitions
            // so before we go looking we need to take note of where we started
            var currentOffset = _input.Position;

            //read the parent name
            _input.Seek(bodyOffset, SeekOrigin.Begin);
            var parentName = BinaryFile.ReadString(_input);
            var cfgClass   = new ConfigClass(name, parentName);

            //read all entries in the class body
            var entryCount = BinaryFile.ReadCompressedInteger(_input);

            for (var c = 0; c < entryCount; c++)
            {
                cfgClass.Add(ReadConfigEntry());
            }
            //ensure we haven't disturbed the seek position
            _input.Seek(currentOffset, SeekOrigin.Begin);
            return(cfgClass);
        }