当前位置: 首页>>代码示例>>C#>>正文


C# JsDictionaryObject.ToString方法代码示例

本文整理汇总了C#中JsDictionaryObject.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# JsDictionaryObject.ToString方法的具体用法?C# JsDictionaryObject.ToString怎么用?C# JsDictionaryObject.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JsDictionaryObject的用法示例。


在下文中一共展示了JsDictionaryObject.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConcatImpl

        /// <summary>
        /// 15.5.4.6
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public JsInstance ConcatImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(target.ToString());

            for (int i = 0; i < parameters.Length; i++) {
                sb.Append(parameters[i].ToString());
            }

            return Global.StringClass.New(sb.ToString());
        }
开发者ID:nate-yocom,项目名称:jint,代码行数:17,代码来源:JsStringConstructor.cs

示例2: CharCodeAtImpl

        /// <summary>
        /// 15.5.4.5
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance CharCodeAtImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            var r = target.ToString();
            var at = (int)parameters[0].ToNumber();

            if (r == String.Empty || at > r.Length - 1) {
                return Global.NaN;
            }
            else {
                return Global.NumberClass.New(Convert.ToInt32(r[at]));
            }
        }
开发者ID:nate-yocom,项目名称:jint,代码行数:18,代码来源:JsStringConstructor.cs

示例3: ToLocaleUpperCaseImpl

 /// <summary>
 /// 15.5.4.19
 /// </summary>
 /// <param name="target"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public JsInstance ToLocaleUpperCaseImpl(JsDictionaryObject target, JsInstance[] parameters) {
     string str = target.ToString();
     return Global.StringClass.New(str.ToUpper());
 }
开发者ID:925coder,项目名称:ravendb,代码行数:10,代码来源:JsStringConstructor.cs

示例4: ToUpperCaseImpl

 /// <summary>
 /// 15.5.4.18
 /// </summary>
 /// <param name="target"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public JsInstance ToUpperCaseImpl(JsDictionaryObject target, JsInstance[] parameters) {
     return Global.StringClass.New(target.ToString().ToUpperInvariant());
 }
开发者ID:925coder,项目名称:ravendb,代码行数:9,代码来源:JsStringConstructor.cs

示例5: ToLocaleLowerCaseImpl

 /// <summary>
 /// 15.5.4.17
 /// </summary>
 /// <param name="target"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public JsInstance ToLocaleLowerCaseImpl(JsDictionaryObject target, JsInstance[] parameters) {
     return Global.StringClass.New(target.ToString().ToLower());
 }
开发者ID:925coder,项目名称:ravendb,代码行数:9,代码来源:JsStringConstructor.cs

示例6: SubstrImpl

        public JsInstance SubstrImpl(JsDictionaryObject target, JsInstance[] parameters) {
            string str = target.ToString();
            int start = 0, end = str.Length;

            if (parameters.Length > 0 && !double.IsNaN(parameters[0].ToNumber())) {
                start = Convert.ToInt32(parameters[0].ToNumber());
            }

            if (parameters.Length > 1 && parameters[1] != JsUndefined.Instance && !double.IsNaN(parameters[1].ToNumber())) {
                end = Convert.ToInt32(parameters[1].ToNumber());
            }

            start = Math.Min(Math.Max(start, 0), Math.Max(0, str.Length - 1));
            end = Math.Min(Math.Max(end, 0), str.Length);
            str = str.Substring(start, end);

            return New(str);
        }
开发者ID:925coder,项目名称:ravendb,代码行数:18,代码来源:JsStringConstructor.cs

示例7: SplitImpl

        /// <summary>
        /// 15.5.4.14
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance SplitImpl(JsDictionaryObject target, JsInstance[] parameters) {
            JsObject A = Global.ArrayClass.New();
            string S = target.ToString();

            if (parameters.Length == 0 || parameters[0] == JsUndefined.Instance) {
                A["0"] = Global.StringClass.New(S);
            }

            JsInstance separator = parameters[0];
            int limit = parameters.Length > 1 ? Convert.ToInt32(parameters[1].ToNumber()) : Int32.MaxValue;
            int s = S.Length;
            string[] result;

            if (separator.Class == JsInstance.CLASS_REGEXP) {
                result = ((JsRegExp)parameters[0]).Regex.Split(S, limit);
            }
            else {
                result = S.Split(new string[] { separator.ToString() }, limit, StringSplitOptions.None);
            }

            for (int i = 0; i < result.Length; i++) {
                A[i.ToString()] = Global.StringClass.New(result[i]);
            }

            return A;
        }
