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
apOptionsActivityPubOptionsOptions for the ActivityPub protocol
jsonLdSerializerIJsonLdSerializerJSON-LD serializer
Fields
_apOptions
private readonly ActivityPubOptions _apOptions
Field Value
_disposed
private bool _disposed
Field Value
_httpClient
private readonly HttpClient _httpClient
Field Value
_jsonLdSerializer
private readonly IJsonLdSerializer _jsonLdSerializer
Field Value
Properties
DefaultGetRecursion
Default recursion depth for Get<T>(Uri, int?, CancellationToken).
public int DefaultGetRecursion { get; set; }
Property Value
- See Also
DefaultResolveRecursion
Default recursion depth for Resolve<T>(Linkable<T>, int?, CancellationToken) and Resolve<T>(LinkableList<T>, int?, CancellationToken)
public int DefaultResolveRecursion { get; set; }
Property Value
- 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
disposingbool
Get(Uri, Type, int?, CancellationToken)
private Task<ASType> Get(Uri uri, Type targetType, int? maxRecursion, CancellationToken cancellationToken = default)
Parameters
uriUritargetTypeTypemaxRecursionint?cancellationTokenCancellationToken
Returns
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
uriUriURI to the object
maxRecursionint?Maximum depth to recurse while populating the returned object. Defaults to DefaultGetRecursion.
cancellationTokenCancellationTokenOptional cancellation token
Returns
- Task<T>
Returns the object
Type Parameters
TType 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
linkablesLinkableList<T>List of linkables to resolve
maxRecursionint?Maximum depth to recurse while populating the returned objects. DefaultResolveRecursion.
cancellationTokenCancellationTokenOptional cancellation token
Returns
Type Parameters
TType 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
linkableLinkable<T>Linkable to resolve
maxRecursionint?Maximum depth to recurse while populating the returned object. DefaultResolveRecursion.
cancellationTokenCancellationTokenOptional cancellation token
Returns
- Task<T>
Returns the object
Type Parameters
TType of object to return. The actual returned object may be a subclass of
.T