Namespace: Json.Schema
Inheritance: FormatRegistry 🡒 object
Represents a thread-safe registry for managing and retrieving format definitions within the application.
Remarks
Use the FormatRegistry to register, unregister, and look up format definitions by key. The static Global property provides access to a shared, application-wide registry pre-populated with common formats. This class is designed for scenarios where centralized management of formats is required, and is safe for use across multiple
Properties
| Name | Type | Summary |
|---|---|---|
| Draft06 | FormatRegistry | Gets the formats defined by the Draft 6 dialect. |
| Draft07 | FormatRegistry | Gets the formats defined by the Draft 7 dialect. |
| Draft201909 | FormatRegistry | Gets the formats defined by the Draft 2019-09 dialect. |
| Draft202012 | FormatRegistry | Gets the formats defined by the Draft 2020-12 dialect. |
| Global | FormatRegistry | Gets the global registry of formats available throughout the application. |
| V1 | FormatRegistry | Gets the formats defined by the V1 dialect. |
Constructors
FormatRegistry(IEnumerable<Format> formats)
Creates a new format registry.
Declaration
1
public FormatRegistry(IEnumerable<Format> formats)
| Parameter | Type | Description |
|---|---|---|
| formats | IEnumerable<Format> | The list of formats for the registry to provide. |
Methods
Get(string key)
Retrieves the format associated with the specified key, searching local and global collections.
Declaration
1
public Format Get(string key)
| Parameter | Type | Description |
|---|---|---|
| key | string | The key that identifies the format to retrieve. Cannot be null. |
Returns
The format associated with the specified key if found; otherwise, a format representing an unknown key.
Remarks
If the format is not found in the local collection, the method searches the global collection
Register(Format format)
Registers the specified format for later retrieval by its key.
Declaration
1
public void Register(Format format)
| Parameter | Type | Description |
|---|---|---|
| format | Format | The format to register. The format’s key must be unique within the collection. |
Unregister(string name)
Unregisters the format associated with the specified name, removing it from the collection if it exists.
Declaration
1
public void Unregister(string name)
| Parameter | Type | Description |
|---|---|---|
| name | string | The name of the format to unregister. Cannot be null. |
Remarks
If no format is registered with the specified name, this method has no effect. This method is