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


C# JsDictionaryObject.Call方法代码示例

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


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

示例1: 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.Call(Global.Visitor, "toString").ToString();
     return Global.StringClass.New(str.ToUpper());
 }
开发者ID:pusp,项目名称:o2platform,代码行数:11,代码来源:JsStringConstructor.cs

示例2: LengthImpl

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

示例3: SubstrImpl

        public JsInstance SubstrImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            string str = target.Call(Global.Visitor, "toString").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:pusp,项目名称:o2platform,代码行数:21,代码来源:JsStringConstructor.cs

示例4: 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.Call(Global.Visitor, "toString").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 == JsRegExp.TYPEOF)
            {
                var regexp = (Regex)((JsRegExp)separator).Value;
                result = regexp.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:pusp,项目名称:o2platform,代码行数:38,代码来源:JsStringConstructor.cs

示例5: LastIndexOfImpl

        /// <summary>
        /// 15.5.4.8
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public JsInstance LastIndexOfImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            string source = target.Call(Global.Visitor, "toString").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:pusp,项目名称:o2platform,代码行数:13,代码来源:JsStringConstructor.cs

示例6: IndexOfImpl

        /// <summary>
        /// 15.5.4.7
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public JsInstance IndexOfImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            string source = target.Call(Global.Visitor, "toString").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:pusp,项目名称:o2platform,代码行数:30,代码来源:JsStringConstructor.cs

示例7: 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.Call(Global.Visitor, "toString").ToString());

            for (int i = 0; i < parameters.Length; i++)
            {
                sb.Append(parameters[i].Call(Global.Visitor, "toString").ToString());
            }

            return Global.StringClass.New(sb.ToString());
        }
开发者ID:pusp,项目名称:o2platform,代码行数:18,代码来源:JsStringConstructor.cs


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