Skip to content
EvilEngine.Formats

ContentId record struct

public readonly record struct ContentId

The name of one piece of content: a namespace and a name, written namespace:name, as in quake:id1/maps/e1m1 or gmod:models/props_c17/oildrum001. It’s a small value type, so pass it around and compare it freely.

The namespace is a mounted game’s name, an adapter’s id or a Plugin’s id. The name is always lowercase with forward slashes, so two spellings of one path are the same id. default is no id at all, so make one with Create or Parse.

Assembly
EvilEngine.Formats
Commit
4ff877b1

Members

Separator field

public const char Separator = ':'

:, between the namespace and the name.

Namespace property

public string Namespace { get; }

The part before the :.

Name property

public string Name { get; }

The part after the :, lowercased, with forward slashes and no empty segments.

Create method

public static ContentId Create(string @namespace, string name)

Makes an id from a namespace and a name. The name’s backslashes become forward slashes, empty segments are dropped and it’s lowercased, so Maps\\E1M1 and maps//e1m1 both make maps/e1m1.

Throws ArgumentException when the namespace isn’t valid by IsValidNamespace, or when the name is empty or holds a :.

Parse method

public static ContentId Parse(string text)

Reads namespace:name text, splitting at the first :, then makes the id as Create does. Throws FormatException when there’s no namespace before a :.

IsValidNamespace method

public static bool IsValidNamespace(string @namespace)

Returns whether a namespace has at least one character and only lowercase letters, digits, ., _ and -, the same rule as an adapter’s or a Plugin’s id.