Пример #1
0
        IEnumerable <AbstractNode> GetChildNodes()
        {
            PropertyInfo countProperty = iListType.GetInterface(typeof(ICollection).FullName).GetProperty("Count");
            Expression   countExpr     = targetObject.AppendPropertyReference(countProperty);
            int          count         = 0;

            try {
                // Do not get string representation since it can be printed in hex
                Value countValue = countExpr.Evaluate(WindowsDebugger.DebuggedProcess.SelectedStackFrame);
                count = (int)countValue.PrimitiveValue;
            } catch (GetValueException) {
                count = -1;
            }
            if (count == -1)
            {
                yield return(ValueNode.Create(countExpr));

                yield break;
            }

            for (int i = 0; i < count; i++)
            {
                PropertyInfo itemProperty = iListType.GetProperty("Item");
                Expression   itemExpr     = targetObject.AppendMemberReference(itemProperty, new PrimitiveExpression(i));
                yield return(ValueNode.Create(itemExpr));
            }
        }
        public static IEnumerable <AbstractNode> GetChildNodesOfObject(Expression targetObject, DebugType shownType)
        {
            BindingFlags Flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Field | BindingFlags.GetProperty;

            if (shownType.BaseType != null)
            {
                yield return(new BaseClassNode(targetObject, shownType.BaseType));
            }
            if (shownType.HasMembers(NonPublicInstanceMembersNode.Flags))
            {
                yield return(new NonPublicInstanceMembersNode(targetObject, shownType));
            }
            if (shownType.HasMembers(StaticMembersNode.Flags) ||
                shownType.HasMembers(NonPublicStaticMembersNode.Flags))
            {
                yield return(new StaticMembersNode(targetObject, shownType));
            }
            DebugType iListType = shownType.GetInterface(typeof(IList).FullName);

            if (iListType != null)
            {
                yield return(new IListNode(targetObject, iListType));
            }
            foreach (Expression childExpr in targetObject.AppendObjectMembers(shownType, Flags))
            {
                yield return(ValueNode.Create(childExpr));
            }
        }
        public static IEnumerable <TreeNode> LazyGetChildNodesOfObject(TreeNode current, Expression targetObject, DebugType shownType)
        {
            MemberInfo[] publicStatic      = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly);
            MemberInfo[] publicInstance    = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
            MemberInfo[] nonPublicStatic   = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly);
            MemberInfo[] nonPublicInstance = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);

            DebugType baseType = (DebugType)shownType.BaseType;

            if (baseType != null)
            {
                yield return(new TreeNode(
                                 DebuggerResourceService.GetImage("Icons.16x16.Class"),
                                 StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.BaseClass}"),
                                 baseType.Name,
                                 baseType.FullName,
                                 current,
                                 newNode => baseType.FullName == "System.Object" ? null : Utils.LazyGetChildNodesOfObject(newNode, targetObject, baseType)
                                 ));
            }

            if (nonPublicInstance.Length > 0)
            {
                yield return(new TreeNode(
                                 null,
                                 StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.NonPublicMembers}"),
                                 string.Empty,
                                 string.Empty,
                                 current,
                                 newNode => Utils.LazyGetMembersOfObject(newNode, targetObject, nonPublicInstance)
                                 ));
            }

            if (publicStatic.Length > 0 || nonPublicStatic.Length > 0)
            {
                yield return(new TreeNode(
                                 null,
                                 StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.StaticMembers}"),
                                 string.Empty,
                                 string.Empty,
                                 current,
                                 p => {
                    var children = Utils.LazyGetMembersOfObject(p, targetObject, publicStatic);
                    if (nonPublicStatic.Length > 0)
                    {
                        TreeNode nonPublicStaticNode = new TreeNode(
                            null,
                            StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.NonPublicStaticMembers}"),
                            string.Empty,
                            string.Empty,
                            p,
                            newNode => Utils.LazyGetMembersOfObject(newNode, targetObject, nonPublicStatic)
                            );
                        children = Utils.PrependNode(nonPublicStaticNode, children);
                    }
                    return children;
                }
                                 ));
            }

            DebugType iListType = (DebugType)shownType.GetInterface(typeof(IList).FullName);

            if (iListType != null)
            {
                yield return(new IListNode(current, targetObject));
            }
            else
            {
                DebugType iEnumerableType, itemType;
                if (shownType.ResolveIEnumerableImplementation(out iEnumerableType, out itemType))
                {
                    yield return(new IEnumerableNode(current, targetObject, itemType));
                }
            }

            foreach (TreeNode node in LazyGetMembersOfObject(current, targetObject, publicInstance))
            {
                yield return(node);
            }
        }
