예제 #1
0
        private static void LoadPlugin()
        {
            lock (ObjLock)
            {
                if (Plugin != null)
                {
                    return;
                }
                Plugin  = Load();
                _loaded = true;

                if (Plugin == null)
                {
                    return;
                }

                InjectedOnInitialize  = Plugin.GetType().GetMethod("OnInitialize");
                InjectedOnEnabled     = Plugin.GetType().GetMethod("OnEnabled");
                InjectedOnDisabled    = Plugin.GetType().GetMethod("OnDisabled");
                InjectedOnButtonPress = Plugin.GetType().GetMethod("OnButtonPress");
                InjectedAuthor        = Plugin.GetType().GetProperty("Author");
                InjectedVersion       = Plugin.GetType().GetProperty("Version");
                InjectedName          = Plugin.GetType().GetProperty("Name");
                InjectedWantButton    = Plugin.GetType().GetProperty("WantButton");
                InjectedButtonText    = Plugin.GetType().GetProperty("ButtonText");

                InjectedOnInitialize.Invoke(Plugin, null);
                if (PluginManager.GetEnabledPlugins().Any(n => n == "Sparrow"))
                {
                    InjectedOnEnabled.Invoke(Plugin, null);
                }
            }
        }
예제 #2
0
 public override void OnInitialize()
 {
     if (!_loaded && Plugin == null)
     {
         LoadPlugin();
     }
     if (Plugin != null)
     {
         InjectedOnInitialize?.Invoke(Plugin, null);
     }
 }