Пример #1
0
        public static string CreateString(this IProcessData process, int verbosity = DefaultVerbosity)
        {
            var processes = process.Enumerate(new HashSet <IProcessData>()).ToList();
            var tags      = process.Data.Where(t => (t.Verbosity <= verbosity)).ToList();

            var cache = processes
                        .Select((p, k) => new { Key = (IProcessRange)p, Value = new ProcessInterval(k, k + 1) })
                        .ToDictionary(x => x.Key, x => x.Value);
            var range = tags.ToDictionary(tag => tag, tag => tag.Range(cache));

            tags = (from tag in tags
                    where range[tag].NonEmpty()
                    orderby range[tag].Max descending
                    select tag)
                   .ToList();

            var ranges = new List <ProcessInterval>();
            var depth  = tags.ToDictionary(
                tag => tag,
                tag => (ranges = ranges
                                 .Where(r => r.Min <= range[tag].Min)
                                 .Concat(new[] { range[tag] })
                                 .ToList())
                .Count() - 1);

            tags.Reverse();

            return(string.Join("\n",
                               from tag in tags
                               select String.Concat(Enumerable.Repeat("    ", depth[tag])) + tag.Label));
        }