Add DbFile TryGetChunk method
This commit is contained in:
parent
b9eae0e437
commit
25e8e50f5e
|
@ -133,6 +133,17 @@ public class DbFile
|
||||||
writer.Write(tocOffset);
|
writer.Write(tocOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool TryGetChunk<T>(string name, out T chunk)
|
||||||
|
{
|
||||||
|
if (Chunks.TryGetValue(name, out var rawChunk))
|
||||||
|
{
|
||||||
|
chunk = (T)rawChunk;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
chunk = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static IChunk NewChunk(string entryName)
|
private static IChunk NewChunk(string entryName)
|
||||||
{
|
{
|
||||||
return entryName switch
|
return entryName switch
|
||||||
|
|
Loading…
Reference in New Issue