示例#1
0
 private void AddField(GDR_DataTypeCode type, byte[] buf)
 {
     byte[] destinationArray = new byte[buf.Length + 1];
     destinationArray[0] = (byte)type;
     Array.Copy(buf, 0, destinationArray, 1, buf.Length);
     this.m_gdrFields.Add(destinationArray);
 }
示例#2
0
 private void AddLengthPrependedField(GDR_DataTypeCode type, byte[] buf)
 {
     byte[] destinationArray = new byte[buf.Length + 2];
     destinationArray[0] = (byte)type;
     destinationArray[1] = (byte)buf.Length;
     Array.Copy(buf, 0, destinationArray, 2, buf.Length);
     this.m_gdrFields.Add(destinationArray);
 }
示例#3
0
        public override int Read(BinaryReader br)
        {
            ushort num;

            this.m_gdrFields.Clear();
            base.Read(br, out num);
            for (ushort i = 0; i < num; i = (ushort)(i + 1))
            {
                byte num3;
                base.Read(br, out num3);
                GDR_DataTypeCode type = (GDR_DataTypeCode)num3;
                switch (type)
                {
                case GDR_DataTypeCode.B0:
                    this.AddField(type, new byte[0]);
                    break;

                case GDR_DataTypeCode.U1:
                case GDR_DataTypeCode.I1:
                case GDR_DataTypeCode.N1:
                    this.AddField(type, br.ReadBytes(1));
                    break;

                case GDR_DataTypeCode.U2:
                case GDR_DataTypeCode.I2:
                    this.AddField(type, br.ReadBytes(2));
                    break;

                case GDR_DataTypeCode.U4:
                case GDR_DataTypeCode.I4:
                case GDR_DataTypeCode.R4:
                    this.AddField(type, br.ReadBytes(4));
                    break;

                case GDR_DataTypeCode.R8:
                    this.AddField(type, br.ReadBytes(8));
                    break;

                case GDR_DataTypeCode.CN:
                case GDR_DataTypeCode.BN:
                    this.AddLengthPrependedField(type, br.ReadBytes(br.ReadByte()));
                    break;

                case GDR_DataTypeCode.DN:
                {
                    byte[] buffer           = br.ReadBytes(2);
                    int    length           = (int)Math.Ceiling((decimal)(BitConverter.ToUInt16(buffer, 0) / 8M));
                    byte[] destinationArray = new byte[length + buffer.Length];
                    Array.Copy(buffer, destinationArray, 2);
                    Array.Copy(br.ReadBytes(length), 0, destinationArray, 2, length);
                    this.AddField(type, destinationArray);
                    break;
                }
                }
            }
            return(this.RecordLength - 4);
        }
示例#4
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder(0x200);

            builder.Append(string.Format("GDR (Generic data record): Record# {0}  FileOffset:{1} Record Length:{2}\n", base.RecordNumber, base.FilePos, base.REC_LEN));
            builder.Append(string.Format("\tField Count: {0}\n", this.FLD_CNT));
            for (int i = 0; i < this.FLD_CNT; i++)
            {
                string           str;
                GDR_DataTypeCode fieldType  = this.GetFieldType(i);
                object           fieldValue = this.GetFieldValue(i);
                switch (fieldType)
                {
                case GDR_DataTypeCode.B0:
                    str = "[Pad Byte]";
                    break;

                case GDR_DataTypeCode.BN:
                    str = "[" + ((byte[])fieldValue).Length + "-byte array";
                    break;

                case GDR_DataTypeCode.DN:
                {
                    bool[]        flagArray = (bool[])this.GetFieldValue(i);
                    StringBuilder builder2  = new StringBuilder();
                    builder2.AppendFormat("[ {0}", flagArray[0].ToString());
                    for (int j = 1; j < ((bool[])fieldValue).Length; j++)
                    {
                        builder2.AppendFormat(", {0}", flagArray[j].ToString());
                    }
                    builder2.Append(" ]");
                    str = builder2.ToString();
                    break;
                }

                default:
                    str = fieldValue.ToString();
                    break;
                }
                builder.Append(string.Format("\t{0}:\t\t{1}\n", fieldType.ToString(), str));
            }
            return(builder.ToString());
        }
示例#5
0
 private void AddLengthPrependedField(GDR_DataTypeCode type, byte[] buf)
 {
     byte[] destinationArray = new byte[buf.Length + 2];
     destinationArray[0] = (byte) type;
     destinationArray[1] = (byte) buf.Length;
     Array.Copy(buf, 0, destinationArray, 2, buf.Length);
     this.m_gdrFields.Add(destinationArray);
 }
示例#6
0
 private void AddField(GDR_DataTypeCode type, byte[] buf)
 {
     byte[] destinationArray = new byte[buf.Length + 1];
     destinationArray[0] = (byte) type;
     Array.Copy(buf, 0, destinationArray, 1, buf.Length);
     this.m_gdrFields.Add(destinationArray);
 }