예제 #1
0
        /// <summary>
        /// Apply the renaming of a grouped script to all items in the group.
        /// </summary>
        /// <param name="projectItem">The project item renamed.</param>
        /// <param name="oldName">The old name of the project item</param>
        public static void OnRename(ProjectItem projectItem, string oldName)
        {
            if (isRenaming)
            {
                return;
            }

            SettingsManager settingsManager = SettingsManager.GetInstance(projectItem.DTE);
            ScriptParameter scriptParameter = settingsManager.CurrentScriptParameter;

            if (!FileClassification.IsSqlScript(scriptParameter, oldName))
            {
                return;
            }

            if (projectItem.ProjectItems == null || projectItem.ProjectItems.Count == 0)
            {
                return;
            }

            string oldStem = Path.GetFileNameWithoutExtension(oldName);
            string newName = projectItem.get_FileNames(1);
            string newStem = Path.GetFileNameWithoutExtension(newName);

            if (newStem.ToLowerInvariant().EndsWith(".all"))
            {
                newStem = Path.GetFileNameWithoutExtension(newStem);
            }

            isRenaming = true;
            try {
                projectItem.DTE.SuppressUI = true;
                foreach (ProjectItem subItem in projectItem.ProjectItems)
                {
                    RenameSubItem(subItem, oldStem, newStem);
                }
            }
            finally {
                projectItem.DTE.SuppressUI = false;
                isRenaming = false;
            }
        }
예제 #2
0
        public override bool CanExecute(VsCommandEventArgs e)
        {
            if (IsExecuting)
            {
                return(false);
            }

            DTE2     application    = e.Application;
            Document activeDocument = application.ActiveDocument;

            if (activeDocument == null)
            {
                return(false);
            }

            SettingsManager settingsManager = SettingsManager.GetInstance(application);
            ScriptParameter scriptParameter = settingsManager.CurrentScriptParameter;

            string fileName    = activeDocument.FullName;
            bool   isSqlScript = FileClassification.IsSqlScript(scriptParameter, fileName);

            return(isSqlScript);
        }