You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public bool IgnoreUnknownFields { get; set; } = false;
48
+
public Func<string, byte[]> ReadFunc { get; set; } = File.ReadAllBytes;
52
49
}
53
50
54
51
public interface IMessagerName
@@ -63,7 +60,7 @@ namespace Tableau
63
60
public TimeSpan Duration;
64
61
}
65
62
66
-
protected Stats LoadStats = new Stats();
63
+
protected Stats LoadStats = new();
67
64
68
65
public ref Stats GetStats() => ref LoadStats;
69
66
@@ -73,26 +70,26 @@ namespace Tableau
73
70
74
71
public virtual bool ProcessAfterLoadAll(in Hub hub) => true;
75
72
76
-
internal bool LoadMessageByPath<T>(out T msg, string dir, Format fmt, in LoadOptions? options = null) where T : IMessage<T>, new()
73
+
internal static bool LoadMessageByPath<T>(out T msg, string dir, Format fmt, in LoadOptions? options = null) where T : Google.Protobuf.IMessage<T>, new()
77
74
{
78
75
msg = new T();
79
76
string name = msg.Descriptor.Name;
80
77
string path = Path.Combine(dir, name + Format2Ext(fmt));
81
78
try
82
79
{
80
+
var readFunc = options is null ? File.ReadAllBytes : options.ReadFunc;
81
+
byte[] content = readFunc(path);
83
82
switch (fmt)
84
83
{
85
84
case Format.JSON:
86
85
{
87
-
string content = File.ReadAllText(path);
88
-
var parser = options is null ? JsonParser.Default : new JsonParser(JsonParser.Settings.Default.WithIgnoreUnknownFields(options.IgnoreUnknownFields));
89
-
msg = parser.Parse<T>(content);
86
+
var parser = options is null ? Google.Protobuf.JsonParser.Default : new Google.Protobuf.JsonParser(Google.Protobuf.JsonParser.Settings.Default.WithIgnoreUnknownFields(options.IgnoreUnknownFields));
0 commit comments