Exemplo n.º 1
0
        public bool HasItemFeatures(SolutionFolder parentFolder, ProjectCreateInformation cinfo)
        {
            ISolutionItemDescriptor sid        = solutionDescriptor.EntryDescriptors [0];
            SolutionEntityItem      sampleItem = sid.CreateItem(cinfo, languagename);

            return(SolutionItemFeatures.GetFeatures(parentFolder, sampleItem).Length > 0);
        }
Exemplo n.º 2
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);
        }
        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);
        }