Table of Contents

Class ASCollection

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

A Collection is a subtype of Object that represents unordered sets of Object or Link instances. May be paged or unpaged.

public class ASCollection : ASObject, IASModel<ASType, ASTypeEntity>, IASModel<ASType>, IASModel<ASObject, ASObjectEntity, ASType>, IASModel<ASObject, ASObjectEntity>, IASModel<ASObject>, IASModel<ASCollection, ASCollectionEntity, ASObject>, IASModel<ASCollection, ASCollectionEntity>, IASModel<ASCollection>, IEnumerable<Linkable<ASObject>>, IEnumerable
Inheritance
ASCollection
Implements
Derived
Inherited Members

Remarks

Refer to the Activity Streams 2.0 Core specification for a complete description of the Collection type.

Constructors

ASCollection()

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

public ASCollection()

ASCollection(ASType)

Constructs a new instance and extends an existing type graph from a provided model.

public ASCollection(ASType existingGraph)

Parameters

existingGraph ASType
See Also
Extend<TModel, TEntity>()

ASCollection(TypeMap, ASCollectionEntity?)

public ASCollection(TypeMap typeMap, ASCollectionEntity? entity)

Parameters

typeMap TypeMap
entity ASCollectionEntity

ASCollection(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 ASCollection(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)

Fields

CollectionType

ActivityStreams type name for "Collection" types.

[PublicAPI]
public const string CollectionType = "Collection"

Field Value

string

Properties

Current

In a paged Collection, indicates the page that contains the most recently updated member items.

public Linkable<ASCollectionPage>? Current { get; set; }

Property Value

Linkable<ASCollectionPage>
See Also

Entity

private ASCollectionEntity Entity { get; }

Property Value

ASCollectionEntity

First

In a paged Collection, indicates the furthest preceding page of items in the collection.

public Linkable<ASCollectionPage>? First { get; set; }

Property Value

Linkable<ASCollectionPage>
See Also

FirstPopulated

In a paged Collection, gets the first populated entity.

public Linkable<ASCollectionPage>? FirstPopulated { get; }

Property Value

Linkable<ASCollectionPage>

HasItems

True if this collection instance contains items, false otherwise.

public bool HasItems { get; }

Property Value

bool

IsPaged

True if this is a paged collection, false otherwise.

public bool IsPaged { get; }

Property Value

bool

Items

Identifies the items contained in a collection. The items might be ordered or unordered.

public LinkableList<ASObject>? Items { get; set; }

Property Value

LinkableList<ASObject>

Remarks

In ordered collection types, this will map to "orderedItems". Otherwise, it maps to "items". In a paged collection, this MAY be null

See Also

Last

In a paged Collection, indicates the furthest proceeding page of the collection.

public Linkable<ASCollectionPage>? Last { get; set; }

Property Value

Linkable<ASCollectionPage>
See Also

TotalItems

A non-negative integer specifying the total number of objects contained by the logical view of the collection. This number might not reflect the actual number of items serialized within the Collection object instance.

public int TotalItems { get; set; }

Property Value

int

Remarks

If not explicitly set, then this will default to the number of elements in Items. Setting this to any value will disable this logic. If neither is set, returns zero. This cannot be set to less than zero.

Methods

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<Linkable<ASObject>> GetEnumerator()

Returns

IEnumerator<Linkable<ASObject>>

An enumerator that can be used to iterate through the collection.

Operators

implicit operator ASCollection(List<ASObject>)

Converts a list of objects into an ASCollection.

public static implicit operator ASCollection(List<ASObject> collection)

Parameters

collection List<ASObject>

Returns

ASCollection

Explicit Interface Implementations

IASModel<ASCollection>.ASTypeName

AS type name of this entity. For the full list of names in the object graph, use ASTypes.

static string IASModel<ASCollection>.ASTypeName { get; }

Returns

string

IASModel<ASCollection>.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 ASCollection IASModel<ASCollection>.FromGraph(TypeMap typeMap)

Parameters

typeMap TypeMap

Returns

ASCollection

IEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.

IEnumerator IEnumerable.GetEnumerator()

Returns

IEnumerator

An IEnumerator object that can be used to iterate through the collection.

See Also