Ejemplo n.º 1
0
        internal static void CompileModule(GrooveModule p_Module)
        {
            if (m_LoadedModules.ContainsKey(p_Module.Name) || !p_Module.Enabled)
                return;

            try
            {
                var s_Scope = m_ScriptEngine.CreateScope();

                s_Scope.ImportModule("clr");

                m_ScriptEngine.Execute("import clr", s_Scope);
                m_ScriptEngine.Execute("from clr import Convert", s_Scope);

                m_ScriptEngine.Execute("clr.AddReference('System.Core')", s_Scope);
                m_ScriptEngine.Execute("from System import Action", s_Scope);
                m_ScriptEngine.Execute("from System.Collections.Generic import List", s_Scope);

                m_ScriptEngine.Execute("clr.AddReference('GS.Lib')", s_Scope);
                m_ScriptEngine.Execute("from GS.Lib import *", s_Scope);

                m_ScriptEngine.Execute("clr.AddReference('GrooveCasterServer')", s_Scope);
                m_ScriptEngine.Execute("from GrooveCaster import *", s_Scope);
                m_ScriptEngine.Execute("from GrooveCaster.Managers import BroadcastManager, ChatManager, QueueManager, SettingsManager, UserManager, SuggestionManager, PlaylistManager", s_Scope);
                m_ScriptEngine.Execute("from GrooveCaster.Application import Library as SharpShark", s_Scope);
                m_ScriptEngine.Execute("from GrooveCaster.Util import ModuleTimer as Timer", s_Scope);

                var s_ScriptSource = m_ScriptEngine.CreateScriptSourceFromString(p_Module.Script.Trim(), SourceCodeKind.File);
                var s_Script = s_ScriptSource.Execute(s_Scope);

                m_LoadedModules.Add(p_Module.Name, new ModuleScript()
                {
                    Source = s_ScriptSource,
                    Script = s_Script,
                    Scope = s_Scope
                });
            }
            catch (Exception s_Exception)
            {
                Console.WriteLine(s_Exception);
                LoadExceptions.Add(p_Module.Name, s_Exception.Message);
            }
        }
Ejemplo n.º 2
0
 internal static void EnableModule(GrooveModule p_Module)
 {
     p_Module.Enabled = true;
     UpdateModule(p_Module);
 }
Ejemplo n.º 3
0
 internal static void DisableModule(GrooveModule p_Module)
 {
     p_Module.Enabled = false;
     UpdateModule(p_Module);
 }
Ejemplo n.º 4
0
 internal static void UpdateModule(GrooveModule p_Module)
 {
     using (var s_Db = Database.GetConnection())
         s_Db.Update(p_Module);
 }
Ejemplo n.º 5
0
        internal static void RemoveModule(GrooveModule p_Module)
        {
            if (p_Module.Default)
                return;

            using (var s_Db = Database.GetConnection())
                s_Db.Delete(p_Module);
        }