|
| 1 | +// Copyright (c) Microsoft Corporation. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +using System; |
| 5 | +using System.Collections.Generic; |
| 6 | +using System.Threading.Tasks; |
| 7 | +using Microsoft.Windows.CommandPalette.Extensions; |
| 8 | +using Windows.ApplicationModel; |
| 9 | + |
| 10 | +namespace Microsoft.CmdPal.Common.Services; |
| 11 | + |
| 12 | +public interface IExtensionWrapper |
| 13 | +{ |
| 14 | + /// <summary> |
| 15 | + /// Gets the DisplayName of the package as mentioned in the manifest |
| 16 | + /// </summary> |
| 17 | + string PackageDisplayName { get; } |
| 18 | + |
| 19 | + /// <summary> |
| 20 | + /// Gets DisplayName of the extension as mentioned in the manifest |
| 21 | + /// </summary> |
| 22 | + string ExtensionDisplayName { get; } |
| 23 | + |
| 24 | + /// <summary> |
| 25 | + /// Gets PackageFullName of the extension |
| 26 | + /// </summary> |
| 27 | + string PackageFullName { get; } |
| 28 | + |
| 29 | + /// <summary> |
| 30 | + /// Gets PackageFamilyName of the extension |
| 31 | + /// </summary> |
| 32 | + string PackageFamilyName { get; } |
| 33 | + |
| 34 | + /// <summary> |
| 35 | + /// Gets Publisher of the extension |
| 36 | + /// </summary> |
| 37 | + string Publisher { get; } |
| 38 | + |
| 39 | + /// <summary> |
| 40 | + /// Gets class id (GUID) of the extension class (which implements IExtension) as mentioned in the manifest |
| 41 | + /// </summary> |
| 42 | + string ExtensionClassId { get; } |
| 43 | + |
| 44 | + /// <summary> |
| 45 | + /// Gets the date on which the application package was installed or last updated. |
| 46 | + /// </summary> |
| 47 | + DateTimeOffset InstalledDate { get; } |
| 48 | + |
| 49 | + /// <summary> |
| 50 | + /// Gets the PackageVersion of the extension |
| 51 | + /// </summary> |
| 52 | + PackageVersion Version { get; } |
| 53 | + |
| 54 | + /// <summary> |
| 55 | + /// Gets the Unique Id for the extension |
| 56 | + /// </summary> |
| 57 | + public string ExtensionUniqueId { get; } |
| 58 | + |
| 59 | + /// <summary> |
| 60 | + /// Checks whether we have a reference to the extension process and we are able to call methods on the interface. |
| 61 | + /// </summary> |
| 62 | + /// <returns>Whether we have a reference to the extension process and we are able to call methods on the interface.</returns> |
| 63 | + bool IsRunning(); |
| 64 | + |
| 65 | + /// <summary> |
| 66 | + /// Starts the extension if not running |
| 67 | + /// </summary> |
| 68 | + /// <returns>An awaitable task</returns> |
| 69 | + Task StartExtensionAsync(); |
| 70 | + |
| 71 | + /// <summary> |
| 72 | + /// Signals the extension to dispose itself and removes the reference to the extension com object |
| 73 | + /// </summary> |
| 74 | + void SignalDispose(); |
| 75 | + |
| 76 | + /// <summary> |
| 77 | + /// Gets the underlying instance of IExtension |
| 78 | + /// </summary> |
| 79 | + /// <returns>Instance of IExtension</returns> |
| 80 | + IExtension? GetExtensionObject(); |
| 81 | + |
| 82 | + /// <summary> |
| 83 | + /// Tells the wrapper that the extension implements the given provider |
| 84 | + /// </summary> |
| 85 | + /// <param name="providerType">The type of provider to be added</param> |
| 86 | + void AddProviderType(ProviderType providerType); |
| 87 | + |
| 88 | + /// <summary> |
| 89 | + /// Checks whether the given provider was added through `AddProviderType` method |
| 90 | + /// </summary> |
| 91 | + /// <param name="providerType">The type of the provider to be checked for</param> |
| 92 | + /// <returns>Whether the given provider was added through `AddProviderType` method</returns> |
| 93 | + bool HasProviderType(ProviderType providerType); |
| 94 | + |
| 95 | + /// <summary> |
| 96 | + /// Starts the extension if not running and gets the provider from the underlying IExtension object |
| 97 | + /// Can be null if not found |
| 98 | + /// </summary> |
| 99 | + /// <typeparam name="T">The type of provider</typeparam> |
| 100 | + /// <returns>Nullable instance of the provider</returns> |
| 101 | + Task<T?> GetProviderAsync<T>() |
| 102 | + where T : class; |
| 103 | + |
| 104 | + /// <summary> |
| 105 | + /// Starts the extension if not running and gets a list of providers of type T from the underlying IExtension object. |
| 106 | + /// If no providers are found, returns an empty list. |
| 107 | + /// </summary> |
| 108 | + /// <typeparam name="T">The type of provider</typeparam> |
| 109 | + /// <returns>Nullable instance of the provider</returns> |
| 110 | + Task<IEnumerable<T>> GetListOfProvidersAsync<T>() |
| 111 | + where T : class; |
| 112 | +} |
0 commit comments