public void Points_FromSampleGpxDocument_AreCorrect() { using (var gpxStream = new MemoryStream(Encoding.UTF8.GetBytes(Properties.Resources.SampleGpxDocument))) { var reader = new GpxReader(gpxStream); Assert.That(reader.Points.Count(), Is.EqualTo(3)); reader.Points.ElementAt(0).AssertPoint(47.644548m, -122.326897m, 4.46m, "2009-10-17T18:37:26Z"); reader.Points.ElementAt(1).AssertPoint(47.644548m, -122.326897m, 4.94m, "2009-10-17T18:37:31Z"); reader.Points.ElementAt(2).AssertPoint(47.644548m, -122.326897m, 6.87m, "2009-10-17T18:37:34Z"); } }
public MainViewModel(IScheduler backgroundScheduler, IFileChooserUi fileChooser) { var gpxReplays = loadGpxDataCommand.RegisterAsyncFunction(_ => { using (var stream = fileChooser.ChooseFile().Result) { // Stream.Null means the user cancelled the file choosing // TODO: A better way for ChooseFile to indicate user cancelling if (stream == Stream.Null) { return(Observable.Empty <GpxSection>()); } var reader = new GpxReader(stream); return(reader.Points.Replay(backgroundScheduler)); } }); currentSection = gpxReplays.Switch().ToProperty(this, x => x.CurrentSection); }
public MainViewModel(IScheduler backgroundScheduler, IFileChooserUi fileChooser) { var gpxReplays = loadGpxDataCommand.RegisterAsyncFunction(_ => { using (var stream = fileChooser.ChooseFile().Result) { // Stream.Null means the user cancelled the file choosing // TODO: A better way for ChooseFile to indicate user cancelling if (stream == Stream.Null) { return Observable.Empty<GpxSection>(); } var reader = new GpxReader(stream); return reader.Points.Replay(backgroundScheduler); } }); currentSection = gpxReplays.Switch().ToProperty(this, x => x.CurrentSection); }