Beispiel #1
0
        public void StartScript(string filename)
        {
            filename = Path.GetFullPath(filename);

            int    offset    = _scriptTypes.Count;
            string extension = Path.GetExtension(filename);

            if (extension.Equals(".dll", StringComparison.OrdinalIgnoreCase) ? !LoadAssembly(filename) : !LoadScript(filename))
            {
                return;
            }

            Log("[INFO]", "Starting ", (_scriptTypes.Count - offset).ToString(), " script(s) ...");

            for (int i = offset; i < _scriptTypes.Count; i++)
            {
                Script script = InstantiateScript(_scriptTypes[i].Item2);

                if (Object.ReferenceEquals(script, null))
                {
                    continue;
                }

                script.Start();
            }
        }
Beispiel #2
0
        public void Start()
        {
            if (_runningScripts.Count != 0)
            {
                return;
            }

            // Start console
            Console.Start();

            // Start script threads
            Log("[INFO]", "Starting ", _scriptTypes.Count.ToString(), " script(s) ...");

            if (_scriptTypes.Count == 0 || !SortScripts(ref _scriptTypes))
            {
                return;
            }

            for (int i = 0; i < _scriptTypes.Count; i++)
            {
                Script script = InstantiateScript(_scriptTypes[i].Item2);

                if (ReferenceEquals(script, null))
                {
                    continue;
                }

                script.Start();
            }
        }
Beispiel #3
0
        public void StartAllScripts()
        {
            string basedirectory = CurrentDomain.AppDomain.BaseDirectory;

            if (Directory.Exists(basedirectory))
            {
                var filenameScripts = new List <string>();

                try
                {
                    filenameScripts.AddRange(Directory.GetFiles(basedirectory, "*.vb", SearchOption.AllDirectories));
                    filenameScripts.AddRange(Directory.GetFiles(basedirectory, "*.cs", SearchOption.AllDirectories));
                    filenameScripts.AddRange(Directory.GetFiles(basedirectory, "*.dll", SearchOption.AllDirectories));
                }
                catch (Exception ex)
                {
                    Log("[ERROR]", "Failed to reload scripts:", Environment.NewLine, ex.ToString());
                }

                int offset = _scriptTypes.Count;

                foreach (var filename in filenameScripts)
                {
                    string extension = Path.GetExtension(filename).ToLower();

                    if (extension.Equals(".dll", StringComparison.OrdinalIgnoreCase) ? !LoadAssembly(filename) : !LoadScript(filename))
                    {
                        return;
                    }
                }

                int TotalScriptCount = _scriptTypes.Count;

                Log("[INFO]", "Starting ", (TotalScriptCount - offset).ToString(), " script(s) ...");

                for (int i = offset; i < TotalScriptCount; i++)
                {
                    Script script = InstantiateScript(_scriptTypes[i].Item2);

                    if (ReferenceEquals(script, null))
                    {
                        continue;
                    }

                    script.Start();
                }
            }
        }