Exemplo n.º 1
0
 public RemoteRawValueArray(EvaluationContext ctx, IObjectSource source, ICollectionAdaptor targetArray, object targetObject)
 {
     this.ctx          = ctx;
     this.targetArray  = targetArray;
     this.targetObject = targetObject;
     this.source       = source;
     Connect();
 }
Exemplo n.º 2
0
 public ArrayElementGroup(EvaluationContext ctx, ICollectionAdaptor array, int[] baseIndices, int firstIndex, int lastIndex)
 {
     this.array       = array;
     this.ctx         = ctx;
     this.dimensions  = array.GetDimensions();
     this.baseIndices = baseIndices;
     this.firstIndex  = firstIndex;
     this.lastIndex   = lastIndex;
 }
Exemplo n.º 3
0
		public ArrayElementGroup (EvaluationContext ctx, ICollectionAdaptor array, int[] baseIndices, int firstIndex, int lastIndex)
		{
			this.array = array;
			this.ctx = ctx;
			this.bounds = array.GetDimensions ();
			this.baseIndices = baseIndices;
			this.firstIndex = firstIndex;
			this.lastIndex = lastIndex;
		}
Exemplo n.º 4
0
        public virtual object ToRawValue(EvaluationContext ctx, IObjectSource source, object obj)
        {
            if (IsEnum(ctx, obj))
            {
                object longType = GetType(ctx, "System.Int64");
                object c        = Cast(ctx, obj, longType);
                return(TargetObjectToObject(ctx, c));
            }
            if (IsPrimitive(ctx, obj))
            {
                return(TargetObjectToObject(ctx, obj));
            }

            if (IsArray(ctx, obj))
            {
                ICollectionAdaptor adaptor = CreateArrayAdaptor(ctx, obj);
                return(new RawValueArray(new RemoteRawValueArray(ctx, source, adaptor, obj)));
            }
            return(new RawValue(new RemoteRawValue(ctx, source, obj)));
        }
