Beispiel #1
0
        public ProjectFile AddFileToProject(SolutionFolderItem policyParent, Project project, string language, string directory, string name)
        {
            generatedFile = SaveFile(policyParent, project, language, directory, name);
            if (generatedFile != null)
            {
                string      buildAction = this.buildAction ?? project.GetDefaultBuildAction(generatedFile);
                ProjectFile projectFile = project.AddFile(generatedFile, buildAction);

                if (!string.IsNullOrEmpty(dependsOn))
                {
                    var    model         = CombinedTagModel.GetTagModel(ProjectTagModel, policyParent, project, language, name, generatedFile);
                    string parsedDepName = StringParserService.Parse(dependsOn, model);
                    if (projectFile.DependsOn != parsedDepName)
                    {
                        projectFile.DependsOn = parsedDepName;
                    }
                }

                if (!string.IsNullOrEmpty(customTool))
                {
                    projectFile.Generator = customTool;
                }

                if (!string.IsNullOrEmpty(customToolNamespace))
                {
                    var model = CombinedTagModel.GetTagModel(ProjectTagModel, policyParent, project, language, name, generatedFile);
                    projectFile.CustomToolNamespace = StringParserService.Parse(customToolNamespace, model);
                }

                DotNetProject netProject = project as DotNetProject;
                if (netProject != null)
                {
                    // Add required references
                    foreach (string aref in references)
                    {
                        string res = netProject.AssemblyContext.GetAssemblyFullName(aref, netProject.TargetFramework);
                        res = netProject.AssemblyContext.GetAssemblyNameForVersion(res, netProject.TargetFramework);
                        if (!ContainsReference(netProject, res))
                        {
                            netProject.References.Add(ProjectReference.CreateAssemblyReference(aref));
                        }
                    }
                }

                return(projectFile);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        void AddEntry(TreeIter iter, SolutionFolderItem entry)
        {
            string icon;

            if (entry.ParentFolder == null)
            {
                icon = MonoDevelop.Ide.Gui.Stock.Solution;
            }
            else if (entry is SolutionFolder)
            {
                icon = MonoDevelop.Ide.Gui.Stock.SolutionFolderClosed;
            }
            else if (entry is Project)
            {
                icon = ((Project)entry).StockIcon;
            }
            else
            {
                icon = MonoDevelop.Ide.Gui.Stock.Project;
            }

            bool visible  = builder.CanBuild(entry);
            bool selected = selectedEntries.ContainsKey(entry);

            if (!(entry is SolutionFolder) && !visible)
            {
                return;
            }

            if (!iter.Equals(TreeIter.Zero))
            {
                iter = store.AppendValues(iter, icon, entry.Name, entry, selected && visible, visible);
            }
            else
            {
                iter = store.AppendValues(icon, entry.Name, entry, selected && visible, visible);
            }

            if (selected)
            {
                tree.ExpandToPath(store.GetPath(iter));
            }

            if (entry is SolutionFolder)
            {
                foreach (SolutionFolderItem ce in ((SolutionFolder)entry).Items)
                {
                    AddEntry(iter, ce);
                }
            }
        }
        string GetIcon(SolutionFolderItem entry)
        {
            if (entry is SolutionFolder)
            {
                return(MonoDevelop.Ide.Gui.Stock.Solution);
            }

            if (entry is Project)
            {
                return(((Project)entry).StockIcon);
            }

            return(MonoDevelop.Ide.Gui.Stock.Project);
        }
        protected override void OnSelectionChanged(object sender, EventArgs args)
        {
            base.OnSelectionChanged(sender, args);
            ITreeNavigator nav = treeView.GetSelectedNode();

            if (nav != null)
            {
                WorkspaceItem c = (WorkspaceItem)nav.GetParentDataItem(typeof(WorkspaceItem), true);
                IdeApp.ProjectOperations.CurrentSelectedWorkspaceItem = c;
                SolutionFolderItem ce = (SolutionFolderItem)nav.GetParentDataItem(typeof(SolutionFolderItem), true);
                IdeApp.ProjectOperations.CurrentSelectedSolutionItem = ce;
                IdeApp.ProjectOperations.CurrentSelectedItem         = nav.DataItem;
            }
        }
Beispiel #5
0
        public DeployFile(ProjectFile pfile)
        {
            DeployProperties props = DeployService.GetDeployProperties(pfile);

            this.targetDirectoryID  = props.TargetDirectory;
            this.sourcePath         = pfile.FilePath;
            this.relativeTargetPath = props.RelativeDeployPath;
            this.attributes         = props.FileAttributes;
            if (props.HasPathReferences)
            {
                isTemplate = true;
            }
            sourceSolutionItem = pfile.Project;
        }
 void AddClasses(ITreeBuilder builder, SolutionFolderItem entry)
 {
     if (entry is SolutionFolder)
     {
         foreach (SolutionFolderItem e in ((SolutionFolder)entry).Items)
         {
             AddClasses(builder, e);
         }
     }
     else if (entry is Project)
     {
         ProjectNodeBuilder.BuildChildNodes(builder, entry as Project);
     }
 }
        public bool CanDeploy(SolutionFolderItem entry, MakefileType type)
        {
            Project project = entry as Project;

            if (project == null)
            {
                return(false);
            }
            if (FindSetupForProject(project) == null)
            {
                return(false);
            }
            return(true);
        }
        public override async Task <bool> AddToProjectAsync(SolutionFolderItem policyParent, Project project, string language, string directory, string name)
        {
            ProjectFile file = await template.AddFileToProjectAsync(policyParent, project, language, directory, name);

            if (file != null)
            {
                file.BuildAction = BuildAction.EmbeddedResource;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #9
0
        public IEnumerable <SolutionItem> CreateProjects(SolutionFolderItem policyParent, ProjectCreateInformation cInfo)
        {
            if (solutionDescriptor.EntryDescriptors.Length == 0)
            {
                throw new InvalidOperationException(GettextCatalog.GetString("Solution template doesn't have any project templates"));
            }

            var solutionEntryItems = new List <SolutionItem> ();

            packageReferencesForCreatedProjects = new List <PackageReferencesForCreatedProject> ();

            foreach (ISolutionItemDescriptor solutionItemDescriptor in GetItemsToCreate(solutionDescriptor, cInfo))
            {
                ProjectCreateInformation itemCreateInfo = GetItemSpecificCreateInfo(solutionItemDescriptor, cInfo);
                itemCreateInfo = new ProjectTemplateCreateInformation(itemCreateInfo, cInfo.ProjectName);
                itemCreateInfo.TemplateInitializationCallback = async p => {
                    try {
                        await solutionItemDescriptor.InitializeItem(policyParent, itemCreateInfo, this.languagename, p);

                        // Handle the case where InitializeItem has to wait for a Task to complete and the project
                        // is saved before all the files are added to the project. Otherwise the project will not contain
                        // the files even though the solution pad shows them.
                        // TODO: Investigate making the InitializeFromTemplate methods Task based.
                        await p.SaveAsync(new ProgressMonitor());
                    } catch (Exception ex) {
                        LoggingService.LogError("TemplateInitializationCallback error.", ex);
                    }
                };

                SolutionItem solutionEntryItem = solutionItemDescriptor.CreateItem(itemCreateInfo, this.languagename);
                if (solutionEntryItem != null)
                {
                    SavePackageReferences(solutionEntryItem, solutionItemDescriptor, itemCreateInfo);
                    solutionEntryItems.Add(solutionEntryItem);
                }
            }

            var pDesc    = this.solutionDescriptor.EntryDescriptors.OfType <ProjectDescriptor> ().FirstOrDefault();
            var metadata = new TemplateMetadata {
                Id       = Id,
                Name     = nonLocalizedName,
                Language = LanguageName,
                Platform = pDesc != null ? pDesc.ProjectType : "Unknown"
            };

            TemplateCounter.Inc(1, null, metadata);

            return(solutionEntryItems);
        }
        public override bool AddToProject(SolutionFolderItem policyParent, Project project, string language, string directory, string name)
        {
            ProjectFile file = template.AddFileToProject(policyParent, project, language, directory, name);

            if (file != null)
            {
                file.BuildAction           = BuildAction.Content;
                file.CopyToOutputDirectory = mode;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #11
0
		void NotifyItemRemovedFromSolutionRec (object sender, SolutionFolderItem e, Solution sol, SolutionItemChangeEventArgs originalArgs)
		{
			if (e == IdeApp.ProjectOperations.CurrentSelectedSolutionItem)
				IdeApp.ProjectOperations.CurrentSelectedSolutionItem = null;
				
			if (e is SolutionFolder) {
				foreach (SolutionFolderItem ce in ((SolutionFolder)e).Items)
					NotifyItemRemovedFromSolutionRec (sender, ce, sol, null);
			}

			// For the root item send the original args, since they contain reload information

			if (ItemRemovedFromSolution != null)
				ItemRemovedFromSolution (sender, originalArgs ?? new SolutionItemChangeEventArgs (e, sol, false));
		}
 public static void Install(SolutionFolderItem entry, ConfigurationSelector configuration)
 {
     using (ProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor()) {
         InstallDialog dlg = new InstallDialog(entry);
         try {
             if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok)
             {
                 DeployService.Install(mon, entry, dlg.Prefix, dlg.AppName, configuration);
             }
         } finally {
             dlg.Destroy();
             dlg.Dispose();
         }
     }
 }
Beispiel #13
0
        public static void CreateFileFromTemplate(Project project, SolutionFolderItem policyItem, FilePath templateSourceDirectory, string fileTemplateName)
        {
            string templateFileName = templateSourceDirectory.Combine(fileTemplateName + ".xft.xml");

            using (Stream stream = File.OpenRead(templateFileName)) {
                var document = new XmlDocument();
                document.Load(stream);

                foreach (XmlElement templateElement in document.DocumentElement["TemplateFiles"].ChildNodes.OfType <XmlElement> ())
                {
                    var template = FileDescriptionTemplate.CreateTemplate(templateElement, templateSourceDirectory);
                    template.AddToProject(policyItem, project, "C#", project.BaseDirectory, null);
                }
            }
        }
Beispiel #14
0
        // Returns the name of the file that this template generates.
        // All parameters are optional (can be null)
        public virtual string GetFileName(SolutionFolderItem policyParent, Project project, string language, string baseDirectory, string entryName)
        {
            if (string.IsNullOrEmpty(entryName) && !string.IsNullOrEmpty(defaultName))
            {
                entryName = defaultName;
            }

            string fileName = entryName;

            //substitute tags
            if ((name != null) && (name.Length > 0))
            {
                //checks if the entryName contains the extension (i.e. added explicitly with the name)
                var identifier = entryName ?? name;
                if (identifier.EndsWith(Path.GetExtension(name), StringComparison.OrdinalIgnoreCase))
                {
                    identifier = Path.GetFileNameWithoutExtension(identifier);
                }
                var model = CombinedTagModel.GetTagModel(ProjectTagModel, policyParent, project, language, identifier, fileName);
                fileName = StringParserService.Parse(name, model);
            }

            if (fileName == null)
            {
                throw new InvalidOperationException(GettextCatalog.GetString("File name not provided in template"));
            }

            //give it an extension if it didn't get one (compatibility with pre-substition behaviour)
            if (Path.GetExtension(fileName).Length == 0)
            {
                if (defaultExtensionDefined)
                {
                    fileName = fileName + defaultExtension;
                }
                else if (!string.IsNullOrEmpty(language))
                {
                    var languageBinding = GetLanguageBinding(language);
                    fileName = languageBinding.GetFileName(fileName);
                }
            }

            if (baseDirectory != null)
            {
                fileName = Path.Combine(baseDirectory, fileName);
            }

            return(fileName);
        }
        void ActiveToggled(object sender, ToggledArgs e)
        {
            TreeIter iter;

            if (store.GetIterFromString(out iter, e.Path))
            {
                bool isTogglod           = (bool)store.GetValue(iter, 1);
                SolutionFolderItem entry = (SolutionFolderItem)store.GetValue(iter, 3);
                if (entry is Project)
                {
                    TranslationProjectInformation info = project.GetProjectInformation(entry, true);
                    info.IsIncluded = !isTogglod;
                    store.SetValue(iter, 1, !isTogglod);
                }
            }
        }
Beispiel #16
0
 public TranslationProjectInformation GetProjectInformation(SolutionFolderItem entry, bool force)
 {
     foreach (TranslationProjectInformation info in this.projectInformations)
     {
         if (info.ProjectName == entry.Name)
         {
             return(info);
         }
     }
     if (force)
     {
         TranslationProjectInformation newInfo = new TranslationProjectInformation(entry.Name);
         this.projectInformations.Add(newInfo);
         return(newInfo);
     }
     return(null);
 }
Beispiel #17
0
        internal static SolutionFolderItem GetCommonSolutionItem(IEnumerable <SolutionFolderItem> entries)
        {
            SolutionFolderItem common = null;

            foreach (SolutionFolderItem it in entries)
            {
                if (common == null)
                {
                    common = it;
                }
                else
                {
                    return(it.ParentSolution.RootFolder);
                }
            }
            return(common);
        }
Beispiel #18
0
        public static PackageBuilder[] GetSupportedPackageBuilders(SolutionFolderItem entry)
        {
            object[]  builders = AddinManager.GetExtensionObjects("/MonoDevelop/DeployService/PackageBuilders", false);
            ArrayList list     = new ArrayList();

            foreach (PackageBuilder builder in builders)
            {
                if (builder.CanBuild(entry))
                {
                    PackageBuilder b = builder.Clone();
                    b.InitializeSettings(entry);
                    list.Add(b);
                }
            }

            return((PackageBuilder[])list.ToArray(typeof(PackageBuilder)));
        }
Beispiel #19
0
            public override Stream CreateFileContent(SolutionFolderItem policyParent, Project project, string language, string fileName, string identifier)
            {
                if (Outer.FormatCode)
                {
                    return(base.CreateFileContent(policyParent, project, language, fileName, identifier));
                }

                var    model = GetTagModel(policyParent, project, language, identifier, fileName);
                string text  = CreateContent(project, model.OverrideTags, language);

                text = ProcessContent(text, model);
                var memoryStream = new MemoryStream();

                byte[] preamble = Encoding.UTF8.GetPreamble();
                memoryStream.Write(preamble, 0, preamble.Length);
                if (AddStandardHeader)
                {
                    string header = StandardHeaderService.GetHeader(policyParent, fileName, true);
                    byte[] bytes  = Encoding.UTF8.GetBytes(header);
                    memoryStream.Write(bytes, 0, bytes.Length);
                }

                var textDocument = TextEditorFactory.CreateNewDocument();

                //var textDocument = new TextDocument ();
                textDocument.Text = text;
                var    textStylePolicy = (policyParent == null) ? PolicyService.GetDefaultPolicy <TextStylePolicy> ("text/plain") : policyParent.Policies.Get <TextStylePolicy> ("text/plain");
                string eolMarker       = TextStylePolicy.GetEolMarker(textStylePolicy.EolMarker);

                byte[] eol    = Encoding.UTF8.GetBytes(eolMarker);
                string indent = (!textStylePolicy.TabsToSpaces) ? null : new string (' ', textStylePolicy.TabWidth);

                foreach (var current in textDocument.GetLines())
                {
                    string line = textDocument.GetTextAt(current.Offset, current.Length);
                    if (indent != null)
                    {
                        line = line.Replace("	", indent);
                    }
                    byte[] bytes = Encoding.UTF8.GetBytes(line);
                    memoryStream.Write(bytes, 0, bytes.Length);
                    memoryStream.Write(eol, 0, eol.Length);
                }
                memoryStream.Position = 0;
                return(memoryStream);
            }
        // Creates a file and saves it to disk. Returns the path to the new file
        // All parameters are optional (can be null)
        public string SaveFile(SolutionFolderItem policyParent, Project project, string language, string baseDirectory, string entryName)
        {
            string      file           = GetFileName(policyParent, project, language, baseDirectory, entryName);
            AlertButton questionResult = null;

            if (File.Exists(file))
            {
                questionResult = MessageService.AskQuestion(GettextCatalog.GetString("File already exists"),
                                                            GettextCatalog.GetString("File {0} already exists.\nDo you want to overwrite the existing file or add it to the project?", file),
                                                            AlertButton.Cancel,
                                                            AlertButton.AddExistingFile,
                                                            AlertButton.OverwriteFile);
                if (questionResult == AlertButton.Cancel)
                {
                    return(null);
                }
            }

            if (!Directory.Exists(Path.GetDirectoryName(file)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(file));
            }

            if (questionResult == null || questionResult == AlertButton.OverwriteFile)
            {
                Stream stream = CreateFileContent(policyParent, project, language, file, entryName);

                byte []    buffer = new byte [2048];
                int        nr;
                FileStream fs = null;
                try {
                    fs = File.Create(file);
                    while ((nr = stream.Read(buffer, 0, 2048)) > 0)
                    {
                        fs.Write(buffer, 0, nr);
                    }
                } finally {
                    stream.Close();
                    if (fs != null)
                    {
                        fs.Close();
                    }
                }
            }
            return(file);
        }
Beispiel #21
0
        protected virtual bool CreateFile(FileDescriptionTemplate newfile, SolutionFolderItem policyParent, Project project, string directory, string language, string name)
        {
            if (project != null)
            {
                var model = project.GetStringTagModel(new DefaultConfigurationSelector());
                newfile.SetProjectTagModel(model);
                try {
                    if (newfile.AddToProject(policyParent, project, language, directory, name))
                    {
                        newfile.Show();
                        return(true);
                    }
                } finally {
                    newfile.SetProjectTagModel(null);
                }
            }
            else
            {
                var singleFile = newfile as SingleFileDescriptionTemplate;
                if (singleFile == null)
                {
                    throw new InvalidOperationException("Single file template expected");
                }

                if (directory != null)
                {
                    string fileName = singleFile.SaveFile(policyParent, project, language, directory, name);
                    if (fileName != null)
                    {
                        IdeApp.Workbench.OpenDocument(fileName, project);
                        return(true);
                    }
                }
                else
                {
                    string fileName = singleFile.GetFileName(policyParent, project, language, directory, name);
                    Stream stream   = singleFile.CreateFileContent(policyParent, project, language, fileName, name);

                    string mimeType = GuessMimeType(fileName);
                    IdeApp.Workbench.NewDocument(fileName, mimeType, stream);
                    return(true);
                }
            }
            return(false);
        }
Beispiel #22
0
        public void LoadFrom(ChangeLogPolicy policy)
        {
            switch (policy.UpdateMode)
            {
            case ChangeLogUpdateMode.None:
                noneRadioButton.Active = true;
                break;

            case ChangeLogUpdateMode.Nearest:
                nearestRadioButton.Active = true;
                break;

            case ChangeLogUpdateMode.ProjectRoot:
                oneChangeLogInProjectRootDirectoryRadioButton.Active = true;
                break;

            case ChangeLogUpdateMode.Directory:
                oneChangeLogInEachDirectoryRadioButton.Active = true;
                break;
            }

            checkVersionControl.Active  = policy.VcsIntegration != VcsIntegration.None;
            checkRequireOnCommit.Active = policy.VcsIntegration == VcsIntegration.RequireEntry;

            style = new CommitMessageStyle();
            style.CopyFrom(policy.MessageStyle);

            var format = new CommitMessageFormat();

            format.MaxColumns = 70;
            format.Style      = style;

            SolutionFolderItem item = null;

            if (parent.ConfiguredSolutionItem != null)
            {
                item = parent.ConfiguredSolutionItem;
            }
            else if (parent.ConfiguredSolution != null)
            {
                item = parent.ConfiguredSolution.RootFolder;
            }

            messageWidget.Load(format, item != null ? item.AuthorInformation : AuthorInformation.Default);
        }
Beispiel #23
0
 public virtual bool Create(SolutionFolderItem policyParent, Project project, string directory, string language, string name)
 {
     if (!String.IsNullOrEmpty(WizardPath))
     {
         return(false);
     }
     else
     {
         foreach (FileDescriptionTemplate newfile in Files)
         {
             if (!CreateFile(newfile, policyParent, project, directory, language, name))
             {
                 return(false);
             }
         }
         return(true);
     }
 }
Beispiel #24
0
        public override void ModifyTags(SolutionFolderItem policyParent, Project project, string language, string identifier, string fileName, ref Dictionary <string, string> tags)
        {
            //prevent parser breakage from missing tags, which SingleFile only provides for DotNetProject
            //if ((project as DotNetProject) == null)
            //	throw new InvalidOperationException ("CodeTranslationFileDescriptionTemplate can only be used with a DotNetProject");

            base.ModifyTags(policyParent, project, language, identifier, fileName, ref tags);

            //swap out the escaped keyword identifiers for the target language with the source language
            //CodeDOM should take care of handling it for the target language
            System.CodeDom.Compiler.CodeDomProvider provider = GetCodeDomProvider(sourceLang);
            tags ["EscapedIdentifier"] = provider.CreateEscapedIdentifier((string)tags ["Name"]);

            //This is a bit hacky doing it here instead of in CreateContent, but need to
            //substitute all tags in code before language is translated, because language
            //translation gets confused by unsubstituted  substitution tokens.
            tempSubstitutedContent = StringParserService.Parse(content, tags);
        }
Beispiel #25
0
        public void AddEntry(SolutionFolderItem entry)
        {
            SolutionItemReference fp = new SolutionItemReference(entry);

            foreach (SolutionItemReference s in childEntries)
            {
                if (s.Equals(fp))
                {
                    return;
                }
            }

            if (rootEntry == fp)
            {
                return;
            }

            List <SolutionFolderItem> list = new List <SolutionFolderItem> ();

            if (RootSolutionItem != null)
            {
                list.Add(RootSolutionItem);
            }
            list.AddRange(GetChildEntries());
            list.Add(entry);

            rootSolutionItem = GetCommonSolutionItem(list);
            list.Remove(rootSolutionItem);

            foreach (SolutionFolderItem e in list.ToArray())
            {
                SolutionFolderItem ce = e.ParentFolder;
                while (ce != rootSolutionItem)
                {
                    if (!list.Contains(ce))
                    {
                        list.Add(ce);
                    }
                    ce = ce.ParentFolder;
                }
            }
            childCombineEntries = list;
            UpdateEntryNames();
        }
 public virtual DeployFileCollection GetDeployFiles(DeployContext ctx, SolutionFolderItem entry, ConfigurationSelector configuration)
 {
     if (entry is SolutionFolder)
     {
         return(GetCombineDeployFiles(ctx, (SolutionFolder)entry, configuration));
     }
     else if (entry is Project)
     {
         return(GetProjectDeployFiles(ctx, (Project)entry, configuration));
     }
     else if (Next != null)
     {
         return(Next.GetDeployFiles(ctx, entry, configuration));
     }
     else
     {
         return(new DeployFileCollection());
     }
 }
Beispiel #27
0
        public SolutionFolderItem[] GetChildEntries()
        {
            if (childCombineEntries != null)
            {
                return(childCombineEntries.ToArray());
            }

            childCombineEntries = new List <SolutionFolderItem> ();

            foreach (SolutionItemReference en in childEntries)
            {
                SolutionFolderItem re = GetEntry(en);
                if (re != null && !(re is UnknownSolutionItem))
                {
                    childCombineEntries.Add(re);
                }
            }
            return(childCombineEntries.ToArray());
        }
Beispiel #28
0
        void OnToggled(object sender, Gtk.ToggledArgs args)
        {
            TreeIter iter;

            store.GetIterFromString(out iter, args.Path);
            SolutionFolderItem ob = (SolutionFolderItem)store.GetValue(iter, 2);

            if (selectedEntries.ContainsKey(ob))
            {
                selectedEntries.Remove(ob);
                store.SetValue(iter, 3, false);
                if (ob is SolutionFolder)
                {
                    foreach (SolutionFolderItem e in ((SolutionFolder)ob).GetAllItems())
                    {
                        selectedEntries.Remove(e);
                    }
                    UpdateSelectionChecks(TreeIter.Zero, false);
                }
            }
            else
            {
                selectedEntries [ob] = ob;
                store.SetValue(iter, 3, true);
                if (ob is SolutionFolder)
                {
                    foreach (SolutionFolderItem e in ((SolutionFolder)ob).GetAllItems())
                    {
                        if (builder.CanBuild(e))
                        {
                            selectedEntries [e] = e;
                        }
                    }
                    UpdateSelectionChecks(TreeIter.Zero, false);
                }
                SelectCommonCombine((SolutionFolderItem)ob);
            }
            if (SelectionChanged != null)
            {
                SelectionChanged(this, EventArgs.Empty);
            }
        }
Beispiel #29
0
        // Returns the name of the file that this template generates.
        // All parameters are optional (can be null)
        public virtual string GetFileName(SolutionFolderItem policyParent, Project project, string language, string baseDirectory, string entryName)
        {
            if (string.IsNullOrEmpty(entryName) && !string.IsNullOrEmpty(defaultName))
            {
                entryName = defaultName;
            }

            string fileName = entryName;

            //substitute tags
            if ((name != null) && (name.Length > 0))
            {
                var model = CombinedTagModel.GetTagModel(ProjectTagModel, policyParent, project, language, entryName ?? name, null);
                fileName = StringParserService.Parse(name, model);
            }

            if (fileName == null)
            {
                throw new InvalidOperationException("File name not provided in template");
            }

            //give it an extension if it didn't get one (compatibility with pre-substition behaviour)
            if (Path.GetExtension(fileName).Length == 0)
            {
                if (defaultExtensionDefined)
                {
                    fileName = fileName + defaultExtension;
                }
                else if (!string.IsNullOrEmpty(language))
                {
                    var languageBinding = GetLanguageBinding(language);
                    fileName = languageBinding.GetFileName(fileName);
                }
            }

            if (baseDirectory != null)
            {
                fileName = Path.Combine(baseDirectory, fileName);
            }

            return(fileName);
        }
Beispiel #30
0
        public SolutionFolderItem[] GetSelectedChildren()
        {
            // The first entry is the root entry
            SolutionFolderItem common = GetCommonSolutionItem();

            if (common == null)
            {
                return(null);
            }
            ArrayList list = new ArrayList();

            foreach (SolutionFolderItem e in selectedEntries.Keys)
            {
                if (e != common)
                {
                    list.Add(e);
                }
            }
            return((SolutionFolderItem[])list.ToArray(typeof(SolutionFolderItem)));
        }
Beispiel #31
0
		public PolicyBag (SolutionFolderItem owner)
		{
			this.Owner = owner;
		}