Пример #4
0
		public static IEnumerable<TreeNode> LazyGetChildNodesOfObject(Expression targetObject, DebugType shownType)
		{
			MemberInfo[] publicStatic      = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.Public    | BindingFlags.Static   | BindingFlags.DeclaredOnly);
			MemberInfo[] publicInstance    = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.Public    | BindingFlags.Instance | BindingFlags.DeclaredOnly);
			MemberInfo[] nonPublicStatic   = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.NonPublic | BindingFlags.Static   | BindingFlags.DeclaredOnly);
			MemberInfo[] nonPublicInstance = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
			
			DebugType baseType = (DebugType)shownType.BaseType;
			if (baseType != null) {
				yield return new TreeNode(
					ImageService.GetImage("Icons.16x16.Class"),
					"BaseClass",
					baseType.Name,
					baseType.FullName,
					baseType.FullName == "System.Object" ? null : Utils.LazyGetChildNodesOfObject(targetObject, baseType)
				);
			}
			
			if (nonPublicInstance.Length > 0) {
				yield return new TreeNode(
					null,
					"NonPublicMembers",
					string.Empty,
					string.Empty,
					Utils.LazyGetMembersOfObject(targetObject, nonPublicInstance)
				);
			}
			
			if (publicStatic.Length > 0 || nonPublicStatic.Length > 0) {
				IEnumerable<TreeNode> childs = Utils.LazyGetMembersOfObject(targetObject, publicStatic);
				if (nonPublicStatic.Length > 0) {
					TreeNode nonPublicStaticNode = new TreeNode(
						null,
						"NonPublicStaticMembers",
						string.Empty,
						string.Empty,
						Utils.LazyGetMembersOfObject(targetObject, nonPublicStatic)
					);
					childs = Utils.PrependNode(nonPublicStaticNode, childs);
				}
				yield return new TreeNode(
					null,
					"StaticMembers",
					string.Empty,
					string.Empty,
					childs
				);
			}
			
			DebugType iListType = (DebugType)shownType.GetInterface(typeof(IList).FullName);
			if (iListType != null) {
				yield return new IListNode(targetObject);
			} else {
				DebugType iEnumerableType, itemType;
				if (shownType.ResolveIEnumerableImplementation(out iEnumerableType, out itemType)) {
					yield return new IEnumerableNode(targetObject, itemType);
				}
			}
			
			foreach(TreeNode node in LazyGetMembersOfObject(targetObject, publicInstance)) {
				yield return node;
			}
		}
