-
Notifications
You must be signed in to change notification settings - Fork 0
/
CredentialsHelper.cs
41 lines (37 loc) · 1.21 KB
/
CredentialsHelper.cs
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
using Newtonsoft.Json;
using SuchByte.MacroDeck.Plugins;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RecklessBoon.MacroDeck.Streamlabs_OBS_Plugin
{
class CredentialsHelper
{
public static void UpsertCredential(string key, string value)
{
var oldCreds = PluginCredentials.GetPluginCredentials(PluginCache.Plugin);
var creds = new Dictionary<string, string>();
if (oldCreds.Count == 1)
{
creds = oldCreds.First();
}
creds[key] = value;
PluginCredentials.SetCredentials(PluginCache.Plugin, creds);
}
public static void UpsertCredential(string key, object value)
{
UpsertCredential(key, JsonConvert.SerializeObject(value));
}
public static void RemoveCredential(string key)
{
var oldCreds = PluginCredentials.GetPluginCredentials(PluginCache.Plugin);
if (oldCreds.Count == 1)
{
var creds = oldCreds.First();
creds.Remove(key);
PluginCredentials.SetCredentials(PluginCache.Plugin, creds);
}
}
}
}