예제 #1
0
        public static void OutputObjectGraphToFile(DiContainer container, string outputPath)
        {
            #if !UNITY_WEBPLAYER
            // Output the entire object graph to file
            var graph = container.CalculateObjectGraph<IDependencyRoot>();

            var resultStr = "digraph { \n";

            foreach (var entry in graph)
            {
                // ignore these to clean up the graph
                if (entry.Key == typeof(EntryPointInitializer) || entry.Key == typeof(KernelInitializer))
                {
                    continue;
                }

                foreach (var dependencyType in entry.Value)
                {
                    // ignore factory dependency to clean up graph
                    if (dependencyType == typeof(DiContainer))
                    {
                        continue;
                    }

                    resultStr += GetFormattedTypeName(entry.Key) + " -> " + GetFormattedTypeName(dependencyType) + "; \n";
                }
            }

            resultStr += " }";

            System.IO.File.WriteAllText(outputPath, resultStr);
            #endif
        }