Exemplo n.º 5
0
        public virtual ObjectValue[] GetObjectValueChildren(EvaluationContext ctx, IObjectSource objectSource, object type, object obj, int firstItemIndex, int count, bool dereferenceProxy)
        {
            if (IsArray(ctx, obj))
            {
                ArrayElementGroup agroup = new ArrayElementGroup(ctx, CreateArrayAdaptor(ctx, obj));
                return(agroup.GetChildren(ctx.Options));
            }

            if (IsPrimitive(ctx, obj))
            {
                return(new ObjectValue[0]);
            }

            bool showRawView = false;

            // If there is a proxy, it has to show the members of the proxy
            object proxy = obj;

            if (dereferenceProxy)
            {
                proxy = GetProxyObject(ctx, obj);
                if (proxy != obj)
                {
                    type        = GetValueType(ctx, proxy);
                    showRawView = true;
                }
            }

            TypeDisplayData tdata = GetTypeDisplayData(ctx, type);
            bool            groupPrivateMembers = ctx.Options.GroupPrivateMembers && (ctx.Options.GroupUserPrivateMembers || IsExternalType(ctx, type));

            List <ObjectValue> values           = new List <ObjectValue> ();
            BindingFlags       flattenFlag      = ctx.Options.FlattenHierarchy ? (BindingFlags)0 : BindingFlags.DeclaredOnly;
            BindingFlags       nonNonPublicFlag = groupPrivateMembers || showRawView ? (BindingFlags)0 : BindingFlags.NonPublic;
            BindingFlags       staticFlag       = ctx.Options.GroupStaticMembers ? (BindingFlags)0 : BindingFlags.Static;
            BindingFlags       access           = BindingFlags.Public | BindingFlags.Instance | flattenFlag | nonNonPublicFlag | staticFlag;

            // Load all members to a list before creating the object values,
            // to avoid problems with objects being invalidated due to evaluations in the target,
            List <ValueReference> list = new List <ValueReference> ();

            list.AddRange(GetMembersSorted(ctx, objectSource, type, proxy, access));

            object tdataType = type;

            foreach (ValueReference val in list)
            {
                try {
                    object decType = val.DeclaringType;
                    if (decType != null && decType != tdataType)
                    {
                        tdataType = decType;
                        tdata     = GetTypeDisplayData(ctx, decType);
                    }
                    DebuggerBrowsableState state = tdata.GetMemberBrowsableState(val.Name);
                    if (state == DebuggerBrowsableState.Never)
                    {
                        continue;
                    }

                    if (state == DebuggerBrowsableState.RootHidden && dereferenceProxy)
                    {
                        object ob = val.Value;
                        if (ob != null)
                        {
                            values.Clear();
                            values.AddRange(GetObjectValueChildren(ctx, val, ob, -1, -1));
                            showRawView = true;
                            break;
                        }
                    }
                    else
                    {
                        ObjectValue oval = val.CreateObjectValue(true);
                        values.Add(oval);
                    }
                }
                catch (Exception ex) {
                    ctx.WriteDebuggerError(ex);
                    values.Add(ObjectValue.CreateError(null, new ObjectPath(val.Name), GetDisplayTypeName(GetTypeName(ctx, val.Type)), ex.Message, val.Flags));
                }
            }

            if (showRawView)
            {
                values.Add(RawViewSource.CreateRawView(ctx, objectSource, obj));
            }
            else
            {
                if (IsArray(ctx, proxy))
                {
                    ICollectionAdaptor col    = CreateArrayAdaptor(ctx, proxy);
                    ArrayElementGroup  agroup = new ArrayElementGroup(ctx, col);
                    ObjectValue        val    = ObjectValue.CreateObject(null, new ObjectPath("Raw View"), "", "", ObjectValueFlags.ReadOnly, values.ToArray());
                    values = new List <ObjectValue> ();
                    values.Add(val);
                    values.AddRange(agroup.GetChildren(ctx.Options));
                }
                else
                {
                    if (ctx.Options.GroupStaticMembers && HasMembers(ctx, type, proxy, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | flattenFlag))
                    {
                        access = BindingFlags.Static | BindingFlags.Public | flattenFlag | nonNonPublicFlag;
                        values.Add(FilteredMembersSource.CreateStaticsNode(ctx, objectSource, type, proxy, access));
                    }
                    if (groupPrivateMembers && HasMembers(ctx, type, proxy, BindingFlags.Instance | BindingFlags.NonPublic | flattenFlag | staticFlag))
                    {
                        values.Add(FilteredMembersSource.CreateNonPublicsNode(ctx, objectSource, type, proxy, BindingFlags.Instance | BindingFlags.NonPublic | flattenFlag | staticFlag));
                    }

                    if (!ctx.Options.FlattenHierarchy)
                    {
                        object baseType = GetBaseType(ctx, type, false);
                        if (baseType != null)
                        {
                            values.Insert(0, BaseTypeViewSource.CreateBaseTypeView(ctx, objectSource, baseType, proxy));
                        }
                    }
                }
            }
            return(values.ToArray());
        }
 public ArrayValueReference(EvaluationContext ctx, object arr, int[] indices) : base(ctx)
 {
     this.indices = indices;
     adaptor      = ctx.Adapter.CreateArrayAdaptor(ctx, arr);
 }
Exemplo n.º 7
0
 public ArrayElementGroup(EvaluationContext ctx, ICollectionAdaptor array, int[] baseIndices)
     : this(ctx, array, baseIndices, 0, -1)
 {
 }
Exemplo n.º 8
0
 public ArrayElementGroup(EvaluationContext ctx, ICollectionAdaptor array)
     : this(ctx, array, new int [0])
 {
 }
Exemplo n.º 9
0
 public ArrayObjectSource(ICollectionAdaptor source, int[] index)
 {
     this.source = source;
     this.path   = ArrayElementGroup.IndicesToString(index);
 }
Exemplo n.º 10
0
		public ArrayValueReference (EvaluationContext ctx, object arr, int[] indices) : base (ctx)
		{
			this.indices = indices;
			adaptor = ctx.Adapter.CreateArrayAdaptor (ctx, arr);
		}
Exemplo n.º 11
0
 public RemoteRawValueArray(EvaluationContext ctx, IObjectSource source, ICollectionAdaptor targetArray, object targetObject)
 {
     this.ctx = ctx;
     this.targetArray = targetArray;
     this.targetObject = targetObject;
     this.source = source;
     Connect ();
 }
Exemplo n.º 12
0
		public ArrayElementGroup (EvaluationContext ctx, ICollectionAdaptor array, int[] baseIndices)
			: this (ctx, array, baseIndices, 0, -1)
		{
		}
Exemplo n.º 13
0
		public ArrayElementGroup (EvaluationContext ctx, ICollectionAdaptor array)
			: this (ctx, array, new int [0])
		{
		}
