Ejemplo n.º 1
0
        public WorkspaceItem CreateWorkspaceItem(ProjectCreateInformation cInfo)
        {
            WorkspaceItemCreatedInformation workspaceItemInfo = solutionDescriptor.CreateEntry(cInfo, this.languagename);

            this.createdSolutionName                 = workspaceItemInfo.WorkspaceItem.FileName;
            this.createdProjectInformation           = cInfo;
            this.packageReferencesForCreatedProjects = workspaceItemInfo.PackageReferencesForCreatedProjects;

            return(workspaceItemInfo.WorkspaceItem);
        }
Ejemplo n.º 2
0
        public WorkspaceItem CreateWorkspaceItem(ProjectCreateInformation cInfo)
        {
            WorkspaceItemCreatedInformation workspaceItemInfo = solutionDescriptor.CreateEntry(cInfo, this.languagename);

            this.createdSolutionName = workspaceItemInfo.WorkspaceItem.FileName;
            this.packageReferencesForCreatedProjects = workspaceItemInfo.PackageReferencesForCreatedProjects;

            var pDesc = this.solutionDescriptor.EntryDescriptors.OfType <ProjectDescriptor> ().ToList();

            var metadata = new Dictionary <string, string> ();

            metadata ["Id"]       = this.Id;
            metadata ["Name"]     = this.nonLocalizedName;
            metadata ["Language"] = this.LanguageName;
            metadata ["Platform"] = pDesc.Count == 1 ? pDesc[0].ProjectType : "Multiple";
            TemplateCounter.Inc(1, null, metadata);

            return(workspaceItemInfo.WorkspaceItem);
        }
Ejemplo n.º 3
0
        public async Task <WorkspaceItem> CreateWorkspaceItem(ProjectCreateInformation cInfo)
        {
            WorkspaceItemCreatedInformation workspaceItemInfo = await solutionDescriptor.CreateEntry(cInfo, this.languagename);

            this.createdSolutionName = workspaceItemInfo.WorkspaceItem.FileName;
            this.packageReferencesForCreatedProjects = workspaceItemInfo.PackageReferencesForCreatedProjects;

            var pDesc = this.solutionDescriptor.EntryDescriptors.OfType <ProjectDescriptor> ().ToList();

            var metadata = new TemplateMetadata {
                Id       = Id,
                Name     = nonLocalizedName,
                Language = LanguageName ?? string.Empty,
                Platform = pDesc.Count == 1 ? pDesc[0].ProjectType : "Multiple"
            };

            TemplateCounter.Inc(1, null, metadata);

            return(workspaceItemInfo.WorkspaceItem);
        }
Ejemplo n.º 4
0
        public WorkspaceItemCreatedInformation CreateEntry(ProjectCreateInformation projectCreateInformation, string defaultLanguage)
        {
            WorkspaceItem workspaceItem = null;

            if (string.IsNullOrEmpty(type))
            {
                workspaceItem = new Solution();
            }
            else
            {
                Type workspaceItemType = addin.GetType(type, false);
                if (workspaceItemType != null)
                {
                    workspaceItem = Activator.CreateInstance(workspaceItemType) as WorkspaceItem;
                }

                if (workspaceItem == null)
                {
                    MessageService.ShowError(GettextCatalog.GetString("Can't create solution with type: {0}", type));
                    return(null);
                }
            }

            var substitution = new string[, ] {
                { "ProjectName", projectCreateInformation.SolutionName }
            };

            workspaceItem.Name = StringParserService.Parse(name, substitution);
            string newStartupProjectName = startupProject;

            if (newStartupProjectName != null)
            {
                newStartupProjectName = StringParserService.Parse(startupProject, substitution);
            }

            workspaceItem.SetLocation(projectCreateInformation.SolutionPath, workspaceItem.Name);

            ProjectCreateInformation localProjectCI;

            if (!string.IsNullOrEmpty(directory) && directory != ".")
            {
                localProjectCI = new ProjectCreateInformation(projectCreateInformation);

                localProjectCI.SolutionPath    = Path.Combine(localProjectCI.SolutionPath, directory);
                localProjectCI.ProjectBasePath = Path.Combine(localProjectCI.ProjectBasePath, directory);

                if (!Directory.Exists(localProjectCI.SolutionPath))
                {
                    Directory.CreateDirectory(localProjectCI.SolutionPath);
                }

                if (!Directory.Exists(localProjectCI.ProjectBasePath))
                {
                    Directory.CreateDirectory(localProjectCI.ProjectBasePath);
                }
            }
            else
            {
                localProjectCI = projectCreateInformation;
            }

            var workspaceItemCreatedInfo = new WorkspaceItemCreatedInformation(workspaceItem);

            Solution solution = workspaceItem as Solution;

            if (solution != null)
            {
                for (int i = 0; i < entryDescriptors.Count; i++)
                {
                    ProjectCreateInformation entryProjectCI;
                    var entry = entryDescriptors[i] as ICustomProjectCIEntry;
                    if (entry != null)
                    {
                        entryProjectCI = entry.CreateProjectCI(localProjectCI);
                    }
                    else
                    {
                        entryProjectCI = localProjectCI;
                    }

                    var solutionItemDesc = entryDescriptors[i];

                    SolutionEntityItem info = solutionItemDesc.CreateItem(entryProjectCI, defaultLanguage);
                    if (info == null)
                    {
                        continue;
                    }

                    solutionItemDesc.InitializeItem(solution.RootFolder, entryProjectCI, defaultLanguage, info);

                    IConfigurationTarget configurationTarget = info as IConfigurationTarget;
                    if (configurationTarget != null)
                    {
                        foreach (ItemConfiguration configuration in configurationTarget.Configurations)
                        {
                            bool flag = false;
                            foreach (SolutionConfiguration solutionCollection in solution.Configurations)
                            {
                                if (solutionCollection.Id == configuration.Id)
                                {
                                    flag = true;
                                }
                            }
                            if (!flag)
                            {
                                solution.AddConfiguration(configuration.Id, true);
                            }
                        }
                    }

                    if ((info is Project) && (solutionItemDesc is ProjectDescriptor))
                    {
                        workspaceItemCreatedInfo.AddPackageReferenceForCreatedProject((Project)info, (ProjectDescriptor)solutionItemDesc);
                    }
                    solution.RootFolder.Items.Add(info);
                    if (newStartupProjectName == info.Name)
                    {
                        solution.StartupItem = info;
                    }
                }
            }

            if (!workspaceItem.FileFormat.CanWrite(workspaceItem))
            {
                // The default format can't write solutions of this type. Find a compatible format.
                FileFormat f = IdeApp.Services.ProjectService.FileFormats.GetFileFormatsForObject(workspaceItem).First();
                workspaceItem.ConvertToFormat(f, true);
            }

            return(workspaceItemCreatedInfo);
        }
