EvaluationResult IObjectValueSource.SetValue(ObjectPath path, string value, EvaluationOptions options) { try { Context.WaitRuntimeInvokes(); var ctx = GetContext(options); ctx.Options.AllowMethodEvaluation = true; ctx.Options.AllowTargetInvoke = true; var vref = ctx.Evaluator.Evaluate(ctx, value, Type); var newValue = ctx.Adapter.Convert(ctx, vref.Value, Type); SetValue(ctx, newValue); } catch (Exception ex) { Context.WriteDebuggerError(ex); Context.WriteDebuggerOutput("Value assignment failed: {0}: {1}\n", ex.GetType(), ex.Message); } try { return(Context.Evaluator.TargetObjectToExpression(Context, Value)); } catch (Exception ex) { Context.WriteDebuggerError(ex); Context.WriteDebuggerOutput("Value assignment failed: {0}: {1}\n", ex.GetType(), ex.Message); } return(null); }
public override IEnumerable <ValueReference> GetChildReferences(EvaluationOptions options) { EvaluationContext ctx = GetContext(options); try { List <ValueReference> list = new List <ValueReference> (); list.AddRange(ctx.Adapter.GetMembersSorted(ctx, this, type, null, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)); List <ValueReference> nestedTypes = new List <ValueReference> (); foreach (object t in ctx.Adapter.GetNestedTypes(ctx, type)) { nestedTypes.Add(new TypeValueReference(ctx, t)); } nestedTypes.Sort(delegate(ValueReference v1, ValueReference v2) { return(v1.Name.CompareTo(v2.Name)); }); list.AddRange(nestedTypes); return(list); } catch (Exception ex) { Console.WriteLine(ex); ctx.WriteDebuggerOutput(ex.Message); return(new ValueReference[0]); } }
public override ObjectValue[] GetChildren(ObjectPath path, int index, int count, EvaluationOptions options) { EvaluationContext ctx = GetContext(options); try { List <ObjectValue> list = new List <ObjectValue> (); BindingFlags flattenFlag = options.FlattenHierarchy ? (BindingFlags)0 : BindingFlags.DeclaredOnly; BindingFlags flags = BindingFlags.Static | BindingFlags.Public | flattenFlag; bool groupPrivateMembers = options.GroupPrivateMembers && (options.GroupUserPrivateMembers || ctx.Adapter.IsExternalType(ctx, type)); if (!groupPrivateMembers) { flags |= BindingFlags.NonPublic; } TypeDisplayData tdata = ctx.Adapter.GetTypeDisplayData(ctx, type); object tdataType = type; foreach (ValueReference val in ctx.Adapter.GetMembersSorted(ctx, this, type, null, flags)) { object decType = val.DeclaringType; if (decType != null && decType != tdataType) { tdataType = decType; tdata = ctx.Adapter.GetTypeDisplayData(ctx, decType); } DebuggerBrowsableState state = tdata.GetMemberBrowsableState(val.Name); if (state == DebuggerBrowsableState.Never) { continue; } ObjectValue oval = val.CreateObjectValue(options); list.Add(oval); } List <ObjectValue> nestedTypes = new List <ObjectValue> (); foreach (object t in ctx.Adapter.GetNestedTypes(ctx, type)) { nestedTypes.Add(new TypeValueReference(ctx, t).CreateObjectValue(options)); } nestedTypes.Sort(delegate(ObjectValue v1, ObjectValue v2) { return(v1.Name.CompareTo(v2.Name)); }); list.AddRange(nestedTypes); if (groupPrivateMembers) { list.Add(FilteredMembersSource.CreateNonPublicsNode(ctx, this, type, null, BindingFlags.NonPublic | BindingFlags.Static | flattenFlag)); } if (!options.FlattenHierarchy) { object baseType = ctx.Adapter.GetBaseType(ctx, type, false); if (baseType != null) { TypeValueReference baseRef = new TypeValueReference(ctx, baseType); ObjectValue baseVal = baseRef.CreateObjectValue(false); baseVal.Name = "base"; list.Insert(0, baseVal); } } return(list.ToArray()); } catch (Exception ex) { Console.WriteLine(ex); ctx.WriteDebuggerOutput(ex.Message); return(new ObjectValue [0]); } }