/// <summary> /// Graph the object <paramref name="o"/> onto stream <paramref name="s"/> /// </summary> /// <param name="s">The XmlWriter to graph object to</param> /// <param name="o">The object to graph</param> public override void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Get an instance ref TEL instance_tel = (TEL)o; // Do a base format base.Graph(s, o, result); // Null flavor if (((ANY)o).NullFlavor != null) return; // Attributes if (instance_tel.Value != null) s.WriteAttributeString("value", instance_tel.Value); if (instance_tel.Use != null && instance_tel.Use.Items != null && instance_tel.Use.Items.Count > 0) s.WriteAttributeString("use", Util.ToWireFormat(instance_tel.Use)); if (instance_tel.Capabilities != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail( ResultDetailType.Warning, "Capabilities", "TEL", s.ToString())); // Elements if (instance_tel.UseablePeriod != null) { s.WriteStartElement("useablePeriod", "urn:hl7-org:v3"); GTSFormatter formatterHelper = new GTSFormatter(); formatterHelper.Host = this.Host; formatterHelper.Graph(s, instance_tel.UseablePeriod, result); s.WriteEndElement(); // usable period } }
public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { AD instance = o as AD; // Do a base format ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o as ANY, result); // Null flavor if (instance.NullFlavor != null) { return; } // use if (instance.Use != null) { s.WriteAttributeString("use", Util.ToWireFormat(instance.Use)); } if (instance.IsNotOrdered != null) { s.WriteAttributeString("isNotOrdered", instance.IsNotOrdered.ToString().ToLower()); } // parts if (instance.Part != null) { foreach (ADXP part in instance.Part) { if (mapping.ContainsKey(part.Type ?? AddressPartType.AddressLine)) { s.WriteStartElement(mapping[part.Type ?? AddressPartType.AddressLine], "urn:hl7-org:v3"); } else { throw new MessageValidationException(string.Format("Can't represent address part '{0}' in datatypes R1 at '{1}'", part.Type, (s as XmlStateWriter).CurrentPath)); } ADXPFormatter adFormatter = new ADXPFormatter(); adFormatter.Graph(s, part, result); s.WriteEndElement(); } } // Useable period if (instance.UseablePeriod != null) { s.WriteStartElement("useablePeriod", "urn:hl7-org:v3"); GTSFormatter gtsFormatter = new GTSFormatter(); gtsFormatter.Host = this.Host; gtsFormatter.Graph(s, instance.UseablePeriod, result); s.WriteEndElement(); } }
/// <summary> /// Graph the object <paramref name="o"/> onto stream <paramref name="s"/> /// </summary> /// <param name="s">The XmlWriter to graph object to</param> /// <param name="o">The object to graph</param> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Get an instance ref TEL instance_tel = (TEL)o; // Do a base format ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o, result); // Null flavor if (((ANY)o).NullFlavor != null) { return; } // Attributes if (instance_tel.Value != null) { s.WriteAttributeString("value", instance_tel.Value); } if (instance_tel.Use != null && instance_tel.Use.Items != null && instance_tel.Use.Items.Count > 0) { s.WriteAttributeString("use", Util.ToWireFormat(instance_tel.Use)); } if (instance_tel.Capabilities != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail( ResultDetailType.Warning, "Capabilities", "TEL", s.ToString())); } // Elements if (instance_tel.UseablePeriod != null) { s.WriteStartElement("useablePeriod", "urn:hl7-org:v3"); GTSFormatter formatterHelper = new GTSFormatter(); formatterHelper.Host = this.Host; formatterHelper.Graph(s, instance_tel.UseablePeriod, result); s.WriteEndElement(); // usable period } //foreach (SXCM<TS> up in instance_tel.UseablePeriod) //{ // // Start element // s.WriteStartElement("useablePeriod", "urn:hl7-org:v3"); // // Attributes for SXCM // if(up.Operator != null) // s.WriteAttributeString("operator", Util.ToWireFormat(up.Operator)); // // Timestamp portion // TSFormatter tsFormatter = new TSFormatter(); // tsFormatter.Graph(s, (TS)up, result); // s.WriteEndElement(); // end usablePeriod //} }
/// <summary> /// Graph the object <paramref name="o"/> onto stream <paramref name="s"/> /// </summary> /// <param name="s">The XmlWriter to graph object to</param> /// <param name="o">The object to graph</param> public override void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Get an instance ref TEL instance_tel = (TEL)o; // Do a base format base.Graph(s, o, result); // Null flavor if (((ANY)o).NullFlavor != null) { return; } // Attributes if (instance_tel.Value != null) { s.WriteAttributeString("value", instance_tel.Value); } if (instance_tel.Use != null && instance_tel.Use.Items != null && instance_tel.Use.Items.Count > 0) { s.WriteAttributeString("use", Util.ToWireFormat(instance_tel.Use)); } if (instance_tel.Capabilities != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail( ResultDetailType.Warning, "Capabilities", "TEL", s.ToString())); } // Elements if (instance_tel.UseablePeriod != null) { s.WriteStartElement("useablePeriod", "urn:hl7-org:v3"); GTSFormatter formatterHelper = new GTSFormatter(); formatterHelper.Host = this.Host; formatterHelper.Graph(s, instance_tel.UseablePeriod, result); s.WriteEndElement(); // usable period } }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse</param> /// <returns>The parsed object</returns> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse the address parts // Parse base (ANY) from the stream ANYFormatter baseFormatter = new ANYFormatter(); // Parse CS AD retVal = baseFormatter.Parse <AD>(s, result); // Now parse our data out... Attributes if (s.GetAttribute("use") != null) { retVal.Use = (SET <CS <PostalAddressUse> >)Util.FromWireFormat(s.GetAttribute("use"), typeof(SET <CS <PostalAddressUse> >)); } if (s.GetAttribute("isNotOrdered") != null) { retVal.IsNotOrdered = (bool)Util.FromWireFormat(s.GetAttribute("isNotOrdered"), typeof(bool)); } // Loop through content // Elements #region Elements if (!s.IsEmptyElement) { int sDepth = s.Depth; string sName = s.Name; s.Read(); // string Name while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName)) { string oldName = s.Name; // Name try { AddressPartType?adxpType; // Address part type // JF - This is a Canadian extension if (s.LocalName == "useablePeriod") // Usable Period, since this is an SXCM we'll need to read manually { // Useable period doesn't exist GTSFormatter sxcmFormatter = new GTSFormatter(); sxcmFormatter.Host = this.Host; retVal.UseablePeriod = sxcmFormatter.Parse(s, result) as GTS; } if (reverseMapping.TryGetValue(s.LocalName, out adxpType)) // Reverse map exists, so this is a part { ADXPFormatter adxpFormatter = new ADXPFormatter(); // ADXP Formatter adxpFormatter.Host = this.Host; ADXP part = (ADXP)adxpFormatter.Parse(s, result); // Parse part.Type = adxpType; retVal.Part.Add(part); // Add to AD } } catch (MessageValidationException e) { result.AddResultDetail(new ResultDetail(ResultDetailType.Error, e.Message, s.ToString(), e)); // Append details } finally { if (oldName == s.Name) { s.Read(); // Read if we need to } } } } #endregion // Validate string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; baseFormatter.Validate(retVal, pathName, result); return(retVal); }
/// <summary> /// Parse the object from stream <paramref name="s"/> /// </summary> /// <param name="s">The XmlReader to parse from</param> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse TS TEL retVal = base.Parse <TEL>(s, result); // Now parse our data out... Attributes if (s.GetAttribute("value") != null) { retVal.Value = s.GetAttribute("value"); } if (s.GetAttribute("use") != null) { retVal.Use = (SET <CS <TelecommunicationAddressUse> >)(Util.FromWireFormat(s.GetAttribute("use"), typeof(SET <CS <TelecommunicationAddressUse> >))); } // Elements #region Elements if (!s.IsEmptyElement) { int sDepth = s.Depth; string sName = s.Name; s.Read(); // string Name while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName)) { string oldName = s.Name; // Name try { if (s.LocalName == "useablePeriod") // Usable Period, since this is an SXCM { // Useable period doesn't exist //if (retVal.UseablePeriod == null) retVal.UseablePeriod = new SET<SXCM<TS>>(); //retVal.UseablePeriod.Add(this.Host.ParseObject(s, typeof(SXCM<TS>)) as SXCM<TS>); GTSFormatter formatter = new GTSFormatter(); formatter.Host = this.Host; retVal.UseablePeriod = formatter.Parse(s, result) as GTS; } } catch (MessageValidationException e) { result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, s.ToString(), e)); } finally { if (s.Name == oldName) { s.Read(); } } } } #endregion // Validate string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; base.Validate(retVal, pathName, result); return(retVal); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse</param> /// <returns>The parsed object</returns> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse the address parts // Parse base (ANY) from the stream ANYFormatter baseFormatter = new ANYFormatter(); // Parse CS AD retVal = baseFormatter.Parse<AD>(s, result); // Now parse our data out... Attributes if (s.GetAttribute("use") != null) retVal.Use = (SET<CS<PostalAddressUse>>)Util.FromWireFormat(s.GetAttribute("use"), typeof(SET<CS<PostalAddressUse>>)); if (s.GetAttribute("isNotOrdered") != null) retVal.IsNotOrdered = (bool)Util.FromWireFormat(s.GetAttribute("isNotOrdered"), typeof(bool)); // Loop through content // Elements #region Elements if (!s.IsEmptyElement) { int sDepth = s.Depth; string sName = s.Name; s.Read(); // string Name while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName)) { string oldName = s.Name; // Name try { AddressPartType? adxpType; // Address part type // JF - This is a Canadian extension if (s.LocalName == "useablePeriod") // Usable Period, since this is an SXCM we'll need to read manually { // Useable period doesn't exist GTSFormatter sxcmFormatter = new GTSFormatter(); sxcmFormatter.Host = this.Host; retVal.UseablePeriod = sxcmFormatter.Parse(s, result) as GTS; } if (reverseMapping.TryGetValue(s.LocalName, out adxpType)) // Reverse map exists, so this is a part { ADXPFormatter adxpFormatter = new ADXPFormatter(); // ADXP Formatter adxpFormatter.Host = this.Host; ADXP part = (ADXP)adxpFormatter.Parse(s, result); // Parse part.Type = adxpType; retVal.Part.Add(part); // Add to AD } } catch (MessageValidationException e) { result.AddResultDetail(new ResultDetail(ResultDetailType.Error, e.Message, s.ToString(), e)); // Append details } finally { if (oldName == s.Name) s.Read(); // Read if we need to } } } #endregion // Validate string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; baseFormatter.Validate(retVal, pathName, result); return retVal; }
public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { AD instance = o as AD; // Do a base format ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o as ANY, result); // Null flavor if (instance.NullFlavor != null) return; // use if (instance.Use != null) s.WriteAttributeString("use", Util.ToWireFormat(instance.Use)); if(instance.IsNotOrdered != null) s.WriteAttributeString("isNotOrdered", instance.IsNotOrdered.ToString().ToLower()); // parts if(instance.Part != null) foreach (ADXP part in instance.Part) { if (mapping.ContainsKey(part.Type ?? AddressPartType.AddressLine)) s.WriteStartElement(mapping[part.Type ?? AddressPartType.AddressLine], "urn:hl7-org:v3"); else throw new MessageValidationException(string.Format("Can't represent address part '{0}' in datatypes R1 at '{1}'", part.Type, (s as XmlStateWriter).CurrentPath)); ADXPFormatter adFormatter = new ADXPFormatter(); adFormatter.Graph(s, part, result); s.WriteEndElement(); } // Useable period if (instance.UseablePeriod != null) { s.WriteStartElement("useablePeriod", "urn:hl7-org:v3"); GTSFormatter gtsFormatter = new GTSFormatter(); gtsFormatter.Host = this.Host; gtsFormatter.Graph(s, instance.UseablePeriod, result); s.WriteEndElement(); } }
/// <summary> /// Parse the object from stream <paramref name="s"/> /// </summary> /// <param name="s">The XmlReader to parse from</param> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse TS TEL retVal = base.Parse<TEL>(s, result); // Now parse our data out... Attributes if (s.GetAttribute("value") != null) retVal.Value = s.GetAttribute("value"); if (s.GetAttribute("use") != null) retVal.Use = (SET<CS<TelecommunicationAddressUse>>)(Util.FromWireFormat(s.GetAttribute("use"), typeof(SET<CS<TelecommunicationAddressUse>>))); // Elements #region Elements if (!s.IsEmptyElement) { int sDepth = s.Depth; string sName = s.Name; s.Read(); // string Name while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName)) { string oldName = s.Name; // Name try { if (s.LocalName == "useablePeriod") // Usable Period, since this is an SXCM { // Useable period doesn't exist //if (retVal.UseablePeriod == null) retVal.UseablePeriod = new SET<SXCM<TS>>(); //retVal.UseablePeriod.Add(this.Host.ParseObject(s, typeof(SXCM<TS>)) as SXCM<TS>); GTSFormatter formatter = new GTSFormatter(); formatter.Host = this.Host; retVal.UseablePeriod = formatter.Parse(s, result) as GTS; } } catch (MessageValidationException e) { result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, s.ToString(), e)); } finally { if(s.Name == oldName) s.Read(); } } } #endregion // Validate string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; base.Validate(retVal, pathName, result); return retVal; }
/// <summary> /// Graph the object <paramref name="o"/> onto stream <paramref name="s"/> /// </summary> /// <param name="s">The XmlWriter to graph object to</param> /// <param name="o">The object to graph</param> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Get an instance ref TEL instance_tel = (TEL)o; // Do a base format ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o, result); // Null flavor if (((ANY)o).NullFlavor != null) return; // Attributes if (instance_tel.Value != null) s.WriteAttributeString("value", instance_tel.Value); if (instance_tel.Use != null && instance_tel.Use.Items != null && instance_tel.Use.Items.Count > 0) s.WriteAttributeString("use", Util.ToWireFormat(instance_tel.Use)); if (instance_tel.Capabilities != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail( ResultDetailType.Warning, "Capabilities", "TEL", s.ToString())); // Elements if (instance_tel.UseablePeriod != null) { s.WriteStartElement("useablePeriod", "urn:hl7-org:v3"); GTSFormatter formatterHelper = new GTSFormatter(); formatterHelper.Host = this.Host; formatterHelper.Graph(s, instance_tel.UseablePeriod, result); s.WriteEndElement(); // usable period } //foreach (SXCM<TS> up in instance_tel.UseablePeriod) //{ // // Start element // s.WriteStartElement("useablePeriod", "urn:hl7-org:v3"); // // Attributes for SXCM // if(up.Operator != null) // s.WriteAttributeString("operator", Util.ToWireFormat(up.Operator)); // // Timestamp portion // TSFormatter tsFormatter = new TSFormatter(); // tsFormatter.Graph(s, (TS)up, result); // s.WriteEndElement(); // end usablePeriod //} }