本文整理汇总了C#中Jint.Native.JsInstance.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# JsInstance.CopyTo方法的具体用法?C# JsInstance.CopyTo怎么用?C# JsInstance.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jint.Native.JsInstance
的用法示例。
在下文中一共展示了JsInstance.CopyTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUTCFullYearImpl
/// <summary>
/// 15.9.5.41
/// </summary>
/// <param name="target"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public JsInstance SetUTCFullYearImpl(JsDictionaryObject target, JsInstance[] parameters)
{
if (parameters.Length == 0)
throw new ArgumentException("There was no year specified");
DateTime valueOf = CreateDateTime(target.ToNumber());
valueOf = valueOf.AddYears(-valueOf.Year);
valueOf = valueOf.AddYears((int)parameters[0].ToNumber());
target.Value = valueOf;
if (parameters.Length > 1)
{
JsInstance[] innerParams = new JsInstance[parameters.Length - 1];
parameters.CopyTo(innerParams, 1);
target = (JsDate)SetMonthImpl(target, innerParams);
}
return target;
}
示例2: Visit
public void Visit(MethodCall methodCall)
{
var that = CallTarget;
var target = Result;
if (target == JsUndefined.Instance || Result == null) {
if (!String.IsNullOrEmpty(lastIdentifier)) {
}
else {
throw new JsException(Global.TypeErrorClass.New("Method isn't defined"));
}
}
Type[] genericParameters = null;
if (methodCall.Generics.Count > 0)
{
genericParameters = new Type[methodCall.Generics.Count];
try
{
int i = 0;
foreach (Expression generic in methodCall.Generics)
{
generic.Accept(this);
genericParameters[i] = Global.Marshaller.MarshalJsValue<Type>(Result);
i++;
}
}
catch (Exception e)
{
throw new JintException("A type parameter is required", e);
}
}
#region Evaluates parameters
JsInstance[] parameters = new JsInstance[methodCall.Arguments.Count];
if (methodCall.Arguments.Count > 0) {
for (int j = 0; j < methodCall.Arguments.Count; j++) {
methodCall.Arguments[j].Accept(this);
parameters[j] = Result;
}
}
#endregion
if (target is JsFunction) {
JsFunction function = (JsFunction)target;
if (DebugMode) {
string stack = function.Name + "(";
string[] paramStrings = new string[parameters.Length];
for (int i = 0; i < parameters.Length; i++) {
if (parameters[i] != null)
paramStrings[i] = parameters[i].ToSource();
else
paramStrings[i] = "null";
}
stack += String.Join(", ", paramStrings);
stack += ")";
CallStack.Push(stack);
}
returnInstance = JsUndefined.Instance;
JsInstance[] original = new JsInstance[parameters.Length];
parameters.CopyTo(original, 0);
ExecuteFunction(function, that, parameters, genericParameters);
for (int i = 0; i < original.Length; i++)
if (original[i] != parameters[i]) {
if (methodCall.Arguments[i] is MemberExpression && ((MemberExpression)methodCall.Arguments[i]).Member is IAssignable)
Assign((MemberExpression)methodCall.Arguments[i], parameters[i]);
else if (methodCall.Arguments[i] is Identifier)
Assign(new MemberExpression(methodCall.Arguments[i], null), parameters[i]);
}
if (DebugMode) {
CallStack.Pop();
}
Result = returnInstance;
returnInstance = JsUndefined.Instance;
return;
}
else {
throw new JsException(Global.ErrorClass.New("Function expected."));
}
}
示例3: SetHoursImpl
/// <summary>
/// 15.9.5.35
/// </summary>
/// <param name="target"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public JsInstance SetHoursImpl(JsDictionaryObject target, JsInstance[] parameters)
{
if (parameters.Length == 0)
throw new ArgumentException("There was no hour specified");
DateTime valueOf = CreateDateTime(target.ToNumber()).ToLocalTime();
valueOf = valueOf.AddHours(-valueOf.Hour);
valueOf = valueOf.AddHours(parameters[0].ToNumber());
target.Value = valueOf;
if (parameters.Length > 1)
{
JsInstance[] innerParams = new JsInstance[parameters.Length - 1];
parameters.CopyTo(innerParams, 1);
target = (JsDate)SetMinutesImpl(target, innerParams);
}
return target;
}