-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathScofing.cs
52 lines (46 loc) · 890 Bytes
/
Scofing.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
42
43
44
45
46
47
48
49
50
51
using Newtonsoft.Json;
using System.IO;
using System.Linq;
using System.Security.Permissions;
namespace Shop
{
public class ShopConfing
{
public _Shop[] ShopC = new _Shop[0];
public ShopConfing Write(string file)
{
File.WriteAllText(file, JsonConvert.SerializeObject(this, Formatting.Indented));
return this;
}
public static ShopConfing Read(string file)
{
if (!File.Exists(file))
{
WriteExample(file);
}
return JsonConvert.DeserializeObject<ShopConfing>(File.ReadAllText(file));
}
public static void WriteExample(string file)
{
var Ex = new _Shop()
{
id = 1,
name = "itemname",
itemid = 1,
C = 1
};
var Conf = new ShopConfing()
{
ShopC = new _Shop[] { Ex }
};
Conf.Write(file);
}
}
public class _Shop
{
public int id = 0;
public string name;
public int itemid;
public int C = 0;
}
}