/// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/> saving
        /// results in <paramref name="result"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Base formatter is the CD type
            CDFormatter baseFormatter = new CDFormatter();

            baseFormatter.Host = this.Host;

            // Graph the value if the null flavor of the object is not null
            PQR opqr = o as PQR;

            if (opqr.NullFlavor == null && opqr.Value.HasValue)
            {
                // Precision
                if (opqr.Precision == null)
                {
                    s.WriteAttributeString("value", Util.ToWireFormat(opqr.Value));
                }
                else
                {
                    s.WriteAttributeString("value", String.Format(String.Format("{{0:0.{0}}}", new String('0', opqr.Precision)), opqr.Value));
                }
            }

            // Graph the base stuff
            baseFormatter.Graph(s, o, result);
        }
Exemple #2
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            var any = o as IAny;

            // Output flavor id
            if (any.Flavor == null && (any.NullFlavor == null || ((NullFlavor)any.NullFlavor).IsChildConcept(NullFlavor.Other)))
            {
                s.WriteAttributeString("flavorId", "CD.CV");
            }

            // Do a base format
            CDFormatter realFormatter = new CDFormatter();

            realFormatter.Host = this.Host;
            realFormatter.Graph(s, o, result);
        }
Exemple #3
0
        /// <summary>
        /// Parse a CE instance from <paramref name="s"/>
        /// </summary>
        public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result)
        {
            CDFormatter realFormatter = new CDFormatter();

            if (String.IsNullOrEmpty(s.GetAttribute("flavorId")) ||
                s.GetAttribute("flavorId") != "CD.CE")
            {
                result.AddResultDetail(new FixedValueMisMatchedResultDetail(s.GetAttribute("flavorId"), "CD.CE", s.ToString()));
            }

            realFormatter.Host = this.Host;
            var retVal = realFormatter.Parse <CE <String> >(s, result);

            retVal.Flavor = null;

            return(retVal);
        }
        /// <summary>
        /// Parse the string
        /// </summary>
        public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result)
        {
            // Temporary holding value for value
            string tValue = null;

            if (s.GetAttribute("value") != null)
            {
                tValue = s.GetAttribute("value");
            }

            // Parse the CD stuff
            CDFormatter baseFormatter = new CDFormatter();

            baseFormatter.Host = this.Host;
            var retVal = baseFormatter.Parse <PQR>(s, result);

            // Interpret the value
            // If the value was interpreted
            if (!String.IsNullOrEmpty(tValue))
            {
                try
                {
                    retVal.Value = Util.Convert <decimal>(tValue);
                    if (tValue.Contains("."))
                    {
                        retVal.Precision = tValue.Length - tValue.IndexOf(".") - 1;
                    }
                }
                catch (Exception e)
                {
                    result.Code = ResultCode.Error;
                    result.AddResultDetail(new ResultDetail(ResultDetailType.Error, e.Message, s.ToString(), e));
                }
            }

            // Validate
            new ANYFormatter().Validate(retVal, s.ToString(), result);

            return(retVal);
        }