本文整理汇总了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());
}
示例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);
}
示例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);
}
示例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;
}
示例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));
}
示例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));
}
示例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());
}