/// <summary>
        /// Encodes the value into the list of bytes
        /// </summary>
        /// <param name="theBytes"></param>
        public override void Encode(ByteStore theBytes)
        {
            ulong tempValue = 0;
            tempValue = m_BaseTypeDefinition.IsSigned ? (ulong)SignedValue : UnsignedValue;

            switch (GetSizeBytes())
            {
                case 0:
                    // 0-size end marker
                    break;
                case 1:
                    theBytes.PutByte((byte)tempValue);
                    break;
                case 2:
                    theBytes.PutUint16((ushort)tempValue);
                    break;
                case 4:
                    theBytes.PutUint32((uint)tempValue);
                    break;
                case 8:
                    theBytes.PutUint64(tempValue);
                    break;
                default:
                    throw new DataDictionaryException(String.Format("{0} Illegal ByteSize {1}",
                        m_BaseTypeDefinition.Name,
                        GetSizeBytes()));
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Encodes the value into the list of bytes
 /// </summary>
 /// <param name="theBytes"></param>
 public override void Encode(ByteStore theBytes)
 {
     switch (GetSizeBytes())
     {
         case 1:
             theBytes.PutByte((byte) IntegerValue);
             break;
         case 2:
             theBytes.PutUint16((ushort) IntegerValue);
             break;
         case 4:
             theBytes.PutUint32((uint) IntegerValue);
             break;
         default:
             throw new DataDictionaryException(string.Format("Illegal byte size {0} for enum {1}", GetSizeBytes(), m_EnumDefinition.Name));
     }
 }