Пример #1
0
 public static Project CreateEntryProject(Project mainProject, IEnumerable<Project> additionalProjects)
 {
     var result = new CustomProject(GeneratedProjectName,
         System.IO.Path.Combine(Directory.GetCurrentDirectory(), string.Format("{0}/{1}.csproj", GeneratedProjectLocation, GeneratedProjectName)), 
         mainProject.StartupObject,
         new [] { mainProject }.Union(additionalProjects));
     Directory.CreateDirectory(GeneratedProjectLocation);
     result.GenerateMainClass(System.IO.Path.Combine(Directory.GetCurrentDirectory(), string.Format("{0}/{1}.cs", GeneratedProjectLocation, GeneratedProjectMainClassName)));
     result.Save(result.Path);
     return result;
 }
Пример #2
0
        public static Solution Generate(Project mainProject, IEnumerable<Project> additionalProjects)
        {
            var projects = 
                mainProject.GetAllReferences()
                .Union(additionalProjects.SelectMany(x => x.GetAllReferences()))
                .Union(additionalProjects);
                    
            var motherProject = Project.CreateEntryProject(mainProject, projects);

            return new Solution(new [] { motherProject, mainProject }.Union(projects));
        }   
Пример #3
0
        public static bool TryLoadFromFile(string path, out Project project)
        {
            if(string.IsNullOrEmpty(path))
            {
                project = null;
                return false;
            }

            XDocument doc;
            try
            {
                doc = XDocument.Load(path);
            }
            catch (DirectoryNotFoundException)
            {
                project = null;
                return false;
            }

            var nameNode = doc.XPathSelectElement(@"/x:Project/x:PropertyGroup/x:AssemblyName", NamespaceManager);
            var projectInfoNode = doc.XPathSelectElement(@"/x:Project/x:PropertyGroup/x:ProjectInfo", NamespaceManager);
            XAttribute projectTypeAttribute = null;
            if(projectInfoNode != null)
            {
                projectTypeAttribute = projectInfoNode.Attribute("Type");
            }
            if(nameNode == null)
            {
                project = null;
                return false;
            }
            if(projectInfoNode != null)
            {
                var skippedNode = projectInfoNode.Attribute("Skip");
                if(skippedNode != null && skippedNode.Value == "true")
                {
                    project = null;
                    return false;
                }

                var type = projectTypeAttribute != null ? ProjectTypeHelper.Parse(projectTypeAttribute.Value) : ProjectType.Unknown;
                project = type.CreateInstance(nameNode.Value, path);
            }
            else
            {
                project = new UnknownProject(nameNode.Value, path);
            }

            return project.TryLoad(doc);
        }
Пример #4
0
 public static Solution GenerateWithAllReferences(UiProject mainProject, IEnumerable<Project> extraProjects = null)
 {
     if(extraProjects == null)
     {
         extraProjects = new Project[0];
     }
     
     var extensionProjects = Scanner.Instance.Projects.OfType<ExtensionProject>();
     var pluginProjects = Scanner.Instance.Projects.OfType<PluginProject>().Where(x => !x.PluginModes.Any() || x.PluginModes.Contains(mainProject.UiType));
     
     var projects = extensionProjects
         .Union(extraProjects)
         .Union(extraProjects.SelectMany(x => x.GetAllReferences()))
         .Union(extensionProjects.SelectMany(x => x.GetAllReferences()))
         .Union(pluginProjects)
         .Union(pluginProjects.SelectMany(x => x.GetAllReferences())).ToList();
             
     return SolutionGenerator.Generate(mainProject, projects);
 }
Пример #5
0
 private static void GenerateReferencesInner(Project project, HashSet<Project> projects)
 {
     if(!projects.Contains(project))
     {
         projects.Add(project);
     
         foreach(var reference in project.GetAllReferences())
         {
             GenerateReferencesInner(reference, projects);
         }
     }
 }