public override void ModifyTags (SolutionFolderItem policyParent, Project project, string language, string identifier, string fileName, ref Dictionary<string,string> tags) { base.ModifyTags (policyParent, project, language, identifier, fileName, ref tags); if (fileName == null) return; tags ["AspNetMaster"] = ""; tags ["AspNetMasterContent"] = ""; var aspProj = project.GetService<AspNetAppProjectFlavor> (); if (aspProj == null) throw new InvalidOperationException ("MasterContentFileDescriptionTemplate is only valid for ASP.NET projects"); ProjectFile masterPage = null; var dialog = new MonoDevelop.Ide.Projects.ProjectFileSelectorDialog (project, null, "*.master"); try { dialog.Title = GettextCatalog.GetString ("Select a Master Page..."); int response = MonoDevelop.Ide.MessageService.RunCustomDialog (dialog); if (response == (int)Gtk.ResponseType.Ok) masterPage = dialog.SelectedFile; } finally { dialog.Destroy (); dialog.Dispose (); } if (masterPage == null) return; tags ["AspNetMaster"] = aspProj.LocalToVirtualPath (masterPage); try { var pd = TypeSystemService.ParseFile (project, masterPage.FilePath).Result as WebFormsParsedDocument; if (pd == null) return; var sb = new System.Text.StringBuilder (); foreach (string id in pd.XDocument.GetAllPlaceholderIds ()) { sb.Append ("<asp:Content ContentPlaceHolderID=\""); sb.Append (id); sb.Append ("\" ID=\""); sb.Append (id); sb.Append ("Content\" runat=\"server\">\n</asp:Content>\n"); } tags["AspNetMasterContent"] = sb.ToString (); } catch (Exception ex) { //no big loss if we just insert blank space //it's just a template for the user to start editing LoggingService.LogWarning ("Error generating AspNetMasterContent for template", ex); } }
public static GtkDesignInfo FromProject (Project project) { var ext = project.GetService<GtkProjectServiceExtension> (); if (ext != null) return ext.DesignInfo; return new GtkDesignInfo (); }
public static void DisableProject (Project project) { if (HasDesignedObjects (project)) return; GtkDesignInfo info = FromProject (project); StringCollection saveFiles = new StringCollection (); saveFiles.AddRange (new string[] {info.ObjectsFile, info.SteticFile}); info.CleanGtkFolder (saveFiles); project.Files.Remove (info.ObjectsFile); project.Files.Remove (info.SteticFile); var ext = project.GetService<GtkProjectServiceExtension> (); if (ext != null) ext.DesignInfo = null; info.Dispose (); ProjectNodeBuilder.OnSupportChanged (project); }