/// <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> /// Graph this object to the specified stream /// </summary> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { ENFormatter formatter = new ENFormatter() { Host = this.Host }; // Validate and remove any incriminating data ON instance = o as ON; for (int i = instance.Part.Count - 1; i >= 0; i--) { if (instance.Part[i].Type == EntityNamePartType.Family || instance.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", instance.Part[i]), s.ToString(), null)); instance.Part.RemoveAt(i); } } formatter.Graph(s, o, result); }
/// <summary> /// Graph object <paramref name="o"/> onto <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse from</param> /// <param name="o">The object to parse</param> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { ENFormatter baseFormatter = new ENFormatter(); baseFormatter.Host = this.Host; baseFormatter.GenericArguments = this.GenericArguments; // Format baseFormatter.Graph(s, o, result); }
/// <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); }