Ejemplo n.º 1
0
 public void Read(BinaryReader r, ChunkHeader header, int startOffset)
 {
     Header = header;
     r.BaseStream.Seek(startOffset + Header.EntryListOffset, SeekOrigin.Begin);
     int read = 0;
     _dataEntries.Clear();
     while (read < Header.EntryListSize)
     {
         ChunkDataEntry entry = new ChunkDataEntry(r);
         read += entry.Length;
         _dataEntries.Add(entry);
     }
 }
Ejemplo n.º 2
0
        public void Read(BinaryReader r, ChunkHeader header, int startOffset)
        {
            Header = header;
            r.BaseStream.Seek(startOffset + Header.EntryListOffset, SeekOrigin.Begin);
            int read = 0;

            _dataEntries.Clear();
            while (read < Header.EntryListSize)
            {
                ChunkDataEntry entry = new ChunkDataEntry(r);
                read += entry.Length;
                _dataEntries.Add(entry);
            }
        }
Ejemplo n.º 3
0
            public StatisticEntry(short index, string name, ChunkData data, ValueType type)
            {
                ChunkDataEntry ce = data[index];

                if (ce == null)
                {
                    throw new ArgumentOutOfRangeException("index");
                }

                Index = index;
                Name  = name;
                Type  = type;

                switch (type)
                {
                case ValueType.Bool:
                {
                    if (ce.Length != 1 + 6)
                    {
                        throw new Exception("not a Bool");
                    }
                    Value = data[index].Data[0] != 0;
                    break;
                }

                case ValueType.Float:
                {
                    if (ce.Length != 4 + 6)
                    {
                        throw new Exception("not a Float");
                    }
                    Value = EndianessSwitchableBitConverter.ToSingle(data[index].Data, 0);
                    break;
                }

                case ValueType.Int:
                {
                    if (ce.Length != 4 + 6)
                    {
                        throw new Exception("not an Int");
                    }
                    Value = EndianessSwitchableBitConverter.ToInt32(data[index].Data, 0);
                    break;
                }

                case ValueType.TimeSpan:
                {
                    if (ce.Length != 8 + 6)
                    {
                        throw new Exception("not a TimeSpan");
                    }
                    Value = TimeSpan.FromSeconds(EndianessSwitchableBitConverter.ToInt64(data[index].Data, 0));
                    break;
                }

                case ValueType.HashedStringList:
                {
                    try
                    {
                        int count = EndianessSwitchableBitConverter.ToInt32(data[index++].Data, 0);
                        List <HashedString> val = new List <HashedString>();
                        for (int i = 0; i < count; i++)
                        {
                            val.Add(new HashedString(data[index++].Data));
                        }
                        Value = val;
                    }
                    catch {
                        throw new Exception("not a list of hashed strings");
                    }
                    break;
                }

                default:
                {
                    throw new NotSupportedException("StatisticEntry: unsupported type");
                }
                }
            }