using System.Runtime.InteropServices;
using Microsoft.CommandPalette.Extensions;

namespace Olive;

[Guid("C7B0BF27-81E6-4A25-B6F7-F11AB1F61C0A")]
public sealed partial class OliveExtension : IExtension, IDisposable
{
  private readonly ManualResetEvent _extensionDisposedEvent;

  private readonly OliveCommandsProvider _provider = new();

  public OliveExtension(ManualResetEvent extensionDisposedEvent)
  {
    _extensionDisposedEvent = extensionDisposedEvent;
  }

  public object? GetProvider(ProviderType providerType)
  {
    return providerType switch
    {
      ProviderType.Commands => _provider,
      _ => null
    };
  }

  public void Dispose()
  {
    _extensionDisposedEvent.Set();
  }
}
