/// <summary> /// Loads a file and parses it into the internal talk list. /// </summary> /// <param name="fileLocation">Absolute location of file in the file system</param> private void loadFile(string fileLocation) { using(StreamReader r = new StreamReader(fileLocation)) { while(!r.EndOfStream) //Read each line of the file { //Parse the title using regex. Per Reqs each line of file is a talk. //Line will have numbers are the end noing time in minutes. If no time, then assume 5 minutes. string talkInput = r.ReadLine(); Talk t = new Talk(talkInput); Match talkRegexMatch = new Regex("\\d{1,2}").Match(talkInput); if(talkRegexMatch.Success) { t.Name = talkInput.Substring(0, talkRegexMatch.Index - 1); t.Duration = Int32.Parse(talkRegexMatch.Value); } _talks.Add(t);//Create list of Talks } } }
/// <summary> /// Fills 2 blocks/sessions of hours with talks and includes a 1 hour luch period. /// </summary> /// <param name="talks">Working list of talks from which to choose from</param> /// <returns>List of talks for a track</returns> private List<Talk> fillTrack(ref List<Talk> talks) { Talk _lunchPlaceholder = new Talk("LUNCH", 60); List<Talk> morningBlock = fillSession(3, ref talks); morningBlock.Add(_lunchPlaceholder); List<Talk> eveningBlock = fillSession(4, ref talks); //TODO: uneccesary line morningBlock.AddRange(eveningBlock); return morningBlock; }