<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Windows;



namespace Saveyour
{
    public class Shell{
    
        private static Modlist modlist;
        private static SaveLoader saveLoad;
        private static Shell theShell;
        private static Settings settings;

        static void OnProcessExit(object sender, EventArgs e)
        {
            getSaveLoader().save();
            Debug.WriteLine("Saving before exit...");
        }

        public static Shell getShell()
        {
            if (theShell == null)
            {
                theShell = new Shell();
            }
            return theShell;
        }

        public static Shell getShell(String username, String password)
        {
            if (theShell == null)
            {
                theShell = new Shell(username, password);
            }
            return theShell;
        }

        public static Module launch(String modID)
        {
            //Run 'modID' + '.exe' in the SaveYour/Modules folder to be implemented later.
            Module newModule;
            if (modID.Equals("QuicknotesControl") && !modlist.hasName("QuicknotesControl"))
            {
                newModule = new QuicknotesControl();
                
            }
            else if (modID.Equals("WeeklyToDo") && !modlist.hasName("WeeklyToDo"))
            {
                newModule = new WeeklyToDo();
            }
            else if (modID.Equals("Google Calendar") && !modlist.hasName("Google Calendar"))
            {
                newModule = new GoogleCalendar();
            }
            else if (modID.Equals("Homework"))
            {
                newModule = new Homework();
            }
            else 
            {
                Debug.WriteLine("Shell attempted to launch an invalid moduleID: " + modID);
                return null;
            }

            Debug.WriteLine("Launching: "+modID);

            if ((newModule != null) && modlist.add((Module)newModule))
            {
                if (modID.Equals("QuicknotesControl")){
                    settings.addQNotes(newModule);
                }
                else if (modID.Equals("WeeklyToDo"))
                {
                    settings.addWTD((Window) newModule);
                }
                else if (modID.Equals("Google Calendar"))
                {
                    settings.addGC((Window) newModule);
                }
                newModule.Show();
            }
         
            return (Module)newModule;
        }

        private Shell() : this(null,null)
        {

            modlist = new Modlist();
 
            saveLoad = new SaveLoader();
            settings = new Settings();

            Debug.WriteLine("Booting other modules");
            saveLoad.loadToLaunch();
            settings.Show();


        }
        private Shell(String username, String password)
        {

            modlist = new Modlist();

            saveLoad = new SaveLoader();
            saveLoad.setLogin(username, password);
            settings = new Settings();

            Debug.WriteLine("Booting other modules");
            saveLoad.loadToLaunch();

            //launch("Quicknotes");
            launch("WeeklyToDo");
            launch("Google Calendar");
            launch("Homework");

            launch("QuicknotesControl");


             
            
            settings.Show();

        }

        public static Modlist getModList()
        {
            return modlist;
        }

        public static SaveLoader getSaveLoader(){
            return saveLoad;
        }

        public void startApp(){            

            //Application.Run(userLogin);
            
        }

    }<commit_msg>Fixes Null Reference in Homework<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Windows;



namespace Saveyour
{
    public class Shell{
    
        private static Modlist modlist;
        private static SaveLoader saveLoad;
        private static Shell theShell;
        private static Settings settings;

        static void OnProcessExit(object sender, EventArgs e)
        {
            getSaveLoader().save();
            Debug.WriteLine("Saving before exit...");
        }

        public static Shell getShell()
        {
            if (theShell == null)
            {
                theShell = new Shell();
            }
            return theShell;
        }

        public static Shell getShell(String username, String password)
        {
            if (theShell == null)
            {
                theShell = new Shell(username, password);
            }
            return theShell;
        }

        public static Module launch(String modID)
        {
            //Run 'modID' + '.exe' in the SaveYour/Modules folder to be implemented later.
            Module newModule;
            if (modID.Equals("QuicknotesControl") && !modlist.hasName("QuicknotesControl"))
            {
                newModule = new QuicknotesControl();
                
            }
            else if (modID.Equals("WeeklyToDo") && !modlist.hasName("WeeklyToDo"))
            {
                newModule = new WeeklyToDo();
            }
            else if (modID.Equals("Google Calendar") && !modlist.hasName("Google Calendar"))
            {
                newModule = new GoogleCalendar();
            }
            else if (modID.Equals("Homework"))
            {
                newModule = new Homework();
            }
            else 
            {
                Debug.WriteLine("Shell attempted to launch an invalid moduleID: " + modID);
                return null;
            }

            Debug.WriteLine("Launching: "+modID);

            if ((newModule != null) && modlist.add((Module)newModule))
            {
                if (modID.Equals("QuicknotesControl")){
                    settings.addQNotes(newModule);
                }
                else if (modID.Equals("WeeklyToDo"))
                {
                    settings.addWTD((Window) newModule);
                }
                else if (modID.Equals("Google Calendar"))
                {
                    settings.addGC((Window) newModule);
                }
                newModule.Show();
            }
         
            return (Module)newModule;
        }

        private Shell() : this(null,null)
        {

            modlist = new Modlist();
 
            saveLoad = new SaveLoader();
            settings = new Settings();

            Debug.WriteLine("Booting other modules");
            saveLoad.loadToLaunch();
            settings.Show();


        }
        private Shell(String username, String password)
        {

            modlist = new Modlist();

            saveLoad = new SaveLoader();
            saveLoad.setLogin(username, password);
            settings = new Settings();

            Debug.WriteLine("Booting other modules");
            saveLoad.loadToLaunch();

            //launch("Quicknotes");
            launch("WeeklyToDo");
            launch("Google Calendar");
<<<<<<< HEAD
            launch("Homework");

            launch("QuicknotesControl");

=======

            launch("Homework");
            launch("QuicknotesControl");
>>>>>>> HomeworkFixes

             
            
            settings.Show();

        }

        public static Modlist getModList()
        {
            return modlist;
        }

        public static SaveLoader getSaveLoader(){
            return saveLoad;
        }

        public void startApp(){            

            //Application.Run(userLogin);
            
        }

    }
{'fraction_non_alphanumeric': 0.09836693033937229, 'fraction_numerical': 0.0, 'mean_word_length': 1.3590129401143545, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6928452', 'n_tokens_mistral': 1916, 'n_tokens_neox': 1806, 'n_words': 434}