Exemplo n.º 14
0
		public ArrayObjectSource (ICollectionAdaptor source, int[] index)
		{
			this.source = source;
			this.path = ArrayElementGroup.IndicesToString (index);
		}
Exemplo n.º 15
0
		public ArrayObjectSource (ICollectionAdaptor source, string path)
		{
			this.source = source;
			this.path = path;
		}
Exemplo n.º 16
0
 public virtual object TargetObjectToObject(EvaluationContext ctx, object obj)
 {
     if (IsNull(ctx, obj))
     {
         return(null);
     }
     else if (IsArray(ctx, obj))
     {
         ICollectionAdaptor adaptor = CreateArrayAdaptor(ctx, obj);
         string             ename   = GetDisplayTypeName(GetTypeName(ctx, adaptor.ElementType));
         int[]         dims         = adaptor.GetDimensions();
         StringBuilder tn           = new StringBuilder("[");
         for (int n = 0; n < dims.Length; n++)
         {
             if (n > 0)
             {
                 tn.Append(',');
             }
             tn.Append(dims[n]);
         }
         tn.Append("]");
         int i = ename.LastIndexOf('>');
         if (i == -1)
         {
             i = 0;
         }
         i = ename.IndexOf('[', i);
         if (i != -1)
         {
             return(new EvaluationResult("{" + ename.Substring(0, i) + tn + ename.Substring(i) + "}"));
         }
         else
         {
             return(new EvaluationResult("{" + ename + tn + "}"));
         }
     }
     else if (IsEnum(ctx, obj))
     {
         object type            = GetValueType(ctx, obj);
         object longType        = GetType(ctx, "System.Int64");
         object c               = Cast(ctx, obj, longType);
         long   val             = (long)TargetObjectToObject(ctx, c);
         long   rest            = val;
         string typeName        = GetTypeName(ctx, type);
         string composed        = string.Empty;
         string composedDisplay = string.Empty;
         foreach (EnumMember em in GetEnumMembers(ctx, type))
         {
             if (em.Value == val)
             {
                 return(new EvaluationResult(typeName + "." + em.Name, em.Name));
             }
             else
             {
                 if (em.Value != 0 && (rest & em.Value) == em.Value)
                 {
                     rest &= ~em.Value;
                     if (composed.Length > 0)
                     {
                         composed        += "|";
                         composedDisplay += "|";
                     }
                     composed        += typeName + "." + em.Name;
                     composedDisplay += em.Name;
                 }
             }
         }
         if (IsFlagsEnumType(ctx, type) && rest == 0 && composed.Length > 0)
         {
             return(new EvaluationResult(composed, composedDisplay));
         }
         else
         {
             return(new EvaluationResult(val.ToString()));
         }
     }
     else if (GetValueTypeName(ctx, obj) == "System.Decimal")
     {
         string res = CallToString(ctx, obj);
         // This returns the decimal formatted using the current culture. It has to be converted to invariant culture.
         decimal dec = decimal.Parse(res);
         res = dec.ToString(System.Globalization.CultureInfo.InvariantCulture);
         return(new EvaluationResult(res));
     }
     else if (IsClassInstance(ctx, obj))
     {
         TypeDisplayData tdata = GetTypeDisplayData(ctx, GetValueType(ctx, obj));
         if (!string.IsNullOrEmpty(tdata.ValueDisplayString) && ctx.Options.AllowDisplayStringEvaluation)
         {
             return(new EvaluationResult(EvaluateDisplayString(ctx, obj, tdata.ValueDisplayString)));
         }
         // Return the type name
         if (ctx.Options.AllowToStringCalls)
         {
             return(new EvaluationResult("{" + CallToString(ctx, obj) + "}"));
         }
         if (!string.IsNullOrEmpty(tdata.TypeDisplayString) && ctx.Options.AllowDisplayStringEvaluation)
         {
             return(new EvaluationResult("{" + EvaluateDisplayString(ctx, obj, tdata.TypeDisplayString) + "}"));
         }
         return(new EvaluationResult("{" + GetDisplayTypeName(GetValueTypeName(ctx, obj)) + "}"));
     }
     return(new EvaluationResult("{" + CallToString(ctx, obj) + "}"));
 }
Exemplo n.º 17
0
 public ArrayObjectSource(ICollectionAdaptor source, string path)
 {
     this.source = source;
     this.path   = path;
 }