示例#1
0
        /// <summary>
        /// Adds an IRapEntry to entry collection based on Type.
        /// </summary>
        /// <param name="entry">Entry to be added.</param>
        /// <param name="reader">Reader for reading binarized rap entry.</param>
        public void AddEntry(IRapEntry entry, RapBinaryReader reader)
        {
            if (entry is RapClass)
            {
                Classes.Add(reader.ReadBinarizedRapEntry <RapClass>());
            }

            if (entry is RapExtern)
            {
                Externs.Add(reader.ReadBinarizedRapEntry <RapExtern>());
            }

            if (entry is RapDelete)
            {
                Deletes.Add(reader.ReadBinarizedRapEntry <RapDelete>());
            }

            if (entry is RapValue)
            {
                Values.Add(reader.ReadBinarizedRapEntry <RapValue>());
            }

            if (entry is RapArray)
            {
                Arrays.Add(reader.ReadBinarizedRapEntry <RapArray>());
            }
        }
示例#2
0
        /// <summary>
        /// Converts raP entry in to a IRapEntry object.
        /// </summary>
        /// <param name="reader">Reader used for reading entry.</param>
        /// <param name="parent">Used for reading arrays recursive.</param>
        /// <returns>Returns a IRapEntry object.</returns>
        public IRapEntry FromBinary(RapBinaryReader reader, bool parent = false)
        {
            var array = reader.ReadRapArray(parent);

            // Empty array.
            if (array.Entries == 0)
            {
                return(array);
            }

            for (var i = 0; i < array.Entries; ++i)
            {
                var type = (RapValueType)reader.ReadByte();
                if (type == RapValueType.String)
                {
                    array.Strings.Add('"' + reader.ReadAsciiz() + '"');
                }
                else if (type == RapValueType.Float)
                {
                    array.Floats.Add(reader.ReadFloat());
                }
                else if (type == RapValueType.Long)
                {
                    array.Longs.Add(reader.ReadUint());
                }
                else if (type == RapValueType.Array)
                {
                    array.Arrays.Add((RapArray)FromBinary(reader, true));
                }
                else if (type == RapValueType.Variable)
                {
                    array.Variables.Add(reader.ReadAsciiz());
                }
            }

            return(array);
        }
示例#3
0
 /// <summary>
 /// Converts raP entry in to a IRapEntry object.
 /// </summary>
 /// <param name="reader">Reader used for reading entry.</param>
 /// <param name="parent">Used for reading arrays recursive.</param>
 /// <returns>Returns a IRapEntry object.</returns>
 public IRapEntry FromBinary(RapBinaryReader reader, bool parent = false) => new RapClass
 {
     Name   = reader.ReadAsciiz(),
     Offset = reader.ReadUint()
 };