private TypeVertex GetVertex(TypeReference tref, string className, DetermineClassDeps dcd)
        {
            TypeVertex V;

            if (dcd.IsExternalType(tref))
            {
                className = DetermineClassDeps.AssemblyNameofType(tref);
            }
            if (classMap.ContainsKey(className))
            {
                V = classMap[className];
            }
            else
            {
                V         = (TypeVertex)this.AddVertex();
                V.Name    = className;
                V.TypeRef = tref;
                if (dcd.IsExternalType(tref))
                {
                    V.ImutableExternalType = true;
                }
                classMap[className] = V;
            }
            return(V);
        }
Exemple #2
0
        private void WriteAssemRefsItemGroup(XmlTextWriter xproj, CondensedVertex va)
        {
            xproj.WriteComment("Assembly Refs");
            xproj.WriteStartElement("ItemGroup");
            foreach (CondensedVertex projRef in Graph.AdjacentVertices(va))
            {
                if (projRef.ImutableExternalType)
                {
                    xproj.WriteStartElement("Reference");
                    string aRefShortName = "";

                    string aRefFQN = DetermineClassDeps.AssemblyNameofType(projRef.ContainedTypes[0]);


                    if (aRefFQN.StartsWith("mscorlib"))
                    {
                        aRefFQN = "System,";
                    }

                    int idx = aRefFQN.IndexOf(",");
                    if (idx > 0)
                    {
                        aRefShortName = aRefFQN.Substring(0, idx);
                    }

                    if (aRefFQN.StartsWith("System"))
                    {
                        xproj.WriteAttributeString("Include", aRefShortName);
                    }
                    else
                    {
                        xproj.WriteAttributeString("Include", aRefFQN);
                        string[] exts = new string[2] {
                            ".dll", ".exe"
                        };
                        foreach (string ext in exts)
                        {
                            string hintPath = Path.Combine(Path.GetDirectoryName(AssemblyFileName), aRefShortName) + ext;
                            if (File.Exists(hintPath))
                            {
                                xproj.WriteElementString("SpecificVersion", false.ToString());
                                //todo - manage directories better
                                xproj.WriteElementString("HintPath", Path.Combine("..", hintPath));
                                break;
                            }
                        }
                    }
                    xproj.WriteEndElement();
                }
            }
            xproj.WriteEndElement();
        }