/// <summary>
 /// Creates an instance of <c>LectureType</c>.
 /// </summary>
 /// <param name="rawname">The given/polish designation of the lecture type.</param>
 public LectureType(string rawname)
 {
     this.RawName  = rawname.Trim();
     this.RawNameL = this.RawName.ToLower();
     this.Name     = LectureType.ResolveRawName(this.RawName);
     this.Hash     = Library.GetHashString(this.RawNameL);
 }
예제 #2
0
        /// <summary>
        /// Takes a <c>CourseJSON</c> instance and serializes it.
        /// Necessary instances of <c>LectureType</c>, <c>CourseMain</c> and <c>CourseEvent</c> are created.
        /// Duplicates of exsisting instances are ignored.
        /// All new instances are added to their respective list holding all instances.
        /// </summary>
        /// <param name="c">An instance of <c>CourseJSON</c> to deserialize.</param>
        public static void SerializeCourseData(CourseJSON c)
        {
            //Serialize LectureType
            LectureType lt = new LectureType(Library.SplitRawCourse(c.GetSubject())[1]);

            //Check for duplicate, add if new
            if (!ALL_LECTURE_TYPE.Contains(lt))
            {
                ALL_LECTURE_TYPE.Add(lt);
            }
            //Retrieve fitting LectureType instance
            lt = ALL_LECTURE_TYPE[ALL_LECTURE_TYPE.IndexOf(lt)];

            //Serialize CourseMain
            CourseMain cm = new CourseMain(Library.SplitRawCourse(c.GetSubject())[0]);

            //Check for duplicate, add if new
            if (!ALL_COURSE_MAIN.Contains(cm))
            {
                ALL_COURSE_MAIN.Add(cm);
                COURSE_MAIN_SUBJ.Add(cm.Subject, cm);
            }
            //Retrieve fitting CourseMain instance
            cm = ALL_COURSE_MAIN[ALL_COURSE_MAIN.IndexOf(cm)];

            //Serialize CourseEvent
            CourseEvent ce = new CourseEvent(c.GetDate(), c.GetStart(), c.GetEnd(), c.GetRoom(), c.GetBuilding(), c.GetTeacher(), cm, lt);

            //Check for duplicate, add if new
            if (!ALL_COURSE_EVENT.Contains(ce))
            {
                ALL_COURSE_EVENT.Add(ce);
            }
        }
예제 #3
0
 /// <summary>
 /// Creates an instance of <c>CourseEvent</c>.
 /// </summary>
 /// <param name="date">Date of the course.</param>
 /// <param name="start">Starting time of the course.</param>
 /// <param name="end">Ending time of the course.</param>
 /// <param name="room">Room designation of the course.</param>
 /// <param name="building">Building designation of the course.</param>
 /// <param name="teacher">The name of the teacher.</param>
 /// <param name="cm">Reference to the subject.</param>
 /// <param name="lt">Reference to the type of lecture.</param>
 public CourseEvent(string date, string start, string end, string room, string building, string teacher, CourseMain cm, LectureType lt)
 {
     this.Start    = DateTime.Parse($"{date.Trim()} {start.Trim()}");
     this.End      = DateTime.Parse($"{date.Trim()} {end.Trim()}");
     this.Room     = room.Trim();
     this.Building = building.Trim();
     this.Course   = cm;
     this.Type     = lt;
     this.Teacher  = teacher;
     this.Hash     = Library.GetHashString($"{this.Start}{this.End}{this.Location}{this.Teacher}{this.Course.Hash}{this.Type.Hash}");
 }