예제 #1
0
        private List <ArrayColumn> ReadColumnsFromProxy(XsdNs.DataArrayType proxy)
        {
            try
            {
                var retval = new List <ArrayColumn>();

                // Are there any fields?
                if (proxy.elementType != null && proxy.elementType.AbstractDataComponent != null &&
                    proxy.elementType.AbstractDataComponent.field != null)
                {
                    var fields = proxy.elementType.AbstractDataComponent.field;

                    // Processing each field
                    foreach (var field in fields)
                    {
                        // Processing column proxy
                        retval.Add(new ArrayColumn(field));
                    }
                }

                return(retval);
            }
            catch (InvalidCastException e)
            {
                throw new XNeut.InvalidMessageException("Failed to read columns of array - expected DataRecord nested in elementType", e);
            }
            catch (NullReferenceException e)
            {
                throw new XNeut.InvalidMessageException("Failed to read columns of array - something missing", e);
            }
        }
예제 #2
0
        private List <object[]> ReadRowsFromProxy(XsdNs.DataArrayType proxy)
        {
            try
            {
                var retval = new List <object[]>();

                // Are there any rows?
                if (proxy.values == null || proxy.values.Array == null ||
                    proxy.values.Array.Row == null)
                {
                    return(retval);
                }

                var rows = proxy.values.Array.Row;

                foreach (var row in rows)
                {
                    var parsedValuesOfRow = new object[Columns.Count];

                    if (row.I == null)
                    {
                        // Expecting no cells in the row
                        if (Columns.Count != 0)
                        {
                            throw new XNeut.InvalidMessageException("No columns defined for array but a row has cells");
                        }
                    }
                    else
                    {
                        // Checking that the cell count matches the column count
                        if (row.I.Length != Columns.Count)
                        {
                            throw new XNeut.InvalidMessageException("Inconsistent cell count in rows of array");
                        }

                        for (int a = 0; a < row.I.Length; ++a)
                        {
                            // Attempting to parse the value after the type of the column
                            var valueParsed = TryParseAfterType(row.I[a], Columns[a].DataType);

                            parsedValuesOfRow[a] = valueParsed;
                        }
                    }

                    retval.Add(parsedValuesOfRow);
                }

                return(retval);
            }
            catch (NullReferenceException e)
            {
                throw new XNeut.InvalidMessageException("Failed to read rows of array - something missing", e);
            }
        }
예제 #3
0
        internal override XsdNs.AbstractDataComponentType GetObjectForXml_DataRecordField(string idPrefix)
        {
            // Creating the proxy skeleton
            var proxy = new XsdNs.DataArrayType()
            {
                // The schema requires the "elementCount" element but nothing inside it
                elementCount = new XsdNs.CountPropertyType(),

                // The schema requires the "elementType" element
                elementType = CreateColumnsForProxy(idPrefix),
                values      = new XsdNs.EncodedValuesPropertyType()
                {
                    Array = CreateRowsForProxy() // throws DateTimeException
                }
            };

            return(proxy);
        }
예제 #4
0
 /// <summary>
 /// Constructor. Use this when populating the object from XML.
 /// </summary>
 /// <param name="proxy">XML proxy.</param>
 /// <exception cref="XNeut.InvalidMessageException">Thrown if an error is encountered.</exception>
 internal Item_Array(XsdNs.DataArrayType proxy)
     : base(XNeut.Helper.TypeUri_Complex)
 {
     Columns = ReadColumnsFromProxy(proxy);
     m_rows  = ReadRowsFromProxy(proxy);
 }