示例#1
0
        public void WriteAppointments(AppointmentList appointmentList)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(AppointmentList), clientTypes.ToArray());
            TextWriter    writer     = new StreamWriter(appointmentsFile);

            serializer.Serialize(writer, appointmentList);
            writer.Close();
        }
示例#2
0
        public AppointmentList ReadAppointments()
        {
            AppointmentList appointmentList = null;
            XmlSerializer   serializer      = new XmlSerializer(typeof(AppointmentList), clientTypes.ToArray());
            StreamReader    reader          = new StreamReader(appointmentsFile);

            // Catching empty file exception
            try
            {
                appointmentList = (AppointmentList)serializer.Deserialize(reader);
            } catch (Exception e)
            {
                Console.WriteLine(e.Message);
            } finally
            {
                reader.Close();
            }
            return(appointmentList);
        }
示例#3
0
        public MainWindow()
        {
            InitializeComponent();
            //Closing the program when the files are not found
            try
            {
                fileManager = FileManager.Instance();
            } catch (Exception e)
            {
                Console.WriteLine(e.Message);
                MessageBox.Show("Files cannot be loaded. Finishing the program...");
                Environment.Exit(0);
            }

            AppointmentList = fileManager.ReadAppointments();
            if (appointmentList == null)
            {
                appointmentList = new AppointmentList();
            }
            timeOptions = fileManager.ReadTime();
            LoadDefaultValues();
            DataContext = this;
        }