Exemplo n.º 1
0
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, o, result);

            // Since this is a generic type, we'll need to get the values we're interested in
            // for the formatting operation
            Type   oType       = o.GetType();
            object numerator   = oType.GetProperty("Numerator").GetValue(o, null),
                   denominator = oType.GetProperty("Denominator").GetValue(o, null);

            // Check for the QTY members
            QTY <Nullable <Double> > qtyPortion = o as QTY <Nullable <Double> >;

            // Check for non-representable properties
            if (qtyPortion.Expression != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Expression", "RTO", s.ToString()));
            }
            if (qtyPortion.OriginalText != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "OriginalText", "RTO", s.ToString()));
            }
            if (qtyPortion.Uncertainty != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Uncertainty", "RTO", s.ToString()));
            }
            if (qtyPortion.UncertaintyType != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "UncertaintyType", "RTO", s.ToString()));
            }
            if (qtyPortion.UncertainRange != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "UncertainRange", "RTO", s.ToString()));
            }
            if (qtyPortion.Value != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Value", "RTO", s.ToString()));
            }


            IXmlStructureFormatter serFormatter = Host;

            // Serialize the data-type
            if (numerator != null)
            {
                s.WriteStartElement("numerator", "urn:hl7-org:v3");

                // Write the XSI type
                string xsiTypeName = Util.CreateXSITypeName(numerator.GetType());

                // Write the type
                if (this.Host.Host == null)
                {
                    s.WriteAttributeString("type", DatatypeFormatter.NS_XSI, xsiTypeName.ToString());
                }
                else
                {
                    s.WriteAttributeString("xsi", "type", DatatypeFormatter.NS_XSI, xsiTypeName.ToString());
                }

                var hostResult = serFormatter.Graph(s, (IGraphable)numerator);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
            if (denominator != null)
            {
                s.WriteStartElement("denominator", "urn:hl7-org:v3");

                // Write the XSI type
                string xsiTypeName = Util.CreateXSITypeName(denominator.GetType());

                // Write the type
                if (this.Host.Host == null)
                {
                    s.WriteAttributeString("type", DatatypeFormatter.NS_XSI, xsiTypeName.ToString());
                }
                else
                {
                    s.WriteAttributeString("xsi", "type", DatatypeFormatter.NS_XSI, xsiTypeName.ToString());
                }

                var hostResult = serFormatter.Graph(s, (IGraphable)denominator);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }

            // Append details
            //details.AddRange(serFormatter.Details);
        }