Class TileCacheBlob
On-disk envelope around a tile payload: a magic and a format tag so the cache can store more than one encoding. The pipeline uses this; most apps never call it.
public static class TileCacheBlob
- Inheritance
-
objectTileCacheBlob
Fields
HeaderSize
Header length in bytes: 4 of magic plus 4 of format.
public const int HeaderSize = 8
Field Value
Methods
TryParse(byte[], int, out Format, out int, out int)
Reads a header whose format tag this build knows. False for a legacy unwrapped record, a different magic, a truncated buffer, or a tag this build does not recognize.
public static bool TryParse(byte[] blob, int blobLength, out TileCacheBlob.Format format, out int payloadOffset, out int payloadLength)
Parameters
blobbyte[]Buffer that may start with this type's header.
blobLengthintValid length of
blobin bytes.formatTileCacheBlob.FormatKnown format on success; default otherwise.
payloadOffsetintByte index of the payload; HeaderSize on success.
payloadLengthintPayload length in bytes on success; 0 otherwise.
Returns
- bool
True when the magic matches and the format tag is one of TileCacheBlob.Format.
TryParseHeader(byte[], int, out int, out int, out int)
Reads the magic and the raw format tag without requiring a known TileCacheBlob.Format. Use this when a caller-registered codec may own a tag this type does not list.
public static bool TryParseHeader(byte[] blob, int blobLength, out int rawFormat, out int payloadOffset, out int payloadLength)
Parameters
blobbyte[]Buffer that may start with this type's header.
blobLengthintValid length of
blobin bytes.rawFormatintInteger format tag from the header; 0 on failure.
payloadOffsetintByte index of the payload; always HeaderSize.
payloadLengthintPayload length in bytes on success; 0 otherwise.
Returns
- bool
True when the buffer is long enough, the magic matches, and the payload is non-empty.
Wrap(Format, byte[], int)
Copies payload behind a magic-and-format header.
public static byte[] Wrap(TileCacheBlob.Format format, byte[] payload, int length)
Parameters
formatTileCacheBlob.FormatEncoding of the payload bytes.
payloadbyte[]Source buffer; only the first
lengthbytes are copied.lengthintPayload length in bytes.
Returns
- byte[]
A new buffer of HeaderSize plus
lengthbytes.