Datamodel.NET is a CLR library which implements the Datamodel structure and Datamodel Exchange file format.
Datamodel is a strongly-typed generic data structure designed by Valve Corporation for use in their games. Datamodel Exchange is a Datamodel container file format with multiple possible encodings; binary and ASCII ("keyvalues2") are included.
The following CLR types are supported as Datamodel attributes:
int
float
bool
string
byte
byte[]
ulong
System.TimeSpan
Additionally, the following Datamodel.NET types are supported:
Element
(a named collection of attributes)Vector2
Vector3
/QAngle
Vector4
/Quaternion
Matrix
(4x4)
IList<T>
collections of the above types are also supported. (This can be a bit confusing given that both byte
and byte[]
are valid attribute types; use the ByteArray
type if you run into trouble.)
- Threaded, thread-safe
- Support for all known versions of Valve's
binary
andkeyvalues2
DMX encodings - Convenient
IEnumerable
,INotifyPropertyChanged
andINotifyCollectionChanged
implementations - Supports partial trust
- Inline documentation
- Binary codec supports just-in-time attribute loading
- Write your own codecs with the
ICodec
interface - Support for property based attributes, Datamodel.Element subclassing (serialize only)
var HelloWorld = new Datamodel.Datamodel("helloworld", 1); // must provide a format name (can be anything) and version
HelloWorld.Root = new Datamodel.Element(HelloWorld, "my_root");
HelloWorld.Root["Hello"] = "World"; // any supported attribute type can be assigned
var MyString = HelloWorld.Root.Get<string>("Hello");
HelloWorld.Save("hello world.dmx", "keyvalues2", 1); // must provide an encoding name and version
<--! dmx encoding keyvalues2 1 format helloworld 1>
{
"Hello" "string" "World"
}