Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 2
0
 public override void OnEnabled()
 {
     if (!_loaded && Plugin == null)
     {
         LoadPlugin();
     }
     if (Plugin != null)
     {
         InjectedOnEnabled?.Invoke(Plugin, null);
     }
 }