Ejemplo n.º 1
0
        public virtual IEnumerable <EnumMember> GetEnumMembers(EvaluationContext ctx, object type)
        {
            object             longType = GetType(ctx, "System.Int64");
            TypeValueReference tref     = new TypeValueReference(ctx, type);

            foreach (ValueReference cr in tref.GetChildReferences(ctx.Options))
            {
                object c = TryCast(ctx, cr.Value, longType);
                if (c == null)
                {
                    continue;
                }
                long       val = (long)TargetObjectToObject(ctx, c);
                EnumMember em  = new EnumMember()
                {
                    Name = cr.Name, Value = val
                };
                yield return(em);
            }
        }
Ejemplo n.º 2
0
		public virtual IEnumerable<EnumMember> GetEnumMembers (EvaluationContext ctx, object type)
		{
			object longType = GetType (ctx, "System.Int64");
			TypeValueReference tref = new TypeValueReference (ctx, type);
			foreach (ValueReference cr in tref.GetChildReferences (ctx.Options)) {
				object c = TryCast (ctx, cr.Value, longType);
				if (c == null)
					continue;
				long val = (long) TargetObjectToObject (ctx, c);
				EnumMember em = new EnumMember () { Name = cr.Name, Value = val };
				yield return em;
			}
		}
		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;
				
				ObjectValueNameTracker names = new ObjectValueNameTracker (ctx);
				
				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);
					names.FixName (val, oval);
					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];
			}
		}
        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]);
            }
        }
		public override ObjectValue[] GetChildren (ObjectPath path, int index, int count, EvaluationOptions options)
		{
			var ctx = GetContext (options);

			try {
				BindingFlags flattenFlag = options.FlattenHierarchy ? (BindingFlags)0 : BindingFlags.DeclaredOnly;
				BindingFlags flags = BindingFlags.Static | BindingFlags.Public | flattenFlag;
				bool groupPrivateMembers = options.GroupPrivateMembers || ctx.Adapter.IsExternalType (ctx, type);
				var list = new List<ObjectValue> ();

				if (!groupPrivateMembers)
					flags |= BindingFlags.NonPublic;
				
				var tdata = ctx.Adapter.GetTypeDisplayData (ctx, type);
				var tdataType = type;

				foreach (var val in ctx.Adapter.GetMembersSorted (ctx, this, type, null, flags)) {
					var decType = val.DeclaringType;
					if (decType != null && decType != tdataType) {
						tdataType = decType;
						tdata = ctx.Adapter.GetTypeDisplayData (ctx, decType);
					}

					var state = tdata.GetMemberBrowsableState (val.Name);
					if (state == DebuggerBrowsableState.Never)
						continue;

					var oval = val.CreateObjectValue (options);
					list.Add (oval);
				}
				
				var nestedTypes = new List<ObjectValue> ();
				foreach (var nestedType in ctx.Adapter.GetNestedTypes (ctx, type))
					nestedTypes.Add (new TypeValueReference (ctx, nestedType).CreateObjectValue (options));
				
				nestedTypes.Sort ((v1, v2) => string.Compare (v1.Name, v2.Name, StringComparison.CurrentCulture));
				
				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) {
						var baseRef = new TypeValueReference (ctx, baseType);
						var baseVal = baseRef.CreateObjectValue (false);
						baseVal.Name = "base";
						list.Insert (0, baseVal);
					}
				}
				
				return list.ToArray ();
			} catch (Exception ex) {
				ctx.WriteDebuggerOutput (ex.Message);
				return new ObjectValue [0];
			}
		}
        public override ObjectValue[] GetChildren(ObjectPath path, int index, int count, EvaluationOptions options)
        {
            var ctx = GetContext(options);

            try {
                BindingFlags flattenFlag         = options.FlattenHierarchy ? (BindingFlags)0 : BindingFlags.DeclaredOnly;
                BindingFlags flags               = BindingFlags.Static | BindingFlags.Public | flattenFlag;
                bool         groupPrivateMembers = options.GroupPrivateMembers || ctx.Adapter.IsExternalType(ctx, type);
                var          list = new List <ObjectValue> ();

                if (!groupPrivateMembers)
                {
                    flags |= BindingFlags.NonPublic;
                }

                var tdata     = ctx.Adapter.GetTypeDisplayData(ctx, type);
                var tdataType = type;

                foreach (var val in ctx.Adapter.GetMembersSorted(ctx, this, type, null, flags))
                {
                    var decType = val.DeclaringType;
                    if (decType != null && decType != tdataType)
                    {
                        tdataType = decType;
                        tdata     = ctx.Adapter.GetTypeDisplayData(ctx, decType);
                    }

                    var state = tdata.GetMemberBrowsableState(val.Name);
                    if (state == DebuggerBrowsableState.Never)
                    {
                        continue;
                    }

                    var oval = val.CreateObjectValue(options);
                    list.Add(oval);
                }

                var nestedTypes = new List <ObjectValue> ();
                foreach (var nestedType in ctx.Adapter.GetNestedTypes(ctx, type))
                {
                    nestedTypes.Add(new TypeValueReference(ctx, nestedType).CreateObjectValue(options));
                }

                nestedTypes.Sort((v1, v2) => string.Compare(v1.Name, v2.Name, StringComparison.CurrentCulture));

                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)
                    {
                        var baseRef = new TypeValueReference(ctx, baseType);
                        var baseVal = baseRef.CreateObjectValue(false);
                        baseVal.Name = "base";
                        list.Insert(0, baseVal);
                    }
                }

                return(list.ToArray());
            } catch (Exception ex) {
                ctx.WriteDebuggerOutput(ex.Message);
                return(new ObjectValue [0]);
            }
        }