Ejemplo n.º 1
0
 void SavePackageReferences(SolutionItem solutionEntryItem, ISolutionItemDescriptor descriptor, ProjectCreateInformation cInfo)
 {
     if ((solutionEntryItem is Project) && (descriptor is ProjectDescriptor))
     {
         var projectPackageReferences = new PackageReferencesForCreatedProject(((Project)solutionEntryItem).Name, ((ProjectDescriptor)descriptor).GetPackageReferences(cInfo));
         packageReferencesForCreatedProjects.Add(projectPackageReferences);
     }
 }
Ejemplo n.º 2
0
 void SavePackageReferences(SolutionEntityItem solutionEntryItem, ISolutionItemDescriptor descriptor)
 {
     packageReferencesForCreatedProjects = new List <PackageReferencesForCreatedProject> ();
     if ((solutionEntryItem is Project) && (descriptor is ProjectDescriptor))
     {
         var projectPackageReferences = new PackageReferencesForCreatedProject(((Project)solutionEntryItem).Name, ((ProjectDescriptor)descriptor).GetPackageReferences());
         packageReferencesForCreatedProjects.Add(projectPackageReferences);
     }
 }
Ejemplo n.º 3
0
        static ProjectCreateInformation GetItemSpecificCreateInfo(ISolutionItemDescriptor descriptor, ProjectCreateInformation cInfo)
        {
            var entry = descriptor as ICustomProjectCIEntry;

            if (entry != null)
            {
                return(entry.CreateProjectCI(cInfo));
            }

            return(cInfo);
        }
Ejemplo n.º 4
0
        public SolutionEntityItem CreateProject(SolutionItem policyParent, ProjectCreateInformation cInfo)
        {
            if (solutionDescriptor.EntryDescriptors.Length == 0)
            {
                throw new InvalidOperationException("Solution template doesn't have any project templates");
            }

            ISolutionItemDescriptor descriptor        = solutionDescriptor.EntryDescriptors [0];
            SolutionEntityItem      solutionEntryItem = descriptor.CreateItem(cInfo, this.languagename);

            descriptor.InitializeItem(policyParent, cInfo, this.languagename, solutionEntryItem);

            SavePackageReferences(solutionEntryItem, descriptor);

            this.createdProjectInformation = cInfo;

            return(solutionEntryItem);
        }
Ejemplo n.º 5
0
		void SavePackageReferences (SolutionItem solutionEntryItem, ISolutionItemDescriptor descriptor, ProjectCreateInformation cInfo)
		{
			if ((solutionEntryItem is Project) && (descriptor is ProjectDescriptor)) {
				var projectPackageReferences = new PackageReferencesForCreatedProject (((Project)solutionEntryItem).Name, ((ProjectDescriptor)descriptor).GetPackageReferences (cInfo));
				packageReferencesForCreatedProjects.Add (projectPackageReferences);
			}
		}
Ejemplo n.º 6
0
		static ProjectCreateInformation GetItemSpecificCreateInfo (ISolutionItemDescriptor descriptor, ProjectCreateInformation cInfo)
		{
			var entry = descriptor as ICustomProjectCIEntry;
				if (entry != null)
					return entry.CreateProjectCI (cInfo);

			return cInfo;
		}
Ejemplo n.º 7
0
 void SavePackageReferences(SolutionEntityItem solutionEntryItem, ISolutionItemDescriptor descriptor)
 {
     packageReferencesForCreatedProjects = new List<PackageReferencesForCreatedProject> ();
     if ((solutionEntryItem is Project) && (descriptor is ProjectDescriptor)) {
         var projectPackageReferences = new PackageReferencesForCreatedProject (((Project)solutionEntryItem).Name, ((ProjectDescriptor)descriptor).GetPackageReferences ());
         packageReferencesForCreatedProjects.Add (projectPackageReferences);
     }
 }
        public WorkspaceItem 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);
                }
            }

            workspaceItem.Name = StringParserService.Parse(name, new string[, ] {
                { "ProjectName", projectCreateInformation.SolutionName }
            });

            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;
            }

            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;
                    }

                    ISolutionItemDescriptor solutionItem = entryDescriptors[i];

                    SolutionEntityItem info = solutionItem.CreateItem(entryProjectCI, defaultLanguage);
                    entryDescriptors[i].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);
                            }
                        }
                    }

                    solution.RootFolder.Items.Add(info);
                    if (startupProject == 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(workspaceItem);
        }