/ src / modules / cmdpal / ext / SamplePagesExtension / SampleExtension.cs
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 SamplePagesExtension;
11  
12  [ComVisible(true)]
13  [Guid("6112D28D-6341-45C8-92C3-83ED55853A9F")]
14  [ComDefaultInterface(typeof(IExtension))]
15  public sealed partial class SampleExtension : IExtension, IDisposable
16  {
17      private readonly ManualResetEvent _extensionDisposedEvent;
18  
19      private readonly SamplePagesCommandsProvider _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  }