Class KVObjectExtensions
Namespace: ValveResourceFormat.Serialization.KeyValues
Assembly: ValveResourceFormat.dll
VRF-specific extension methods for KVObject. These provide the same behavior as the old VRF KVObject property getters.
public static class KVObjectExtensionsInheritance
Methods
GetArray(KVObject, string)
Gets the values of an array child by name. Returns the underlying collection without copying.
public static IReadOnlyList<KVObject> GetArray(this KVObject obj, string name)Parameters
obj KVObject
name string
Returns
IReadOnlyList<KVObject>
GetArray<T>(KVObject, string)
Gets a typed array of primitive values by name. Also handles binary blobs.
public static T[] GetArray<T>(this KVObject obj, string name)Parameters
obj KVObject
name string
Returns
T[]
Type Parameters
T
GetBooleanProperty(KVObject, string, bool)
Gets a boolean property from the key-value object.
public static bool GetBooleanProperty(this KVObject obj, string name, bool defaultValue = false)Parameters
obj KVObject
name string
defaultValue bool
Returns
GetByteProperty(KVObject, string)
Gets a byte property from the key-value object.
public static byte GetByteProperty(this KVObject obj, string name)Parameters
obj KVObject
name string
Returns
GetDoubleProperty(KVObject, string, double)
Gets a double property from the key-value object.
public static double GetDoubleProperty(this KVObject obj, string name, double defaultValue = 0)Parameters
obj KVObject
name string
defaultValue double
Returns
GetEnumValue<TEnum>(KVObject, string, bool, string)
Gets an enum value from the key-value object.
public static TEnum GetEnumValue<TEnum>(this KVObject obj, string name, bool normalize = false, string stripExtension = "Flags") where TEnum : EnumParameters
obj KVObject
name string
normalize bool
stripExtension string
Returns
TEnum
Type Parameters
TEnum
GetFloatArray(KVObject, string)
Gets an array of floats by name.
public static float[] GetFloatArray(this KVObject obj, string name)Parameters
obj KVObject
name string
Returns
float[]
GetFloatProperty(KVObject, string, float)
Gets a float property from the key-value object.
public static float GetFloatProperty(this KVObject obj, string name, float defaultValue = 0)Parameters
obj KVObject
name string
defaultValue float
Returns
GetInt32Property(KVObject, string, int)
Gets an Int32 property from the key-value object.
public static int GetInt32Property(this KVObject obj, string name, int defaultValue = 0)Parameters
obj KVObject
name string
defaultValue int
Returns
GetIntegerArray(KVObject, string)
Gets an array of long integers by name.
public static long[] GetIntegerArray(this KVObject obj, string name)Parameters
obj KVObject
name string
Returns
long[]
GetIntegerProperty(KVObject, string, long)
Gets a 64-bit integer property from the key-value object.
public static long GetIntegerProperty(this KVObject obj, string name, long defaultValue = 0)Parameters
obj KVObject
name string
defaultValue long
Returns
GetStringProperty(KVObject, string, string?)
Gets a string property from the key-value object.
public static string GetStringProperty(this KVObject obj, string name, string? defaultValue = null)Parameters
obj KVObject
name string
defaultValue string?
Returns
GetSubCollection(KVObject, string)
Gets a child (sub-collection) by name.
public static KVObject GetSubCollection(this KVObject obj, string name)Parameters
obj KVObject
name string
Returns
KVObject
GetUInt32Property(KVObject, string, uint)
Gets a UInt32 property from the key-value object.
public static uint GetUInt32Property(this KVObject obj, string name, uint defaultValue = 0)Parameters
obj KVObject
name string
defaultValue uint
Returns
GetUnsignedIntegerArray(KVObject, string)
Gets an unsigned integer array, with unchecked int-to-ulong conversion for binary KV3 compatibility.
public static ulong[] GetUnsignedIntegerArray(this KVObject obj, string name)Parameters
obj KVObject
name string
Returns
ulong[]
GetUnsignedIntegerProperty(KVObject, string, ulong)
Gets an unsigned integer property, with unchecked int-to-ulong conversion for binary KV3 compatibility.
public static ulong GetUnsignedIntegerProperty(this KVObject obj, string name, ulong defaultValue = 0)Parameters
obj KVObject
name string
defaultValue ulong
Returns
IsNotBlobType(KVObject, string)
Determines whether the specified key contains an array (not a blob type).
public static bool IsNotBlobType(this KVObject obj, string key)Parameters
obj KVObject
key string
Returns
NormalizeEnumName<TEnum>(string, string)
Normalize C Style VALVE_ENUM_VALUE_1 to C# ValveEnum.Value1
public static string NormalizeEnumName<TEnum>(string name, string stripExtension = "") where TEnum : EnumParameters
name string
stripExtension string
Returns
Type Parameters
TEnum
ToMatrix4x4(IReadOnlyList<KVObject>)
Converts an array of key-value objects to a Matrix4x4.
public static Matrix4x4 ToMatrix4x4(this IReadOnlyList<KVObject> array)Parameters
array IReadOnlyList<KVObject>
Returns
ToMatrix4x4(KVObject)
Converts the key-value object to a Matrix4x4.
public static Matrix4x4 ToMatrix4x4(this KVObject array)Parameters
array KVObject
Returns
ToQuaternion(KVObject)
Converts the key-value object to a Quaternion.
public static Quaternion ToQuaternion(this KVObject obj)Parameters
obj KVObject
Returns
ToTransform(KVObject)
Converts the key-value object to a tuple containing Position, Uniform Scale, and Rotation.
public static (Vector3 Position, float Scale, Quaternion Rotation) ToTransform(this KVObject obj)Parameters
obj KVObject
Returns
(Vector3 Position, float Scale, Quaternion Rotation)
ToVector2(KVObject)
Converts the key-value object to a Vector2.
public static Vector2 ToVector2(this KVObject obj)Parameters
obj KVObject
Returns
ToVector3(KVObject)
Converts the key-value object to a Vector3.
public static Vector3 ToVector3(this KVObject obj)Parameters
obj KVObject
Returns
ToVector4(KVObject)
Converts the key-value object to a Vector4.
public static Vector4 ToVector4(this KVObject obj)Parameters
obj KVObject

