-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStorage.cs
More file actions
63 lines (58 loc) · 1.83 KB
/
Copy pathStorage.cs
File metadata and controls
63 lines (58 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xamarin.Essentials;
namespace ShishaBacon
{
class Storage
{
public async static Task<Rater> GetRater()
{
try
{
return JsonConvert.DeserializeObject<Rater>(await SecureStorage.GetAsync("ShishaBacon_Rater"));
}
catch (Exception)
{
return null;
// Possible that device doesn't support secure storage on device.
}
;
}
public static void SetRater(Rater rater)
{
try
{
_ = SecureStorage.SetAsync("ShishaBacon_Rater", JsonConvert.SerializeObject(rater, Formatting.Indented));
}
catch (Exception)
{
// Possible that device doesn't support secure storage on device.
}
}
public async static Task<List<Tabacco>> GetTabaccoList()
{
try
{
return new List<Tabacco>(JsonConvert.DeserializeObject<Tabacco[]>(await SecureStorage.GetAsync("ShishaBacon_List")));
}
catch (Exception)
{
return null;
// Possible that device doesn't support secure storage on device.
}
}
public static void SetTabaccoList(List<Tabacco> list)
{
try
{
_ = SecureStorage.SetAsync("ShishaBacon_List", JsonConvert.SerializeObject(list.ToArray(), Formatting.Indented));
}
catch (Exception)
{
// Possible that device doesn't support secure storage on device.
}
}
}
}