Exemplo n.º 1
0
        public static ConcatenatedString Concat(ScriptEngine engine, object thisObject, params object[] strings)
        {
            if (thisObject is ConcatenatedString)
            {
                // Append the strings together.
                ConcatenatedString result = (ConcatenatedString)thisObject;
                if (strings.Length == 0)
                {
                    return(result);
                }
                result = result.Concatenate(strings[0]);
                for (int i = 1; i < strings.Length; i++)
                {
                    result.Append(strings[i]);
                }
                return(result);
            }
            else
            {
                // Convert "this" to a string.
                TypeUtilities.VerifyThisObject(engine, thisObject, "concat");
                var thisObject2 = TypeConverter.ToString(thisObject);

                // Append the strings together.
                var result = new ConcatenatedString(thisObject2);
                foreach (object str in strings)
                {
                    result.Append(str);
                }
                return(result);
            }
        }
Exemplo n.º 2
0
        private static string ToString(object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            if (value is ConcatenatedString)
            {
                ConcatenatedString cs = (ConcatenatedString)value;
                return(cs.ToString());
            }

            return(value.ToString());
        }
Exemplo n.º 3
0
        public static ConcatenatedString Concat(ScriptEngine engine, object thisObject, params object[] strings)
        {
            if (thisObject is ConcatenatedString)
            {
                // Append the strings together.
                ConcatenatedString result = (ConcatenatedString)thisObject;
                if (strings.Length == 0)
                    return result;
                result = result.Concatenate(strings[0]);
                for (int i = 1; i < strings.Length; i ++)
                    result.Append(strings[i]);
                return result;
            }
            else
            {
                // Convert "this" to a string.
                TypeUtilities.VerifyThisObject(engine, thisObject, "concat");
                var thisObject2 = TypeConverter.ToString(thisObject);

                // Append the strings together.
                var result = new ConcatenatedString(thisObject2);
                foreach (object str in strings)
                    result.Append(str);
                return result;
            }
        }