-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStorage.cs
More file actions
44 lines (42 loc) · 1.1 KB
/
Storage.cs
File metadata and controls
44 lines (42 loc) · 1.1 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
using System;
using System.IO;
namespace Square9.QuickstartSample
{
/// <summary>
/// A simple token storage class.
///
/// For the sake of simplicity, this example writes to an unsophisticated local file.
/// </summary>
public static class Storage
{
/// <summary>
/// Gets or sets token from storage.
/// </summary>
/// <value>Stored token.</value>
public static string Token
{
get
{
try
{
// Read the stored token from file.
return File.ReadAllText("token");
}
catch (Exception)
{
return null;
}
}
set
{
if (string.IsNullOrEmpty(value))
{
// Clear stored token when null/empty provided.
File.Delete("token");
}
// Write a new stored token to file.
File.WriteAllText("token", value);
}
}
}
}