Example #1
0
        public Program()
        {
            var builder = new ConfigurationBuilder().SetBasePath(AppContext.BaseDirectory).AddJsonFile(path: "config.json");

            this.config = builder.Build();

            #region Read users from file
            //  The path to the file to read from
            DataScanner <User> scanner = new DataScanner <User> (@"\Data\Users\STB.UP");
            List <User>        users   = new List <User> ();

            //  Add each user to the list of users
            foreach (DataContainer item in scanner.ReadFromFile(':'))
            {
                users.Add(new User(ulong.Parse(item [0]), item [1], item [2], item [3], item [4]));
            }

            //  Set list of users
            UserManager.SetUserList(users);
            #endregion

            #region Read events from file
            //  The path to the file to read from
            DataScanner <Event> eventScanner = new DataScanner <Event> (@"\Data\Events\STB.EP");
            List <Event>        events       = new List <Event> ();

            //  Add each event to the list of events
            foreach (DataContainer item in eventScanner.ReadFromFile(':'))
            {
                events.Add(new Event(item [0], new DateTime().Parse(item [3]), new DateTime().Parse(item [4]), item [1], item [2], new DateTime().Parse(item [5]), item [6]));
            }

            //  Set event list
            EventManager.SetEventsList(events);
            #endregion

            #region Read Vacation
            DataScanner <Vacation> vacScanner = new DataScanner <Vacation> (@"\Data\Events\STB.VP");
            DataContainer?         container  = vacScanner.ReadFromFile(0);
            DiscordHandler.Instance.Vacation = (container != null ? Vacation.Parse(container.Value [0]) : Vacation.SetInvalidVacation());
            #endregion
        }