public ExercisingServices() { if (!File.Exists("exercise.txt")) { _exercisingDb = new ActivitiesDb <Exercising>(); return; } var formatter = new BinaryFormatter(); using (var stream = new FileStream("exercise.txt", FileMode.Open, FileAccess.Read)) { _exercisingDb = (ActivitiesDb <Exercising>)formatter.Deserialize(stream); } if (_exercisingDb == null) { _exercisingDb = new ActivitiesDb <Exercising>(); } }
public HobiesServices() { if (!File.Exists("hobies.txt")) { _hobiesDb = new ActivitiesDb <Hobie>(); return; } var formatter = new BinaryFormatter(); using (var stream = new FileStream("hobies.txt", FileMode.Open, FileAccess.Read)) { _hobiesDb = (ActivitiesDb <Hobie>)formatter.Deserialize(stream); } if (_hobiesDb == null) { _hobiesDb = new ActivitiesDb <Hobie>(); } }