-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServiceConfig.cs
37 lines (30 loc) · 1.17 KB
/
ServiceConfig.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace OscVRCProxy
{
internal class ServiceConfig
{
public List<EndpointData> EndpointData { get; set; }=new List<EndpointData> (){
new EndpointData { Ip = "127.0.0.1", ParamPath = "/", Port = 9001 },
new EndpointData { Ip = "192.168.1.186", ParamPath = "/HeadPat", Port = 228 }
};
public int RecvPort { get; set; } = 9005;
public static ServiceConfig Instance { get; set; }
public static ServiceConfig LoadConfig() {
try {
Instance = JsonSerializer.Deserialize<ServiceConfig>(File.ReadAllText("config.json"));
}catch(Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine("Config recreated, cause file not found or not correct.");
Instance=new ServiceConfig();
File.WriteAllText("config.json",JsonSerializer.Serialize(Instance, new JsonSerializerOptions { WriteIndented = true }));
}
return Instance;
}
}
}