当前位置: 首页>>代码示例>>C#>>正文


C# DTE.ExecuteCommand方法代码示例

本文整理汇总了C#中DTE.ExecuteCommand方法的典型用法代码示例。如果您正苦于以下问题:C# DTE.ExecuteCommand方法的具体用法?C# DTE.ExecuteCommand怎么用?C# DTE.ExecuteCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DTE的用法示例。


在下文中一共展示了DTE.ExecuteCommand方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Restart

        internal void Restart(DTE dte, bool elevated)
        {
            var currentProcess = Process.GetCurrentProcess();

            var parser = new ArgumentParser(dte.CommandLineArguments);

            var builder = new RestartProcessBuilder()
                .WithDevenv(currentProcess.MainModule.FileName)
                .WithArguments(parser.GetArguments());

            var openedItem = GetOpenedItem(dte);
            if (openedItem != OpenedItem.None)
            {
                if (openedItem.IsSolution)
                {
                    builder.WithSolution(openedItem.Name);
                }
                else
                {
                    builder.WithProject(openedItem.Name);
                }
            }

            if (elevated)
            {
                builder.WithElevatedPermission();
            }

            const string commandName = "File.Exit";
            var closeCommand = dte.Commands.Item(commandName);

            CommandEvents closeCommandEvents = null;
            if (closeCommand != null)
            {
                closeCommandEvents = dte.Events.CommandEvents[closeCommand.Guid, closeCommand.ID];
            }

            // Install the handler
            var handler = new VisualStudioEventHandler(dte.Events.DTEEvents, closeCommandEvents, builder.Build());

            if (closeCommand != null && closeCommand.IsAvailable)
            {
                // if the Exit commad is present, execute it with all gracefulls dialogs by VS
                dte.ExecuteCommand(commandName);
            }
            else
            {
                // Close brutally
                dte.Quit();
            }
        }
开发者ID:modulexcite,项目名称:vs-restart,代码行数:51,代码来源:VisualStuioRestarter.cs

示例2: GoToDisassembly

        public void GoToDisassembly(DTE dte, String method, int offset)
        {
            Initialize(dte);
            if (s_treeview == null)
            {
                return;
            }

            // Make sure the windows are inti.alized
            DTE dteX5 = dte.Windows.Item(GuidBreakpoints).DTE;
            dte.Windows.Item(GuidDisassembly).Visible = dte.Windows.Item(GuidDisassembly).Visible;

            String address = GetAddress(method, offset);

            int countBefore = s_treeview.Count;
            Breakpoints bps = dte.Debugger.Breakpoints.Add("", "", 0, 0, "", dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue,
                "C#", "", 0, address, 0, dbgHitCountType.dbgHitCountTypeNone);
            int countAfter = s_treeview.Count;

            IntPtr selected;
            IntPtr foundItem;

            if(!FindBreakpoint(address, method, offset, out foundItem, out selected))
            {
                return;
            }

            s_treeview.Select(foundItem);

            dte.ExecuteCommand(MenuGoToDisassembly, "");

            if (countAfter > countBefore)
            {
                bps.Item(1).Delete();
            }

            s_treeview.Select(selected);

            dte.Windows.Item(GuidThreadStack).Activate();
            dte.Windows.Item(GuidDisassembly).Activate();
        }
开发者ID:mayerwin,项目名称:DebugInspector,代码行数:41,代码来源:BreakpointsWindow.cs

