public static EvaluationResult GetProperty(Thread thread, TargetPropertyInfo property, TargetStructObject instance, EvaluationFlags flags, int timeout, out string error, out TargetObject result) { error = null; RuntimeInvokeResult rti; try { RuntimeInvokeFlags rti_flags = RuntimeInvokeFlags.VirtualMethod; if ((flags & EvaluationFlags.NestedBreakStates) != 0) rti_flags |= RuntimeInvokeFlags.NestedBreakStates; rti = thread.RuntimeInvoke ( property.Getter, instance, new TargetObject [0], rti_flags); if (!rti.CompletedEvent.WaitOne (timeout, false)) { rti.Abort (); result = null; return EvaluationResult.Timeout; } if ((rti.TargetException != null) && (rti.TargetException.Type == TargetError.ClassNotInitialized)) { result = null; error = rti.ExceptionMessage; return EvaluationResult.NotInitialized; } if (rti.Result is Exception) { result = null; error = ((Exception) rti.Result).Message; return EvaluationResult.UnknownError; } result = (TargetObject) rti.ReturnObject; if (rti.ExceptionMessage != null) { error = rti.ExceptionMessage; return EvaluationResult.Exception; } else if (rti.ReturnObject == null) { rti.Abort (); return EvaluationResult.UnknownError; } return EvaluationResult.Ok; } catch (TargetException ex) { result = null; error = ex.ToString (); return EvaluationResult.UnknownError; } }
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 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; }
public IndexerValueReference (EvaluationContext ctx, TargetStructObject target, TargetObject[] index, TargetPropertyInfo indexerProp): base (ctx) { this.indexer = indexerProp; this.target = target; this.index = index; }
protected string FormatProperty(string prefix, TargetPropertyInfo prop, bool is_static, Hashtable hash) { StringBuilder sb = new StringBuilder (); sb.Append (FormatMember (prefix, prop, is_static, hash)); sb.Append (" {"); if (prop.CanRead) sb.Append (" get;"); if (prop.CanWrite) sb.Append (" set;"); sb.Append (" };\n"); return sb.ToString (); }
public EE.EvaluationResult GetProperty(Thread thread, TargetPropertyInfo property, TargetStructObject instance, EE.EvaluationFlags flags, int timeout, out string error, out TargetObject value) { return EE.GetProperty (thread, property, instance, flags, timeout, out error, out value); }
public PropertyReference (EvaluationContext ctx, TargetPropertyInfo prop, TargetStructObject thisobj): base (ctx) { this.prop = prop; if (!prop.IsStatic) this.thisobj = thisobj; }