public bool ReadData() { if (isIOInProgress) { return(false); } try { isIOInProgress = true; if (System.IO.File.Exists(strFilePath)) { TimerCollection.Clear(); // read the model... IEnumerable <Data.ActivityTimerRow> rows; using (System.IO.StreamReader sReader = new System.IO.StreamReader(strFilePath)) using (CsvHelper.CsvReader csvReader = new CsvHelper.CsvReader(sReader)) { rows = csvReader.GetRecords <Data.ActivityTimerRow>(); foreach (Data.ActivityTimerRow row in rows) { // and update the ViewModel from the Model... AddTimer(ActivityTimerVM.Create(TimeSpan.FromHours(row.TotalHours), row.ActivityText)); } } return(true); } return(false); } finally { isIOInProgress = false; } }
public virtual void AddNewTimer() { AddTimer(ActivityTimerVM.Create()); }