コード例 #1
0
        // Loading data
        public async Task <IEnumerable <LocationDataItem> > GetDataAsync()
        {
            using (var stream = await StreamHelperEx.GetEmbeddedFileStreamAsync(GetType(), "LocationSampleData.csv"))
            {
                var list = new List <LocationDataItem>();

                using (var sr = new StreamReader(stream))
                {
                    while (!sr.EndOfStream)
                    {
                        string   line   = sr.ReadLine();
                        string[] values = line.Split(',');

                        list.Add(
                            new LocationDataItem()
                        {
                            Location    = values[0],
                            Coordinates = $"{values[1]} , {values[2]}"
                        });
                    }
                }

                _items = new ObservableCollection <LocationDataItem>(
                    list
#if __WASM__        // Uncomment this line to load the sample faster in WASM interpreted mode
                    .Take(10)
#endif
                    );
                return(_items);
            }
        }
コード例 #2
0
        // Loading data
        public async Task <IEnumerable <MountainDataItem> > GetDataAsync()
        {
            using (var stream = await StreamHelperEx.GetEmbeddedFileStreamAsync(GetType(), "MountainSampleData.csv"))
            {
                var list = new List <MountainDataItem>();

                using (var sr = new StreamReader(stream))
                {
                    while (!sr.EndOfStream)
                    {
                        string   line   = sr.ReadLine();
                        string[] values = line.Split(',');

                        list.Add(
                            new MountainDataItem()
                        {
                            Rank            = uint.Parse(values[0]),
                            Mountain        = values[1],
                            Height_m        = uint.Parse(values[2]),
                            Range           = values[3],
                            Coordinates     = values[4],
                            Prominence      = uint.Parse(values[5]),
                            Parent_mountain = values[6],
                            First_ascent    = uint.Parse(values[7]),
                            Ascents         = values[8]
                        });
                    }
                }

                _items = new ObservableCollection <MountainDataItem>(
                    list
#if __WASM__        // Uncomment this line to load the sample faster in WASM interpreted mode
                    .Take(15)
#endif
                    );
                return(_items);
            }
        }