Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AttributeValue"/> class.
 /// </summary>
 /// <param name="theDefinition">The definition.</param>
 /// <param name="theValue">The value.</param>
 /// <param name="theParentStruct">The parent struct.</param>
 public AttributeValue(AttributeDefinition theDefinition, Value theValue, StructureValue theParentStruct)
 {
     Definition = theDefinition;
     Name = theDefinition.Name;
     Value = theValue;
     ParentStruct = theParentStruct;
 }
        /// <summary>
        /// Finishes construction of the object by populating properties of the object from
        /// the XML node
        /// </summary>
        /// <param name="theNode"></param>
        /// <param name="theManager"></param>
        public override void FinishConstruction(XElement theNode, DictionaryManager theManager)
        {
            try
            {
                if (theNode.Element("ByteSize") != null)
                {
                    SetByteSize(theNode.Element("ByteSize").Value);
                }

                IsTlvStructure = false;

                // Parse each of the attribute nodes in turn - this may well get recursive
                m_AttributeDefinitions = new AttributeDefinitionCollection(Name);
                foreach (var attributeNode in theNode.Elements("Attribute"))
                {
                    AttributeDefinition theAttribute = new AttributeDefinition(attributeNode, theManager, this);
                    m_AttributeDefinitions.Add(theAttribute);
                    if (theAttribute.HasDiscriminator && theAttribute.HasLengthIndicator)
                    {
                        IsTlvStructure = true;
                        m_TlvControlAttribute = theAttribute;
                    }
                }

                // Check the name. If it's null then make one up
                if (theNode.Element("Name") == null)
                {
                    Name = String.Format("XXStruct_{0}", Ref);
                }
            }
            catch (DataDictionaryException ex)
            {
                throw new DataDictionaryException("Error constructing definition for Struct. XML:\n{0}\nException: {1}", theNode, ex.Message);
            }
            catch (XmlException ex)
            {
                throw new DataDictionaryException("Error constructing definition for Struct. XML:\n{0}\nException: {1}", theNode, ex.Message);
            }
        }