internal static void RemoveCustomCommand(SolutionEntityItem project, CustomExecutionMode cmode)
        {
            CustomExecutionModes modes = GetCustomExecutionModeList(project, cmode.Scope);

            modes.Data.Remove(cmode);
            if (cmode.Scope == CustomModeScope.Global)
            {
                SaveGlobalCustomExecutionModes();
            }
            else
            {
                IdeApp.Workspace.SavePreferences();
            }
        }
Esempio n. 2
0
 internal static IEnumerable <CustomExecutionMode> GetCustomModes(CommandExecutionContext ctx)
 {
     if (ctx.Project != null)
     {
         CustomExecutionModes modes = ctx.Project.UserProperties.GetValue <CustomExecutionModes> ("MonoDevelop.Ide.CustomExecutionModes", GetDataContext());
         if (modes != null)
         {
             foreach (CustomExecutionMode mode in modes.Data)
             {
                 mode.Project = ctx.Project;
                 if (ctx.CanExecute(mode.ExecutionHandler))
                 {
                     mode.Scope = CustomModeScope.Project;
                     yield return(mode);
                 }
             }
         }
         modes = ctx.Project.ParentSolution.UserProperties.GetValue <CustomExecutionModes> ("MonoDevelop.Ide.CustomExecutionModes", GetDataContext());
         if (modes != null)
         {
             foreach (CustomExecutionMode mode in modes.Data)
             {
                 mode.Project = ctx.Project;
                 if (ctx.CanExecute(mode.ExecutionHandler))
                 {
                     mode.Scope = CustomModeScope.Solution;
                     yield return(mode);
                 }
             }
         }
     }
     foreach (CustomExecutionMode mode in GetGlobalCustomExecutionModes().Data)
     {
         if (ctx.CanExecute(mode.ExecutionHandler))
         {
             mode.Scope = CustomModeScope.Global;
             yield return(mode);
         }
     }
 }
Esempio n. 3
0
        static CustomExecutionModes GetGlobalCustomExecutionModes()
        {
            if (globalModes == null)
            {
                try {
                    XmlDataSerializer ser  = new XmlDataSerializer(GetDataContext());
                    FilePath          file = UserProfile.Current.ConfigDir.Combine("custom-command-modes.xml");
                    if (File.Exists(file))
                    {
                        globalModes = (CustomExecutionModes)ser.Deserialize(file, typeof(CustomExecutionModes));
                    }
                } catch (Exception ex) {
                    LoggingService.LogError("Could not load global custom execution modes.", ex);
                }

                if (globalModes == null)
                {
                    globalModes = new CustomExecutionModes();
                }
            }
            return(globalModes);
        }
        static CustomExecutionModes GetGlobalCustomExecutionModes()
        {
            if (globalModes == null) {
                try {
                    XmlDataSerializer ser = new XmlDataSerializer (GetDataContext ());
                    FilePath file = UserProfile.Current.ConfigDir.Combine ("custom-command-modes.xml");
                    if (File.Exists (file))
                        globalModes = (CustomExecutionModes) ser.Deserialize (file, typeof(CustomExecutionModes));
                } catch (Exception ex) {
                    LoggingService.LogError ("Could not load global custom execution modes.", ex);
                }

                if (globalModes == null)
                    globalModes = new CustomExecutionModes ();
            }
            return globalModes;
        }
        static CustomExecutionModes GetCustomExecutionModeList(SolutionEntityItem project, CustomModeScope scope)
        {
            CustomExecutionModes modes;
            if (scope == CustomModeScope.Global) {
                modes = GetGlobalCustomExecutionModes ();
            }
            else {
                PropertyBag props;
                if (scope == CustomModeScope.Project)
                    props = project.UserProperties;
                else
                    props = project.ParentSolution.UserProperties;

                if (props.HasValue ("MonoDevelop.Ide.CustomExecutionModes"))
                    modes = props.GetValue<CustomExecutionModes> ("MonoDevelop.Ide.CustomExecutionModes", GetDataContext ());
                else {
                    modes = new CustomExecutionModes ();
                    props.SetValue<CustomExecutionModes> ("MonoDevelop.Ide.CustomExecutionModes", modes);
                }
            }
            return modes;
        }