Class BinaryKV3
Namespace: ValveResourceFormat.ResourceTypes
Assembly: ValveResourceFormat.dll
Represents a binary KeyValues3 data block.
public class BinaryKV3 : BlockInheritance
Derived
AnimGraph, AnimationClip, GenericData, SmartProp
Inherited Members
Block.Type, Block.Offset, Block.Size, Block.Resource, Block.Read(BinaryReader), Block.ToString(), Block.WriteText(IndentedTextWriter), Block.Serialize(Stream)
Extension Methods
ResourceDataExtensions.AsKeyValueCollection(Block)
Constructors
BinaryKV3()
Initializes a new instance of the BinaryKV3 class with DATA block type.
public BinaryKV3()BinaryKV3(BlockType)
Initializes a new instance of the BinaryKV3 class with the specified block type.
public BinaryKV3(BlockType type)Parameters
type BlockType
The block type.
BinaryKV3(KVObject, KV3ID, BlockType)
Initializes a new instance of the BinaryKV3 class with the specified data and format.
public BinaryKV3(KVObject data, KV3ID format, BlockType blockType = BlockType.Undefined)Parameters
data KVObject
The KeyValues3 data.
format KV3ID
The format identifier.
blockType BlockType
The block type.
Fields
MAGIC0
Magic number for VKV3 format.
public const int MAGIC0 = 55987030Field Value
int
MAGIC1
Magic number for KV3 version 1.
public const int MAGIC1 = 1263940353Field Value
int
MAGIC2
Magic number for KV3 version 2.
public const int MAGIC2 = 1263940354Field Value
int
MAGIC3
Magic number for KV3 version 3.
public const int MAGIC3 = 1263940355Field Value
int
MAGIC4
Magic number for KV3 version 4.
public const int MAGIC4 = 1263940356Field Value
int
MAGIC5
Magic number for KV3 version 5.
public const int MAGIC5 = 1263940357Field Value
int
Properties
Data
Gets the deserialized KeyValues3 data.
[AllowNull]
public KVDocument Data { get; set; }Property Value
KVDocument
Remarks
Can be set to null to release the data. Next probe will deserialize again.
SerializationCompressionMethod
Gets or sets the compression method used when serializing this block.
public KV3BinaryCompressionMethod SerializationCompressionMethod { get; set; }Property Value
SerializationVersion
Gets or sets the binary KV3 version used when serializing this block. Supported values are 4 and 5.
public int SerializationVersion { get; set; }Property Value
int
Type
Gets the block type.
public override BlockType Type { get; }Property Value
Methods
ConvertBinaryKV3ToText(nint, int)
Converts binary KV3 data to text format. This method is exposed for unmanaged callers.
public static nint ConvertBinaryKV3ToText(nint dataPtr, int dataLength)Parameters
dataPtr nint
Pointer to the binary KV3 data.
dataLength int
Length of the binary data.
Returns
Pointer to the text representation of the KV3 data.
IsBinaryKV3(uint)
Checks if the given magic number represents a binary KV3 format.
public static bool IsBinaryKV3(uint magic)Parameters
magic uint
The magic number to check.
Returns
bool
True if the magic number is a valid binary KV3 format.
Read(BinaryReader)
Reads the block data from a binary reader.
public override void Read(BinaryReader reader)Parameters
reader BinaryReader
The binary reader to read from.
Serialize(Stream)
Writes the block data in its binary form, as stored in a resource file. Blocks that do not support serialization throw NotImplementedException.
public override void Serialize(Stream stream)Parameters
stream Stream
The stream to write the block data to.
WriteText(IndentedTextWriter)
Writes a human readable text dump of the block contents. This is the output Block.ToString() returns.
public override void WriteText(IndentedTextWriter writer)Parameters
writer IndentedTextWriter
The writer that receives the text, which handles indentation.
Remarks
Converts the binary KV3 data to text format and writes it.

