Exemple #1
0
        public void Calculate(Dependency dependency)
        {
            if (dependency.Children.Count == 0 && dependency.Parent != null)
            {
                var levels = CalculateUsage.Levels(dependency.Parent);

                var counts = new int[levels.Count];
                var walker = this.Count(this.root, dependency, levels, counts);
                this.Usages[dependency] = counts;

                var max = counts[levels.Count - 1];
                for (int i = 0; i < levels.Count; ++i)
                {
                    if (counts[i] == max)
                    {
                        if (!this.Interfaces.ContainsKey(levels[i]))
                        {
                            this.Interfaces[levels[i]] = new List <Dependency>();
                        }

                        this.Interfaces[levels[i]].Add(dependency);
                        break;
                    }
                }
            }

            foreach (var child in dependency.Children)
            {
                this.Calculate(child);
            }
        }
Exemple #2
0
        private void UsageTable(Dependency branch, Dictionary <Dependency, int> mapping, bool visibleHeader, int section)
        {
            var leaves = new List <Dependency>();

            foreach (var child in branch.Children)
            {
                if (child.Children.Count != 0)
                {
                    continue;
                }

                leaves.Add(child);
            }

            if (leaves.Count == 0)
            {
                return;
            }

            this.WriteLine(string.Format(this.SubsectionBegin, "Usage" + section, "Usage"));

            var levels = CalculateUsage.Levels(branch);

            this.Write(string.Format(this.TableBegin, string.Empty));
            this.Write(this.TableHeadBegin);
            this.Write(string.Format(this.TableRowBegin, " id=\"main\"", string.Empty));
            this.file.Write(string.Format(this.TableHeadItem, " id=\"main\"", " rowspan=\"2\" title=\"Leaf of this node\"", "Dependency"));
            this.file.Write(string.Format(this.TableHeadItem, " id=\"main\"", string.Format(" colspan=\"{0}\" title=\"Number of times leaf is referenced beneath or blank if the maximum has been reached\"", levels.Count), "Sum at this level"));
            if (visibleHeader)
            {
                for (int i = 1; i < levels.Count; ++i)
                {
                    this.file.Write(string.Format(this.TableHeadItem, string.Empty, string.Empty, string.Empty));
                }
            }

            this.file.Write(this.TableRowEnd);
            this.TableHeadRowDiv(levels.Count + 1);
            this.Write(string.Format(this.TableRowBegin, " id=\"main\"", string.Empty));
            if (visibleHeader)
            {
                this.file.Write(string.Format(this.TableHeadItem, string.Empty, string.Empty, string.Empty));
            }

            foreach (var item in levels)
            {
                var name = item.Name;
                if (item.Parent == null)
                {
                    name = "Top Level";
                }

                var index = mapping[item];
                this.file.Write(string.Format(this.TableHeadItem, " id=\"main\"", " title=\"Number of times leaf is referenced beneath or blank if the maximum has been reached\"", string.Format(this.Link, index, name)));
            }

            this.file.Write(this.TableRowEnd);
            this.Write(this.TableHeadEnd);
            this.Write(this.TableBodyBegin);
            foreach (var leaf in leaves.OrderBy(o => o.Name))
            {
                this.Write(string.Format(this.TableRowBegin, string.Empty, string.Empty));
                this.file.Write(string.Format(this.TableBodyItem, " id=\"main\"", leaf.Name));
                var counts = this.assembled.Usages[leaf];
                var max    = counts[levels.Count - 1];
                var found  = false;
                foreach (var count in counts)
                {
                    if (found)
                    {
                        this.file.Write(string.Format(this.TableBodyItem, " id=\"main\"", string.Empty));
                    }
                    else
                    {
                        found = count == max;
                        this.file.Write(string.Format(this.TableBodyItem, " id=\"main\"", count));
                    }
                }

                this.file.Write(this.TableRowEnd);
            }

            this.Write(this.TableBodyEnd);
            this.Write(this.TableEnd);
            this.file.Write(this.ParagraphBegin);
            this.WriteLine(string.Empty);
            this.file.Write(this.ParagraphEnd);

            this.file.Write(this.SubsectionEnd);
        }
Exemple #3
0
        public void Usage(Dependency root)
        {
            var usages = new CalculateUsage(root, this.Usages, this.Interfaces);

            usages.Calculate(root);
        }