alielie
2026-06-04 771a0e7b6b1276087515bbe94de28358cb92963b
HMI.Core/Api/PluginPackage.cs
@@ -3,7 +3,6 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using System.Web.UI.WebControls;
namespace HMI.Core.Api
{
@@ -12,7 +11,7 @@
        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 null) return null;
            if (obj is IPlugin plugin)
            {
                return plugin;
@@ -34,6 +33,8 @@
        private MethodInfo OnTabChangeMethod;
        private MethodInfo SetBaseFolderMethod;
        private MethodInfo SetLoggerMethod;
        private MethodInfo CanDeActiveMethod;
        private MethodInfo CanActiveMethod;
        public PluginPackage(object content)
        {
@@ -47,6 +48,8 @@
            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()
@@ -93,5 +96,15 @@
        {
            SetLoggerMethod?.Invoke(Content, new object[] { logger });
        }
        public bool CanActive()
        {
            return (bool)CanActiveMethod?.Invoke(Content, null);
        }
        public bool CanDeActive()
        {
            return (bool)CanDeActiveMethod?.Invoke(Content, null);
        }
    }
}