// Copyright (c) Microsoft. All rights reserved. using System; using System.Text.Json.Serialization; using Microsoft.Shared.Diagnostics; namespace Microsoft.Agents.AI.Workflows; /// /// Represents a checkpoint with a unique identifier. /// public sealed class CheckpointInfo : IEquatable { /// /// Gets the unique identifier for the current session. /// public string SessionId { get; } /// /// The unique identifier for the checkpoint. /// public string CheckpointId { get; } /// /// Initializes a new instance of the class with a unique identifier. /// internal CheckpointInfo(string sessionId) : this(sessionId, Guid.NewGuid().ToString("N")) { } /// /// Initializes a new instance of the CheckpointInfo class with the specified session and checkpoint identifiers. /// /// The unique identifier for the session. Cannot be null or empty. /// The unique identifier for the checkpoint. Cannot be null or empty. [JsonConstructor] public CheckpointInfo(string sessionId, string checkpointId) { this.SessionId = Throw.IfNullOrEmpty(sessionId); this.CheckpointId = Throw.IfNullOrEmpty(checkpointId); } /// public bool Equals(CheckpointInfo? other) => other is not null && this.SessionId == other.SessionId && this.CheckpointId == other.CheckpointId; /// public override bool Equals(object? obj) => this.Equals(obj as CheckpointInfo); /// public override int GetHashCode() => HashCode.Combine(this.SessionId, this.CheckpointId); /// public override string ToString() => $"CheckpointInfo(SessionId: {this.SessionId}, CheckpointId: {this.CheckpointId})"; }