本文整理汇总了C#中ICSharpCode.SharpDevelop.Project.Solution.AddFolder方法的典型用法代码示例。如果您正苦于以下问题:C# Solution.AddFolder方法的具体用法?C# Solution.AddFolder怎么用?C# Solution.AddFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.SharpDevelop.Project.Solution
的用法示例。
在下文中一共展示了Solution.AddFolder方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SolutionWithOneProjectOpen
IProject SolutionWithOneProjectOpen()
{
var solution = new Solution(new MockProjectChangeWatcher());
var project = new MockCSharpProject(solution, "MyProject");
solution.AddFolder(project);
runTestCommandContext.Solution = solution;
return project;
}
示例2: CreateTestProject
public static TestableProject CreateTestProject(
Solution parentSolution,
string name,
string fileName = @"d:\projects\Test\TestProject\TestProject.csproj")
{
ProjectCreateInformation createInfo = new ProjectCreateInformation();
createInfo.Solution = parentSolution;
createInfo.ProjectName = name;
createInfo.SolutionPath = @"d:\projects\Test";
createInfo.ProjectBasePath = @"d:\projects\Test\TestProject";
createInfo.OutputProjectFileName = fileName;
var project = new TestableProject(createInfo);
project.Parent = parentSolution;
parentSolution.AddFolder(project);
return project;
}
示例3: CreateTestProject
public static TestableProject CreateTestProject(string name)
{
Solution solution = new Solution(new MockProjectChangeWatcher());
solution.FileName = @"d:\projects\Test\TestSolution.sln";
ProjectCreateInformation createInfo = new ProjectCreateInformation();
createInfo.Solution = solution;
createInfo.ProjectName = name;
createInfo.SolutionPath = @"d:\projects\Test";
createInfo.ProjectBasePath = @"d:\projects\Test\TestProject";
createInfo.OutputProjectFileName = @"d:\projects\Test\TestProject\TestProject.csproj";
var project = new TestableProject(createInfo);
project.Parent = solution;
solution.AddFolder(project);
return project;
}
示例4: LoadProjectInternal
static void LoadProjectInternal(string fileName)
{
if (!Path.IsPathRooted(fileName))
throw new ArgumentException("Path must be rooted!");
string solutionFile = Path.ChangeExtension(fileName, ".sln");
if (File.Exists(solutionFile)) {
LoadSolutionInternal(solutionFile);
if (openSolution != null) {
bool found = false;
foreach (IProject p in openSolution.Projects) {
if (FileUtility.IsEqualFileName(fileName, p.FileName)) {
found = true;
break;
}
}
if (found == false) {
string[,] parseArgs = {{"SolutionName", Path.GetFileName(solutionFile)}, {"ProjectName", Path.GetFileName(fileName)}};
int res = MessageService.ShowCustomDialog(MessageService.ProductName,
StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.OpenCombine.SolutionDoesNotContainProject}", parseArgs),
0, 2,
StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.OpenCombine.SolutionDoesNotContainProject.AddProjectToSolution}", parseArgs),
StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.OpenCombine.SolutionDoesNotContainProject.CreateNewSolution}", parseArgs),
"${res:Global.IgnoreButtonText}");
if (res == 0) {
// Add project to solution
Commands.AddExitingProjectToSolution.AddProject((ISolutionFolderNode)ProjectBrowserPad.Instance.SolutionNode, fileName);
SaveSolution();
return;
} else if (res == 1) {
CloseSolution();
try {
File.Copy(solutionFile, Path.ChangeExtension(solutionFile, ".old.sln"), true);
} catch (IOException){}
} else {
// ignore, just open the solution
return;
}
} else {
// opened solution instead and correctly found the project
return;
}
} else {
// some problem during opening, abort
return;
}
}
Solution solution = new Solution();
solution.Name = Path.GetFileNameWithoutExtension(fileName);
IProjectBinding binding = ProjectBindingService.GetBindingPerProjectFile(fileName);
IProject project;
if (binding != null) {
project = ProjectBindingService.LoadProject(new ProjectLoadInformation(solution, fileName, solution.Name));
if (project is UnknownProject) {
if (((UnknownProject)project).WarningDisplayedToUser == false) {
((UnknownProject)project).ShowWarningMessageBox();
}
return;
}
} else {
MessageService.ShowError(StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.OpenCombine.InvalidProjectOrCombine}", new string[,] {{"FileName", fileName}}));
return;
}
solution.AddFolder(project);
ProjectSection configSection = solution.GetSolutionConfigurationsSection();
foreach (string configuration in project.ConfigurationNames) {
foreach (string platform in project.PlatformNames) {
string key;
if (platform == "AnyCPU") { // Fix for SD2-786
key = configuration + "|Any CPU";
} else {
key = configuration + "|" + platform;
}
configSection.Items.Add(new SolutionItem(key, key));
}
}
solution.FixSolutionConfiguration(new IProject[] { project });
if (FileUtility.ObservedSave((NamedFileOperationDelegate)solution.Save, solutionFile) == FileOperationResult.OK) {
// only load when saved succesfully
LoadSolution(solutionFile);
}
}
示例5: SetupSolutionLoadSolutionProjects
static ProjectSection SetupSolutionLoadSolutionProjects(Solution newSolution, StreamReader sr, IProgressMonitor progressMonitor)
{
if (progressMonitor == null)
throw new ArgumentNullException("progressMonitor");
string solutionDirectory = Path.GetDirectoryName(newSolution.FileName);
ProjectSection nestedProjectsSection = null;
IList<ProjectLoadInformation> projectsToLoad = new List<ProjectLoadInformation>();
IList<IList<ProjectSection>> readProjectSections = new List<IList<ProjectSection>>();
// process the solution file contents
while (true) {
string line = sr.ReadLine();
if (line == null) {
break;
}
Match match = projectLinePattern.Match(line);
if (match.Success) {
string projectGuid = match.Result("${ProjectGuid}");
string title = match.Result("${Title}");
string location = match.Result("${Location}");
string guid = match.Result("${Guid}");
if (!FileUtility.IsUrl(location)) {
location = FileUtility.NormalizePath(Path.Combine(solutionDirectory, location));
}
if (projectGuid == FolderGuid) {
SolutionFolder newFolder = SolutionFolder.ReadFolder(sr, title, location, guid);
newSolution.AddFolder(newFolder);
} else {
ProjectLoadInformation loadInfo = new ProjectLoadInformation(newSolution, location, title);
loadInfo.TypeGuid = projectGuid;
loadInfo.Guid = guid;
projectsToLoad.Add(loadInfo);
IList<ProjectSection> currentProjectSections = new List<ProjectSection>();
ReadProjectSections(sr, currentProjectSections);
readProjectSections.Add(currentProjectSections);
}
match = match.NextMatch();
} else {
match = globalSectionPattern.Match(line);
if (match.Success) {
ProjectSection newSection = ProjectSection.ReadGlobalSection(sr, match.Result("${Name}"), match.Result("${Type}"));
// Don't put the NestedProjects section into the global sections list
// because it's transformed to a tree representation and the tree representation
// is transformed back to the NestedProjects section during save.
if (newSection.Name == "NestedProjects") {
nestedProjectsSection = newSection;
} else {
newSolution.Sections.Add(newSection);
}
}
}
}
// load projects
for(int i=0; i<projectsToLoad.Count; i++) {
ProjectLoadInformation loadInfo = projectsToLoad[i];
IList<ProjectSection> projectSections = readProjectSections[i];
loadInfo.ProjectSections = projectSections;
// set the target platform
SolutionItem projectConfig = newSolution.GetProjectConfiguration(loadInfo.Guid);
loadInfo.Platform = AbstractProject.GetPlatformNameFromKey(projectConfig.Location);
loadInfo.ProgressMonitor = progressMonitor;
progressMonitor.Progress = (double)i / projectsToLoad.Count;
progressMonitor.TaskName = "Loading " + loadInfo.ProjectName;
using (IProgressMonitor nestedProgressMonitor = progressMonitor.CreateSubTask(1.0 / projectsToLoad.Count)) {
loadInfo.ProgressMonitor = nestedProgressMonitor;
IProject newProject = ProjectBindingService.LoadProject(loadInfo);
newProject.IdGuid = loadInfo.Guid;
newProject.ProjectSections.AddRange(projectSections);
newSolution.AddFolder(newProject);
}
}
return nestedProjectsSection;
}
示例6: SetupSolution
static bool SetupSolution(Solution newSolution, string fileName)
{
string solutionDirectory = Path.GetDirectoryName(fileName);
ProjectSection nestedProjectsSection = null;
bool needsConversion = false;
// read solution files using system encoding, but detect UTF8 if BOM is present
using (StreamReader sr = new StreamReader(fileName, Encoding.Default, true)) {
string line = GetFirstNonCommentLine(sr);
Match match = versionPattern.Match(line);
if (!match.Success) {
MessageService.ShowErrorFormatted("${res:SharpDevelop.Solution.InvalidSolutionFile}", fileName);
return false;
}
switch (match.Result("${Version}")) {
case "7.00":
needsConversion = true;
if (!MessageService.AskQuestion("${res:SharpDevelop.Solution.ConvertSolutionVersion7}")) {
return false;
}
break;
case "8.00":
needsConversion = true;
if (!MessageService.AskQuestion("${res:SharpDevelop.Solution.ConvertSolutionVersion8}")) {
return false;
}
break;
case "9.00":
break;
default:
MessageService.ShowErrorFormatted("${res:SharpDevelop.Solution.UnknownSolutionVersion}", match.Result("${Version}"));
return false;
}
while (true) {
line = sr.ReadLine();
if (line == null) {
break;
}
match = projectLinePattern.Match(line);
if (match.Success) {
string projectGuid = match.Result("${ProjectGuid}");
string title = match.Result("${Title}");
string location = match.Result("${Location}");
string guid = match.Result("${Guid}");
if (!FileUtility.IsUrl(location)) {
location = Path.GetFullPath(Path.Combine(solutionDirectory, location));
}
if (projectGuid == FolderGuid) {
SolutionFolder newFolder = SolutionFolder.ReadFolder(sr, title, location, guid);
newSolution.AddFolder(newFolder);
} else {
IProject newProject = LanguageBindingService.LoadProject(newSolution, location, title, projectGuid);
ReadProjectSections(sr, newProject.ProjectSections);
newProject.IdGuid = guid;
newSolution.AddFolder(newProject);
}
match = match.NextMatch();
} else {
match = globalSectionPattern.Match(line);
if (match.Success) {
ProjectSection newSection = ProjectSection.ReadGlobalSection(sr, match.Result("${Name}"), match.Result("${Type}"));
// Don't put the NestedProjects section into the global sections list
// because it's transformed to a tree representation and the tree representation
// is transformed back to the NestedProjects section during save.
if (newSection.Name == "NestedProjects") {
nestedProjectsSection = newSection;
} else {
newSolution.Sections.Add(newSection);
}
}
}
}
}
// Create solution folder 'tree'.
if (nestedProjectsSection != null) {
foreach (SolutionItem item in nestedProjectsSection.Items) {
string from = item.Name;
string to = item.Location;
ISolutionFolderContainer folder = newSolution.guidDictionary[to] as ISolutionFolderContainer;
folder.AddFolder(newSolution.guidDictionary[from]);
}
}
if (newSolution.FixSolutionConfiguration(newSolution.Projects) || needsConversion) {
// save in new format
newSolution.Save();
}
return true;
}
示例7: SetupSolutionLoadSolutionProjects
static ProjectSection SetupSolutionLoadSolutionProjects(Solution newSolution, StreamReader sr, IProgressMonitor progressMonitor)
{
string solutionDirectory = Path.GetDirectoryName(newSolution.FileName);
ProjectSection nestedProjectsSection = null;
while (true) {
string line = sr.ReadLine();
if (line == null) {
break;
}
Match match = projectLinePattern.Match(line);
if (match.Success) {
string projectGuid = match.Result("${ProjectGuid}");
string title = match.Result("${Title}");
string location = match.Result("${Location}");
string guid = match.Result("${Guid}");
if (!FileUtility.IsUrl(location)) {
location = FileUtility.NormalizePath(Path.Combine(solutionDirectory, location));
}
if (projectGuid == FolderGuid) {
SolutionFolder newFolder = SolutionFolder.ReadFolder(sr, title, location, guid);
newSolution.AddFolder(newFolder);
} else {
IProject newProject = LanguageBindingService.LoadProject(newSolution, location, title, projectGuid, progressMonitor);
ReadProjectSections(sr, newProject.ProjectSections);
newProject.IdGuid = guid;
newSolution.AddFolder(newProject);
}
match = match.NextMatch();
} else {
match = globalSectionPattern.Match(line);
if (match.Success) {
ProjectSection newSection = ProjectSection.ReadGlobalSection(sr, match.Result("${Name}"), match.Result("${Type}"));
// Don't put the NestedProjects section into the global sections list
// because it's transformed to a tree representation and the tree representation
// is transformed back to the NestedProjects section during save.
if (newSection.Name == "NestedProjects") {
nestedProjectsSection = newSection;
} else {
newSolution.Sections.Add(newSection);
}
}
}
}
return nestedProjectsSection;
}
示例8: AddProjectToSolution
TestableProject AddProjectToSolution(Solution solution)
{
var project = ProjectHelper.CreateTestProject();
solution.AddFolder(project);
return project;
}