From d5f83cf5f89180a5a1a4140a7634e4eead17e9fd Mon Sep 17 00:00:00 2001 From: Kamil Kosek Date: Fri, 23 Jun 2017 14:27:59 +0200 Subject: [PATCH] Implement GetCommands() on $psEditor --- .../Extensions/EditorObject.cs | 8 ++++++++ .../Extensions/ExtensionService.cs | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/PowerShellEditorServices/Extensions/EditorObject.cs b/src/PowerShellEditorServices/Extensions/EditorObject.cs index ecd387308..54605ebd4 100644 --- a/src/PowerShellEditorServices/Extensions/EditorObject.cs +++ b/src/PowerShellEditorServices/Extensions/EditorObject.cs @@ -90,6 +90,14 @@ public void UnregisterCommand(string commandName) this.extensionService.UnregisterCommand(commandName); } + /// + /// Returns all registered EditorCommands. + /// + /// An Array of all registered EditorCommands. + public EditorCommand[] GetCommands() + { + return this.extensionService.GetCommands(); + } /// /// Gets the EditorContext which contains the state of the editor /// at the time this method is invoked. diff --git a/src/PowerShellEditorServices/Extensions/ExtensionService.cs b/src/PowerShellEditorServices/Extensions/ExtensionService.cs index ceb7245f6..82b948931 100644 --- a/src/PowerShellEditorServices/Extensions/ExtensionService.cs +++ b/src/PowerShellEditorServices/Extensions/ExtensionService.cs @@ -170,6 +170,16 @@ public void UnregisterCommand(string commandName) } } + /// + /// Returns all registered EditorCommands. + /// + /// An Array of all registered EditorCommands. + public EditorCommand[] GetCommands() + { + EditorCommand[] commands = new EditorCommand[this.editorCommands.Count]; + this.editorCommands.Values.CopyTo(commands,0); + return commands; + } #endregion #region Events