Exemplo n.º 1
0
        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
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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
        }
Exemplo n.º 4
0
        public virtual object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result)
        {
            ANY instance = this.Parse <ANY>(s, result);

            if (result.ValidateConformance && !instance.Validate())
            {
                foreach (var r in instance.ValidateEx())
                {
                    r.Location = s.ToString();
                    result.AddResultDetail(r);
                }
            }
            //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);
        }
Exemplo n.º 5
0
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            ANY instance = o as ANY;

            IResultDetail[] enumer = new IResultDetail[0], flavor = new IResultDetail[0],
            invalidAttributes = new IResultDetail[0];

            // Now render
            if (instance == null)
            {
                throw new InvalidOperationException("Could not cast object to the ANY data type");
            }

            if (instance.Flavor != null &&
                (instance.NullFlavor == null ||
                 (instance is ICodedSimple && ((NullFlavor)instance.NullFlavor).IsChildConcept(NullFlavor.Other)) ||
                 (instance is IQuantity && ((NullFlavor)instance.NullFlavor).IsChildConcept(NullFlavor.Derived))
                )
                )
            {
                s.WriteAttributeString("flavorId", instance.Flavor);
            }

            if (instance.NullFlavor != null)
            {
                s.WriteAttributeString("nullFlavor", Util.ToWireFormat(instance.NullFlavor));
            }
            else
            {
                // Warn if items can't be represented in R2
                if (instance.ControlActExt != null)
                {
                    s.WriteAttributeString("controlInformationExtension", instance.ControlActExt);
                }
                if (instance.ControlActRoot != null)
                {
                    s.WriteAttributeString("controlInformationRoot", instance.ControlActRoot);
                }
                if (instance.ValidTimeHigh != null && !instance.ValidTimeHigh.IsNull)
                {
                    s.WriteAttributeString("validTimeHigh", instance.ValidTimeHigh.Value);
                }
                if (instance.ValidTimeLow != null && !instance.ValidTimeLow.IsNull)
                {
                    s.WriteAttributeString("validTimeLow", instance.ValidTimeLow.Value);
                }
                if (instance.UpdateMode != null && !instance.UpdateMode.IsNull)
                {
                    s.WriteAttributeString("updateMode", Util.ToWireFormat(instance.UpdateMode));
                }
            }

            string currentElementName = "";

            if (s is MARC.Everest.Xml.XmlStateWriter)
            {
                currentElementName = (s as MARC.Everest.Xml.XmlStateWriter).CurrentPath;
            }

            // Validate
            if (result.ValidateConformance && !instance.Validate())
            {
                foreach (var r in instance.ValidateEx())
                {
                    r.Location = currentElementName;
                    result.AddResultDetail(r);
                }
            }
            //{
            //    result.AddResultDetail(new DatatypeValidationResultDetail(ResultDetailType.Error, o.GetType().Name, currentElementName));
            //}

            // Disabled for test
            // Validate flavor...
            if (result.ValidateConformance && instance.Flavor != null && Util.ValidateFlavor(instance.Flavor.ToUpper(), instance, out flavor) == false)
            {
                result.AddResultDetail(new DatatypeFlavorValidationResultDetail(ResultDetailType.Warning, instance.GetType().Name, instance.Flavor, currentElementName));
                result.AddResultDetail(flavor);
            }
        }
Exemplo n.º 6
0
        public virtual void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            ANY            instance = o as ANY;
            XmlStateWriter stw      = s as XmlStateWriter;

            // Now render
            if (instance == null)
            {
                throw new InvalidOperationException("Could not cast object to the ANY data type");
            }
            else if (instance.NullFlavor != null)
            {
                s.WriteAttributeString("nullFlavor", Util.ToWireFormat(instance.NullFlavor));
            }
            else if (instance.Flavor != null)
            {
                if (result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian)
                {
                    s.WriteAttributeString("specializationType", instance.Flavor);
                }
                else
                {
                    result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Flavor", "ANY", s.ToString()));
                }
            }

            // Validate
            if (result.ValidateConformance && !instance.Validate())
            {
                foreach (var r in instance.ValidateEx())
                {
                    r.Location = s.ToString();
                    result.AddResultDetail(r);
                }
                result.Code = ResultCode.Rejected;
            }
            // 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);
                if (result.Code < ResultCode.AcceptedNonConformant)
                {
                    result.Code = ResultCode.AcceptedNonConformant;
                }
            }

            // Warn if items can't be represented in R1
            if (instance.ControlActExt != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "ControlActExt", "ANY", s.ToString()));
            }
            if (instance.ControlActRoot != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "ControlActRoot", "ANY", s.ToString()));
            }
            if (instance.ValidTimeHigh != null && !(instance is EN))
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "ValidTimeHigh", "ANY", s.ToString()));
            }
            if (instance.ValidTimeLow != null && !(instance is EN))
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "ValidTimeLow", "ANY", s.ToString()));
            }
            if (instance.UpdateMode != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "UpdateMode", "ANY", s.ToString()));
            }
        }
Exemplo n.º 7
0
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            ANY            instance = o as ANY;
            XmlStateWriter stw      = s as XmlStateWriter;

            // Now render
            if (instance == null)
            {
                throw new InvalidOperationException("Could not cast object to the ANY data type");
            }
            else if (instance.NullFlavor != null)
            {
                s.WriteAttributeString("nullFlavor", Util.ToWireFormat(instance.NullFlavor));
            }
            else if (instance.Flavor != null)
            {
                if (result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian)
                {
                    s.WriteAttributeString("specializationType", instance.Flavor);
                }
                else
                {
                    result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Flavor", "ANY", s.ToString()));
                }
            }

            string currentElementName = "";

            if (s is MARC.Everest.Xml.XmlStateWriter)
            {
                currentElementName = (s as MARC.Everest.Xml.XmlStateWriter).CurrentPath;
            }

            // Validate
            if (result.ValidateConformance && !instance.Validate())
            {
                result.AddResultDetail(new DatatypeValidationResultDetail(ResultDetailType.Error, o.GetType().Name, currentElementName));
            }

            // 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, currentElementName));
                result.AddResultDetail(flavor);
            }

            // Warn if items can't be represented in R1
            if (instance.ControlActExt != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "ControlActExt", "ANY", currentElementName));
            }
            if (instance.ControlActRoot != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "ControlActRoot", "ANY", currentElementName));
            }
            if (instance.ValidTimeHigh != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "ValidTimeHigh", "ANY", currentElementName));
            }
            if (instance.ValidTimeLow != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "ValidTimeLow", "ANY", currentElementName));
            }
            if (instance.UpdateMode != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "UpdateMode", "ANY", currentElementName));
            }
        }