/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param name='commandName'>The name of the command to execute.</param> /// <param name='executeOption'>Describes how the command should be run.</param> /// <param name='varIn'>Parameters passed from the caller to the command handler.</param> /// <param name='varOut'>Parameters passed from the command handler to the caller.</param> /// <param name='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (commandName == HideSourceCommandName) { handled = true; var doc = _applicationObject.ActiveDocument; if (doc == null) { return; } string lineComment = GetLineComment(doc.Language); if (lineComment == null) { return; } TextDocument textDoc = (TextDocument)doc.Object("TextDocument"); if (textDoc == null) { return; } var startEditPoint = textDoc.StartPoint.CreateEditPoint(); string text = startEditPoint.GetText(textDoc.EndPoint); // TODO: Read key and IV from settings byte[] key = new byte[] { }; byte[] iv = new byte[] { }; string newText = TextHelper.EncryptOrDecryptText(text, lineComment, key, iv); if (!newText.Equals(text)) { textDoc.Selection.Cancel(); textDoc.ClearBookmarks(); startEditPoint.Delete(textDoc.EndPoint); startEditPoint.Insert(newText); } } } }