ToLocaleString() static private method

static private ToLocaleString ( Object value ) : String
value Object
return String
        internal static String Join(Object thisob, String separator, bool localize)
        {
            StringBuilder str        = new StringBuilder();
            uint          thisLength = Convert.ToUint32(LateBinding.GetMemberValue(thisob, "length"));

            if (thisLength > int.MaxValue)
            {
                throw new JScriptException(JSError.OutOfMemory);
            }
            // Small optimization so we're not doing a bunch of reallocs for large arrays.
            if (thisLength > str.Capacity)
            {
                str.Capacity = (int)thisLength;
            }
            for (uint i = 0; i < thisLength; i++)
            {
                Object value = LateBinding.GetValueAtIndex(thisob, i);
                if (value != null && !(value is Missing))
                {
                    if (localize)
                    {
                        str.Append(Convert.ToLocaleString(value));
                    }
                    else
                    {
                        str.Append(Convert.ToString(value));
                    }
                }
                if (i < thisLength - 1)
                {
                    str.Append(separator);
                }
            }
            return(str.ToString());
        }
Beispiel #2
0
        internal static String Join(Object thisob, String separator, bool localize)
        {
            StringBuilder str        = new StringBuilder();
            uint          thisLength = Convert.ToUint32(LateBinding.GetMemberValue(thisob, "length"));

            for (uint i = 0; i < thisLength; i++)
            {
                Object value = LateBinding.GetValueAtIndex(thisob, i);
                if (value != null && !(value is Missing))
                {
                    if (localize)
                    {
                        str.Append(Convert.ToLocaleString(value));
                    }
                    else
                    {
                        str.Append(Convert.ToString(value));
                    }
                }
                if (i < thisLength - 1)
                {
                    str.Append(separator);
                }
            }
            return(str.ToString());
        }