Exemplo n.º 1
0
        //*************************************************************
        //Method: Initialize
        //
        //Purpose: Initializes the DataLayer, will deserialize data
        //         from JSON files into the class' member variables.
        //*************************************************************
        public void Initialize()
        {
            //Desearlizes Course information into the courses member variable.
            FileStream cReader = new FileStream("TestCourse.json", FileMode.Open, FileAccess.Read);
            DataContractJsonSerializer cInput;

            cInput  = new DataContractJsonSerializer(typeof(CourseCollection));
            courses = (CourseCollection)cInput.ReadObject(cReader);
            cReader.Close();
            //Desearlizes Professor information into the professors member variable.
            FileStream pReader = new FileStream("TestProfessor.json", FileMode.Open, FileAccess.Read);
            DataContractJsonSerializer pInput;

            pInput     = new DataContractJsonSerializer(typeof(ProfessorCollection));
            professors = (ProfessorCollection)pInput.ReadObject(pReader);
            pReader.Close();
            //Desearlizes Room information into the rooms member variable.
            FileStream rReader = new FileStream("TestRoom.json", FileMode.Open, FileAccess.Read);
            DataContractJsonSerializer rInput;

            rInput = new DataContractJsonSerializer(typeof(RoomCollection));
            rooms  = (RoomCollection)rInput.ReadObject(rReader);
            rReader.Close();
            //Desearlizes CourseMeeting information into the courseMeeting member variable.
            FileStream cmReader = new FileStream("TestCourseMeet.json", FileMode.Open, FileAccess.Read);
            DataContractJsonSerializer cmInput;

            cmInput        = new DataContractJsonSerializer(typeof(CourseMeetingCollection));
            courseMeetings = (CourseMeetingCollection)cmInput.ReadObject(cmReader);
            cmReader.Close();
        }
Exemplo n.º 2
0
 //*************************************************************
 //Method: DataLayer
 //
 //Purpose: Constructor for the DataLayer class that assigns
 //         default values.
 //*************************************************************
 public DataLayer()
 {
     courses        = new CourseCollection();
     professors     = new ProfessorCollection();
     rooms          = new RoomCollection();
     courseMeetings = new CourseMeetingCollection();
 }
Exemplo n.º 3
0
        //*************************************************************
        //Method: InitializeProf
        //
        //Purpose: Initializes the DataLayer, with ProfessorCollection
        //data, will deseralize data from a specified filename passed
        //as an argument.
        //*************************************************************
        public void InitializeProf(string newname)
        {
            //Desearlizes Professor information into the professors member variable.
            FileStream pReader = new FileStream(newname, FileMode.Open, FileAccess.Read);
            DataContractJsonSerializer pInput;

            pInput     = new DataContractJsonSerializer(typeof(ProfessorCollection));
            professors = (ProfessorCollection)pInput.ReadObject(pReader);
            pReader.Close();
        }