Наследование: IDisposable
Пример #1
0
        private void WriteModuleGraph(
            ModuleGenerator completeModule,
            IDictionary <string, Binding> allBindings,
            string graphvizDirectory)
        {
            var safeModuleName = completeModule.ModuleType.FullName.Replace('/', '.');
            var fileName       = Path.Combine(graphvizDirectory, safeModuleName + ".dot");

            using (var fs = File.Open(fileName, FileMode.Create, FileAccess.Write))
                using (var dotWriter = new DotWriter(fs))
                {
                    new GraphWriter().Write(dotWriter, allBindings);
                }
        }
Пример #2
0
        public void Write(DotWriter dotWriter, IDictionary <string, Binding> allBindings)
        {
            var nameIndex = GetNodeNames(allBindings);
            var visited   = new HashSet <Binding>();
            var q         = new Queue <Tuple <Binding, string> >(nameIndex.Select(kvp => Tuple.Create(kvp.Key, kvp.Value)));

            dotWriter.BeginGraph("cluster", "true");

            while (q.Count > 0)
            {
                var current = q.Dequeue();

                if (visited.Contains(current.Item1))
                {
                    continue;
                }

                var binding      = current.Item1;
                var sourceName   = current.Item2;
                var dependencies = new HashSet <Binding>();
                binding.GetDependencies(dependencies, dependencies);

                foreach (var dependency in dependencies)
                {
                    string targetName;
                    if (nameIndex.TryGetValue(dependency, out targetName))
                    {
                        dotWriter.WriteEdge(sourceName, targetName);
                        q.Enqueue(Tuple.Create(dependency, targetName));
                    }
                    else if (binding is CompilerSetBinding)
                    {
                        var providesBinding = Unwrap(dependency);
                        var gen             = providesBinding.Generator;
                        var name            = gen.Key + " (" + gen.ProviderMethod.Name + ")";
                        dotWriter.WriteEdge(sourceName, name);
                        q.Enqueue(Tuple.Create(dependency, name));
                    }
                    else
                    {
                        dotWriter.WriteEdge(sourceName, "Unbound: " + dependency.ProviderKey);
                    }
                }

                visited.Add(binding);
            }

            dotWriter.EndGraph();
        }
Пример #3
0
        public void Write(DotWriter dotWriter, IDictionary<string, Binding> allBindings)
        {
            var nameIndex = GetNodeNames(allBindings);
            var visited = new HashSet<Binding>();
            var q = new Queue<Tuple<Binding, string>>(nameIndex.Select(kvp => Tuple.Create(kvp.Key, kvp.Value)));

            dotWriter.BeginGraph("cluster", "true");

            while (q.Count > 0)
            {
                var current = q.Dequeue();

                if (visited.Contains(current.Item1))
                {
                    continue;
                }

                var binding = current.Item1;
                var sourceName = current.Item2;
                var dependencies = new HashSet<Binding>();
                binding.GetDependencies(dependencies, dependencies);

                foreach (var dependency in dependencies)
                {
                    string targetName;
                    if (nameIndex.TryGetValue(dependency, out targetName))
                    {
                        dotWriter.WriteEdge(sourceName, targetName);
                        q.Enqueue(Tuple.Create(dependency, targetName));
                    }
                    else if (binding is CompilerSetBinding)
                    {
                        var providesBinding = Unwrap(dependency);
                        var gen = providesBinding.Generator;
                        var name = gen.Key + " (" + gen.ProviderMethod.Name + ")";
                        dotWriter.WriteEdge(sourceName, name);
                        q.Enqueue(Tuple.Create(dependency, name));
                    }
                    else
                    {
                        dotWriter.WriteEdge(sourceName, "Unbound: " + dependency.ProviderKey);
                    }
                }

                visited.Add(binding);
            }

            dotWriter.EndGraph();
        }
Пример #4
0
 private void WriteModuleGraph(
     ModuleGenerator completeModule,
     IDictionary<string, Binding> allBindings,
     string graphvizDirectory)
 {
     var safeModuleName = completeModule.ModuleType.FullName.Replace('/', '.');
     var fileName = Path.Combine(graphvizDirectory, safeModuleName + ".dot");
     using (var fs = File.Open(fileName, FileMode.Create, FileAccess.Write))
     using (var dotWriter = new DotWriter(fs))
     {
         new GraphWriter().Write(dotWriter, allBindings);
     }
 }