private List CreateTree()

in Source/Tx.LinqPad/TxDataContextDriver.cs [239:278]


        private List<ExplorerItem> CreateTree(Dictionary<Type, long> stat)
        {
            var result = new List<ExplorerItem>();

            KeyValuePair<Type, long>[] x = (from pair in stat
                                            orderby pair.Key.Namespace, pair.Key.Name
                                            select pair).ToArray();

            string currentNamespace = null;
            ExplorerItem scope = null;
            foreach (var pair in x)
            {
                if (pair.Key.Namespace != currentNamespace)
                {
                    scope = CreateNamespace(pair.Key.Namespace, result);
                    currentNamespace = pair.Key.Namespace;
                }
                ;

                var eventType = new ExplorerItem(pair.Key.Name, ExplorerItemKind.QueryableObject, ExplorerIcon.Table);
                eventType.ToolTipText = "Occurences: " + pair.Value + "\n";
                foreach (object a in pair.Key.GetCustomAttributes(false).OrderBy(a => a.GetType().Name))
                {
                    eventType.ToolTipText += '\n' + a.ToString() + '\n';
                }

                eventType.DragText = "playback.GetObservable<" + pair.Key.FullName + ">()";
                eventType.Children = new List<ExplorerItem>();
                scope.Children.Add(eventType);

                foreach (PropertyInfo p in pair.Key.GetProperties())
                {
                    var field = new ExplorerItem(p.Name, ExplorerItemKind.Property, ExplorerIcon.Column);
                    eventType.Children.Add(field);
                    field.ToolTipText = p.PropertyType.Name;
                }
            }

            return result;
        }