コード例 #1
0
        /// <exception cref="Ca.Infoway.Messagebuilder.Marshalling.HL7.XmlToModelTransformationException"></exception>
        private Int32?ParseNonNullNode(ParseContext context, XmlElement element, XmlToModelResult xmlToModelResult)
        {
            Int32? result          = null;
            string unparsedInteger = GetAttributeValue(element, "value");

            if (StringUtils.IsNotBlank(unparsedInteger))
            {
                if (!NumberUtil.IsNumber(unparsedInteger))
                {
                    RecordNotAValidNumberError(element, xmlToModelResult);
                }
                else
                {
                    result = NumberUtil.ParseAsInteger(unparsedInteger);
                    // using the isNumeric check to catch silly things such as passing in a hexadecimal number (0x1a, for example)
                    bool mustBePositive = StandardDataType.INT_POS.Type.Equals(context.Type);
                    if (StandardDataType.INT.Type.Equals(context.Type) && unparsedInteger.StartsWith("-"))
                    {
                        // remove negative sign to not confuse isNumeric() check
                        unparsedInteger = Ca.Infoway.Messagebuilder.StringUtils.Substring(unparsedInteger, 1);
                    }
                    if (!NumberUtil.IsInteger(unparsedInteger) || !StringUtils.IsNumeric(unparsedInteger))
                    {
                        RecordInvalidIntegerError(result, element, mustBePositive, xmlToModelResult);
                    }
                    else
                    {
                        if (mustBePositive && result.Value == 0)
                        {
                            RecordMustBeGreaterThanZeroError(element, xmlToModelResult);
                        }
                    }
                }
            }
            else
            {
                if (element.HasAttribute("value"))
                {
                    RecordEmptyValueError(element, xmlToModelResult);
                }
                else
                {
                    RecordMissingValueError(element, xmlToModelResult);
                }
            }
            return(result);
        }
コード例 #2
0
        /// <exception cref="Ca.Infoway.Messagebuilder.Marshalling.HL7.XmlToModelTransformationException"></exception>
        private Int32?ParseNonNullNode(ParseContext context, XmlElement element, BareANY bareAny, XmlToModelResult xmlToModelResult
                                       )
        {
            Int32? result          = null;
            string unparsedInteger = GetAttributeValue(element, "value");

            if (StringUtils.IsNotBlank(unparsedInteger))
            {
                if (!NumberUtil.IsNumber(unparsedInteger))
                {
                    RecordNotAValidNumberError(element, xmlToModelResult);
                }
                else
                {
                    result = NumberUtil.ParseAsInteger(unparsedInteger);
                    if (unparsedInteger.StartsWith("-"))
                    {
                        // remove negative sign to not confuse isNumeric() check
                        unparsedInteger = Ca.Infoway.Messagebuilder.StringUtils.Substring(unparsedInteger, 1);
                    }
                    // using the isNumeric check to catch silly things such as passing in a hexadecimal number (0x1a, for example)
                    if (!NumberUtil.IsInteger(unparsedInteger) || !StringUtils.IsNumeric(unparsedInteger))
                    {
                        RecordInvalidIntegerError(result, element, xmlToModelResult);
                    }
                }
            }
            else
            {
                if (element.HasAttribute("value"))
                {
                    RecordEmptyValueError(element, xmlToModelResult);
                }
                else
                {
                    RecordMissingValueError(element, xmlToModelResult);
                }
            }
            this.sxcmHelper.HandleOperator(element, context, xmlToModelResult, (ANYMetaData)bareAny);
            if (element.HasAttribute("unsorted"))
            {
                bool unsorted = Ca.Infoway.Messagebuilder.BooleanUtils.ValueOf(element.GetAttribute("unsorted"));
                ((ANYMetaData)bareAny).Unsorted = unsorted;
            }
            return(result);
        }