Exemplo n.º 1
0
        /// <summary>
        ///     Saves the data as CSV.
        /// </summary>
        /// <param name="file">The file</param>
        /// <param name="dataToSave">The data to save.</param>
        public async void SaveDataAsCsv(StorageFile file, CovidLocationDataCollection dataToSave)
        {
            var locationCollection = dataToSave.CollectionOfCovidLocationData;
            var data = $"{CsvConstants.HeaderInformation} {Environment.NewLine}";

            data = locationCollection.Select(currentLocation => currentLocation.Value.CovidCases).Aggregate(data, (current, locationData) => current + extractDataFromLocation(locationData));

            await FileIO.WriteTextAsync(file, data);
        }
Exemplo n.º 2
0
        /// <summary>Saves the data as CSV.</summary>
        /// <param name="file">The storage file to save to.</param>
        /// <param name="covidCollection">The covid collection to save.</param>
        public async void WriteToXml(StorageFile file, CovidLocationDataCollection covidCollection)
        {
            var allCovidCases = getAllCovidCases(covidCollection);

            var outStream = await file.OpenStreamForWriteAsync();

            var serializer = new XmlSerializer(typeof(List <CovidCase>), new XmlRootAttribute("CovidCollection"));

            serializer.Serialize(outStream, allCovidCases);
            outStream.Dispose();
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="MainPage" /> class.
        /// </summary>
        public MainPage()
        {
            this.InitializeComponent();

            ApplicationView.PreferredLaunchViewSize = new Size {
                Width = ApplicationWidth, Height = ApplicationHeight
            };
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
            ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(ApplicationWidth, ApplicationHeight));

            this.csvReader                  = new CsvReader();
            this.covidCollection            = new CovidLocationDataCollection();
            this.lowerThresholdTextBox.Text = LowerThresholdDefault.ToString();
            this.upperThresholdTextBox.Text = UpperThresholdDefault.ToString();
        }
Exemplo n.º 4
0
 private static IList <CovidCase> getAllCovidCases(CovidLocationDataCollection covidCollection)
 {
     return(covidCollection.CollectionOfCovidLocationData.SelectMany(currentLocation => currentLocation.Value.CovidCases).ToList());
 }