示例#1
0
 public void AddProjectReference(Project p)
 {
     XmlNode referencePath = projectDocument.SelectSingleNode("/VisualStudioProject/CSHARP/Build/References");
     XmlElement elem = projectDocument.CreateElement("Reference");
     AddAttribute(elem, "Name", p.Name);
     AddAttribute(elem, "Project", "{" + p.Guid + "}");
     AddAttribute(elem, "Package", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}");
     referencePath.AppendChild(elem);
 }
示例#2
0
 private string GetFullPath(string fileName, Project p)
 {
     string folder = Path.Combine(InputFolder, p.Folder);
     return Path.Combine(folder, fileName);
 }
示例#3
0
 private Project GetDefaultProject()
 {
     Project project;
     project = new Project();
     project.Name = Solution;
     project.Folder = ".";
     project.OutputFolder = ".";
     project.FileSet = new FileSet(InputFolder);
     return project;
 }
示例#4
0
 private void DeserializeFiles(XmlNode node, Project p)
 {
     foreach (XmlNode subNode in FilterNodes(node.ChildNodes))
     {
         string path = subNode.Attributes["Path"].Value;
         if (subNode.Name == "Include")
         {
             p.FileSet.Includes.Add(path);
             if (subNode.Attributes["Stub"] != null)
             {
                 Stubs.Add(GetFullPath(subNode.Attributes["Path"].Value, p), subNode.Attributes["Stub"].Value);
             }
         }
         else if (subNode.Name == "Stub")
         {
             if (subNode.Attributes["Members"] != null)
                 Stubs.Add(GetFullPath(subNode.Attributes["Path"].Value, p), subNode.Attributes["Members"].Value);
         }
         else
         {
             int index = path.IndexOf(":");
             if (index != -1)
             {
                 string fileName = path.Substring(0, index);
                 string methods = path.Substring(index + 1);
                 string file = GetFullPath(fileName, p);
                 MembersExcludes.Add(file, methods);
             }
             else
                 p.FileSet.Excludes.Add(path);
         }
     }
 }
示例#5
0
 private void Deserialize(XmlNode node, object obj)
 {
     Type type = obj.GetType();
     if (node.Name == "Files")
     {
         Project project;
         if (Projects.Count > 0)
             project = (Project) Projects[0];
         else
         {
             project = GetDefaultProject();
             Projects.Add(project);
         }
         DeserializeFiles(node, project);
     }
     else if (node.Name == "Projects")
     {
         foreach (XmlNode childNode in FilterNodes(node.ChildNodes))
         {
             Project p = new Project();
             p.FileSet = new FileSet(Path.Combine(InputFolder, childNode.Attributes["Folder"].Value));
             foreach (XmlAttribute attribute in childNode.Attributes)
                 Deserialize(attribute, p);
             DeserializeFiles(childNode, p);
             Projects.Add(p);
         }
     }
     else
     {
         FieldInfo field = type.GetField(node.Name);
         object fieldValue = field.GetValue(obj);
         if (fieldValue == null || node.Name == "Solution")
             field.SetValue(obj, node.InnerText);
     }
 }
示例#6
0
        private void AddAssemblyReferences(Project project, string referenceFolder)
        {
            if (Mode == "IKVM")
                project.AddAssemblyReference(referenceFolder + Path.DirectorySeparatorChar + "IKVM.GNU.Classpath.dll");

            IDictionary references = options.GetKeys("References");

            UsingVisitor uv = new UsingVisitor();
            foreach (Source source in Sources.Values)
            {
                if (source.CodeFile && source.OutputFile.StartsWith(project.OutputFolder))
                    uv.VisitCompilationUnit(source.CompilationUnit, null);
            }
            IList added = new ArrayList();
            foreach (string key in uv.Usings.Keys)
            {
                foreach (DictionaryEntry entry in references)
                {
                    if (key.StartsWith(entry.Key.ToString()))
                    {
                        string[] assemblies = entry.Value.ToString().Split(',');
                        foreach (string assembly in assemblies)
                        {
                            if (added.Contains(assembly))
                                continue;
                            project.AddAssemblyReference(referenceFolder + Path.DirectorySeparatorChar + assembly + ".dll");
                            added.Add(assembly);
                        }
                    }
                }
            }
        }