예제 #1
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            if (_dte == null)
            {
                return;
            }

            var solution = _dte.Solution;
            var project  = (EnvDTE.Project)((object[])_dte.ActiveSolutionProjects)[0];
            var active   = project.ConfigurationManager.ActiveConfiguration;
            var fullPath = project.FullName;

            if (File.Exists(fullPath))
            {
                try
                {
                    var stateMachine = new UserSecretStateMachine(fullPath, "UserSecretsId", this._dte, this.package);
                    // state still has next.
                    while (stateMachine.MoveNext())
                    {
                        _dte.PrintMessageLine($"current state: {stateMachine.Current}");
                        stateMachine.Command?.Execute();
                    }

                    // final command
                    _dte.PrintMessageLine($"current state: {stateMachine.Current}");
                    stateMachine.Command?.Execute();
                }
                catch (Exception ex)
                {
                    Debug.Print($"{ex.GetType().FullName}, {ex.Message}, {ex.StackTrace}");
                }
            }
        }
예제 #2
0
        public void Execute()
        {
            subCommand?.Execute();

            ThreadHelper.ThrowIfNotOnUIThread();
            dte.PrintMessageLine($"Open UserSecret file. {path}");
            dte.ExecuteCommand("File.OpenFile", path);
        }
예제 #3
0
        public void Execute()
        {
            var message = $"Detected {sdk} which include UserSecrets in Sdk.";

            dte.PrintMessageLine(message);
        }
예제 #4
0
        public void Execute()
        {
            var message = $"Please install required pacakge {package}";

            dte.PrintMessageLine(message);
        }