开发者ID:925coder,项目名称:ravendb,代码行数:32,代码来源:JsStringConstructor.cs

示例8: SliceImpl

        /// <summary>
        /// 15.5.4.13
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance SliceImpl(JsDictionaryObject target, JsInstance[] parameters) {
            string source = target.ToString();
            int start = (int)parameters[0].ToNumber();
            int end = source.Length;
            if (parameters.Length > 1) {
                end = (int)parameters[1].ToNumber();
                if (end < 0) {
                    end = source.Length + end;
                }
            }

            if (start < 0) {
                start = source.Length + start;
            }

            return Global.StringClass.New(source.Substring(start, end - start));
        }
开发者ID:925coder,项目名称:ravendb,代码行数:23,代码来源:JsStringConstructor.cs

示例9: SearchImpl

        /// <summary>
        /// 15.5.4.12
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance SearchImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            // Converts the parameters to a regex
            if (parameters[0].Class == JsString.TYPEOF)
            {
                parameters[0] = Global.RegExpClass.New(parameters[0].ToString(), false, false, false);
            }

            Match m = ((Regex)(parameters[0].Value)).Match(target.ToString());

            if (m != null)
            {
                return Global.NumberClass.New(m.Index);
            }
            else
            {
                return Global.NumberClass.New(-1);
            }
        }
开发者ID:pusp,项目名称:o2platform,代码行数:25,代码来源:JsStringConstructor.cs