Пример #5
0
        public static IEnumerable <TreeNode> LazyGetChildNodesOfObject(Expression targetObject, DebugType shownType)
        {
            MemberInfo[] publicStatic      = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly);
            MemberInfo[] publicInstance    = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
            MemberInfo[] nonPublicStatic   = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly);
            MemberInfo[] nonPublicInstance = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);

            DebugType baseType = (DebugType)shownType.BaseType;

            if (baseType != null)
            {
                yield return(new TreeNode(
                                 ImageCache.GetIcon(TypeIcon.Class, BackgroundType.DebuggerToolTip),
                                 "BaseClass",
                                 baseType.Name,
                                 baseType.FullName,
                                 baseType.FullName == "System.Object" ? null : Utils.LazyGetChildNodesOfObject(targetObject, baseType)
                                 ));
            }

            if (nonPublicInstance.Length > 0)
            {
                yield return(new TreeNode(
                                 null,
                                 "NonPublicMembers",
                                 string.Empty,
                                 string.Empty,
                                 Utils.LazyGetMembersOfObject(targetObject, nonPublicInstance)
                                 ));
            }

            if (publicStatic.Length > 0 || nonPublicStatic.Length > 0)
            {
                IEnumerable <TreeNode> childs = Utils.LazyGetMembersOfObject(targetObject, publicStatic);
                if (nonPublicStatic.Length > 0)
                {
                    TreeNode nonPublicStaticNode = new TreeNode(
                        null,
                        "NonPublicStaticMembers",
                        string.Empty,
                        string.Empty,
                        Utils.LazyGetMembersOfObject(targetObject, nonPublicStatic)
                        );
                    childs = Utils.PrependNode(nonPublicStaticNode, childs);
                }
                yield return(new TreeNode(
                                 null,
                                 "StaticMembers",
                                 string.Empty,
                                 string.Empty,
                                 childs
                                 ));
            }

            DebugType iListType = (DebugType)shownType.GetInterface(typeof(IList).FullName);

            if (iListType != null)
            {
                yield return(new IListNode(targetObject));
            }
            else
            {
                DebugType iEnumerableType, itemType;
                if (shownType.ResolveIEnumerableImplementation(out iEnumerableType, out itemType))
                {
                    yield return(new IEnumerableNode(targetObject, itemType));
                }
            }

            foreach (TreeNode node in LazyGetMembersOfObject(targetObject, publicInstance))
            {
                yield return(node);
            }
        }
        public static IEnumerable <TreeNode> LazyGetChildNodesOfObject(Expression targetObject, DebugType shownType)
        {
            MemberInfo[] publicStatic      = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly);
            MemberInfo[] publicInstance    = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
            MemberInfo[] nonPublicStatic   = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly);
            MemberInfo[] nonPublicInstance = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);

            DebugType baseType = (DebugType)shownType.BaseType;

            if (baseType != null)
            {
                if (Variables.Langue == "en")
                {
                    yield return(new TreeNode(
                                     Properties.Resources._namespace,
                                     StringParser.Parse(VelerSoftware.SZC.Properties.Resources.MainWindow_Windows_Debug_LocalVariables_BaseClass_EN),
                                     baseType.Name,
                                     baseType.FullName,
                                     baseType.FullName == "System.Object" ? null : Utils.LazyGetChildNodesOfObject(targetObject, baseType)
                                     ));
                }
                else
                {
                    yield return(new TreeNode(
                                     Properties.Resources._namespace,
                                     StringParser.Parse(VelerSoftware.SZC.Properties.Resources.MainWindow_Windows_Debug_LocalVariables_BaseClass),
                                     baseType.Name,
                                     baseType.FullName,
                                     baseType.FullName == "System.Object" ? null : Utils.LazyGetChildNodesOfObject(targetObject, baseType)
                                     ));
                }
            }

            // if (nonPublicInstance.Length > 0) {
            //     if (Variables.Langue == "en")
            //     {
            //         yield return new TreeNode(
            //             null,
            //             StringParser.Parse(VelerSoftware.SZC.Properties.Resources.MainWindow_Windows_Debug_LocalVariables_NonPublicMembers_EN),
            //             string.Empty,
            //             string.Empty,
            //             Utils.LazyGetMembersOfObject(targetObject, nonPublicInstance)
            //         );
            //     }
            //     else
            //     {
            //         yield return new TreeNode(
            //             null,
            //             StringParser.Parse(VelerSoftware.SZC.Properties.Resources.MainWindow_Windows_Debug_LocalVariables_NonPublicMembers),
            //             string.Empty,
            //             string.Empty,
            //             Utils.LazyGetMembersOfObject(targetObject, nonPublicInstance)
            //         );
            //     }
            // }
            //
            // if (publicStatic.Length > 0 || nonPublicStatic.Length > 0) {
            //  IEnumerable<TreeNode> childs = Utils.LazyGetMembersOfObject(targetObject, publicStatic);
            //  if (nonPublicStatic.Length > 0) {
            //         if (Variables.Langue == "en")
            //         {
            //             TreeNode nonPublicStaticNode = new TreeNode(
            //                 null,
            //                 StringParser.Parse(VelerSoftware.SZC.Properties.Resources.MainWindow_Windows_Debug_LocalVariables_NonPublicStaticMembers_EN),
            //                 string.Empty,
            //                 string.Empty,
            //                 Utils.LazyGetMembersOfObject(targetObject, nonPublicStatic)
            //             );
            //             childs = Utils.PrependNode(nonPublicStaticNode, childs);
            //         }
            //         else
            //         {
            //             TreeNode nonPublicStaticNode = new TreeNode(
            //                 null,
            //                 StringParser.Parse(VelerSoftware.SZC.Properties.Resources.MainWindow_Windows_Debug_LocalVariables_NonPublicStaticMembers),
            //                 string.Empty,
            //                 string.Empty,
            //                 Utils.LazyGetMembersOfObject(targetObject, nonPublicStatic)
            //             );
            //             childs = Utils.PrependNode(nonPublicStaticNode, childs);
            //         }
            //  }
            //     if (Variables.Langue == "en")
            //     {
            //         yield return new TreeNode(
            //             null,
            //             StringParser.Parse(VelerSoftware.SZC.Properties.Resources.MainWindow_Windows_Debug_LocalVariables_StaticMembers_EN),
            //             string.Empty,
            //             string.Empty,
            //             childs
            //         );
            //     }
            //     else
            //     {
            //         yield return new TreeNode(
            //             null,
            //             StringParser.Parse(VelerSoftware.SZC.Properties.Resources.MainWindow_Windows_Debug_LocalVariables_StaticMembers),
            //             string.Empty,
            //             string.Empty,
            //             childs
            //         );
            //     }
            // }

            DebugType iListType = (DebugType)shownType.GetInterface(typeof(IList).FullName);

            if (iListType != null)
            {
                yield return(new IListNode(targetObject));
            }
            else
            {
                DebugType iEnumerableType, itemType;
                if (shownType.ResolveIEnumerableImplementation(out iEnumerableType, out itemType))
                {
                    yield return(new IEnumerableNode(targetObject, itemType));
                }
            }

            foreach (TreeNode node in LazyGetMembersOfObject(targetObject, publicInstance))
            {
                yield return(node);
            }
        }