Skip to content

CLR library implementing Valve's Datamodel structure and Datamodel Exchange file format (fork to maintain and future proof incase upstream goes down)

License

Notifications You must be signed in to change notification settings

Team-Fennec/Datamodel.NET

 
 

Repository files navigation

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.

Datamodel Attributes

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.)

Datamodel.NET features

  • Threaded, thread-safe
  • Support for all known versions of Valve's binary and keyvalues2 DMX encodings
  • Convenient IEnumerable, INotifyPropertyChanged and INotifyCollectionChanged 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)

Quick example

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"
}

About

CLR library implementing Valve's Datamodel structure and Datamodel Exchange file format (fork to maintain and future proof incase upstream goes down)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%