static public bool TryParse(string s, out SleepStage result) { switch (s) { case "Wake": result = Wake; return(true); case "REM": result = REM; return(true); case "Stage 1": result = Stage1; return(true); case "Stage 2": result = Stage2; return(true); case "Stage 3": result = Stage3; return(true); default: result = None; return(false); } }
public void LoadFromFile(string path) { string[] lines = File.ReadAllLines(path); DateTime t0 = DateTime.Parse(lines[0].Split(',')[2]); DateTime t1 = DateTime.Parse(lines[1].Split(',')[2]); SampleRate = 1.0 / (t1 - t0).TotalSeconds; SleepStages = lines.Select(l => SleepStage.Parse(l.Split(',')[3])).ToArray(); }