support all major types
This commit is contained in:
@@ -21,19 +21,29 @@ namespace SharedSettingsAbstraction.Extensions
|
|||||||
if (refType == typeof(string))
|
if (refType == typeof(string))
|
||||||
{
|
{
|
||||||
ed.PutString(key,(String)value);
|
ed.PutString(key,(String)value);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (refType == typeof(bool))
|
if (refType == typeof(bool))
|
||||||
{
|
{
|
||||||
ed.PutBoolean(key, (bool)value);
|
ed.PutBoolean(key, (bool)value);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (refType == typeof(int))
|
if (refType == typeof(int))
|
||||||
{
|
{
|
||||||
ed.PutInt(key, (int)value);
|
ed.PutInt(key, (int)value);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (refType == typeof(float))
|
if (refType == typeof(float))
|
||||||
{
|
{
|
||||||
ed.PutFloat(key, (float)value);
|
ed.PutFloat(key, (float)value);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
if (refType == typeof(long))
|
||||||
|
{
|
||||||
|
ed.PutLong(key, (long)value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new InvalidOperationException("Type not supported, only use String, Bool, Int, Float, Long");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,11 +25,13 @@ namespace SharedSettingsAbstraction.Setting
|
|||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
private string _preferenceName;
|
private string _preferenceName;
|
||||||
private T _defaultValue;
|
private T _defaultValue;
|
||||||
public List<string> SpinnerOptions { get; set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Setup key
|
/// Abstraction around shared preferences
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="_key"></param>
|
/// <param name="_key">Name the key</param>
|
||||||
|
/// <param name="preferenceName">Name the preference (should be consistant accross all settings)</param>
|
||||||
|
/// <param name="defaultValue">Give a default value</param>
|
||||||
public SettingsKey(string _key, string preferenceName, T defaultValue)
|
public SettingsKey(string _key, string preferenceName, T defaultValue)
|
||||||
{
|
{
|
||||||
key = _key;
|
key = _key;
|
||||||
|
|||||||
Reference in New Issue
Block a user