public static ObjectValue CreateObject (IObjectValueSource source, ObjectPath path, string typeName, EvaluationResult value, ObjectValueFlags flags, ObjectValue[] children)
		{
			ObjectValue ob = Create (source, path, typeName);
			ob.path = path;
			ob.flags = flags | ObjectValueFlags.Object;
			ob.value = value.Value;
			ob.displayValue = value.DisplayValue;
			if (children != null) {
				ob.children = new List<ObjectValue> ();
				ob.children.AddRange (children);
			}
			return ob;
		}
		internal void UpdateFromTrace (string trace)
		{
			EvaluationResult res = new EvaluationResult (trace);
			ObjectValueFlags flags = ObjectValueFlags.Primitive | ObjectValueFlags.Field;
			string type = "";
			if (value != null) {
				flags = value.Flags;
				type = value.TypeName;
			}
			value = ObjectValue.CreatePrimitive (null, new ObjectPath (Expression), type, res, flags);
			evaluated = true;
			NotifyChanged ();
		}
Exemplo n.º 3
0
		protected virtual ObjectValue CreateObjectValueImpl (EvaluationContext ctx, Mono.Debugging.Backend.IObjectValueSource source, ObjectPath path, object obj, ObjectValueFlags flags)
		{
			string typeName = obj != null ? GetValueTypeName (ctx, obj) : "";

			if (obj == null || IsNull (ctx, obj)) {
				return ObjectValue.CreateNullObject (source, path, GetDisplayTypeName (typeName), flags);
			}
			else if (IsPrimitive (ctx, obj) || IsEnum (ctx,obj)) {
				return ObjectValue.CreatePrimitive (source, path, GetDisplayTypeName (typeName), ctx.Evaluator.TargetObjectToExpression (ctx, obj), flags);
			}
			else if (IsArray (ctx, obj)) {
				return ObjectValue.CreateObject (source, path, GetDisplayTypeName (typeName), ctx.Evaluator.TargetObjectToExpression (ctx, obj), flags, null);
			}
			else {
				TypeDisplayData tdata = GetTypeDisplayData (ctx, GetValueType (ctx, obj));
				
				EvaluationResult tvalue;
				if (!string.IsNullOrEmpty (tdata.ValueDisplayString) && ctx.Options.AllowDisplayStringEvaluation)
					tvalue = new EvaluationResult (EvaluateDisplayString (ctx, obj, tdata.ValueDisplayString));
				else
					tvalue = ctx.Evaluator.TargetObjectToExpression (ctx, obj);
				
				string tname;
				if (!string.IsNullOrEmpty (tdata.TypeDisplayString) && ctx.Options.AllowDisplayStringEvaluation)
					tname = EvaluateDisplayString (ctx, obj, tdata.TypeDisplayString);
				else
					tname = GetDisplayTypeName (typeName);
				
				ObjectValue oval = ObjectValue.CreateObject (source, path, tname, tvalue, flags, null);
				if (!string.IsNullOrEmpty (tdata.NameDisplayString) && ctx.Options.AllowDisplayStringEvaluation)
					oval.Name = EvaluateDisplayString (ctx, obj, tdata.NameDisplayString);
				return oval;
			}
		}
		public static ObjectValue CreatePrimitive (IObjectValueSource source, ObjectPath path, string typeName, EvaluationResult value, ObjectValueFlags flags)
		{
			ObjectValue ob = Create (source, path, typeName);
			ob.flags = flags | ObjectValueFlags.Primitive;
			ob.value = value.Value;
			ob.displayValue = value.DisplayValue;
			return ob;
		}
        protected virtual ObjectValue CreateObjectValueImpl(EvaluationContext ctx, IObjectValueSource source, ObjectPath path, object obj, ObjectValueFlags flags)
        {
            object type = obj != null ? GetValueType (ctx, obj) : null;
            string typeName = type != null ? GetTypeName (ctx, type) : "";

            if (obj == null || IsNull (ctx, obj))
                return ObjectValue.CreateNullObject (source, path, GetDisplayTypeName (typeName), flags);

            if (IsPrimitive (ctx, obj) || IsEnum (ctx,obj))
                return ObjectValue.CreatePrimitive (source, path, GetDisplayTypeName (typeName), ctx.Evaluator.TargetObjectToExpression (ctx, obj), flags);

            if (IsArray (ctx, obj))
                return ObjectValue.CreateObject (source, path, GetDisplayTypeName (typeName), ctx.Evaluator.TargetObjectToExpression (ctx, obj), flags, null);

            EvaluationResult tvalue = null;
            TypeDisplayData tdata = null;
            string tname;

            if (IsNullableType (ctx, type)) {
                if (NullableHasValue (ctx, type, obj)) {
                    ValueReference value = NullableGetValue (ctx, type, obj);

                    tdata = GetTypeDisplayData (ctx, value.Type);
                    obj = value.Value;
                } else {
                    tdata = GetTypeDisplayData (ctx, type);
                    tvalue = new EvaluationResult ("null");
                }

                tname = GetDisplayTypeName (typeName);
            } else {
                tdata = GetTypeDisplayData (ctx, type);

                if (!string.IsNullOrEmpty (tdata.TypeDisplayString) && ctx.Options.AllowDisplayStringEvaluation)
                    tname = EvaluateDisplayString (ctx, obj, tdata.TypeDisplayString);
                else
                    tname = GetDisplayTypeName (typeName);
            }

            if (tvalue == null) {
                if (!string.IsNullOrEmpty (tdata.ValueDisplayString) && ctx.Options.AllowDisplayStringEvaluation)
                    tvalue = new EvaluationResult (EvaluateDisplayString (ctx, obj, tdata.ValueDisplayString));
                else
                    tvalue = ctx.Evaluator.TargetObjectToExpression (ctx, obj);
            }

            ObjectValue oval = ObjectValue.CreateObject (source, path, tname, tvalue, flags, null);
            if (!string.IsNullOrEmpty (tdata.NameDisplayString) && ctx.Options.AllowDisplayStringEvaluation)
                oval.Name = EvaluateDisplayString (ctx, obj, tdata.NameDisplayString);

            return oval;
        }
		ObjectValue EvaluatePrimitive (byte[] rawBytes, int start, PrimitiveType t, ObjectValueFlags flags, ObjectPath path)
		{
			var evalResult = new EvaluationResult (DGdbTools.GetValueFunction (t.TypeToken)
			                                      (rawBytes, start, DisplayAsHex));
			return ObjectValue.CreatePrimitive (ValueSource, path, t.ToCode (), evalResult, flags);
		}