/// <summary> /// Graph object <paramref name="o"/> onto stream <paramref name="s"/> /// </summary> /// <param name="s">The stream</param> /// <param name="o">The object</param> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { SETFormatter formatter = new SETFormatter(); formatter.Host = this.Host; formatter.Graph(s, o, result); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { SETFormatter formatter = new SETFormatter(); formatter.Host = this.Host; formatter.GenericArguments = this.GenericArguments; object retval = formatter.Parse(s, result); return retval; }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { SETFormatter formatter = new SETFormatter(); formatter.Host = this.Host; formatter.GenericArguments = this.GenericArguments; object retval = formatter.Parse(s, result); return(retval); }
/// <summary> /// Graph object <paramref name="o"/> onto stream <paramref name="s"/> /// </summary> /// <param name="s">The stream</param> /// <param name="o">The object</param> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { SETFormatter formatter = new SETFormatter(); formatter.Host = this.Host; // Create new generic arguments var uvpType = typeof(UVP<>); var genType = uvpType.MakeGenericType(GenericArguments); formatter.GenericArguments = new Type[] { genType }; formatter.Graph(s, o, result); }
/// <summary> /// Graph object <paramref name="o"/> onto stream <paramref name="s"/> /// </summary> /// <param name="s">The stream</param> /// <param name="o">The object</param> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { SETFormatter formatter = new SETFormatter(); formatter.Host = this.Host; // Create new generic arguments var uvpType = typeof(UVP <>); var genType = uvpType.MakeGenericType(GenericArguments); formatter.GenericArguments = new Type[] { genType }; formatter.Graph(s, o, result); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { SETFormatter formatter = new SETFormatter(); formatter.Host = this.Host; // Create new generic arguments var uvpType = typeof(UVP <>); var genType = uvpType.MakeGenericType(GenericArguments); formatter.GenericArguments = new Type[] { genType }; object retval = formatter.Parse(s, result); return(retval); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { result.AddResultDetail(new MARC.Everest.Connectors.NotImplementedResultDetail(Connectors.ResultDetailType.Warning, "The NPPD type is not an official R1 data type, the data has been parsed", s.ToString())); SETFormatter formatter = new SETFormatter(); formatter.Host = this.Host; // Create new generic arguments var uvpType = typeof(UVP<>); var genType = uvpType.MakeGenericType(GenericArguments); formatter.GenericArguments = new Type[] { genType }; object retval = formatter.Parse(s, result); base.Validate((ANY)retval, s.ToString(), result); return retval; }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { result.AddResultDetail(new MARC.Everest.Connectors.NotImplementedResultDetail(Connectors.ResultDetailType.Warning, "The NPPD type is not an official R1 data type, the data has been parsed", s.ToString())); SETFormatter formatter = new SETFormatter(); formatter.Host = this.Host; // Create new generic arguments var uvpType = typeof(UVP <>); var genType = uvpType.MakeGenericType(GenericArguments); formatter.GenericArguments = new Type[] { genType }; object retval = formatter.Parse(s, result); base.Validate((ANY)retval, s.ToString(), result); return(retval); }
/// <summary> /// Graph object <paramref name="o"/> onto stream <paramref name="s"/> /// </summary> /// <param name="s">The stream</param> /// <param name="o">The object</param> public override void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // When graphing an NPPD, we're actually graphing a set of UVP, for example // NPPD<INT> is really SET<UVP<INT>> // This is why we do the formatting in such an odd way result.AddResultDetail(new MARC.Everest.Connectors.NotImplementedResultDetail(Connectors.ResultDetailType.Warning, "The NPPD type is not an official R1 data type, the data has been graphed but may not be interpreted by remote systems", s.ToString())); SETFormatter formatter = new SETFormatter(); formatter.Host = this.Host; // Create new generic arguments var uvpType = typeof(UVP<>); var genType = uvpType.MakeGenericType(GenericArguments); formatter.GenericArguments = new Type[] { genType }; formatter.Graph(s, o, result); }
/// <summary> /// Graph object <paramref name="o"/> onto stream <paramref name="s"/> /// </summary> /// <param name="s">The stream</param> /// <param name="o">The object</param> public override void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // When graphing an NPPD, we're actually graphing a set of UVP, for example // NPPD<INT> is really SET<UVP<INT>> // This is why we do the formatting in such an odd way result.AddResultDetail(new MARC.Everest.Connectors.NotImplementedResultDetail(Connectors.ResultDetailType.Warning, "The NPPD type is not an official R1 data type, the data has been graphed but may not be interpreted by remote systems", s.ToString())); SETFormatter formatter = new SETFormatter(); formatter.Host = this.Host; // Create new generic arguments var uvpType = typeof(UVP <>); var genType = uvpType.MakeGenericType(GenericArguments); formatter.GenericArguments = new Type[] { genType }; formatter.Graph(s, o, result); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse</param> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { PDVFormatter pdvFormatter = new PDVFormatter(); PQ retVal = pdvFormatter.Parse<PQ>(s, result); if (s.GetAttribute("unit") != null) retVal.Unit = s.GetAttribute("unit"); // Precision is not supported in R1, but is still useful to have so // we will report the precision of the data that was on the wire string valStr = s.GetAttribute("value"); if (valStr != null && valStr.Contains(".")) retVal.Precision = valStr.Length - valStr.IndexOf(".") - 1; else retVal.Precision = 0; #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 == "translation") // Format using ED { SETFormatter pqrFormatter = new SETFormatter(); pqrFormatter.GenericArguments = new Type[] { typeof(PQR) }; pqrFormatter.Host = Host.Clone() as IXmlStructureFormatter; retVal.Translation = new SET<PQR>((LIST<IGraphable>)pqrFormatter.Parse(s, result)); // Parse ED //details.AddRange(pqrFormatter.Details); } } catch (MessageValidationException e) { result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, e)); } finally { if (s.Name == oldName) s.Read(); } } } #endregion // Validate ANYFormatter fmtr = new ANYFormatter(); string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; fmtr.Validate(retVal, pathName, result); return retVal; }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse</param> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { PQ retVal = base.Parse <PQ>(s, result); retVal.Unit = s.GetAttribute("unit"); // Precision is not supported in R1, but is still useful to have so // we will report the precision of the data that was on the wire string valStr = s.GetAttribute("value"); if (valStr != null && valStr.Contains(DatatypeFormatter.FormatterCulture.NumberFormat.NumberDecimalSeparator)) { retVal.Precision = valStr.Length - valStr.IndexOf(DatatypeFormatter.FormatterCulture.NumberFormat.NumberDecimalSeparator) - 1; } else { retVal.Precision = 0; } #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 == "translation") // Format using ED { SETFormatter pqrFormatter = new SETFormatter(); pqrFormatter.GenericArguments = new Type[] { typeof(PQR) }; pqrFormatter.Host = Host.Clone() as IXmlStructureFormatter; retVal.Translation = new SET <PQR>((LIST <IGraphable>)pqrFormatter.Parse(s, result)); // Parse ED //details.AddRange(pqrFormatter.Details); } else { result.AddResultDetail(new NotImplementedElementResultDetail(ResultDetailType.Warning, s.LocalName, s.NamespaceURI, null)); } } catch (MessageValidationException e) { result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, e)); } finally { if (s.Name == oldName) { s.Read(); } } } } #endregion // Validate base.Validate(retVal, s.ToString(), result); return(retVal); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { SETFormatter formatter = new SETFormatter(); formatter.Host = this.Host; // Create new generic arguments var uvpType = typeof(UVP<>); var genType = uvpType.MakeGenericType(GenericArguments); formatter.GenericArguments = new Type[] { genType }; object retval = formatter.Parse(s, result); return retval; }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse</param> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { PQ retVal = base.Parse<PQ>(s, result); retVal.Unit = s.GetAttribute("unit"); // Precision is not supported in R1, but is still useful to have so // we will report the precision of the data that was on the wire string valStr = s.GetAttribute("value"); if (valStr != null && valStr.Contains(DatatypeFormatter.FormatterCulture.NumberFormat.NumberDecimalSeparator)) retVal.Precision = valStr.Length - valStr.IndexOf(DatatypeFormatter.FormatterCulture.NumberFormat.NumberDecimalSeparator) - 1; else retVal.Precision = 0; #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 == "translation") // Format using ED { SETFormatter pqrFormatter = new SETFormatter(); pqrFormatter.GenericArguments = new Type[] { typeof(PQR) }; pqrFormatter.Host = Host.Clone() as IXmlStructureFormatter; retVal.Translation = new SET<PQR>((LIST<IGraphable>)pqrFormatter.Parse(s, result)); // Parse ED //details.AddRange(pqrFormatter.Details); } else result.AddResultDetail(new NotImplementedElementResultDetail(ResultDetailType.Warning, s.LocalName, s.NamespaceURI, null)); } catch (MessageValidationException e) { result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, e)); } finally { if (s.Name == oldName) s.Read(); } } } #endregion // Validate base.Validate(retVal, s.ToString(), result); return retVal; }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse</param> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { PDVFormatter pdvFormatter = new PDVFormatter(); PQ retVal = pdvFormatter.Parse <PQ>(s, result); if (s.GetAttribute("unit") != null) { retVal.Unit = s.GetAttribute("unit"); } // Precision is not supported in R1, but is still useful to have so // we will report the precision of the data that was on the wire string valStr = s.GetAttribute("value"); if (valStr != null && valStr.Contains(".")) { retVal.Precision = valStr.Length - valStr.IndexOf(".") - 1; } else { retVal.Precision = 0; } #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 == "translation") // Format using ED { SETFormatter pqrFormatter = new SETFormatter(); pqrFormatter.GenericArguments = new Type[] { typeof(PQR) }; pqrFormatter.Host = Host.Clone() as IXmlStructureFormatter; retVal.Translation = new SET <PQR>((LIST <IGraphable>)pqrFormatter.Parse(s, result)); // Parse ED //details.AddRange(pqrFormatter.Details); } } catch (MessageValidationException e) { result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, e)); } finally { if (s.Name == oldName) { s.Read(); } } } } #endregion // Validate ANYFormatter fmtr = new ANYFormatter(); string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; fmtr.Validate(retVal, pathName, result); return(retVal); }
internal static T Parse <T>(System.Xml.XmlReader s, IXmlStructureFormatter host, DatatypeFormatterParseResult result) where T : ANY, ICodedValue, new() { // Parse base (ANY) from the stream ANYFormatter anyFormatter = new ANYFormatter(); string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; // Parse CV anyFormatter.Host = host; T retVal = anyFormatter.Parse <T>(s, result); // Now parse our data out... Attributes // Was there a null flavor processed? if (s.GetAttribute("code") != null) { retVal.CodeValue = s.GetAttribute("code"); } if (s.GetAttribute("codeSystem") != null) { retVal.CodeSystem = s.GetAttribute("codeSystem"); } if (s.GetAttribute("codeSystemName") != null) { retVal.CodeSystemName = s.GetAttribute("codeSystemName"); } if (s.GetAttribute("codeSystemVersion") != null) { retVal.CodeSystemVersion = s.GetAttribute("codeSystemVersion"); } if (s.GetAttribute("displayName") != null) { retVal.DisplayName = Util.Convert <ST>(s.GetAttribute("displayName")); } // 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 == "originalText") // Format using ED { EDFormatter edFormatter = new EDFormatter(); edFormatter.Host = host; retVal.OriginalText = (ED)edFormatter.Parse(s, result); // Parse ED } else if (s.LocalName == "translation" && retVal is ICodedEquivalents) // Translation { LISTFormatter setFormatter = new LISTFormatter(); setFormatter.GenericArguments = new Type[] { typeof(CD <String>) }; setFormatter.Host = host; if (retVal is ICodedEquivalents) { ((ICodedEquivalents)retVal).Translation = (LIST <IGraphable>)setFormatter.Parse(s, result); // Parse LIST } else { result.AddResultDetail(new NotImplementedElementResultDetail(ResultDetailType.Warning, s.LocalName, s.NamespaceURI, s.ToString(), null)); } } else if (s.LocalName == "qualifier" && retVal is IConceptDescriptor) // Qualifier { SETFormatter setFormatter = new SETFormatter(); setFormatter.GenericArguments = new Type[] { typeof(CR <String>) }; setFormatter.Host = host; if (retVal is IConceptDescriptor) { ((IConceptDescriptor)retVal).Qualifier = (LIST <IGraphable>)setFormatter.Parse(s, result); // Parse SET } else { result.AddResultDetail(new NotImplementedElementResultDetail(ResultDetailType.Warning, s.LocalName, s.NamespaceURI, s.ToString(), null)); } } } catch (VocabularyException e) { result.AddResultDetail(new VocabularyIssueResultDetail(ResultDetailType.Error, e.Message, e)); } 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 anyFormatter.Validate(retVal, pathName, result); // Add validation to details return(retVal); }