From 8b910500c6f3a2fe170cdc8261c6d0add722b744 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Thu, 9 Jan 2025 21:43:33 +0800
Subject: [PATCH] Add IApp & AppExtensions for accessing the properties &
functions from anywhere in the application
---
Flow.Launcher.Core/AppExtensions.cs | 15 +++++++++++++++
Flow.Launcher.Core/IApp.cs | 13 +++++++++++++
2 files changed, 28 insertions(+)
create mode 100644 Flow.Launcher.Core/AppExtensions.cs
create mode 100644 Flow.Launcher.Core/IApp.cs
diff --git a/Flow.Launcher.Core/AppExtensions.cs b/Flow.Launcher.Core/AppExtensions.cs
new file mode 100644
index 000000000..b02612d72
--- /dev/null
+++ b/Flow.Launcher.Core/AppExtensions.cs
@@ -0,0 +1,15 @@
+using System.Windows;
+using Flow.Launcher.Plugin;
+
+namespace Flow.Launcher.Core;
+
+///
+/// Extension properties and functions of the current application singleton object.
+///
+public static class AppExtensions
+{
+ ///
+ /// Gets the public API of the current application singleton object.
+ ///
+ public static IPublicAPI API => (Application.Current as IApp)!.PublicAPI;
+}
diff --git a/Flow.Launcher.Core/IApp.cs b/Flow.Launcher.Core/IApp.cs
new file mode 100644
index 000000000..233fd5ed1
--- /dev/null
+++ b/Flow.Launcher.Core/IApp.cs
@@ -0,0 +1,13 @@
+using Flow.Launcher.Plugin;
+
+namespace Flow.Launcher.Core
+{
+ ///
+ /// Interface for the current application singleton object exposing the properties
+ /// and functions that can be accessed from anywhere in the application.
+ ///
+ public interface IApp
+ {
+ public IPublicAPI PublicAPI { get; }
+ }
+}