public PacketTreeViewItem(PacketTreeViewItem parent, string property)
 {
     Parent   = parent;
     Property = property;
 }
        private void BuildObjectTree(PacketTreeViewItem parent, object obj, string name, bool expand = false, bool isPath = true)
        {
            PacketTreeViewItem tvi = null;

            if (obj == null)
            {
                tvi = new PropertyValueTreeViewItem(parent, name, "null", isPath);
            }
            else if (obj is string)
            {
                tvi = new PropertyValueTreeViewItem(parent, name, EscapeString(obj as string), isPath);
            }
            else if (obj.GetType().IsArray)
            {
                object[] arr = obj as object[];
                tvi = new PropertyObjectTreeViewItem(parent, name, "Array" + '[' + arr.Length.ToString() + "]", isPath);
                for (int i = 0; i < arr.Length; i++)
                {
                    BuildObjectTree(tvi, arr[i], '[' + i.ToString() + ']');
                }
            }
            else if (obj is ArrayCollection)
            {
                ArrayCollection col = obj as ArrayCollection;
                tvi = new PropertyObjectTreeViewItem(parent, name, "ArrayCollection" + '[' + col.Count.ToString() + "]", isPath);
                for (int i = 0; i < col.Count; i++)
                {
                    BuildObjectTree(tvi, col[i], '[' + i.ToString() + ']');
                }
            }
            else if (obj is ArrayList)
            {
                ArrayList col = obj as ArrayList;
                tvi = new PropertyObjectTreeViewItem(parent, name, "Array" + '[' + col.Count.ToString() + "]", isPath);
                for (int i = 0; i < col.Count; i++)
                {
                    BuildObjectTree(tvi, col[i], '[' + i.ToString() + ']');
                }
            }
            else if (obj is IDictionary <string, object> )
            {
                IDictionary <string, object> dict = obj as IDictionary <string, object>;
                if (obj is AsObject)
                {
                    tvi = new PropertyObjectTreeViewItem(parent, name, (obj as AsObject).TypeName, isPath);
                }
                else
                {
                    tvi = new PropertyObjectTreeViewItem(parent, name, RiotSerializationContext.Instance.GetAlias(obj.GetType().GetGenericTypeDefinition().FullName), isPath);
                }
                foreach (var kv in dict)
                {
                    BuildObjectTree(tvi, kv.Value, kv.Key);
                }
            }
            else if (obj is DateTime)
            {
                tvi = new PropertyValueTreeViewItem(parent, name, obj.ToString(), isPath);
            }
            else if (obj.GetType().Namespace == "System")
            {
                tvi = new PropertyValueTreeViewItem(parent, name, obj.ToString(), isPath);
            }
            else if (Attribute.IsDefined(obj.GetType(), typeof(SerializableAttribute)))
            {
                PropertyInfo[] pis = obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
                tvi = new PropertyObjectTreeViewItem(parent, name, RiotSerializationContext.Instance.GetAlias(obj.GetType().FullName), isPath);
                foreach (var prop in pis)
                {
                    if (prop.CanRead && prop.GetIndexParameters().Length == 0 && !Attribute.IsDefined(prop, typeof(HiddenAttribute)))
                    {
                        string pname = null;
                        SerializedNameAttribute[] attributes = (SerializedNameAttribute[])prop.GetCustomAttributes(typeof(SerializedNameAttribute), false);
                        if (attributes.Length == 1)
                        {
                            pname = attributes[0].SerializedName;
                        }
                        else if (attributes.Length > 0)
                        {
                            foreach (var a in attributes)
                            {
                                if (a.Canonical)
                                {
                                    pname = a.SerializedName;
                                }
                            }
                            if (pname == null)
                            {
                                pname = attributes[0].SerializedName;
                            }
                        }
                        else
                        {
                            pname = prop.Name;
                        }
                        BuildObjectTree(tvi, prop.GetValue(obj), pname);
                    }
                }
            }
            if (tvi != null)
            {
                parent.Items.Add(tvi);
                tvi.IsNodeExpanded = expand;
            }
        }