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
ActivityPubOptionsOptions for the ActivityPub protocol
jsonLdSerializer
IJsonLdSerializerJSON-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
disposing
bool
Get(Uri, Type, int?, CancellationToken)
private Task<ASType> Get(Uri uri, Type targetType, int? maxRecursion, CancellationToken cancellationToken = default)
Parameters
uri
UritargetType
TypemaxRecursion
int?cancellationToken
CancellationToken
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
uri
UriURI to the object
maxRecursion
int?Maximum depth to recurse while populating the returned object. Defaults to DefaultGetRecursion.
cancellationToken
CancellationTokenOptional 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
CancellationTokenOptional cancellation token
Returns
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
CancellationTokenOptional 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