forked from anjoy8/Blog.Core
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathAppSecretConfig.cs
More file actions
47 lines (37 loc) · 1.21 KB
/
AppSecretConfig.cs
File metadata and controls
47 lines (37 loc) · 1.21 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
using System.IO;
namespace Blog.Core.Common.AppConfig
{
public class AppSecretConfig
{
private static string Audience_Secret = Appsettings.app(new string[] { "Audience", "Secret" });
private static string Audience_Secret_File = Appsettings.app(new string[] { "Audience", "SecretFile" });
public static string Audience_Secret_String => InitAudience_Secret();
private static string InitAudience_Secret()
{
var securityString = DifDBConnOfSecurity(Audience_Secret_File);
if (!string.IsNullOrEmpty(Audience_Secret_File)&& !string.IsNullOrEmpty(securityString))
{
return securityString;
}
else
{
return Audience_Secret;
}
}
private static string DifDBConnOfSecurity(params string[] conn)
{
foreach (var item in conn)
{
try
{
if (File.Exists(item))
{
return File.ReadAllText(item).Trim();
}
}
catch (System.Exception) { }
}
return "";
}
}
}