Class JsonLDContext
- Namespace
- ActivityPub.Types.Util
- Assembly
- ActivityPub.Types.dll
Mutable implementation of IJsonLDContext.
[JsonConverter(typeof(JsonLDContextConverter))]
public class JsonLDContext : IJsonLDContext, IReadOnlyCollection<JsonLDContextObject>, ICollection<JsonLDContextObject>, IEnumerable<JsonLDContextObject>, IEnumerable
- Inheritance
-
JsonLDContext
- Implements
- Inherited Members
Constructors
JsonLDContext()
Creates a new, empty context.
public JsonLDContext()
JsonLDContext(IJsonLDContext?)
Derives a new child context from the specified parent
public JsonLDContext(IJsonLDContext? parent)
Parameters
parent
IJsonLDContext
Fields
_declaredContexts
All local contexts that have been declared directly on this object, including those that are hidden by the parent.
private readonly HashSet<JsonLDContextObject> _declaredContexts
Field Value
_localContexts
private HashSet<JsonLDContextObject> _localContexts
Field Value
Properties
Contexts
All context objects that are either defined in this context, or inherited from the parent.
public IEnumerable<JsonLDContextObject> Contexts { get; }
Property Value
Count
Gets the number of elements contained in the ICollection<T>.
public int Count { get; }
Property Value
- int
The number of elements contained in the ICollection<T>.
IsReadOnly
Gets a value indicating whether the ICollection<T> is read-only.
public bool IsReadOnly { get; }
Property Value
- bool
true if the ICollection<T> is read-only; otherwise, false.
LocalContexts
All context objects that are defined in this context, not inherited from the parent.
public IEnumerable<JsonLDContextObject> LocalContexts { get; }
Property Value
Parent
Parent context that this one derives from. All context objects in the parent are automatically inherited by the child and will appear in Contexts.
public IJsonLDContext? Parent { get; private set; }
Property Value
Methods
Add(IJsonLDContext)
Adds all context objects from the specified context.
public void Add(IJsonLDContext context)
Parameters
context
IJsonLDContext
Add(JsonLDContextObject)
Adds a context object to this context
public void Add(JsonLDContextObject contextObject)
Parameters
contextObject
JsonLDContextObject
Clear()
Removes all local context objects from the context. Objects in the parent are ignored.
public void Clear()
Contains(IJsonLDContext)
public bool Contains(IJsonLDContext context)
Parameters
context
IJsonLDContext
Returns
Contains(JsonLDContextObject)
public bool Contains(JsonLDContextObject contextObject)
Parameters
contextObject
JsonLDContextObject
Returns
Contains(JsonLDTerm)
public bool Contains(JsonLDTerm term)
Parameters
term
JsonLDTerm
Returns
CopyTo(JsonLDContextObject[], int)
Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.
public void CopyTo(JsonLDContextObject[] array, int arrayIndex)
Parameters
array
JsonLDContextObject[]The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing.
arrayIndex
intThe zero-based index in
array
at which copying begins.
Exceptions
- ArgumentNullException
array
is null.- ArgumentOutOfRangeException
arrayIndex
is less than 0.- ArgumentException
The number of elements in the source ICollection<T> is greater than the available space from
arrayIndex
to the end of the destinationarray
.
CreateASContext(IJsonLDContext?)
Constructs a new context, pre-initialized with the ActivityStreams context. A parent can optionally be linked.
public static JsonLDContext CreateASContext(IJsonLDContext? parent = null)
Parameters
parent
IJsonLDContext
Returns
- See Also
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<JsonLDContextObject> GetEnumerator()
Returns
- IEnumerator<JsonLDContextObject>
An enumerator that can be used to iterate through the collection.
Remove(JsonLDContextObject)
Removes the specified context object from the context. Only applies to local objects - inherited objects are ignored.
public bool Remove(JsonLDContextObject item)
Parameters
item
JsonLDContextObject
Returns
SetParent(IJsonLDContext?)
Sets or changes the parent associated with this context. Local contexts will be updated with new shadowing.
public void SetParent(IJsonLDContext? parent)
Parameters
parent
IJsonLDContext
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through a collection.
IEnumerator IEnumerable.GetEnumerator()
Returns
- IEnumerator
An IEnumerator object that can be used to iterate through the collection.