/// <summary> /// Returns an XML object for observation metadata. (Initially, there was a separate function for metadata.) /// </summary> /// <param name="id">An ID that is unique within the XML document.</param> /// <returns>Object.</returns> private XsdNs.TimeInstantType GetXmlObjectForMetadata(string id) { var resultTimePos = new XsdNs.TimePositionType { Value = XNeut.Helper.DateTimeToString(Value) // throws DateTimeException }; var resultTimeInstant = new XsdNs.TimeInstantType { timePosition = resultTimePos, // An ID is required; using a random ID as the default id = id }; return(resultTimeInstant); }
/// <summary> /// Constructor. Use this to instantiate an item from XML (phenomenon time). /// </summary> /// <param name="el">XML contents.</param> internal Item_TimeInstant(XsdNs.TimeInstantType el) : base(XNeut.Helper.TypeUri_Temporal) { // PhenomenonTime field uses this ctor. try { string valueRaw = el.timePosition.Value; Value = XNeut.Helper.DateTimeFromString(valueRaw); } catch (FormatException e) { throw new XNeut.InvalidMessageException("Failed to read time instant", e); } catch (NullReferenceException e) { throw new XNeut.InvalidMessageException("Failed to read time instant (something missing?)", e); } }