-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathJSONAssemblyListFile.cs
More file actions
46 lines (37 loc) · 1.13 KB
/
JSONAssemblyListFile.cs
File metadata and controls
46 lines (37 loc) · 1.13 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
using System;
using System.IO;
using System.Text.Json.Nodes;
namespace Il2CppInterop.Runtime.Injection
{
internal class JSONAssemblyListFile : IAssemblyListFile
{
private JsonNode node;
private JsonArray names;
private JsonArray types;
private string newFile;
public void Setup(string originalFilePath)
{
if (node != null) return;
node = JsonNode.Parse(File.ReadAllText(originalFilePath));
names = node["names"].AsArray();
types = node["types"].AsArray();
}
public bool IsTargetFile(string originalFilePath)
{
return originalFilePath.Contains("ScriptingAssemblies.json");
}
public void AddAssembly(string name)
{
names.Add(name);
types.Add(16);
}
public string GetOrCreateNewFile()
{
if (!string.IsNullOrEmpty(newFile)) return newFile;
var newJson = node.ToJsonString();
newFile = Path.GetTempFileName();
File.WriteAllText(newFile, newJson);
return newFile;
}
}
}