Skip to content

Commit b27bc66

Browse files
authored
Add FirstPopulated property (resolves #161)
* Add `FirstPopulated` property to return first populate page property
1 parent a2da312 commit b27bc66

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Source/ActivityPub.Types/AS/Collection/ASCollection.cs

+6
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,14 @@ public LinkableList<ASObject>? Items
112112
/// <summary>
113113
/// True if this is a paged collection, false otherwise.
114114
/// </summary>
115+
[MemberNotNullWhen(true, nameof(FirstPopulated))]
115116
public bool IsPaged => Current != null || First != null || Last != null;
116117

118+
/// <summary>
119+
/// In a paged Collection, gets the first populated entity.
120+
/// </summary>
121+
public Linkable<ASCollectionPage>? FirstPopulated => Current ?? First ?? Last;
122+
117123
/// <summary>
118124
/// True if this collection instance contains items, false otherwise.
119125
/// </summary>

Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

+6
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,14 @@ public LinkableList<ASObject>? Items
113113
/// <summary>
114114
/// True if this is a paged collection, false otherwise.
115115
/// </summary>
116+
[MemberNotNullWhen(true, nameof(FirstPopulated))]
116117
public bool IsPaged => Current != null || First != null || Last != null;
117118

119+
/// <summary>
120+
/// In a paged Collection, gets the first populated entity.
121+
/// </summary>
122+
public Linkable<ASOrderedCollectionPage>? FirstPopulated => Current ?? First ?? Last;
123+
118124
/// <summary>
119125
/// True if this collection instance contains items, false otherwise.
120126
/// </summary>

0 commit comments

Comments
 (0)