コード例 #1
0
        /// <summary>
        /// Codepoints to string operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:codepoints-to-string operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence codepoints_to_string(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence codepoints_to_string(ICollection args)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());
            var         j     = cargs.GetEnumerator();

            j.MoveNext();
            ResultSequence arg1 = (ResultSequence)j.Current;

            if (arg1 == null || arg1.empty())
            {
                return(new XSString(""));
            }

            int[] codePointArray = new int[arg1.size()];
            int   codePointIndex = 0;

            for (var i = arg1.iterator(); i.MoveNext();)
            {
                XSInteger code = (XSInteger)i.Current;

                int codepoint = (int)code.int_value();
                if (codepoint < MIN_LEGAL_CODEPOINT || codepoint > MAX_LEGAL_CODEPOINT)
                {
                    throw DynamicError.unsupported_codepoint("U+" + Convert.ToString(codepoint, 16).ToUpper());
                }

                codePointArray[codePointIndex] = codepoint;
                codePointIndex++;
            }

            try
            {
                var    c   = codePointArray.Select(x => (char)x).ToArray();
                string str = new string(c);
                return(new XSString(str));
            }
            catch (System.ArgumentException iae)
            {
                // This should be duoble checked above, but rather safe than sorry
                throw DynamicError.unsupported_codepoint(iae.Message);
            }
        }
コード例 #2
0
 /// <summary>
 /// Constructor for IntegerLiteral
 /// </summary>
 /// <param name="i">
 ///            integer value </param>
 public IntegerLiteral(System.Numerics.BigInteger i)
 {
     _value = new XSInteger(i);
 }