Ejemplo n.º 5
0
		public WorkspaceItemCreatedInformation CreateEntry (ProjectCreateInformation projectCreateInformation, string defaultLanguage)
        {
            WorkspaceItem workspaceItem = null;

            if (string.IsNullOrEmpty (type))
                workspaceItem = new Solution ();
            else {
                Type workspaceItemType = addin.GetType (type, false);
                if (workspaceItemType != null)
                    workspaceItem = Activator.CreateInstance (workspaceItemType) as WorkspaceItem;

                if (workspaceItem == null) {
                    MessageService.ShowError (GettextCatalog.GetString ("Can't create solution with type: {0}", type));
					return null;
				}
            }

			var substitution = new string[,] { { "ProjectName", projectCreateInformation.SolutionName } };
            workspaceItem.Name = StringParserService.Parse (name, substitution);
			string newStartupProjectName = startupProject;
			if (newStartupProjectName != null) {
				newStartupProjectName = StringParserService.Parse (startupProject, substitution);
			}

            workspaceItem.SetLocation (projectCreateInformation.SolutionPath, workspaceItem.Name);

            ProjectCreateInformation localProjectCI;
            if (!string.IsNullOrEmpty (directory) && directory != ".") {
                localProjectCI = new ProjectCreateInformation (projectCreateInformation);

                localProjectCI.SolutionPath = Path.Combine (localProjectCI.SolutionPath, directory);
                localProjectCI.ProjectBasePath = Path.Combine (localProjectCI.ProjectBasePath, directory);

                if (!Directory.Exists (localProjectCI.SolutionPath))
                    Directory.CreateDirectory (localProjectCI.SolutionPath);

                if (!Directory.Exists (localProjectCI.ProjectBasePath))
                    Directory.CreateDirectory (localProjectCI.ProjectBasePath);
            }
            else
                localProjectCI = projectCreateInformation;

			var workspaceItemCreatedInfo = new WorkspaceItemCreatedInformation (workspaceItem);

            Solution solution = workspaceItem as Solution;
            if (solution != null) {
                for ( int i = 0; i < entryDescriptors.Count; i++ ) {
                    ProjectCreateInformation entryProjectCI;
                    var entry = entryDescriptors[i] as ICustomProjectCIEntry;
					if (entry != null) {
						entryProjectCI = entry.CreateProjectCI (localProjectCI);
						entryProjectCI = new ProjectTemplateCreateInformation (entryProjectCI, localProjectCI.ProjectName);
					} else
	                    entryProjectCI = localProjectCI;

					var solutionItemDesc = entryDescriptors[i];

					SolutionEntityItem info = solutionItemDesc.CreateItem (entryProjectCI, defaultLanguage);
					if (info == null)
						continue;

					solutionItemDesc.InitializeItem (solution.RootFolder, entryProjectCI, defaultLanguage, info);

                    IConfigurationTarget configurationTarget = info as IConfigurationTarget;
                    if (configurationTarget != null) {
                        foreach (ItemConfiguration configuration in configurationTarget.Configurations) {
                            bool flag = false;
                            foreach (SolutionConfiguration solutionCollection in solution.Configurations) {
                                if (solutionCollection.Id == configuration.Id)
                                    flag = true;
                            }
                            if (!flag)
                                solution.AddConfiguration (configuration.Id, true);
                        }
                    }

					if ((info is Project) && (solutionItemDesc is ProjectDescriptor)) {
						workspaceItemCreatedInfo.AddPackageReferenceForCreatedProject ((Project)info, (ProjectDescriptor)solutionItemDesc, projectCreateInformation);
					}
                    solution.RootFolder.Items.Add (info);
					if (newStartupProjectName == info.Name)
						solution.StartupItem = info;
                }
            }

			if (!workspaceItem.FileFormat.CanWrite (workspaceItem)) {
				// The default format can't write solutions of this type. Find a compatible format.
				FileFormat f = IdeApp.Services.ProjectService.FileFormats.GetFileFormatsForObject (workspaceItem).First ();
				workspaceItem.ConvertToFormat (f, true);
			}
			
			return workspaceItemCreatedInfo;
        }