From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点

---
 HMI.Core/Api/PluginPackage.cs |  110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 110 insertions(+), 0 deletions(-)

diff --git a/HMI.Core/Api/PluginPackage.cs b/HMI.Core/Api/PluginPackage.cs
new file mode 100644
index 0000000..da7969e
--- /dev/null
+++ b/HMI.Core/Api/PluginPackage.cs
@@ -0,0 +1,110 @@
+锘縰sing log4net;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Reflection;
+
+namespace HMI.Core.Api
+{
+    public class PluginPackage : IPlugin
+    {
+        public static Dictionary<object, IPlugin> Cache = new Dictionary<object, IPlugin>();
+        public static IPlugin Get(object obj)
+        {
+            if (obj is null) return null;
+            if (obj is IPlugin plugin)
+            {
+                return plugin;
+            }
+            if (Cache.ContainsKey(obj)) return Cache[obj];
+            PluginPackage pluginPackage = new PluginPackage(obj);
+            Cache.Add(obj, pluginPackage);
+            return pluginPackage;
+        }
+
+        private object Content;
+
+        private MethodInfo ActiveMethod;
+        private MethodInfo DeActiveMethod;
+        private MethodInfo DoCloseMethod;
+        private MethodInfo InitMethod;
+        private MethodInfo InitFinishMethod;
+        private MethodInfo OnCloseMethod;
+        private MethodInfo OnTabChangeMethod;
+        private MethodInfo SetBaseFolderMethod;
+        private MethodInfo SetLoggerMethod;
+        private MethodInfo CanDeActiveMethod;
+        private MethodInfo CanActiveMethod;
+
+        public PluginPackage(object content)
+        {
+            this.Content = content;
+            ActiveMethod = content.GetType().GetMethod("Active");
+            DeActiveMethod = content.GetType().GetMethod("DeActive");
+            DoCloseMethod = content.GetType().GetMethod("DoClose", new Type[] { typeof(object), typeof(EventArgs) });
+            InitMethod = content.GetType().GetMethod("Init");
+            InitFinishMethod = content.GetType().GetMethod("InitFinish");
+            OnCloseMethod = content.GetType().GetMethod("OnClose", new Type[] { typeof(object), typeof(CancelEventArgs) });
+            OnTabChangeMethod = content.GetType().GetMethod("OnTabChange", new Type[] { typeof(object), typeof(object) });
+            SetBaseFolderMethod = content.GetType().GetMethod("SetBaseFolder", new Type[] { typeof(string) });
+            SetLoggerMethod = content.GetType().GetMethod("SetLogger", new Type[] { typeof(ILog) });
+            CanDeActiveMethod = content.GetType().GetMethod("CanDeActive");
+            CanActiveMethod = content.GetType().GetMethod("CanActive");
+        }
+
+        public void Active()
+        {
+            ActiveMethod?.Invoke(Content, null);
+        }
+
+        public void DeActive()
+        {
+            DeActiveMethod?.Invoke(Content, null);
+        }
+
+        public void DoClose(object sender, EventArgs e)
+        {
+            DoCloseMethod?.Invoke(Content, new object[] { sender, e });
+        }
+
+        public void Init()
+        {
+            InitMethod?.Invoke(Content, null);
+        }
+
+        public void InitFinish()
+        {
+            InitFinishMethod?.Invoke(Content, null);
+        }
+
+        public void OnClose(object sender, CancelEventArgs e)
+        {
+            OnCloseMethod?.Invoke(Content, new object[] { sender, e });
+        }
+
+        public void OnTabChange(object sender, object args)
+        {
+            OnTabChangeMethod?.Invoke(Content, new object[] { sender, args });
+        }
+
+        public void SetBaseFolder(string folder)
+        {
+            SetBaseFolderMethod?.Invoke(Content, new object[] { folder });
+        }
+
+        public void SetLogger(ILog logger)
+        {
+            SetLoggerMethod?.Invoke(Content, new object[] { logger });
+        }
+
+        public bool CanActive()
+        {
+            return (bool)CanActiveMethod?.Invoke(Content, null);
+        }
+
+        public bool CanDeActive()
+        {
+            return (bool)CanDeActiveMethod?.Invoke(Content, null);
+        }
+    }
+}

--
Gitblit v1.9.1