You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Datamodel.NET is a CLR library which implements the Datamodel structure and Datamodel Exchange file format.
1
+
Datamodel.NET is a library which implements the Datamodel structure and Datamodel Exchange (DMX) file format.
2
2
3
-
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.
3
+
Datamodel is a strongly-typed generic data structure designed by Valve Corporation. It is primarily used as a developer storage format for meshes, animations, and maps.
4
4
5
-
## Datamodel Attributes
5
+
## Usage
6
+
```shell
7
+
dotnet add package KeyValues2
8
+
```
6
9
7
-
The following CLR types are supported as Datamodel attributes:
10
+
```cs
11
+
usingvarDatamodel;
8
12
9
-
*`int`
10
-
*`float`
11
-
*`bool`
12
-
*`string`
13
-
*`byte`
14
-
*`byte[]`
15
-
*`ulong`
16
-
*`System.TimeSpan`
13
+
// Load a file with unknown layout
14
+
vardm=Datamodel.Load("my_file.dmx");
15
+
varelement=dm.Root;
16
+
varvalue=element.Get<string>("my_property");
17
17
18
-
Additionally, the following Datamodel.NET types are supported:
`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.)
* Write your own codecs with the `ICodec` interface
34
41
* Serialize and deserialize support for Datamodel.Element subclasses
35
42
36
-
## Quick example
43
+
## Serialization
37
44
38
45
```c#
39
46
varHelloWorld=newDatamodel.Datamodel("helloworld", 1); // must provide a format name (can be anything) and version
@@ -52,3 +59,27 @@ HelloWorld.Save("hello world.dmx", "keyvalues2", 1); // must provide an encoding
52
59
"Hello" "string" "World"
53
60
}
54
61
```
62
+
63
+
## Datamodel Attributes
64
+
65
+
The following CLR types are supported as Datamodel attributes:
66
+
67
+
*`int`
68
+
*`float`
69
+
*`bool`
70
+
*`string`
71
+
*`byte`
72
+
*`byte[]`
73
+
*`ulong`
74
+
*`System.TimeSpan`
75
+
76
+
Additionally, the following Datamodel.NET types are supported:
77
+
78
+
*`Element` (a named collection of attributes)
79
+
*`Vector2`
80
+
*`Vector3` / `QAngle`
81
+
*`Vector4` / `Quaternion`
82
+
*`Matrix` (4x4)
83
+
84
+
`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.)
0 commit comments