Files
pkNX/pkNX.Structures.FlatBuffers/Util/FlatDumper.cs
Kurt 2578ba073c Refactoring
File scoped namespaces for all lib projects
netstandard2.0 => net6; now uniform. bye netframework!
2022-10-01 17:08:17 -07:00

28 lines
783 B
C#

using System.IO;
namespace pkNX.Structures.FlatBuffers;
public static class FlatDumper
{
public static string GetTable<T1, T2>(string path) where T1 : class, IFlatBufferArchive<T2> where T2 : class
{
var data = File.ReadAllBytes(path);
return GetTable<T1, T2>(data);
}
public static string GetTable<T1, T2>(byte[] data) where T1 : class, IFlatBufferArchive<T2> where T2 : class
{
var obj = FlatBufferConverter.DeserializeFrom<T1>(data);
var table = obj.Table;
return TableUtil.GetTable(table);
}
public static string GetSchema<T>() where T : class, new()
{
var t = typeof(T);
var obj = new T();
var dump = new FlatSchemaDump(obj);
return dump.GetSingleFileSchema(t);
}
}