/*public ObjectDumpNode(string text)
    {
      Name = text;
      IsVisible = true;
    }*/

    /*public ObjectDumpNode(string text, object target)
    {
      Name = text;
      //Target = target;
      IsVisible = true;
    }*/

    public ObjectDumpNode(string text, ObjectDumpNode parent = null)
    {
      Name = text;
      //Target = target;
      Parent = parent;
      IsVisible = true;
    }
Exemple #2
0
        /*public ObjectDumpNode(string text)
         * {
         * Name = text;
         * IsVisible = true;
         * }*/

        /*public ObjectDumpNode(string text, object target)
         * {
         * Name = text;
         * //Target = target;
         * IsVisible = true;
         * }*/

        public ObjectDumpNode(string text, ObjectDumpNode parent = null)
        {
            Name = text;
            //Target = target;
            Parent    = parent;
            IsVisible = true;
        }
        public ObjectDumpNode GetDumpTree()
        {
            Type type = Target.GetType();
            var tree = new ObjectDumpNode(type.Name);

            foreach (var node in InternalDump(Target, tree))
            {
                tree.Childrens.Add(node);
            }

            return tree;
        }
        public ObjectDumpNode GetDumpTree()
        {
            Type type = Target.GetType();
            var  tree = new ObjectDumpNode(type.Name);

            foreach (var node in InternalDump(Target, tree))
            {
                tree.Childrens.Add(node);
            }

            return(tree);
        }
Exemple #5
0
        private void OnMesssageDispatched(MessageDispatcher dispatcher, Message message)
        {
            if (IsPaused && !OnTheFly)
            {
                return;
            }

            var            dumper = new TreeDumper(message);
            ObjectDumpNode tree   = dumper.GetDumpTree();

            NetworkMessage networkMessage = message as NetworkMessage;

            if (networkMessage != null)
            {
                tree.TimeStamp = DateTime.Now;
                tree.Id        = networkMessage.MessageId;
                tree.From      = networkMessage.From;

                foreach (ObjectDumpNode child in tree.Childrens)
                {
                    if (m_seeProperties)
                    {
                        child.IsVisible = true;
                    }
                    else if (child.IsProperty)
                    {
                        child.IsVisible = false;
                    }
                }

                if (!IsPaused)
                {
                    m_messages.Add(tree);

                    #region Cleaning : avoid memory overflow on a long run
                    if (NbMessagesToKeep > 0 && m_messages.Count > NbMessagesToKeep)
                    {
                        m_messages.RemoveAt(0);
                    }
                    #endregion Cleaning : avoid memory overflow on a long run
                }
                #region Record On the fly
                if (OnTheFly)
                {
                    FlushOnTheFly(tree.ExportToString(true));
                }
                #endregion Record On the fly
            }
            else
            if (OnTheFly)
            {
                if (message is InformationMessage)
                {
                    #region Record On the fly
                    if (OnTheFly)
                    {
                        FlushOnTheFly((message as InformationMessage).Message + "\n");
                    }
                    #endregion Record On the fly
                }
            }
        }
        public IEnumerable<ObjectDumpNode> InternalDump(object obj, ObjectDumpNode parent)
        {
            if (obj == null || obj is ValueType || obj is string)
            {
                yield return new ObjectDumpNode(FormatValue(obj), parent);
                yield break;
            }

            var enumerableElement = obj as IEnumerable;
            if (enumerableElement != null)
            {
                int count = 0;
                foreach (object item in enumerableElement)
                {
                    count++;
                    if (item == null || item is ValueType || item is string)
                    {
                        yield return new ObjectDumpNode(FormatValue(item), parent);
                    }
                    else
                    {
                        var node = new ObjectDumpNode(item.GetType().Name, parent);
                        foreach (var child in InternalDump(item, node))
                        {
                            node.Childrens.Add(child);
                        }
                        yield return node;
                    }
                }


                if (count == 0)
                {
                    yield return new ObjectDumpNode("-Empty-", parent);
                    yield break;
                }
            }
            else
            {

                Type type = obj.GetType();

                PropertyInfo[] properties = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);

                foreach (PropertyInfo property in properties)
                {
                    object value = property.GetValue(obj, new object[0]);

                    if (value is MulticastDelegate)
                        continue;

                    var node = new ObjectDumpNode(property.Name, parent);
                    foreach (var child in InternalDump(value, node))
                    {
                        node.Childrens.Add(child);
                    } 
                    node.IsProperty = true;
                    yield return node;
                }

                FieldInfo[] fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);

                foreach (FieldInfo field in fields)
                {
                    object value = field.GetValue(obj);

                    if (value is MulticastDelegate)
                        continue;

                    var node = new ObjectDumpNode(field.Name, parent);
                    foreach (var child in InternalDump(value, node))
                    {
                        node.Childrens.Add(child);
                    } 
                    yield return node;
                }
            }
        }
        public IEnumerable <ObjectDumpNode> InternalDump(object obj, ObjectDumpNode parent)
        {
            if (obj == null || obj is ValueType || obj is string)
            {
                yield return(new ObjectDumpNode(FormatValue(obj), parent));

                yield break;
            }

            var enumerableElement = obj as IEnumerable;

            if (enumerableElement != null)
            {
                int count = 0;
                foreach (object item in enumerableElement)
                {
                    count++;
                    if (item == null || item is ValueType || item is string)
                    {
                        yield return(new ObjectDumpNode(FormatValue(item), parent));
                    }
                    else
                    {
                        var node = new ObjectDumpNode(item.GetType().Name, parent);
                        foreach (var child in InternalDump(item, node))
                        {
                            node.Childrens.Add(child);
                        }
                        yield return(node);
                    }
                }


                if (count == 0)
                {
                    yield return(new ObjectDumpNode("-Empty-", parent));

                    yield break;
                }
            }
            else
            {
                Type type = obj.GetType();

                PropertyInfo[] properties = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);

                foreach (PropertyInfo property in properties)
                {
                    object value = property.GetValue(obj, new object[0]);

                    if (value is MulticastDelegate)
                    {
                        continue;
                    }

                    var node = new ObjectDumpNode(property.Name, parent);
                    foreach (var child in InternalDump(value, node))
                    {
                        node.Childrens.Add(child);
                    }
                    node.IsProperty = true;
                    yield return(node);
                }

                FieldInfo[] fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);

                foreach (FieldInfo field in fields)
                {
                    object value = field.GetValue(obj);

                    if (value is MulticastDelegate)
                    {
                        continue;
                    }

                    var node = new ObjectDumpNode(field.Name, parent);
                    foreach (var child in InternalDump(value, node))
                    {
                        node.Childrens.Add(child);
                    }
                    yield return(node);
                }
            }
        }