Exemple #1
0
        private void ReadDataRecord(XsdNs.DataRecordType el)
        {
            // Getting identifier
            Identifier = el.identifier;

            // Any fields?
            if (el.field != null)
            {
                foreach (var field in el.field)
                {
                    string fieldName = field.name;

                    if (fieldName == emptyRecordItemIndicator)
                    {
                        // Empty item -> skip it.
                        // Empty items can exist, because there are use cases for
                        // empty data records but the XML schema does not allow
                        // empty records.
                        continue;
                    }

                    try
                    {
                        ProcessOneField(field);
                    }
                    catch (NullReferenceException e)
                    {
                        throw new XNeut.InvalidMessageException("Data record field is invalid: " + fieldName, e);
                    }
                }
            }
        }
Exemple #2
0
        public Item_DataRecord(XsdNs.DataRecordType el) : this()
        {
            Identifier = el.identifier;

            // Reading field names.
            // The test does not test Item_DataRecord, but it is important to test
            // that the Observation calls a constructor that parses XML.
            foreach (var field in el.field)
            {
                m_fieldName = field.name;
            }
        }
Exemple #3
0
        /// <summary>
        /// Builds a proxy for XML serialisation.
        /// </summary>
        /// <param name="idPrefix">A prefix to be appended to the IDs of any child XML elements that
        /// require an ID. For certain XML elements, the schema requires an ID that is unique within
        /// the XML document. Instead of generating random IDs, these are systematic and hierarchical
        /// in this software. To ensure uniqueness, each ID prefix can occur only once. The ID is of
        /// type xsd:id. This derives from xsd:NCName, so not all characters are allowed.</param>
        /// <returns>Proxy.</returns>
        internal XsdNs.DataRecordType ToXmlProxy(string idPrefix)
        {
            Dictionary <string, DataRecordItem> itemsForAdd = null;

            // If there are no fields, adding an empty value
            if (m_recItems.Count < 1)
            {
                // Add the "empty item" indicator
                itemsForAdd = new Dictionary <string, DataRecordItem>()
                {
                    { emptyRecordItemIndicator, new DataRecordItem(emptyRecordItemIndicator, new Item_Text("")) }
                };
            }
            else
            {
                // Just add the items
                itemsForAdd = m_recItems;
            }

            var retval = new XsdNs.DataRecordType
            {
                // Assigning identifier
                identifier = Identifier,

                // Creating array for fields
                field = new XsdNs.DataRecordTypeField[itemsForAdd.Count]
            };

            // Assigning field values
            int counter = 0;

            foreach (string fieldName in itemsForAdd.Keys)
            {
                var idPrefixForField = idPrefix + "_" + (counter + 1) + "_";

                var recItem = itemsForAdd[fieldName];

                // Add the field element to the return value
                retval.field[counter] = CreateOneProxyField(fieldName, recItem, idPrefixForField);
                ++counter;
            }

            return(retval);
        }
Exemple #4
0
 /// <summary>
 /// Constructor. Use to instantiate an item from XML data (data record field).
 /// </summary>
 /// <param name="el">XML data.</param>
 /// <exception cref="XNeut.InvalidMessageException">Thrown if an error is encountered.</exception>
 internal Item_DataRecord(XsdNs.DataRecordType el)
     : base(XNeut.Helper.TypeUri_Complex)
 {
     ReadDataRecord(el);
 }