namespace AyCode.Core.Serializers; /// /// Represents a deserialize chain that allows multiple deserializations from the same parsed data. /// Maintains reference identity for IId objects across chain operations. /// Implements IDisposable - call Dispose() when done or use 'using' statement. /// public interface IDeserializeChain : IDisposable { /// /// The first deserialized value. /// T? Value { get; } /// /// Deserialize to another type from the same data. /// TResult? ThenDeserialize(); /// /// Populate an existing object from the same data. /// Returns this chain for fluent API. /// IDeserializeChain ThenPopulate(object target); } /// /// Empty deserialize chain implementation for null/empty data. /// public sealed class EmptyDeserializeChain : IDeserializeChain { public static readonly IDeserializeChain Instance = new EmptyDeserializeChain(); private EmptyDeserializeChain() { } public T? Value => default; public TResult? ThenDeserialize() => default; public IDeserializeChain ThenPopulate(object target) => this; public void Dispose() { } }