Пример #1
0
        public FieldDefinitionRecord(RandomAccess rx)
        {
            if (rx == null)
            {
                throw new ArgumentNullException(nameof(rx));
            }

            Type         = (TpsTypeCode)rx.Byte();
            Offset       = rx.ShortLE();
            FullName     = rx.ZeroTerminatedString();
            ElementCount = rx.ShortLE();
            Length       = rx.ShortLE();
            Flags        = rx.ShortLE();
            Index        = rx.ShortLE();

            switch (Type)
            {
            case TpsTypeCode.Decimal:
                BcdDigitsAfterDecimalPoint = rx.Byte();
                BcdElementLength           = rx.Byte();
                break;

            case TpsTypeCode.String:
            case TpsTypeCode.CString:
            case TpsTypeCode.PString:
                StringLength = rx.ShortLE();
                StringMask   = rx.ZeroTerminatedString();
                if (StringMask.Length == 0)
                {
                    rx.Byte();
                }
                break;
            }
        }
Пример #2
0
        public IndexDefinitionRecord(RandomAccess rx)
        {
            if (rx == null)
            {
                throw new ArgumentNullException(nameof(rx));
            }

            ExternalFile = rx.ZeroTerminatedString();

            if (ExternalFile.Length == 0)
            {
                int read = rx.Byte();

                if (read != 0x01)
                {
                    throw new ArgumentException($"Bad index definition: missing 0x01 after zero string ({read:X2})");
                }
            }

            Name        = rx.ZeroTerminatedString();
            Flags       = rx.Byte();
            FieldsInKey = rx.ShortLE();

            KeyField     = new int[FieldsInKey];
            KeyFieldFlag = new int[FieldsInKey];

            for (int i = 0; i < FieldsInKey; i++)
            {
                KeyField[i]     = rx.ShortLE();
                KeyFieldFlag[i] = rx.ShortLE();
            }
        }
Пример #3
0
        /// <summary>
        /// Instantiates a new null-terminated string.
        /// </summary>
        /// <param name="rx">The binary reader containing the raw string data.</param>
        /// <param name="encoding">The text encoding from which to create a well-formed string.</param>
        public TpsCString(RandomAccess rx, Encoding encoding)
        {
            if (rx == null)
            {
                throw new ArgumentNullException(nameof(rx));
            }

            if (encoding == null)
            {
                throw new ArgumentNullException(nameof(encoding));
            }

            Value = rx.ZeroTerminatedString(encoding);
        }
Пример #4
0
        public MemoDefinitionRecord(RandomAccess rx)
        {
            if (rx == null)
            {
                throw new ArgumentNullException(nameof(rx));
            }

            ExternalFile = rx.ZeroTerminatedString();

            if (ExternalFile.Length == 0)
            {
                byte memoMarker = rx.Byte();

                if (memoMarker != 1)
                {
                    throw new ArgumentException($"Bad memo definition: missing 0x01 after zero string. Was 0x{memoMarker:x2}.");
                }
            }

            FullName = rx.ZeroTerminatedString();
            Length   = rx.ShortLE();
            Flags    = rx.ShortLE();
        }