Table of Contents

Class ASType

Namespace
ActivityPub.Types.AS
Assembly
ActivityPub.Types.dll

Base type of all ActivityStreams / ActivityPub objects. Subtypes MUST NOT contain any fields or auto-properties! Instead, all data should be stored in a matching entity class which derives from ASEntity.

[UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature, ImplicitUseTargetFlags.WithInheritors)]
public class ASType : IASModel<ASType, ASTypeEntity>, IASModel<ASType>
Inheritance
ASType
Implements
Derived
Inherited Members

Remarks

This is a synthetic type created to help adapt ActivityStreams to the .NET object model. It does not exist in the ActivityStreams standard.

Constructors

ASType()

Constructs a new instance and attaches it to a new, empty type graph.

public ASType()

ASType(TypeMap, ASTypeEntity?)

Constructs a new instance using entities from an existing type graph.

public ASType(TypeMap typeMap, ASTypeEntity? entity)

Parameters

typeMap TypeMap
entity ASTypeEntity

ASType(TypeMap, bool)

Constructs a new instance from an existing type graph. The existing graph is either extended or wrapped, depending on the value of

isExtending
public ASType(TypeMap typeMap, bool isExtending = true)

Parameters

typeMap TypeMap
isExtending bool

Remarks

All overrides MUST call this using

base(typeMap, false)

Exceptions

InvalidOperationException

If

extendGraph
is true and the entity type already exists in the graph
InvalidOperationException

If

extendGraph
is true and the entity requires another entity that is missing from the graph
InvalidCastException

If

extendGraph
is false and the object is not of type
TEntity
See Also
ProjectTo<TModel, TEntity>(bool)

Properties

AttributedTo

Identifies one or more entities to which this object is attributed. The attributed entities might not be Actors. For instance, an object might be attributed to the completion of another activity.

public LinkableList<ASObject> AttributedTo { get; set; }

Property Value

LinkableList<ASObject>
See Also

Entity

private ASTypeEntity Entity { get; }

Property Value

ASTypeEntity

Id

Provides the globally unique identifier for an

Object
or
Link
.
public string? Id { get; set; }

Property Value

string
See Also

IsAnonymous

True if this object is anonymous and should be considered part of its parent context.

public bool IsAnonymous { get; }

Property Value

bool

Remarks

JsonLDContext

JSON-LD context that describes this object. This returns a live instance that will be automatically updated whenever the graph is extended.

[JsonIgnore]
public IJsonLDContext JsonLDContext { get; }

Property Value

IJsonLDContext

MediaType

When used on a Link, identifies the MIME media type of the referenced resource. When used on an Object, identifies the MIME media type of the value of the content property. If not specified, the content property is assumed to contain text/html content.

public string? MediaType { get; set; }

Property Value

string
See Also

Name

A simple, human-readable, plain-text name for the object. HTML markup MUST NOT be included.

public NaturalLanguageString? Name { get; set; }

Property Value

NaturalLanguageString
See Also

Preview

Identifies an entity that provides a preview of this object.

public Linkable<ASObject>? Preview { get; set; }

Property Value

Linkable<ASObject>
See Also

Type

AS type names that are represented by this object, excluding those that have been shadowed. The returned object is a live, read-only view of the collection. Changes will be reflected immediately.

[JsonIgnore]
public IReadOnlySet<string> Type { get; }

Property Value

IReadOnlySet<string>
See Also

TypeMap

Type graph that contains this object.

[JsonIgnore]
public TypeMap TypeMap { get; }

Property Value

TypeMap

Methods

As<TModel>()

Gets an object representing the graph as model type

TModel
.
public TModel As<TModel>() where TModel : ASType, IASModel<TModel>

Returns

TModel

Type Parameters

TModel

Remarks

This function will not extend the object to include a new type. To safely convert to an instance that might be present, use IsModel<TModel>(out TModel?).

Exceptions

InvalidCastException

If the graph cannot be represented by the type

See Also
IsModel<TModel>()
IsModel<TModel>(out TModel)

Is<TModel>()

Checks if the graph contains a particular model type.

public bool Is<TModel>() where TModel : ASType, IASModel<TModel>

Returns

bool

Type Parameters

TModel
See Also
IsModel<TModel>(out TModel)
AsModel<TModel>()

Is<TModel>(out TModel?)

Checks if the graph contains a particular model type. If so, then the instance of that model is extracted and returned.

public bool Is<TModel>(out TModel? instance) where TModel : ASType, IASModel<TModel>

Parameters

instance TModel

Returns

bool

Type Parameters

TModel
See Also
IsModel<TModel>()
AsModel<TModel>()

Explicit Interface Implementations

IASModel<ASType>.FromGraph(TypeMap)

Constructs an instance from this type from a pre-populated type graph. The provided TypeMap instance is guaranteed to include an instance of type EntityType.

static ASType IASModel<ASType>.FromGraph(TypeMap typeMap)

Parameters

typeMap TypeMap

Returns

ASType

See Also