public RuntimeInvoke ( Thread thread, |
||
thread | Thread | |
function | ||
object_argument | ||
param_objects | ||
flags | RuntimeInvokeFlags | |
Résultat |
protected TargetObject GetProperty(ScriptingContext context, TargetPropertyInfo prop) { RuntimeInvokeFlags flags = context.GetRuntimeInvokeFlags (); RuntimeInvokeResult result = context.RuntimeInvoke ( context.CurrentThread, prop.Getter, InstanceObject, new TargetObject [0], flags); if (result.ExceptionMessage != null) throw new ScriptingException ( "Invocation of `{0}' raised an exception: {1}", Name, result.ExceptionMessage); return result.ReturnObject; }
protected void SetProperty(ScriptingContext context, TargetPropertyInfo prop, TargetObject obj) { ResolveClass (context.CurrentThread); if (prop.Setter == null) throw new ScriptingException ("Property `{0}' has no setter.", Name); RuntimeInvokeFlags flags = context.GetRuntimeInvokeFlags (); RuntimeInvokeResult result = context.RuntimeInvoke ( context.CurrentThread, prop.Setter, InstanceObject, new TargetObject [] { obj }, flags); if (result.ExceptionMessage != null) throw new ScriptingException ( "Invocation of `{0}' raised an exception: {1}", Name, result.ExceptionMessage); }
protected TargetObject DoInvoke(ScriptingContext context, bool debug) { TargetObject[] args = new TargetObject [arguments.Length]; for (int i = 0; i < arguments.Length; i++) args [i] = arguments [i].EvaluateObject (context); TargetMethodSignature sig = method.GetSignature (context.CurrentThread); TargetObject[] objs = new TargetObject [args.Length]; for (int i = 0; i < args.Length; i++) { objs [i] = Convert.ImplicitConversionRequired ( context, args [i], sig.ParameterTypes [i]); } TargetStructObject instance = method_expr.InstanceObject; if (!method.IsStatic && !method.IsConstructor && (instance == null)) throw new ScriptingException ( "Cannot invoke instance method `{0}' with a type reference.", method.FullName); try { Thread thread = context.CurrentThread; RuntimeInvokeResult result; RuntimeInvokeFlags flags = context.GetRuntimeInvokeFlags (); if (debug) flags |= RuntimeInvokeFlags.BreakOnEntry | RuntimeInvokeFlags.SendEventOnCompletion | RuntimeInvokeFlags.NestedBreakStates; result = context.RuntimeInvoke (thread, method, instance, objs, flags); if (result == null) throw new ScriptingException ( "Invocation of `{0}' aborted abnormally.", Name); if (result.ExceptionMessage != null) throw new InvocationException (Name, result.ExceptionMessage, result.ReturnObject); return result.ReturnObject; } catch (TargetException ex) { throw new ScriptingException ( "Invocation of `{0}' raised an exception: {1}", Name, ex.Message); } catch (EvaluationTimeoutException ex) { throw new ScriptingException ("Invocation of `{0}' timed out.", Name); } }