示例10: ReplaceImpl

        /// <summary>
        /// 15.5.4.11
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance ReplaceImpl(JsDictionaryObject target, JsInstance[] parameters) {
            if (parameters.Length == 0) {
                return Global.StringClass.New(target.ToString());
            }

            JsInstance searchValue = parameters[0];
            JsInstance replaceValue = JsUndefined.Instance;

            if (parameters.Length > 1) {
                replaceValue = parameters[1];
            }

            string source = target.ToString();

            JsFunction function = replaceValue as JsFunction;
            if (searchValue.Class == JsInstance.CLASS_REGEXP) {
                int count = ((JsRegExp)parameters[0]).IsGlobal ? int.MaxValue : 1;
                var regexp = ((JsRegExp)parameters[0]);
                int lastIndex = regexp.IsGlobal ? 0 : Math.Max(0, (int)regexp["lastIndex"].ToNumber() - 1);

                if (regexp.IsGlobal) {
                    regexp["lastIndex"] = Global.NumberClass.New(0);
                }

                if (replaceValue is JsFunction)
                {
                    string ret = ((JsRegExp)parameters[0]).Regex.Replace(source, delegate(Match m) {
                        List<JsInstance> replaceParameters = new List<JsInstance>();
                        if (!regexp.IsGlobal) {
                            regexp["lastIndex"] = Global.NumberClass.New(m.Index + 1);
                        }

                        replaceParameters.Add(Global.StringClass.New(m.Value));
                        for (int i = 1; i < m.Groups.Count; i++) {
                            if (m.Groups[i].Success) {
                                replaceParameters.Add(Global.StringClass.New(m.Groups[i].Value));
                            }
                            else {
                                replaceParameters.Add(JsUndefined.Instance);
                            }
                        }
                        replaceParameters.Add(Global.NumberClass.New(m.Index));
                        replaceParameters.Add(Global.StringClass.New(source));

                        Global.Visitor.ExecuteFunction(function, null, replaceParameters.ToArray());

                        return Global.Visitor.Returned.ToString();
                    }, count, lastIndex);


                    return Global.StringClass.New(ret);

                }
                else {
                    string str = parameters[1].ToString();
                    string ret = ((JsRegExp)parameters[0]).Regex.Replace(target.ToString(), delegate(Match m) {
                        if (!regexp.IsGlobal) {
                            regexp["lastIndex"] = Global.NumberClass.New(m.Index + 1);
                        }

                        string after = source.Substring(Math.Min(source.Length - 1, m.Index + m.Length));
                        return EvaluateReplacePattern(m.Value, source.Substring(0, m.Index), after, str, m.Groups);
                    }, count, lastIndex);

                    return Global.StringClass.New(ret);
                }


            }
            else {
                string search = searchValue.ToString();
                int index = source.IndexOf(search);
                if (index != -1) {
                    if (replaceValue is JsFunction)
                    {
                        List<JsInstance> replaceParameters = new List<JsInstance>();
                        replaceParameters.Add(Global.StringClass.New(search));
                        replaceParameters.Add(Global.NumberClass.New(index));
                        replaceParameters.Add(Global.StringClass.New(source));

                        Global.Visitor.ExecuteFunction(function, null, replaceParameters.ToArray());
                        replaceValue = Global.Visitor.Result;

                        return Global.StringClass.New(source.Substring(0, index) + replaceValue.ToString() + source.Substring(index + search.Length));
                    }
                    else {
                        string before = source.Substring(0, index);
                        string after = source.Substring(index + search.Length);
                        string newString = EvaluateReplacePattern(search, before, after, replaceValue.ToString(), null);
                        return Global.StringClass.New(before + newString + after);
                    }
                }
                else {
                    return Global.StringClass.New(source);
//.........这里部分代码省略.........
开发者ID:925coder,项目名称:ravendb,代码行数:101,代码来源:JsStringConstructor.cs

示例11: MatchFunc

        /// <summary>
        /// 15.5.4.10
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance MatchFunc(JsDictionaryObject target, JsInstance[] parameters)
        {
            JsRegExp regexp = parameters[0].Class == JsInstance.CLASS_STRING
                ? Global.RegExpClass.New(parameters[0].ToString(), false, false, false)
                : (JsRegExp)parameters[0];

            if (!regexp.IsGlobal)
            {
                return Global.RegExpClass.ExecImpl(regexp, new JsInstance[] {target});
            }
            else
            {
                var result = Global.ArrayClass.New();
                var matches = Regex.Matches(target.ToString(), regexp.Pattern, regexp.Options);
                if (matches.Count > 0)
                {
                    var i = 0;
                    foreach (Match match in matches)
                    {
                        result[Global.NumberClass.New(i++)] = Global.StringClass.New(match.Value);
                    }

                    return result;
                }
                else
                {
                    return JsNull.Instance;
                }
            }
        }
开发者ID:925coder,项目名称:ravendb,代码行数:36,代码来源:JsStringConstructor.cs

示例12: LocaleCompareImpl

 /// <summary>
 /// 15.5.4.9
 /// </summary>
 /// <param name="target"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public JsInstance LocaleCompareImpl(JsDictionaryObject target, JsInstance[] parameters) {
     return Global.NumberClass.New(target.ToString().CompareTo(parameters[0].ToString()));
 }
开发者ID:925coder,项目名称:ravendb,代码行数:9,代码来源:JsStringConstructor.cs

示例13: LastIndexOfImpl

        /// <summary>
        /// 15.5.4.8
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public JsInstance LastIndexOfImpl(JsDictionaryObject target, JsInstance[] parameters) {
            string source = target.ToString();
            string searchString = parameters[0].ToString();
            int position = parameters.Length > 1 ? (int)parameters[1].ToNumber() : source.Length;

            return Global.NumberClass.New(source.Substring(0, position).LastIndexOf(searchString));
        }
开发者ID:925coder,项目名称:ravendb,代码行数:12,代码来源:JsStringConstructor.cs

示例14: IndexOfImpl

        /// <summary>
        /// 15.5.4.7
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public JsInstance IndexOfImpl(JsDictionaryObject target, JsInstance[] parameters) {
            string source = target.ToString();
            string searchString = parameters[0].ToString();
            int position = parameters.Length > 1 ? (int)parameters[1].ToNumber() : 0;

            if (searchString == String.Empty) {
                if (parameters.Length > 1) {
                    return Global.NumberClass.New(Math.Min(source.Length, position));
                }
                else {
                    return Global.NumberClass.New(0);
                }
            }

            if (position >= source.Length) {
                return Global.NumberClass.New(-1);
            }

            return Global.NumberClass.New(source.IndexOf(searchString, position));
        }
开发者ID:925coder,项目名称:ravendb,代码行数:25,代码来源:JsStringConstructor.cs

示例15: LengthImpl

 /// <summary>
 /// 15.5.5.1
 /// </summary>
 /// <param name="target"></param>
 /// <returns></returns>
 public JsInstance LengthImpl(JsDictionaryObject target) {
     string str = target.ToString();
     return Global.NumberClass.New(str.Length);
 }
开发者ID:925coder,项目名称:ravendb,代码行数:9,代码来源:JsStringConstructor.cs


注:本文中的JsDictionaryObject.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。