Home

Awesome

Community.PowerToys.Run.Plugin.Abstractions

build Community.PowerToys.Run.Plugin.Abstractions

This NuGet package is intended for PowerToys Run community plugins authors.

It contains abstractions for the Wox DLLs:

In other words, interfaces and wrappers for the static classes:

Installation

.NET CLI:

dotnet add package Community.PowerToys.Run.Plugin.Abstractions

Package Manager:

PM> NuGet\Install-Package Community.PowerToys.Run.Plugin.Abstractions

PackageReference:

<PackageReference Include="Community.PowerToys.Run.Plugin.Abstractions" Version="0.1.0" />

Example

<ItemGroup>
  <InternalsVisibleTo Include="Community.PowerToys.Run.Plugin.Sample.UnitTests" />
</ItemGroup>
using Community.PowerToys.Run.Plugin.Abstractions;
using static Wox.Infrastructure.Helper;
/// <summary>
/// Initializes a new instance of the <see cref="Main"/> class.
/// </summary>
public Main()
{
    Helper = new HelperWrapper();
    DefaultBrowserInfo = new DefaultBrowserInfoWrapper();
    Log = new LogWrapper();
}

internal Main(IHelper helper, IDefaultBrowserInfo defaultBrowserInfo, ILog log)
{
    Helper = helper;
    DefaultBrowserInfo = defaultBrowserInfo;
    Log = log;
}

private IHelper Helper { get; }
private IDefaultBrowserInfo DefaultBrowserInfo { get; }
private ILog Log { get; }
DefaultBrowserInfo.UpdateIfTimePassed();

if (!Helper.OpenCommandInShell(DefaultBrowserInfo.Path, DefaultBrowserInfo.ArgumentsPattern, url))
{
    Log.Error("Open default browser failed.", GetType());
    Api.ShowMsg($"Plugin: {Metadata.Name}", "Open default browser failed.");
}
[SetUp]
public void SetUp()
{
    _subject = new Main(Substitute.For<IHelper>(), Substitute.For<IDefaultBrowserInfo>(), Substitute.For<ILog>());
}

Disclaimer

This is not an official Microsoft PowerToys package.