Skip to content

Instantly share code, notes, and snippets.

@wierzba3
Created January 3, 2017 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wierzba3/9236c379e4e0fa668e7a92046aa66f34 to your computer and use it in GitHub Desktop.
Save wierzba3/9236c379e4e0fa668e7a92046aa66f34 to your computer and use it in GitHub Desktop.
Settings.cs file
// Helpers/SettingsModel.cs
using Plugin.Settings;
using Plugin.Settings.Abstractions;
namespace PatrolLiveApp.Helpers
{
/// <summary>
/// This is the SettingsModel static class that can be used in your Core solution or in any
/// of your client applications. All settings are laid out the same exact way with getters
/// and setters.
/// </summary>
public static class Settings
{
private static ISettings AppSettings
{
get
{
return CrossSettings.Current;
}
}
#region Setting Constants
private const string SettingsKey = "settings_key";
private static readonly string SettingsDefault = string.Empty;
//the settings 'key' for the api key
private const string ApiKeyKey = "api_key";
private static readonly string ApiKeyDefault = "";
private const string DeviceIdKey = "device_id_key";
private static readonly long DeviceIdDefault = 0;
#endregion
public static string ApiKey
{
get { return AppSettings.GetValueOrDefault<string>(ApiKeyKey, ApiKeyDefault); }
set { AppSettings.AddOrUpdateValue<string>(ApiKeyKey, value); }
}
public static long DeviceId
{
get { return AppSettings.GetValueOrDefault<long>(DeviceIdKey, DeviceIdDefault); }
set { AppSettings.AddOrUpdateValue<long>(DeviceIdKey, value); }
}
public static string GeneralSettings
{
get
{
return AppSettings.GetValueOrDefault<string>(SettingsKey, SettingsDefault);
}
set
{
AppSettings.AddOrUpdateValue<string>(SettingsKey, value);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment