SampleExtension.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System; 6 using System.Runtime.InteropServices; 7 using System.Threading; 8 using Microsoft.CommandPalette.Extensions; 9 10 namespace ProcessMonitorExtension; 11 12 [ComVisible(true)] 13 [Guid("8BD7A6C4-7185-4426-AE8D-61E438A3E740")] 14 [ComDefaultInterface(typeof(IExtension))] 15 public sealed partial class SampleExtension : IExtension, IDisposable 16 { 17 private readonly ManualResetEvent _extensionDisposedEvent; 18 19 private readonly ProcessMonitorCommandProvider _provider = new(); 20 21 public SampleExtension(ManualResetEvent extensionDisposedEvent) 22 { 23 this._extensionDisposedEvent = extensionDisposedEvent; 24 } 25 26 public object GetProvider(ProviderType providerType) 27 { 28 switch (providerType) 29 { 30 case ProviderType.Commands: 31 return _provider; 32 default: 33 return null; 34 } 35 } 36 37 public void Dispose() 38 { 39 this._extensionDisposedEvent.Set(); 40 } 41 }