/// <summary> /// Initializes a new instance of the <see cref="BaseTypeValue"/> class with /// values extracted from the byte store /// </summary> /// <param name="baseTypeDefinition">The base type definition.</param> /// <param name="theBytes">The bytes.</param> /// <param name="parent">The parent.</param> public BaseTypeValue(BaseTypeDefinition baseTypeDefinition, ByteStore theBytes, Value parent) : this(baseTypeDefinition, parent) { ulong tempValue = 0; switch (m_BaseTypeDefinition.FixedSizeBytes.Value) { case 0: // Special case for end-markers for lists of elements break; case 1: tempValue = theBytes.GetByte(); break; case 2: tempValue = theBytes.GetUint16(); break; case 4: tempValue = theBytes.GetUint32(); break; case 8: tempValue = theBytes.GetUint64(); break; default: throw new DataDictionaryException(String.Format("{0} Illegal ByteSize {1}", m_BaseTypeDefinition.Name, m_BaseTypeDefinition.FixedSizeBytes.Value)); } if (m_BaseTypeDefinition.IsSigned) { SignedValue = (long)tempValue; } else { UnsignedValue = tempValue; } }
/// <summary> /// Initializes a new instance of the <see cref="EnumValue"/> class by extracting the /// encoded value from the byte store /// </summary> /// <param name="theEnumDefinition">The enum definition.</param> /// <param name="theBytes">The bytes.</param> /// <param name="parent">The parent.</param> public EnumValue(EnumDefinition theEnumDefinition, ByteStore theBytes, Value parent) : this(theEnumDefinition, parent) { switch (theEnumDefinition.FixedSizeBytes) { case 1: IntegerValue = (int)theBytes.GetByte(); break; case 2: IntegerValue = (int)theBytes.GetUint16(); break; case 4: IntegerValue = (int)theBytes.GetUint32(); break; default: throw new DataDictionaryException(string.Format("Illegal byte size {0} for enum {1}", theEnumDefinition.FixedSizeBytes, m_EnumDefinition.Name)); } StringValue = m_EnumDefinition.IntegerValueToString(IntegerValue); }