logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class AchievementScreenshotAttachment

    Turns the frame that was on screen at unlock time into a stored blob and hands back the unlock record carrying its key.

    Inheritance
    object
    AchievementScreenshotAttachment
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Achievements.Application.Services
    Assembly: Serenity.Achievements.Application.dll
    Syntax
    public class AchievementScreenshotAttachment
    Remarks

    The whole flow is best-effort: a disabled capturer, an empty frame or a store that refuses the write all end the same way — the caller gets no record back and the unlock stands without a screenshot. The re-persisted record carries a fresh revision so the store's upsert-if-newer comparison accepts it over the row the unlock itself wrote. Because the capture outlives the unlock that started it, every write is gated on the AchievementSessionGeneration captured when it began — a reset that lands mid-capture must not be undone by the capture finishing.

    Constructors

    AchievementScreenshotAttachment(IAchievementScreenshotCapturer, IAchievementScreenshotStore, AchievementStoreAccess, IAchievementSettings, AchievementSessionGeneration)

    Initializes a new instance of the AchievementScreenshotAttachment class.

    Declaration
    public AchievementScreenshotAttachment(IAchievementScreenshotCapturer screenshotCapturer, IAchievementScreenshotStore screenshotStore, AchievementStoreAccess store, IAchievementSettings settings, AchievementSessionGeneration sessionGeneration)
    Parameters
    Type Name Description
    IAchievementScreenshotCapturer screenshotCapturer

    Capturer used to grab the unlock frame.

    IAchievementScreenshotStore screenshotStore

    Store the captured bytes are written to.

    AchievementStoreAccess store

    Store the re-stamped unlock record is written back to.

    IAchievementSettings settings

    Achievement configuration, read for the capture switch.

    AchievementSessionGeneration sessionGeneration

    The reset counter every write is gated on.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when a collaborator is null.

    Properties

    IsEnabled

    Whether the project asked for screenshots and the capturer can take one.

    Declaration
    public bool IsEnabled { get; }
    Property Value
    Type Description
    bool

    Methods

    DeleteAllAsync(PlayerId, CancellationToken)

    Removes every screenshot stored for a player.

    Declaration
    public Task DeleteAllAsync(PlayerId player, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    PlayerId player

    The player to clear.

    CancellationToken cancellationToken

    Token used to cancel the operation.

    Returns
    Type Description
    Task

    TryAttachAsync(AchievementUnlockRecord, PlayerId, int, CancellationToken)

    Captures, stores and re-persists the screenshot for an unlock.

    Declaration
    public Task<AchievementUnlockRecord?> TryAttachAsync(AchievementUnlockRecord record, PlayerId player, int capturedGeneration, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    AchievementUnlockRecord record

    The unlock record to attach the screenshot to.

    PlayerId player

    The player the unlock belongs to.

    int capturedGeneration

    The session generation the unlock happened under.

    CancellationToken cancellationToken

    Token used to cancel the operation.

    Returns
    Type Description
    Task<AchievementUnlockRecord?>

    The re-persisted record carrying the screenshot key, or null when nothing was captured, the store refused the write, or a reset invalidated the capture while it ran.

    In this article
    © 2026 Serenity. All Rights Reserved