Ejemplo n.º 1
0
        internal void GetMinMax(XmlElement elNode, bool isAttribute, ref int minOccurs, ref int maxOccurs)
        {
            string occurs = elNode.GetAttribute(Keywords.MINOCCURS);

            if (occurs != null && occurs.Length > 0)
            {
                try {
                    minOccurs = Int32.Parse(occurs, CultureInfo.InvariantCulture);
                }
                catch (Exception e) {
                    //
                    if (!ADP.IsCatchableExceptionType(e))
                    {
                        throw;
                    }
                    throw ExceptionBuilder.AttributeValues("minOccurs", "0", "1");
                }
            }
            occurs = elNode.GetAttribute(Keywords.MAXOCCURS);

            if (occurs != null && occurs.Length > 0)
            {
                int bZeroOrMore = string.Compare(occurs, Keywords.STAR, StringComparison.Ordinal);
                if (bZeroOrMore == 0)
                {
                    maxOccurs = -1;
                }
                else
                {
                    try {
                        maxOccurs = Int32.Parse(occurs, CultureInfo.InvariantCulture);
                    }
                    catch (Exception e) {
                        //
                        if (!ADP.IsCatchableExceptionType(e))
                        {
                            throw;
                        }
                        throw ExceptionBuilder.AttributeValues("maxOccurs", "1", Keywords.STAR);
                    }
                    if (maxOccurs != 1)
                    {
                        throw ExceptionBuilder.AttributeValues("maxOccurs", "1", Keywords.STAR);
                    }
                }
            }
        }
        internal void GetMinMax(XmlElement elNode, bool isAttribute, ref int minOccurs, ref int maxOccurs)
        {
            string attribute = elNode.GetAttribute("minOccurs");

            if ((attribute != null) && (attribute.Length > 0))
            {
                try
                {
                    minOccurs = int.Parse(attribute, CultureInfo.InvariantCulture);
                }
                catch (Exception exception2)
                {
                    if (!ADP.IsCatchableExceptionType(exception2))
                    {
                        throw;
                    }
                    throw ExceptionBuilder.AttributeValues("minOccurs", "0", "1");
                }
            }
            attribute = elNode.GetAttribute("maxOccurs");
            if ((attribute != null) && (attribute.Length > 0))
            {
                if (string.Compare(attribute, "*", StringComparison.Ordinal) == 0)
                {
                    maxOccurs = -1;
                }
                else
                {
                    try
                    {
                        maxOccurs = int.Parse(attribute, CultureInfo.InvariantCulture);
                    }
                    catch (Exception exception)
                    {
                        if (!ADP.IsCatchableExceptionType(exception))
                        {
                            throw;
                        }
                        throw ExceptionBuilder.AttributeValues("maxOccurs", "1", "*");
                    }
                    if (maxOccurs != 1)
                    {
                        throw ExceptionBuilder.AttributeValues("maxOccurs", "1", "*");
                    }
                }
            }
        }