-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStore.cs
More file actions
78 lines (73 loc) · 1.83 KB
/
Store.cs
File metadata and controls
78 lines (73 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.Text;
namespace TestConsole
{
public class Store
{
public string _ = "";
public LocalStorage ls ;
public Store(string prefix)
{
this._ = coalesce(_ , "");
}
private string coalesce(string a, string b)
{
throw new NotImplementedException();
}
private object coalesce(object a, object b)
{
throw new NotImplementedException();
}
public Store prefix(string prefix ) {
return new Store(prefix);
}
public Store ns(string prefix)
{
return this.prefix( prefix);
}
public int set(string key, object val)
{
var data="";
try
{
data = JSON.stringify( coalesce ( val , null));
ls.setItem(this._ + key, data);
return data.Length;
}
catch (Exception e)
{
return 0;
}
}
public Exception setItem(string key, string val)
{
if ( ! (val != null) ) return null;
try
{
ls.setItem(this._ + key, val);
return null;
}
catch (Exception e)
{
return e;
}
}
public Job get(string key)
{
try
{
return new Job();// JSON.parse(ls.getItem(this._ + coalesce(key , "")));//TODO
}
catch (Exception _error)
{
return null;
}
}
internal List<string> get()
{
//throw new NotImplementedException();
return new List<string>();
}
}
}