/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse from</param> /// <returns>The parsed object</returns> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Read value before we lose context string valStr = s.GetAttribute("value"); // Create retval PQR retVal = CDFormatter.Parse <PQR>(s, Host, result); // 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 if (valStr != null && valStr.Contains(".")) { retVal.Precision = valStr.Length - valStr.IndexOf(".") - 1; } else { retVal.Precision = 0; } retVal.Value = (decimal?)Util.FromWireFormat(valStr, typeof(decimal?)); // 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 instance from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse from</param> /// <returns>The parsed object</returns> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse PN retVal = base.Parse <PN>(s, result); return(retVal); }
/// <summary> /// Parse from the stream /// </summary> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { result.AddResultDetail(new NotImplementedResultDetail(ResultDetailType.Warning, "QSET and derivatives cannot be parsed by the R1 formatter directly, processing as SXPR", s.ToString(), null)); object retval = base.Parse(s, result); return retval; }
/// <summary> /// Parse from the stream /// </summary> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { result.AddResultDetail(new NotImplementedResultDetail(ResultDetailType.Warning, "QSET and derivatives cannot be parsed by the R1 formatter directly, processing as SXPR", s.ToString(), null)); object retval = base.Parse(s, result); return(retval); }
/// <summary> /// Parse object from <paramref name="s"/> /// </summary> /// <param name="s">The XmlReader to graph from</param> public virtual object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { IResultDetail[] details = null; CV <String> retVal = CDFormatter.Parse <CV <String> >(s, Host, result); return(retVal); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse from</param> /// <returns>The parsed object</returns> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { PDVFormatter pdvFormatter = new PDVFormatter(); INT retVal = pdvFormatter.Parse <INT>(s, result); return(retVal); }
/// <summary> /// Parse the object from the specified stream /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { ENFormatter formatter = new ENFormatter() { Host = this.Host }; var instance = formatter.Parse(s, result) as EN; ON retVal = new ON(EntityNameUse.Alphabetic, instance.Part) { Use = instance.Use }; // Remove non-allowed parts for (int i = retVal.Part.Count - 1; i >= 0; i--) { if (retVal.Part[i].Type == EntityNamePartType.Family || retVal.Part[i].Type == EntityNamePartType.Given) { result.AddResultDetail(new VocabularyIssueResultDetail(ResultDetailType.Warning, String.Format("Part name '{0}' in ON instance will be removed. ON Parts cannot have FAM or GIV parts", retVal.Part[i]), s.ToString(), null)); retVal.Part.RemoveAt(i); } } retVal.NullFlavor = instance.NullFlavor; retVal.Flavor = instance.Flavor; return(retVal); }
/// <summary> /// Parse an object from stream <paramref name="s"/> /// </summary> /// <param name="s">The stream to read from</param> /// <returns>The parsed object</returns> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { PDVFormatter pdvFormatter = new PDVFormatter(); MO retVal = pdvFormatter.Parse <MO>(s, result); if (s.GetAttribute("currency") != null) { retVal.Currency = s.GetAttribute("currency"); } // 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; } // Validate ANYFormatter fmtr = new ANYFormatter(); string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; fmtr.Validate(retVal, pathName, result); return(retVal); }
public T Parse <T>(XmlReader xr, DatatypeFormatterParseResult result) where T : ANY, new() { ANYFormatter baseFormatter = new ANYFormatter(); // Base formatter T retVal = baseFormatter.Parse <T>(xr, result); // If it is null return the null flavor if (retVal.NullFlavor != null) { return(retVal); } PropertyInfo pi = typeof(T).GetProperty("Value"); try { // Value if (xr.GetAttribute("value") != null) { pi.SetValue(retVal, Util.FromWireFormat(xr.GetAttribute("value"), pi.PropertyType), null); } } catch (Exception e) { result.AddResultDetail(new ResultDetail(ResultDetailType.Error, e.Message, xr.ToString(), e)); } return(retVal); }
public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { ANY instance = new ANY(); // Read the NullFlavor, and Specialization data from the wire if (s.GetAttribute("nullFlavor") != null) // Stop processing if null flavor is present { instance.NullFlavor = (NullFlavor)Util.FromWireFormat(s.GetAttribute("nullFlavor"), typeof(NullFlavor)); } else if (s.GetAttribute("specializationType") != null && result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian) { instance.Flavor = s.GetAttribute("specializationType"); } if (result.ValidateConformance && !instance.Validate()) { result.AddResultDetail(new DatatypeValidationResultDetail(ResultDetailType.Error, instance.GetType().Name, s.ToString())); } // Disabled for test // Validate flavor... IResultDetail[] flavor; if (instance.Flavor != null && result.ValidateConformance && Util.ValidateFlavor(instance.Flavor.ToUpper(), instance, out flavor) == false) { result.AddResultDetail(new DatatypeFlavorValidationResultDetail(ResultDetailType.Warning, instance.GetType().Name, instance.Flavor, s.ToString())); result.AddResultDetail(flavor); } return(instance); }
/// <summary> /// Parse an ADXP from stream <paramref name="s"/> /// </summary> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse CS ADXP retVal = base.Parse<ADXP>(s, result); // Now parse our data out... if (!s.IsEmptyElement) { if (s.GetAttribute("code") != null && result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian) retVal.Code = s.GetAttribute("code"); else if(s.GetAttribute("code") != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "code", "ADXP", s.ToString())); // Read next for text elemnt string sName = s.Name; s.Read(); while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && sName == s.Name)) { if (s.NodeType == System.Xml.XmlNodeType.Text) retVal.Value = s.Value; s.Read(); } } // 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 from</param> /// <returns>The parsed object</returns> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { INT retVal = base.Parse <INT>(s, result); base.Validate(retVal, s.ToString(), result); return(retVal); }
internal void Validate(ANY instance, string path, DatatypeFormatterParseResult resultDetails) { // Don't validate null if (instance == null) { return; } IResultDetail[] flavor; // Validate if (resultDetails.ValidateConformance && !instance.Validate()) { foreach (var dtl in instance.ValidateEx()) { dtl.Location = path; resultDetails.AddResultDetail(dtl); } } // Validate flavor... if (instance.Flavor != null && resultDetails.ValidateConformance && Util.ValidateFlavor(instance.Flavor.ToUpper(), instance, out flavor) == false) { resultDetails.AddResultDetail(new DatatypeFlavorValidationResultDetail(ResultDetailType.Warning, instance.GetType().Name, instance.Flavor, path)); } // Append details }
/// <summary> /// Parse the TN from the XmlReader <paramref name="s"/>. /// </summary> /// <param name="s">XmlReader stream to parse from.</param> /// <returns>Parsed TN.</returns> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { ANYFormatter baseFormatter = new ANYFormatter(); TN tn = baseFormatter.Parse <TN>(s, result); // Parse the mixed content and add it to the list. if (!s.IsEmptyElement) { string oldName = s.LocalName; ENXP tnPart = new ENXP(""); while (s.Read() && s.NodeType != System.Xml.XmlNodeType.EndElement && s.LocalName != oldName) { if (s.NodeType == System.Xml.XmlNodeType.Text || s.NodeType == System.Xml.XmlNodeType.CDATA) { tnPart.Value += s.Value; } else if (s.NodeType == System.Xml.XmlNodeType.Element) { result.AddResultDetail(new NotImplementedElementResultDetail(ResultDetailType.Warning, s.LocalName, s.NamespaceURI, s.ToString(), null)); } } tn.Part.Add(tnPart); } return(tn); }
/// <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 the object from <paramref name="s"/> /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse ANYFormatter anyFormatter = new ANYFormatter(); GTS retVal = anyFormatter.Parse <GTS>(s, result); // Is there any need to continue? if (retVal.NullFlavor != null) { return(retVal); } // Now determine the type of GTS string typeName = s.GetAttribute("type", "http://www.w3.org/2001/XMLSchema-instance"); IDatatypeFormatter formatter; // Parse the type switch (typeName) { case "IVL_TS": formatter = new IVLFormatter(); break; case "PIVL_TS": formatter = new PIVLFormatter(); break; case "EIVL_TS": formatter = new EIVLFormatter(); break; case "SXPR_TS": formatter = new SXPRFormatter(); break; case "SXCM_TS": formatter = new SXCMFormatter(); break; default: result.AddResultDetail(new NotSupportedChoiceResultDetail(ResultDetailType.Error, String.Format("Cannot parse a GTS Hull of type '{0}'", typeName), s.ToString(), null)); return(null); } // Graph the Hull formatter.Host = this.Host; formatter.GenericArguments = new Type[] { typeof(TS) }; retVal.Hull = formatter.Parse(s, result) as SXCM <TS>; // Correct the flavor, the flavor of the hull becomes the flavor of the object retVal.Flavor = retVal.Flavor ?? retVal.Hull.Flavor; retVal.Hull.Flavor = null; retVal.NullFlavor = retVal.NullFlavor ?? (retVal.Hull.NullFlavor != null ? retVal.Hull.NullFlavor.Clone() as CS <NullFlavor> : null); retVal.Hull.NullFlavor = null; // Set the details 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); }
public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { ANYFormatter pdvFormatter = new ANYFormatter(); // parse PDV portion Type uvpType = typeof(UVP <>).MakeGenericType(GenericArguments); ConstructorInfo ci = uvpType.GetConstructor(Type.EmptyTypes); ANY retVal = ci.Invoke(null) as ANY; // Property information PropertyInfo probabilityProperty = uvpType.GetProperty("Probability"), valueProperty = uvpType.GetProperty("Value"); // Clean the if (s.GetAttribute("type", DatatypeFormatter.NS_XSI) != null && s is XmlStateReader) { (s as XmlStateReader).AddFakeAttribute("type", Util.CreateXSITypeName(GenericArguments[0])); } // Probability if (s.GetAttribute("probability") != null) { decimal prob = (decimal)0.0f; if (!Decimal.TryParse(s.GetAttribute("probability"), out prob)) // Try to parse { result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, string.Format("Value '{0}' can't be processed into 'Probability' on data type UVP", s.GetAttribute("probability")), s.ToString(), null)); } else // Success, so assign { probabilityProperty.SetValue(retVal, prob, null); } } // Set value var hostResult = Host.Parse(s, GenericArguments[0]); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); valueProperty.SetValue(retVal, hostResult.Structure, null); // Move null flavors and flavors up ANY resultAny = hostResult.Structure as ANY; retVal.NullFlavor = resultAny.NullFlavor; resultAny.NullFlavor = null; retVal.Flavor = resultAny.Flavor; resultAny.Flavor = null; // Validate the data type ANYFormatter validator = new ANYFormatter(); string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; validator.Validate(retVal, pathName, result); return(retVal); }
/// <summary> /// Parse the object /// </summary> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse base (ANY) from the stream // Parse ED ST retVal = base.Parse<ST>(s, result); // Now parse our data out... Attributes if (s.GetAttribute("mediaType") != null && s.GetAttribute("mediaType") != "text/plain") result.AddResultDetail(new FixedValueMisMatchedResultDetail(s.GetAttribute("mediaType"), "text/plain", String.Format("{0}/@mediaType", s.ToString()))); if (s.GetAttribute("language") != null) retVal.Language = s.GetAttribute("language"); // Elements and inner data #region Elements string innerData = ""; if (!s.IsEmptyElement) { // Exit markers int sDepth = s.Depth; string sName = s.Name; s.Read(); // Read until exit condition is fulfilled while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName)) { string oldName = s.Name; // Name try { if (s.NodeType == System.Xml.XmlNodeType.Text || s.NodeType == System.Xml.XmlNodeType.CDATA) innerData += s.Value; } 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(); } } } else innerData = s.Value; #endregion retVal.Value = innerData; // Validate base.Validate(retVal, s.ToString(), 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 from the stream /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { result.AddResultDetail(new NotImplementedResultDetail(ResultDetailType.Warning, "QSS cannot be parsed by the R1 formatter directly, processing as SXPR", s.ToString(), null)); SXPRFormatter formatter = new SXPRFormatter(); formatter.Host = this.Host; formatter.GenericArguments = this.GenericArguments; object retval = formatter.Parse(s, result); return(retval); }
public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { BL retVal = base.Parse<BL>(s, result); // Now parse our data out... Attributes if (s.GetAttribute("value") != null) retVal.Value = XmlConvert.ToBoolean(s.GetAttribute("value")); base.Validate(retVal, s.ToString(), result); return retVal; }
/// <summary> /// Parse an instance from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse from</param> /// <returns>The parsed object</returns> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse the object ENFormatter baseFormatter = new ENFormatter(); baseFormatter.Host = this.Host; baseFormatter.GenericArguments = this.GenericArguments; // Parse PN retVal = baseFormatter.Parse <PN>(s, result); return(retVal); }
public SXCM <T> Parse <T>(System.Xml.XmlReader s, DatatypeFormatterParseResult result) where T : IAny, new() { // Return value //SXCM<T> retVal = (T)Host.ParseObject(s, typeof(T)); //// Operator //if (s.GetAttribute("operator") != null) // retVal.Operator = (SetOperator?)Util.FromWireFormat(s.GetAttribute("operator"), typeof(SetOperator)); //return retVal; result.AddResultDetail(new NotImplementedResultDetail(ResultDetailType.Error, "SXCM is an abstract class and cannot be instantiated by itself", s.ToString(), null)); return(null); }
public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { BL retVal = base.Parse <BL>(s, result); // Now parse our data out... Attributes if (s.GetAttribute("value") != null) { retVal.Value = XmlConvert.ToBoolean(s.GetAttribute("value")); } 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 from</param> /// <returns>The parsed object</returns> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // The SC to return. ANYFormatter baseFormatter = new ANYFormatter(); SC sc = baseFormatter.Parse <SC>(s, result); if (sc.NullFlavor != null) { return(sc); } if (s.GetAttribute("code") != null || s.GetAttribute("codeSystem") != null || s.GetAttribute("codeSystemVersion") != null || s.GetAttribute("codeSystemName") != null || s.GetAttribute("displayName") != null) { sc.Code = new CD <string>(); } if (s.GetAttribute("code") != null) { sc.Code.Code = Util.Convert <CodeValue <String> >(s.GetAttribute("code")); } if (s.GetAttribute("codeSystem") != null) { sc.Code.CodeSystem = s.GetAttribute("codeSystem"); } if (s.GetAttribute("codeSystemVersion") != null) { sc.Code.CodeSystemVersion = s.GetAttribute("codeSystemVersion"); } if (s.GetAttribute("codeSystemName") != null) { sc.Code.CodeSystemName = s.GetAttribute("codeSystemName"); } if (s.GetAttribute("displayName") != null) { sc.Code.DisplayName = s.GetAttribute("displayName"); } // Read the ST parts STFormatter stFormatter = new STFormatter(); ST st = (ST)stFormatter.Parse(s, result); sc.Language = st.Language; sc.Value = st.Value; return(sc); }
public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse base (ANY) from the stream ANYFormatter baseFormatter = new ANYFormatter(); // Parse TS BL retVal = baseFormatter.Parse <BL>(s, result); // Now parse our data out... Attributes if (s.GetAttribute("value") != null) { retVal.Value = Convert.ToBoolean(s.GetAttribute("value")); } return(retVal); }
/// <summary> /// Parse an object from <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 TS retVal = base.Parse<TS>(s, result); // Now parse our data out... Attributes if (s.GetAttribute("value") != null) retVal.Value = s.GetAttribute("value"); // Validate string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; base.Validate(retVal, pathName, result); return retVal; }
/// <summary> /// Parse ANY object using a concrete implementation of ANY /// </summary> internal T Parse <T>(System.Xml.XmlReader s, DatatypeFormatterParseResult result) where T : ANY, new() { T instance = new T(); // Read the NullFlavor, and Specialization data from the wire if (s.GetAttribute("nullFlavor") != null) // Stop processing if null flavor is present { instance.NullFlavor = (NullFlavor)Util.FromWireFormat(s.GetAttribute("nullFlavor"), typeof(NullFlavor)); } if (s.GetAttribute("specializationType") != null && result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian) { instance.Flavor = s.GetAttribute("specializationType"); } return(instance); }
public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // parse PDV portion Type uvpType = typeof(UVP<>).MakeGenericType(GenericArguments); ConstructorInfo ci = uvpType.GetConstructor(Type.EmptyTypes); ANY retVal = ci.Invoke(null) as ANY; // Property information PropertyInfo probabilityProperty = uvpType.GetProperty("Probability"), valueProperty = uvpType.GetProperty("Value"); // Clean the type if (s.GetAttribute("type", DatatypeFormatter.NS_XSI) != null && s is XmlStateReader) { (s as XmlStateReader).AddFakeAttribute("type", Util.CreateXSITypeName(GenericArguments[0])); } // Probability if (s.GetAttribute("probability") != null) { decimal prob = (decimal)0.0f; if (!Decimal.TryParse(s.GetAttribute("probability"), out prob)) // Try to parse result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, string.Format("Value '{0}' can't be processed into 'Probability' on data type UVP", s.GetAttribute("probability")), s.ToString(), null)); else // Success, so assign probabilityProperty.SetValue(retVal, prob, null); } // Set value var hostResult = Host.Parse(s, GenericArguments[0]); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); valueProperty.SetValue(retVal, hostResult.Structure, null); // Move null flavors and flavors up ANY resultAny = hostResult.Structure as ANY; retVal.NullFlavor = resultAny.NullFlavor; resultAny.NullFlavor = null; retVal.Flavor = resultAny.Flavor; resultAny.Flavor = null; // Validate the data type 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> 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> /// <param name="s">The stream to parse from</param> /// <returns>The parsed object</returns> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse CS CS<String> retVal = base.Parse<CS<String>>(s, result); // Now parse our data out... Attributes if (retVal.NullFlavor == null && s.GetAttribute("code") != null) retVal.Code = s.GetAttribute("code"); // 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> 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); }
internal void Validate(ANY instance, string path, DatatypeFormatterParseResult resultDetails) { IResultDetail[] flavor; // Validate if (resultDetails.ValidateConformance && !instance.Validate()) { resultDetails.AddResultDetail(new DatatypeValidationResultDetail(ResultDetailType.Error, instance.GetType().Name, path)); } // Validate flavor... if (instance.Flavor != null && resultDetails.ValidateConformance && Util.ValidateFlavor(instance.Flavor.ToUpper(), instance, out flavor) == false) { resultDetails.AddResultDetail(new DatatypeFlavorValidationResultDetail(ResultDetailType.Warning, instance.GetType().Name, instance.Flavor, path)); } // Append details }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse from</param> /// <returns>The parsed object</returns> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { REAL retVal = base.Parse<REAL>(s, result); // 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; // Validate base.Validate(retVal, s.ToString(), result); return retVal; }
/// <summary> /// Parse an ENXP from stream <paramref name="s"/> /// </summary> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse base (ANY) from the stream // Parse CS ENXP retVal = base.Parse <ENXP>(s, result); EntityNamePartType?enp = null; if (s.GetAttribute("qualifier") != null) { retVal.Qualifier = Util.Convert <SET <CS <EntityNamePartQualifier> > >(s.GetAttribute("qualifier")); } if (s.GetAttribute("type") != null) { retVal.Type = Util.Convert <EntityNamePartType>(s.GetAttribute("type")); } else if (ENFormatter.reverseMapping.TryGetValue(s.LocalName, out enp)) // try mapping { retVal.Type = enp; } // Now parse our data out... if (!s.IsEmptyElement) { // Read next for text elemnt string sName = s.Name; s.Read(); while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && sName == s.Name)) { if (s.NodeType == System.Xml.XmlNodeType.Text) { retVal.Value = s.Value; } s.Read(); } } // Validation is handled by the EN formatter string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; //base.Validate(retVal, pathName, result); return(retVal); }
/// <summary> /// Parse an SXCM from the wire /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Determine the generic type formatter var formatter = DatatypeFormatter.GetFormatter(GenericArguments[0]); // Create the return value Type sxcmType = typeof(SXCM <>); Type genType = sxcmType.MakeGenericType(GenericArguments); ConstructorInfo ci = genType.GetConstructor(Type.EmptyTypes); Object retVal = null; if (ci != null) { retVal = ci.Invoke(null); } else { throw new ArgumentException("Constructor on type must have a parameterless constructor"); } // Operator if (s.GetAttribute("operator") != null) { genType.GetProperty("Operator").SetValue(retVal, Util.FromWireFormat(s.GetAttribute("operator"), typeof(SetOperator)), null); } // Value if (formatter != null) { formatter.Host = this.Host; var value = formatter.Parse(s, result); genType.GetProperty("Value").SetValue(retVal, value, null); if (value != null) { ((ANY)retVal).NullFlavor = ((ANY)value).NullFlavor; ((ANY)retVal).Flavor = ((ANY)value).Flavor; ((ANY)value).NullFlavor = null; ((ANY)value).Flavor = null; } } return(retVal); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse from</param> /// <returns>The parsed object</returns> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse CS CS <String> retVal = base.Parse <CS <String> >(s, result); // Now parse our data out... Attributes if (retVal.NullFlavor == null && s.GetAttribute("code") != null) { retVal.Code = s.GetAttribute("code"); } // Validate string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; base.Validate(retVal, pathName, result); return(retVal); }
/// <summary> /// Parse function /// </summary> /// <param name="s"></param> /// <returns></returns> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { var retVal = CDFormatter.Parse<CD<String>>(s, Host, result); CO instance = new CO(); instance.Code = retVal; // Propogate if (instance.Code != null) { instance.Flavor = instance.Code.Flavor; instance.NullFlavor = instance.Code.NullFlavor; instance.Code.NullFlavor = null; instance.Code.Flavor = null; } base.Validate(instance, s.ToString(), result); return instance; }
/// <summary> /// Parse function /// </summary> /// <param name="s"></param> /// <returns></returns> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { var retVal = CDFormatter.Parse <CD <String> >(s, Host, result); CO instance = new CO(); instance.Code = retVal; // Propogate if (instance.Code != null) { instance.Flavor = instance.Code.Flavor; instance.NullFlavor = instance.Code.NullFlavor; instance.Code.NullFlavor = null; instance.Code.Flavor = null; } base.Validate(instance, s.ToString(), result); return(instance); }
/// <summary> /// Parse the object from the specified stream /// </summary> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { ON retVal = Util.Convert<ON>(base.Parse(s, result) as EN); // Remove non-allowed parts for (int i = retVal.Part.Count - 1; i >= 0; i--) if (retVal.Part[i].Type == EntityNamePartType.Family || retVal.Part[i].Type == EntityNamePartType.Given) { result.AddResultDetail(new VocabularyIssueResultDetail(ResultDetailType.Warning, String.Format("Part name '{0}' in ON instance will be removed. ON Parts cannot have FAM or GIV parts", retVal.Part[i]), s.ToString(), null)); retVal.Part.RemoveAt(i); } return retVal; }
/// <summary> /// Parse this object /// </summary> public object Parse(XmlReader s, DatatypeFormatterParseResult result) { // Parse base (ANY) from the stream ANYFormatter baseFormatter = new ANYFormatter(); // Parse CS II retVal = baseFormatter.Parse <II>(s, result); // Now parse our data out... Attributes if (s.GetAttribute("root") != null) { retVal.Root = s.GetAttribute("root"); } if (s.GetAttribute("extension") != null) { retVal.Extension = s.GetAttribute("extension"); } if (s.GetAttribute("displayable") != null) { retVal.Displayable = (bool)Util.FromWireFormat(s.GetAttribute("displayable"), typeof(bool)); } if (s.GetAttribute("use") != null) { switch (s.GetAttribute("use")) { case "VER": retVal.Scope = IdentifierScope.VersionIdentifier; break; case "BUS": retVal.Scope = IdentifierScope.BusinessIdentifier; break; } } // Validate string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; baseFormatter.Validate(retVal, pathName, result); return(retVal); }
/// <summary> /// Parse an ENXP from stream <paramref name="s"/> /// </summary> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse base (ANY) from the stream // Parse CS ENXP retVal = base.Parse<ENXP>(s, result); EntityNamePartType? enp = null; if (s.GetAttribute("qualifier") != null) retVal.Qualifier = Util.Convert<SET<CS<EntityNamePartQualifier>>>(s.GetAttribute("qualifier")); if (s.GetAttribute("type") != null) retVal.Type = Util.Convert<EntityNamePartType>(s.GetAttribute("type")); else if (ENFormatter.reverseMapping.TryGetValue(s.LocalName, out enp)) // try mapping retVal.Type = enp; // Now parse our data out... if (!s.IsEmptyElement) { // Read next for text elemnt string sName = s.Name; s.Read(); while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && sName == s.Name)) { if (s.NodeType == System.Xml.XmlNodeType.Text) retVal.Value = s.Value; s.Read(); } } // Validation is handled by the EN formatter string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; //base.Validate(retVal, pathName, result); return retVal; }
/// <summary> /// Parse the TN from the XmlReader <paramref name="s"/>. /// </summary> /// <param name="s">XmlReader stream to parse from.</param> /// <returns>Parsed TN.</returns> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { TN tn = base.Parse<TN>(s, result); // Parse the mixed content and add it to the list. if (!s.IsEmptyElement) { string oldName = s.LocalName; ENXP tnPart = new ENXP(""); while (s.Read() && s.NodeType != System.Xml.XmlNodeType.EndElement && s.LocalName != oldName) { if (s.NodeType == System.Xml.XmlNodeType.Text || s.NodeType == System.Xml.XmlNodeType.CDATA) tnPart.Value += s.Value; else if (s.NodeType == System.Xml.XmlNodeType.Element) result.AddResultDetail(new NotImplementedElementResultDetail(ResultDetailType.Warning, s.LocalName, s.NamespaceURI, s.ToString(), null)); } tn.Part.Add(tnPart); } return tn; }
/// <summary> /// Parse an object from stream <paramref name="s"/> /// </summary> /// <param name="s">The stream to read from</param> /// <returns>The parsed object</returns> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { MO retVal = base.Parse<MO>(s, result); if (s.GetAttribute("currency") != null) retVal.Currency = s.GetAttribute("currency"); // 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; // 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 from</param> /// <returns>The parsed object</returns> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Read value before we lose context string valStr = s.GetAttribute("value"); // Create retval PQR retVal = CDFormatter.Parse<PQR>(s, Host, result); // 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 if (valStr != null && valStr.Contains(DatatypeFormatter.FormatterCulture.NumberFormat.NumberDecimalSeparator)) retVal.Precision = valStr.Length - valStr.IndexOf(DatatypeFormatter.FormatterCulture.NumberFormat.NumberDecimalSeparator) - 1; else retVal.Precision = 0; retVal.Value = (decimal?)Util.FromWireFormat(valStr, typeof(decimal?)); // 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 read from</param> public virtual object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Get the current element name string currentElementName = s.LocalName; LIST<IGraphable> retVal = new LIST<IGraphable>(); // Read until the current name is exhausted while (s.LocalName == currentElementName && !s.EOF) { if (s.NodeType == System.Xml.XmlNodeType.Element) { // Correct the XSI attribute //if (Util.CreateXSITypeName(GenericArguments[0]) != s.GetAttribute("type", DatatypeFormatter.NS_XSI) && // s is XmlStateReader && !String.IsNullOrEmpty(s.GetAttribute("type", DatatypeFormatter.NS_XSI))) // (s as XmlStateReader).AddFakeAttribute("type", Util.CreateXSITypeName(GenericArguments[0])); var hostResult = Host.Parse(s, GenericArguments[0]); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); retVal.Add(hostResult.Structure); } // Read until the next element s.Read(); while (s.NodeType != System.Xml.XmlNodeType.Element && !s.EOF) { if (s.NodeType == System.Xml.XmlNodeType.EndElement && s.LocalName != currentElementName) return retVal; s.Read(); } } // Return the array return retVal; }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse from</param> /// <returns>The parsed object</returns> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { PDVFormatter pdvFormatter = new PDVFormatter(); REAL retVal = pdvFormatter.Parse<REAL>(s, result); // 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; // 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 from</param> /// <returns>The parsed object</returns> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { PDVFormatter pdvFormatter = new PDVFormatter(); INT retVal = pdvFormatter.Parse<INT>(s, 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; }
/// <summary> /// Parse from the stream /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { return null; }
/// <summary> /// Parse the object from <paramref name="s"/> /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse ANYFormatter anyFormatter = new ANYFormatter(); GTS retVal = anyFormatter.Parse<GTS>(s, result); // Is there any need to continue? if (retVal.NullFlavor != null) { return retVal; } // Now determine the type of GTS string typeName = s.GetAttribute("type", "http://www.w3.org/2001/XMLSchema-instance"); IDatatypeFormatter formatter; // Parse the type switch (typeName) { case "IVL_TS": formatter = new IVLFormatter(); break; case "PIVL_TS": formatter = new PIVLFormatter(); break; case "EIVL_TS": formatter = new EIVLFormatter(); break; case "SXPR_TS": formatter = new SXPRFormatter(); break; case "SXCM_TS": formatter = new SXCMFormatter(); break; default: result.AddResultDetail(new NotSupportedChoiceResultDetail(ResultDetailType.Error, String.Format("Cannot parse a GTS Hull of type '{0}'", typeName), s.ToString(), null)); return null; } // Graph the Hull formatter.Host = this.Host; formatter.GenericArguments = new Type[] { typeof(TS) }; retVal.Hull = formatter.Parse(s, result) as SXCM<TS>; // Correct the flavor, the flavor of the hull becomes the flavor of the object retVal.Flavor = retVal.Flavor ?? retVal.Hull.Flavor; retVal.Hull.Flavor = null; retVal.NullFlavor = retVal.NullFlavor ?? (retVal.Hull.NullFlavor != null ? retVal.Hull.NullFlavor.Clone() as CS<NullFlavor> : null); retVal.Hull.NullFlavor = null; // Set the details return retVal; }
/// <summary> /// Parse an object from stream <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse from</param> /// <remarks>This need to be implemented in this manner (duplicating code) because of the way that /// the XMLReader object functions</remarks> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { IResultDetail[] details = null; CE<String> retVal = CDFormatter.Parse<CE<String>>(s, Host, result); return retVal; }
public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Create the types Type pivlType = typeof(PIVL<>); Type pivlGenericType = pivlType.MakeGenericType(GenericArguments); // For the phase Type ivlType = typeof(IVL<>); Type phaseIvlType = ivlType.MakeGenericType(GenericArguments); // Create an instance of rto from the rtoType object instance = pivlGenericType.GetConstructor(Type.EmptyTypes).Invoke(null); if (s.GetAttribute("specializationType") != null && result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian) ((ANY)instance).Flavor = s.GetAttribute("specializationType"); if (s.GetAttribute("nullFlavor") != null) ((ANY)instance).NullFlavor = (NullFlavor)Util.FromWireFormat(s.GetAttribute("nullFlavor"), typeof(NullFlavor)); // Try get operator and value if (s.GetAttribute("operator") != null) pivlGenericType.GetProperty("Operator").SetValue(instance, Util.FromWireFormat(s.GetAttribute("operator"), typeof(SetOperator?)), null); if (s.GetAttribute("value") != null) result.AddResultDetail(new NotSupportedChoiceResultDetail( ResultDetailType.Warning, "The 'value' attribute of a SXCM does not interpretable in this context, and has been ignored", s.ToString(), null)); // pivlGenericType.GetProperty("Value").SetValue(instance, Util.FromWireFormat(s.GetAttribute("value"), GenericArguments[0]), null); if (s.GetAttribute("institutionSpecified") != null) pivlGenericType.GetProperty("InstitutionSpecified").SetValue(instance, Util.FromWireFormat(s.GetAttribute("institutionSpecified"), typeof(bool?)), null); if (s.GetAttribute("alignment") != null) pivlGenericType.GetProperty("Alignment").SetValue(instance, Util.FromWireFormat(s.GetAttribute("alignment"), typeof(CalendarCycle?)), null); // Get property information PropertyInfo phaseProperty = pivlGenericType.GetProperty("Phase"), periodProperty = pivlGenericType.GetProperty("Period"), frequencyProperty = pivlGenericType.GetProperty("Frequency"); // Now process the 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 == "phase") // low value { var hostResult = Host.Parse(s, phaseIvlType); result.AddResultDetail(hostResult.Details); phaseProperty.SetValue(instance, hostResult.Structure, null); } else if (s.LocalName == "period") // high value { var hostResult = Host.Parse(s, typeof(PQ)); result.AddResultDetail(hostResult.Details); periodProperty.SetValue(instance, hostResult.Structure, null); } else if (s.LocalName == "frequency" && result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian) // frequency { var hostResult = Host.Parse(s, typeof(RTO<INT, PQ>)); result.AddResultDetail(hostResult.Details); frequencyProperty.SetValue(instance, hostResult.Structure, null); } else if (s.NodeType == System.Xml.XmlNodeType.Element) result.AddResultDetail(new NotImplementedElementResultDetail(ResultDetailType.Warning, s.LocalName, s.NamespaceURI, s.ToString(), null)); } catch (MessageValidationException e) // Message validation error { 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(instance as ANY, pathName, result); return instance; }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Create the types Type sxprType = typeof(SXPR<>); Type sxprGenericType = sxprType.MakeGenericType(GenericArguments); // Details // Create an instance of rto from the rtoType object instance = sxprGenericType.GetConstructor(Type.EmptyTypes).Invoke(null); if (s.GetAttribute("nullFlavor") != null) ((ANY)instance).NullFlavor = (NullFlavor)Util.FromWireFormat(s.GetAttribute("nullFlavor"), typeof(NullFlavor)); // Try get operator if (s.GetAttribute("operator") != null) sxprGenericType.GetProperty("Operator").SetValue(instance, Util.FromWireFormat(s.GetAttribute("operator"), typeof(SetOperator?)), null); if (s.GetAttribute("specializationType") != null) { if (result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian) sxprGenericType.GetProperty("Flavor").SetValue(instance, s.GetAttribute("specializationType"), null); else result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Flavor", "SXPR", s.ToString())); } #region Element Processing // List of components LIST<IGraphable> componentList = new LIST<IGraphable>(); // Parse 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 == "comp") // component { // Now determine the type of GTS //string typeName = s.GetAttribute("type", DatatypeFormatter.NS_XSI); //IDatatypeFormatter formatter = DatatypeFormatter.GetFormatter(typeName); //if (formatter == null) //{ // result.AddResultDetail(new ResultDetail(String.Format("Cannot parse a SXPR member of type '{0}'", typeName))); // return null; //} //else //{ // // Graph the Hull // formatter.Host = this.Host; // formatter.GenericArguments = GenericArguments; // componentList.Add(formatter.Parse(s, result) as IGraphable); //} var hostResult = this.Host.Parse(s, GenericArguments[0]); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); componentList.Add(hostResult.Structure as IGraphable); } } catch (MessageValidationException e) // Message validation error { result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, e)); } finally { if (s.Name == oldName) s.Read(); } } } ((IListContainer)instance).ContainedList = componentList; #endregion // Validate ANYFormatter validation = new ANYFormatter(); string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; validation.Validate(instance as ANY, pathName, result); return instance; }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse the object from</param> /// <returns>The constructed object</returns> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { Type crGenericType = typeof(CR<>).MakeGenericType(GenericArguments); ConstructorInfo ci = crGenericType.GetConstructor(Type.EmptyTypes); if (ci == null) throw new InvalidOperationException("Type being parsed must have parameterless constructor"); object instance = ci.Invoke(null); // NullFlavor ? if (s.GetAttribute("nullFlavor") != null) ((ANY)instance).NullFlavor = (NullFlavor)Util.FromWireFormat(s.GetAttribute("nullFlavor"), typeof(NullFlavor)); // JF - Supported only in CA extensions to R1 data types if (s.GetAttribute("specializationType") != null && result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian) ((ANY)instance).Flavor = s.GetAttribute("specializationType"); // Inverted if (s.GetAttribute("inverted") != null) crGenericType.GetProperty("Inverted").SetValue(instance, Util.FromWireFormat(s.GetAttribute("inverted"), typeof(bool)), null); #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 == "name") // Format using ED { CVFormatter cvFormatter = new CVFormatter(); cvFormatter.Host = this.Host; cvFormatter.GenericArguments = this.GenericArguments; crGenericType.GetProperty("Name").SetValue(instance, Util.FromWireFormat(cvFormatter.Parse(s, result), crGenericType.GetProperty("Name").PropertyType), null); } else if (s.LocalName == "value") { CDFormatter cdFormatter = new CDFormatter(); cdFormatter.Host = this.Host; cdFormatter.GenericArguments = this.GenericArguments; crGenericType.GetProperty("Value").SetValue(instance, Util.FromWireFormat(cdFormatter.Parse(s, result), crGenericType.GetProperty("Value").PropertyType), null); } else result.AddResultDetail(new NotImplementedElementResultDetail(ResultDetailType.Warning, s.LocalName, s.NamespaceURI, s.ToString(), null)); } 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 base.Validate((ANY)instance, s.ToString(), result); return instance; }
/// <summary> /// Parse from the stream /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { result.AddResultDetail(new NotImplementedResultDetail(ResultDetailType.Warning, "QSET cannot be parsed by the R1 formatter directly, processing as SXPR", s.ToString(), null)); SXPRFormatter formatter = new SXPRFormatter(); formatter.Host = this.Host; formatter.GenericArguments = this.GenericArguments; object retval = formatter.Parse(s, result); return retval; }
/// <summary> /// Parse the object from the specified stream /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { ENFormatter formatter = new ENFormatter() { Host = this.Host }; var instance = formatter.Parse(s, result) as EN; ON retVal = new ON(EntityNameUse.Alphabetic, instance.Part) { Use = instance.Use }; // Remove non-allowed parts for (int i = retVal.Part.Count - 1; i >= 0; i--) if (retVal.Part[i].Type == EntityNamePartType.Family || retVal.Part[i].Type == EntityNamePartType.Given) { result.AddResultDetail(new VocabularyIssueResultDetail(ResultDetailType.Warning, String.Format("Part name '{0}' in ON instance will be removed. ON Parts cannot have FAM or GIV parts", retVal.Part[i]), s.ToString(), null)); retVal.Part.RemoveAt(i); } retVal.NullFlavor = instance.NullFlavor; retVal.Flavor = instance.Flavor; return retVal; }
/// <summary> /// Parse this object /// </summary> public object Parse(XmlReader s, DatatypeFormatterParseResult result) { // Parse CS II retVal = base.Parse<II>(s, result); // Now parse our data out... Attributes if (s.GetAttribute("root") != null) retVal.Root = s.GetAttribute("root"); if (s.GetAttribute("extension") != null) retVal.Extension = s.GetAttribute("extension"); if (s.GetAttribute("displayable") != null) retVal.Displayable = (bool)Util.FromWireFormat(s.GetAttribute("displayable"), typeof(bool)); if (s.GetAttribute("use") != null) switch (s.GetAttribute("use")) { case "VER": retVal.Scope = IdentifierScope.VersionIdentifier; break; case "BUS": retVal.Scope = IdentifierScope.BusinessIdentifier; break; } // Validate string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; base.Validate(retVal, pathName, result); return retVal; }