/// <summary> /// Initializes a new instance of the <see cref="ArrayTypeValue"/> class. /// Values are default values /// </summary> /// <param name="theArrayTypeDefinition">The array type definition.</param> /// <param name="parent">The parent.</param> public ArrayTypeValue(ArrayTypeDefinition theArrayTypeDefinition, Value parent) : base(theArrayTypeDefinition, parent) { m_ArrayTypeDefinition = theArrayTypeDefinition; m_ArrayValues = new ArrayValueContainer(m_ArrayTypeDefinition.UpperBound); if (m_ArrayTypeDefinition.Rank > 0) { // Fixed-size arrays - populate with instantiate elements // Variable-size arrays are populated on demand m_ArrayValues.Populate(() => m_ArrayTypeDefinition.ElementType.Instantiate(this)); } }
/// <summary> /// Initializes a new instance of the <see cref="ArrayTypeValue"/> class. /// Values are decoded from the byte store /// </summary> /// <param name="theArrayTypeDefinition">The array type definition.</param> /// <param name="theBytes">The bytes.</param> /// <param name="parent">The parent.</param> public ArrayTypeValue(ArrayTypeDefinition theArrayTypeDefinition, ByteStore theBytes, Value parent) : base(theArrayTypeDefinition, parent) { m_ArrayTypeDefinition = theArrayTypeDefinition; m_ArrayValues = new ArrayValueContainer(m_ArrayTypeDefinition.UpperBound); if (m_ArrayTypeDefinition.Rank > 0) { // Fixed-size arrays - populate with decoded elements of the base type m_ArrayValues.Populate(() => m_ArrayTypeDefinition.ElementType.Decode(theBytes, this)); } else if (!string.IsNullOrEmpty(m_ArrayTypeDefinition.UpperBoundVariable)) { // Variable size array. Locate the discriminator if there is one // TODO } else { // Variable size array - number of elements limited by the number of bytes available or an end marker being discovered bool done = false; do { Value theValue = m_ArrayTypeDefinition.ElementType.Decode(theBytes, this); m_ArrayValues.Add(theValue); if (theValue.FundamentalType.TypeId == TypeId.StructType) { done = IsEndMarker(theValue as StructureValue); } } while (!done); } }