This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void StartTracking() | |
{ | |
_geolocator.ReportInterval = (uint)TimeSpan.FromSeconds(30).TotalMilliseconds; | |
_geolocator.MovementThreshold = 100; | |
// this implicitly starts the tracking operation | |
_geolocator.PositionChanged += PositionChangedHandler; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async void PositionChangedHandler(Geolocator sender, PositionChangedEventArgs args) | |
{ | |
if (args.Position == null || args.Position.Coordinate == null) return; | |
//save updated coordinates to a property on the class | |
//can do whatever we want with position, all I need are the coordinates | |
Position = args.Position.Coordinate; | |
//stop the tracking once we have our desired accuracy in meters | |
if (args.Position.Coordinate.Accuracy < 500) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
using MadWorldApps.Phone.Helpers.Interfaces; | |
namespace Places.BLL.Services | |
{ | |
public enum DistanceType { Miles, Kilometers }; | |
public class SettingsService : ISettingsService |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class EnumExtensions | |
{ | |
/// <summary> | |
/// Converts the enum member names into an enumberable of strings. | |
/// </summary> | |
/// <typeparam name="TEnum">A valid enum type.</typeparam> | |
/// <returns>An enumerable of strings based on the enum members.</returns> | |
public static IEnumerable<string> GetNames<TEnum>() where TEnum : struct | |
{ | |
var typeInfo = ValidateEnum<TEnum>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
namespace MadWorldApps.PCL.Helpers.Extensions | |
{ | |
public static class EnumExtensions | |
{ | |
/// <summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace MadWorldApps.PCL.Helpers.Extensions | |
{ | |
public static class StringExtensions | |
{ | |
/// <summary> | |
/// Adds spaces to words based on capital characters. | |
/// </summary> | |
/// <param name="s">The CamelCase string you want spaces added to.</param> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<IEnumerable<StorageFile>> GetFilesInCameraRoll() | |
{ | |
var cameraRoll = await KnownFolders.PicturesLibrary.GetFolderAsync("Camera Roll"); | |
return await cameraRoll.GetFilesAsync(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<bool> LoginAsync() | |
{ | |
var authenticator = new Windows.Security.Authentication.OnlineId.OnlineIdAuthenticator(); | |
var mobileServicesTicket = new Windows.Security.Authentication.OnlineId.OnlineIdServiceTicketRequest("https://yourendpoint.azure-mobile.net/", "JWT"); | |
var ticketRequests = new List<OnlineIdServiceTicketRequest>() { mobileServicesTicket }; | |
var authResult = await authenticator.AuthenticateUserAsync(ticketRequests, CredentialPromptType.PromptIfNeeded); | |
if ((authResult.Tickets.Count == 1) && (authResult.Tickets[0].ErrorCode == 0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async Task SaveChangesAsync() | |
{ | |
try | |
{ | |
await _dbContext.SaveChangesAsync(); | |
} | |
catch (DbUpdateConcurrencyException ex) | |
{ | |
//adapted from: https://docs.microsoft.com/en-us/ef/core/saving/concurrency | |
foreach (var entry in ex.Entries) |