Table of Contents

Class ActivityPubClient

Namespace
ActivityPub.Client
Assembly
ActivityPub.Client.dll

Default implementation of IActivityPubClient.

public class ActivityPubClient : IActivityPubClient, IDisposable
Inheritance
ActivityPubClient
Implements
Inherited Members

Constructors

ActivityPubClient(ActivityPubOptions, IJsonLdSerializer)

Constructs a new ActivityPub client

public ActivityPubClient(ActivityPubOptions apOptions, IJsonLdSerializer jsonLdSerializer)

Parameters

apOptions ActivityPubOptions

Options for the ActivityPub protocol

jsonLdSerializer IJsonLdSerializer

JSON-LD serializer

Fields

_apOptions

private readonly ActivityPubOptions _apOptions

Field Value

ActivityPubOptions

_disposed

private bool _disposed

Field Value

bool

_httpClient

private readonly HttpClient _httpClient

Field Value

HttpClient

_jsonLdSerializer

private readonly IJsonLdSerializer _jsonLdSerializer

Field Value

IJsonLdSerializer

Properties

DefaultGetRecursion

Default recursion depth for Get<T>(Uri, int?, CancellationToken).

public int DefaultGetRecursion { get; set; }

Property Value

int
See Also

DefaultResolveRecursion

public int DefaultResolveRecursion { get; set; }

Property Value

int
See Also

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

Dispose the object's resources

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

Get(Uri, Type, int?, CancellationToken)

private Task<ASType> Get(Uri uri, Type targetType, int? maxRecursion, CancellationToken cancellationToken = default)

Parameters

uri Uri
targetType Type
maxRecursion int?
cancellationToken CancellationToken

Returns

Task<ASType>

Get<T>(Uri, int?, CancellationToken)

Retrieves and validates an ActivityPub object. Links are automatically followed, up to

maxRecursion
layers of recursion.
public Task<T> Get<T>(Uri uri, int? maxRecursion = null, CancellationToken cancellationToken = default) where T : ASType

Parameters

uri Uri

URI to the object

maxRecursion int?

Maximum depth to recurse while populating the returned object. Defaults to DefaultGetRecursion.

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<T>

Returns the object

Type Parameters

T

Type of object to return. The actual returned object may be a subclass of

T
.

Resolve<T>(LinkableList<T>, int?, CancellationToken)

Resolves a LinkableList<T> to objects. Each linkable is resolved using Resolve<T>(Linkable<T>, int?, CancellationToken).

public Task<List<T>> Resolve<T>(LinkableList<T> linkables, int? maxRecursion = null, CancellationToken cancellationToken = default) where T : ASObject

Parameters

linkables LinkableList<T>

List of linkables to resolve

maxRecursion int?

Maximum depth to recurse while populating the returned objects. DefaultResolveRecursion.

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<List<T>>

Returns a list of resolved objects.

Type Parameters

T

Type of objects to return. The actual returned objects may be subclasses of

T
.

Resolve<T>(Linkable<T>, int?, CancellationToken)

Resolves a Linkable<T> to an object. If the linkable has an object, then its returned. If it has a link, then the link is retrieved using Get<T>(Uri, int?, CancellationToken).

public Task<T> Resolve<T>(Linkable<T> linkable, int? maxRecursion = null, CancellationToken cancellationToken = default) where T : ASObject

Parameters

linkable Linkable<T>

Linkable to resolve

maxRecursion int?

Maximum depth to recurse while populating the returned object. DefaultResolveRecursion.

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<T>

Returns the object

Type Parameters

T

Type of object to return. The actual returned object may be a subclass of

T
.