Exemplo n.º 1
0
 /// <summary>Construct a new string storage definition (in <see cref="Shell.EndianFormat.Little"/> byte order)</summary>
 /// <param name="widthType">Width size of a single character of this string definition</param>
 /// <param name="type">Storage method for this string definition</param>
 /// <param name="fixedLength">The storage fixed length (in characters) of this string definition</param>
 public StringStorage(StringStorageWidthType widthType, StringStorageType type, short fixedLength) :
     this(widthType, type, Shell.EndianFormat.Little, fixedLength)
 {
     Contract.Requires(!type.UsesLengthPrefix(), "Use ctor with StringStorageLengthPrefix instead");
     Contract.Requires(fixedLength >= 0);
     Contract.Requires(fixedLength == 0 || !widthType.IsVariableWidth(),
                       "Can't use a variable width encoding with fixed buffers!");
 }
Exemplo n.º 2
0
        /// <summary>Construct a new string storage definition</summary>
        /// <param name="widthType">Width size of a single character of this string definition</param>
        /// <param name="type">Storage method for this string definition</param>
        /// <param name="byteOrder"></param>
        /// <param name="fixedLength">The storage fixed length (in characters) of this string definition</param>
        public StringStorage(StringStorageWidthType widthType, StringStorageType type,
                             Shell.EndianFormat byteOrder = Shell.EndianFormat.Little, short fixedLength = 0)
        {
            Contract.Requires(!type.UsesLengthPrefix(), "Use ctor with StringStorageLengthPrefix instead");
            Contract.Requires(fixedLength >= 0);
            Contract.Requires(fixedLength == 0 || !widthType.IsVariableWidth(),
                              "Can't use a variable width encoding with fixed buffers!");

            mWidthType    = widthType;
            mType         = type;
            mByteOrder    = byteOrder;
            mLengthPrefix = StringStorageLengthPrefix.None;
            mFixedLength  = fixedLength;

            kHashCode = CalculateHashCode(mWidthType, mType, mByteOrder, mLengthPrefix, mFixedLength);
        }