Class XapiDocument
A document of the State, Activity Profile or Agent Profile resource: arbitrary bytes with a content type, plus the ETag and Last-Modified time the LRS returned with it.
public sealed record XapiDocument : IEquatable<XapiDocument>
- Inheritance
-
XapiDocument
- Implements
- Inherited Members
Remarks
Equality compares the content type, the bytes, the ETag and the Last-Modified time.
The document keeps the memory it is given; the bytes are not copied. Do not change them while the document is in use, for example between creating it and sending it. Copy the buffer first if it is reused.
Constructors
XapiDocument(ReadOnlyMemory<byte>, string)
Creates a document.
public XapiDocument(ReadOnlyMemory<byte> content, string contentType)
Parameters
contentReadOnlyMemory<byte>The document bytes. Kept without a copy, so they must not change afterwards.
contentTypestringThe media type, for example
application/json.
Properties
Content
The document bytes. They are not copied, so they must not change while the document is in use.
public ReadOnlyMemory<byte> Content { get; init; }
Property Value
ContentType
The media type, for example application/json.
public string ContentType { get; init; }
Property Value
ETag
The ETag response header, exactly as the LRS sent it. Pass it to
IfMatch(string) to update or delete only this version of the document.
public string? ETag { get; init; }
Property Value
LastModified
The Last-Modified response header.
public DateTimeOffset? LastModified { get; init; }
Property Value
Methods
Equals(XapiDocument?)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(XapiDocument? other)
Parameters
otherXapiDocumentAn object to compare with this object.
Returns
FromJson(JsonElement)
Creates an application/json document.
public static XapiDocument FromJson(JsonElement json)
Parameters
jsonJsonElementThe JSON value. The State and profile resources merge only JSON objects on POST.
Returns
- XapiDocument
The document.
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
ToJson()
Parses the content as JSON.
public JsonElement ToJson()
Returns
- JsonElement
The parsed value, which stays valid after this document is gone.
Exceptions
- JsonException
The content is not JSON.