public void LoadPlugins() { if (CoreConfig.GetInstance().GetBoolValue("csharp", "enabled")) { foreach (string name in GetPluginNames()) { LoadPlugin(name); } } else { Logger.LogDebug("[CSharpPluginLoader] C# plugins are disabled in Core.cfg."); } }
public void LoadPlugins() { if (CoreConfig.GetInstance().GetBoolValue(PluginLoaderHelper.GetSettingName <T1>(), "enabled")) { foreach (string name in GetPluginNames()) { LoadPlugin(name); } } else { Logger.LogDebug($"[{ToString()}] {PluginLoaderHelper.GetSettingName<T1>()} is disabled in Core.cfg."); } }
public PYPlugin(string name) : base(name) { string code = File.ReadAllText(GetPluginPath()); if (CoreConfig.GetInstance().GetBoolValue("python", "checkHash") && !code.VerifyMD5Hash()) { Logger.LogDebug($"[{GetType().Name}] MD5Hash not found for: {name}"); State = PluginState.HashNotFound; return; } System.Threading.ThreadPool.QueueUserWorkItem( new System.Threading.WaitCallback(a => Load(code)), null); }
public PHPPlugin(string name) : base(name) { rpath = rootdir; if (CoreConfig.GetInstance().GetBoolValue("php", "checkHash") && !code.VerifyMD5Hash()) { Logger.LogDebug(String.Format("[Plugin] MD5Hash not found for: {0} [{1}]!", name, Type)); State = PluginState.HashNotFound; return; } System.Threading.ThreadPool.QueueUserWorkItem( new System.Threading.WaitCallback(a => Load(code)), null); }
public override void Load(string code) { try { if (CoreConfig.GetInstance().GetBoolValue("javascript", "checkHash") && !code.VerifyMD5Hash()) { Logger.LogDebug($"[{GetType().Name}] MD5Hash not found for: {Name}"); State = PluginState.HashNotFound; } else { Engine = new JintEngine(Options.Ecmascript5) .AllowClr(true); Engine.SetParameter("DataStore", DataStore.GetInstance()) .SetParameter("GlobalData", GlobalData) .SetParameter("Plugin", this) .SetParameter("Util", Util.GetInstance()) .SetParameter("Web", Web) .SetFunction("importClass", new importit(importClass)); AssignVariables(); Program = JintEngine.Compile(code, false); Globals = (from statement in Program.Statements where statement.GetType() == typeof(FunctionDeclarationStatement) select((FunctionDeclarationStatement)statement).Name).ToList(); Engine.Run(Program); object author = GetGlobalObject("Author"); object about = GetGlobalObject("About"); object version = GetGlobalObject("Version"); Author = author == null ? "" : author.ToString(); About = about == null ? "" : about.ToString(); Version = version == null ? "" : version.ToString(); State = PluginState.Loaded; } } catch (Exception ex) { Logger.LogException(ex); State = PluginState.FailedToLoad; } PluginLoader.GetInstance().OnPluginLoaded(this); }
public override void Load(string code = "") { try { if (CoreConfig.GetInstance().GetBoolValue("lua", "checkHash") && !code.VerifyMD5Hash()) { Logger.LogDebug($"[{GetType().Name}] MD5Hash not found for: {Name}"); State = PluginState.HashNotFound; } else { UserData.RegistrationPolicy = InteropRegistrationPolicy.Automatic; script = new Script(); script.Globals["Plugin"] = this; script.Globals["Util"] = Util.GetInstance(); script.Globals["DataStore"] = DataStore.GetInstance(); script.Globals["GlobalData"] = GlobalData; script.Globals["Web"] = Web.GetInstance(); AssignVariables(); script.DoString(code); Author = script.Globals.Get("Author").String; About = script.Globals.Get("About").String; Version = script.Globals.Get("Version").String; State = PluginState.Loaded; foreach (DynValue v in script.Globals.Keys) { Globals.Add(v.ToString().Replace("\"", "")); } Tables = script.Globals; } } catch (Exception ex) { Logger.LogException(ex); State = PluginState.FailedToLoad; } PluginLoader.GetInstance().OnPluginLoaded(this); }
public override void Load(string code) { try { byte[] bin = File.ReadAllBytes(code); if (CoreConfig.GetInstance().GetBoolValue("csharp", "checkHash") && !bin.VerifyMD5Hash()) { Logger.LogDebug($"[{GetType().Name}] MD5Hash not found for: {Name}"); State = PluginState.HashNotFound; } else { LoadReferences(); Assembly assembly = Assembly.Load(bin); Type classType = assembly.GetType($"{Name}.{Name}"); if (classType == null || !classType.IsSubclassOf(typeof(CSharpPlugin)) || !classType.IsPublic || classType.IsAbstract) { Console.WriteLine("Main module class not found:" + Name); State = PluginState.FailedToLoad; } else { Engine = (CSharpPlugin)Activator.CreateInstance(classType); Engine.Plugin = this; Globals = (from method in classType.GetMethods() select method.Name).ToList(); State = PluginState.Loaded; } } } catch (Exception ex) { Logger.LogException(ex); State = PluginState.FailedToLoad; } PluginLoader.GetInstance().OnPluginLoaded(this); }
public bool CheckDependencies() { return(CoreConfig.GetInstance().GetBoolValue("csharp", "enabled")); }