logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class PersistenceService

    Default IPersistenceService implementation. Delegates every operation to an injected PersistenceUseCases instance, turning the persistence aggregate into a resolvable, extendable service. Every delegating method is virtual so a decorator (e.g. caching, encryption) can override a subset while falling back to this default for the rest.

    Inheritance
    object
    PersistenceService
    Implements
    IPersistenceService
    IService
    IFoundationSettings
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Persistence.Application.Services
    Assembly: Serenity.Global.Application.dll
    Syntax
    public class PersistenceService : IPersistenceService, IService, IFoundationSettings

    Constructors

    PersistenceService(PersistenceUseCases)

    Initializes a new instance of the PersistenceService class.

    Declaration
    public PersistenceService(PersistenceUseCases useCases)
    Parameters
    Type Name Description
    PersistenceUseCases useCases

    The aggregated persistence use cases to delegate to.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when useCases is null.

    Properties

    Guid

    Declaration
    public string Guid { get; set; }
    Property Value
    Type Description
    string

    Id

    Declaration
    public string Id { get; set; }
    Property Value
    Type Description
    string

    LogService

    Declaration
    public ILogService LogService { get; set; }
    Property Value
    Type Description
    ILogService

    Gets or sets the log service for logging purposes.

    Methods

    AppendBytesAsync(PersistenceAppendBytesInput, CancellationToken)

    Appends a byte array to an existing blob in the store.

    Declaration
    public virtual Task AppendBytesAsync(PersistenceAppendBytesInput input, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    PersistenceAppendBytesInput input

    The key, data to append, and creation policy.

    CancellationToken cancellationToken

    A token to monitor for cancellation requests.

    Returns
    Type Description
    Task

    A task that represents the asynchronous append operation.

    LoadBytesAsync(PersistenceLoadBytesInput, CancellationToken)

    Loads a byte array from the blob store.

    Declaration
    public virtual Task<byte[]> LoadBytesAsync(PersistenceLoadBytesInput input, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    PersistenceLoadBytesInput input

    The key of the byte data to load.

    CancellationToken cancellationToken

    A token to monitor for cancellation requests.

    Returns
    Type Description
    Task<byte[]>

    A task containing the loaded byte array.

    LoadObjectAsync<T>(PersistenceLoadObjectInput<T>, CancellationToken)

    Loads a deserialized object from the blob store.

    Declaration
    public virtual Task<T> LoadObjectAsync<T>(PersistenceLoadObjectInput<T> input, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    PersistenceLoadObjectInput<T> input

    The key, serializer and optional transformer.

    CancellationToken cancellationToken

    A token to monitor for cancellation requests.

    Returns
    Type Description
    Task<T>

    A task containing the loaded and deserialized object.

    Type Parameters
    Name Description
    T

    The type of the object to load.

    SaveBytesAsync(PersistenceSaveBytesInput, CancellationToken)

    Saves a byte array to the blob store.

    Declaration
    public virtual Task SaveBytesAsync(PersistenceSaveBytesInput input, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    PersistenceSaveBytesInput input

    The key and byte data to store.

    CancellationToken cancellationToken

    A token to monitor for cancellation requests.

    Returns
    Type Description
    Task

    A task that represents the asynchronous save operation.

    SaveObjectAsync<T>(PersistenceSaveObjectInput<T>, CancellationToken)

    Saves a serialized object to the blob store.

    Declaration
    public virtual Task SaveObjectAsync<T>(PersistenceSaveObjectInput<T> input, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    PersistenceSaveObjectInput<T> input

    The key, value, serializer and optional transformer.

    CancellationToken cancellationToken

    A token to monitor for cancellation requests.

    Returns
    Type Description
    Task

    A task that represents the asynchronous save operation.

    Type Parameters
    Name Description
    T

    The type of the object to save.

    Implements

    IPersistenceService
    IService
    IFoundationSettings
    In this article
    © 2026 Serenity. All Rights Reserved