BeFriend.ViewModel.SosPageViewModel.LocationAccesser C# (CSharp) Метод

LocationAccesser() приватный Метод

private LocationAccesser ( ) : Task
Результат Task
        private async Task LocationAccesser()
        {
            SosPageText += "Trying to get the most accurate location co-ordinates... \n";
            RaisePropertyChanged(() => SosPageText);
            try
            {
                var accessStatus = await Geolocator.RequestAccessAsync();

                switch (accessStatus)
                {
                    case GeolocationAccessStatus.Allowed:

                        // If DesiredAccuracy or DesiredAccuracyInMeters are not set (or value is 0), DesiredAccuracy.Default is used.
                        var geolocator = new Geolocator { DesiredAccuracy = PositionAccuracy.High };
                        // Carry out the operation
                        var pos = await geolocator.GetGeopositionAsync();
                        _latitude = pos.Coordinate.Point.Position.Latitude.ToString();
                        _longitude = pos.Coordinate.Point.Position.Longitude.ToString();
                        var location = new BasicGeoposition
                        {
                            Latitude = pos.Coordinate.Point.Position.Latitude,
                            Longitude = pos.Coordinate.Point.Position.Longitude
                        };
                        SosPageText += "Location accessed... \n" + _latitude + "\n" + _longitude ;

                        break;
                    case GeolocationAccessStatus.Denied:
                        Debug.WriteLine("Access Denied!");
                        SosPageText += "Access Denied \n";
                        break;

                    case GeolocationAccessStatus.Unspecified:
                        Debug.WriteLine("Unspecified");
                        SosPageText += "Unknown error \n";
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
            RaisePropertyChanged(() => SosPageText);
        }