fBaseXtensions.Settings.UIControl.RecompilePlugins C# (CSharp) Method

RecompilePlugins() private static method

private static RecompilePlugins ( ) : void
return void
        private static void RecompilePlugins()
        {
            if (BotMain.IsRunning)
            {
                BotMain.Stop(false, "Recompiling Plugin!");
                while (BotMain.BotThread.IsAlive)
                    Thread.Sleep(0);
            }

            var EnabledPlugins = PluginManager.GetEnabledPlugins().ToArray();

            foreach (var p in PluginManager.Plugins)
            {
                p.Enabled = false;
            }

            PluginManager.ShutdownAllPlugins();

            Logger.DBLog.DebugFormat("Disposing All Routines");
            foreach (var r in RoutineManager.Routines)
            {
                r.Dispose();
            }

            string sDemonBuddyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            string sTrinityPluginPath = FolderPaths.PluginPath;

            CodeCompiler FunkyCode = new CodeCompiler(sTrinityPluginPath);
            //FunkyCode.ParseFilesForCompilerOptions();
            Logger.DBLog.DebugFormat("Recompiling Funky Bot");
            FunkyCode.Compile();
            Logger.DBLog.DebugFormat(FunkyCode.CompiledToLocation);

            Logger.DBLog.DebugFormat("Clearing all treehooks");
            TreeHooks.Instance.ClearAll();

            Logger.DBLog.DebugFormat("Disposing of current bot");
            BotMain.CurrentBot.Dispose();

            Logger.DBLog.DebugFormat("Removing old Assemblies");
            CodeCompiler.DeleteOldAssemblies();

            BrainBehavior.CreateBrain();

            Logger.DBLog.DebugFormat("Reloading Plugins");
            PluginManager.ReloadAllPlugins(sDemonBuddyPath + @"\Plugins\");

            Logger.DBLog.DebugFormat("Enabling Plugins");
            PluginManager.SetEnabledPlugins(EnabledPlugins);

            Logger.DBLog.DebugFormat("Reloading Routines");
            RoutineManager.Reload();
        }