Add IApp & AppExtensions for accessing the properties & functions from anywhere in the application

This commit is contained in:
Jack251970 2025-01-09 21:43:33 +08:00
parent 20ffff6d1b
commit 8b910500c6
2 changed files with 28 additions and 0 deletions

View file

@ -0,0 +1,15 @@
using System.Windows;
using Flow.Launcher.Plugin;
namespace Flow.Launcher.Core;
/// <summary>
/// Extension properties and functions of the current application singleton object.
/// </summary>
public static class AppExtensions
{
/// <summary>
/// Gets the public API of the current application singleton object.
/// </summary>
public static IPublicAPI API => (Application.Current as IApp)!.PublicAPI;
}

View file

@ -0,0 +1,13 @@
using Flow.Launcher.Plugin;
namespace Flow.Launcher.Core
{
/// <summary>
/// Interface for the current application singleton object exposing the properties
/// and functions that can be accessed from anywhere in the application.
/// </summary>
public interface IApp
{
public IPublicAPI PublicAPI { get; }
}
}