示例3: MigrateCustomizationProject

        private void MigrateCustomizationProject(DTE service, Project project)
        {
            Helpers.EnsureCheckout(service, project);

            Helpers.LogMessage(service, this, "*** Migrating project '" + project.Name + "' ****");

            if (Helpers2.IsSharePointVSTemplate(service, project))
            {
              try
              {
                ProjectItem packageGeneratorTT = Helpers.GetProjectItemByName(Helpers.GetProjectItemByName(project.ProjectItems, "Package").ProjectItems, "Package.Generator.tt");
                if (packageGeneratorTT != null)
                {
                  Helpers.LogMessage(service, this, "Deleting Package/Package.Generator.tt");
                  Helpers.EnsureCheckout(service, packageGeneratorTT);
                  packageGeneratorTT.Delete();
                }
              }
              catch
              {
                Helpers.LogMessage(service, this, "Warning: Could not delete Package/Package.Generator.tt");
              }

              try
              {
                ProjectItem packageGeneratorTMP = Helpers.GetProjectItemByName(Helpers.GetProjectItemByName(project.ProjectItems, "Package").ProjectItems, "Package.Generator.tmp");
                if (packageGeneratorTMP != null)
                {
                  Helpers.LogMessage(service, this, "Deleting Package/Package.Generator.tmp");
                  Helpers.EnsureCheckout(service, packageGeneratorTMP);
                  packageGeneratorTMP.Delete();
                }
              }
              catch
              {
                Helpers.LogMessage(service, this, "Warning: Could not delete Package/Package.Generator.tmp");
              }

              Helpers.LogMessage(service, this, "Settings IncludeAssemblyInPackge to True");
              try
              {
                Helpers.SetProjectPropertyGroupValue(project, "IncludeAssemblyInPackage", "True");
              }
              catch
              {
              }
            }

            //4. add property Sandboxedsolution if property is not available
            try
            {
                string testvalue = Helpers.GetProjectPropertyGroupValue(project, "Sandboxedsolution", "NOTFOUND").ToString();
                if (testvalue == "NOTFOUND")
                {
                    Helpers.LogMessage(service, this, "Updated project property 'Sandboxedsolution'");
                    Helpers.SetProjectPropertyGroupValue(project, "Sandboxedsolution", "False");
                }
            }
            catch { }

            try
            {
                string nameOfProject =  project.Name;
                //Helpers2.MoveProjectToSolutionFolder(service, project.Name, "Solutions");
               //after moving we need to get the moved project again from the name
                project = Helpers.GetProjectByName(service, nameOfProject);
            }
            catch { }

            //5. Add import to SharePoint.targets (e.g. for WSP projects)
            string fileName = project.FullName;
            Helpers.SelectProject(project);

            if (service.SuppressUI || MessageBox.Show("The project file of project " + project.Name + " must be updated. Can SPSF save and unload the project?", "Unloading project", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                service.Documents.CloseAll(vsSaveChanges.vsSaveChangesPrompt);

                try
                {
                    Helpers.LogMessage(project.DTE, this, "Updating csproj file");
                    service.ExecuteCommand("File.SaveAll", string.Empty);
                    service.ExecuteCommand("Project.UnloadProject", string.Empty);
                    MigrateFile(fileName);
                    //project.Imports.AddNewImport(@"C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.CSharp.targets", null);
                    //project.Save(fileName);
                    service.ExecuteCommand("Project.ReloadProject", string.Empty);
                }
                catch { }
            }
        }
开发者ID:sunday-out,项目名称:SharePoint-Software-Factory,代码行数:90,代码来源:MigrateSelectedProjects.cs

示例4: Invoke

 /// <summary>
 ///     Invoke menu action for the given menu item using specified operation type
 /// </summary>
 /// <param name="dte">The DTE object</param>
 /// <param name="menuItem">The menu item</param>
 /// <param name="operationType">The type of the operation, i.e., via menu command or keyboard</param>
 public static void Invoke(DTE dte, MenuItem menuItem, OperationType operationType)
 {
     switch (operationType)
     {
         case OperationType.MenuCommand:
             dte.ExecuteCommand(CommandStrings[menuItem], string.Empty);
             break;
         case OperationType.Keyboard:
             // TODO: This is not stable right now and might cause rolling build failure.
             // So it is just a placeholder for now.
             // SendKeys.SendWait(KeyStrokes[menuItem]);
             // TODO: throwing an exception if not used should be removed
             // otherwise fix verify and remove the other TODO
             throw new NotSupportedException("OperationType");
         default:
             throw new NotSupportedException("OperationType");
     }
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:24,代码来源:DesignerUtilities.cs

示例5: SaveAllFiles

 public static void SaveAllFiles(DTE dte)
 {
     dte.ExecuteCommand("File.SaveAll");
 }
开发者ID:sboulema,项目名称:TGit,代码行数:4,代码来源:FileHelper.cs


注:本文中的DTE.ExecuteCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。