Ejemplo n.º 1
0
        private AsmReference GetReferences(IAssembly currentAssembly, AsmReference referenceDictionary, uint currentRecursionLimit = uint.MaxValue)
        {
            Contract.Requires<ArgumentNullException>(currentAssembly != null);
            Contract.Requires<ArgumentNullException>(referenceDictionary != null);

            if (referenceDictionary.ContainsKey(currentAssembly))
            {
                return referenceDictionary;
            }

            if (currentRecursionLimit == 0)
            {
                return referenceDictionary;
            }

            referenceDictionary.Add(currentAssembly, currentAssembly.References);
            currentRecursionLimit--;
            foreach (var referencedAssembly in currentAssembly.References)
            {
                var assemblyReferences = GetReferences(referencedAssembly, referenceDictionary, currentRecursionLimit);
                referenceDictionary.Add(assemblyReferences);
            }

            return referenceDictionary;
        }
        private DelegateVertexAndEdgeListGraph<IAssembly, SEquatableEdge<IAssembly>> CreateGraph()
        {
            var graphDictionary = new AsmReference(asmReference.Keys);
            foreach (var names in asmReference.Values)
            {
                foreach (var name in names.Where(name => !graphDictionary.ContainsKey(name)))
                {
                    graphDictionary.Add(name);
                }
            }
            foreach (var assembly in asmReference)
            {
                graphDictionary[assembly.Key] = assembly.Value;
            }

            var graph =
                graphDictionary.ToVertexAndEdgeListGraph(kv => kv.Value.Select(v => new SEquatableEdge<IAssembly>(kv.Key, v)));
            return graph;
        }