Table of Contents

Class JsonLDContextObject

Namespace
ActivityPub.Types.Util
Assembly
ActivityPub.Types.dll

A JSON-LD context object. Can be embedded within a document or referenced by a link.

[JsonConverter(typeof(JsonLDContextObjectConverter))]
public record JsonLDContextObject : IEquatable<JsonLDContextObject>
Inheritance
JsonLDContextObject
Implements
Inherited Members

Constructors

JsonLDContextObject(IReadOnlyDictionary<string, JsonLDTerm>)

Construct an embedded context

public JsonLDContextObject(IReadOnlyDictionary<string, JsonLDTerm> terms)

Parameters

terms IReadOnlyDictionary<string, JsonLDTerm>

Terms to include in the context

JsonLDContextObject(string)

Construct an external context

public JsonLDContextObject(string externalLink)

Parameters

externalLink string

Link to the external context file

Fields

_terms

private readonly JsonLDContextObject.TermMap? _terms

Field Value

JsonLDContextObject.TermMap

Properties

ActivityStreams

Immutable, shared reference to the ActivityStreams (ActivityPub) context.

public static JsonLDContextObject ActivityStreams { get; }

Property Value

JsonLDContextObject

For an externally linked context, this is the actual link. WARNING: this may be a relative URI!

public string? ExternalLink { get; }

Property Value

string

IsEmbedded

If true, then this context is embedded directly in an object and all terms are available.

public bool IsEmbedded { get; }

Property Value

bool

IsExternal

If true, then this context is located externally and we only have a link.

public bool IsExternal { get; }

Property Value

bool

Terms

For an embedded context, these are the terms defined. Important: terms may be defined by other external contexts.

public IReadOnlyDictionary<string, JsonLDTerm>? Terms { get; }

Property Value

IReadOnlyDictionary<string, JsonLDTerm>

Methods

Contains(JsonLDTerm)

Checks if this context object contains the specified term. Always returns false for remote contexts.

public bool Contains(JsonLDTerm term)

Parameters

term JsonLDTerm

Returns

bool

Contains(string)

Checks if this context object contains any term with the specified ID. Always returns false for remote contexts.

public bool Contains(string termId)

Parameters

termId string

Returns

bool

If this is an external context, gets the link value.

public bool TryGetLink(out string? link)

Parameters

link string

Returns

bool

TryGetTerms(out IReadOnlyDictionary<string, JsonLDTerm>?)

If this is an embedded context, gets the terms.

public bool TryGetTerms(out IReadOnlyDictionary<string, JsonLDTerm>? terms)

Parameters

terms IReadOnlyDictionary<string, JsonLDTerm>

Returns

bool

Operators

implicit operator JsonLDContextObject(string)

Converts a string into a link-form context object

public static implicit operator JsonLDContextObject(string str)

Parameters

str string

Returns

JsonLDContextObject

See Also