# ContentId record struct

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

Namespace `EvilEngine.Formats`, assembly `EvilEngine.Formats`. Engine commit 4ff877b1.

```csharp
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](#create) or [Parse](#parse).

## Members

### Separator (field)

```csharp
public const char Separator = ':'
```

`:`, between the namespace and the name.

### Namespace (property)

```csharp
public string Namespace { get; }
```

The part before the `:`.

### Name (property)

```csharp
public string Name { get; }
```

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

### Create (method)

```csharp
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](#isvalidnamespace), or when the name is empty or holds a `:`.

### Parse (method)

```csharp
public static ContentId Parse(string text)
```

Reads `namespace:name` text, splitting at the first `:`, then makes the id as [Create](#create) does. Throws `FormatException` when there's no namespace before a `:`.

### IsValidNamespace (method)

```csharp
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`.
