using System.Reflection;

namespace AyCode.Core.Serializers.Jsons;

/// <summary>
/// Options for AcJsonSerializer and AcJsonDeserializer.
/// </summary>
public sealed class AcJsonSerializerOptions : AcSerializerOptions
{
    public override AcSerializerType SerializerType { get; init; } = AcSerializerType.Json;

    /// <summary>
    /// Default options instance with reference handling enabled and max depth.
    /// Returns a new instance each time to prevent shared state corruption.
    /// </summary>
    public static AcJsonSerializerOptions Default => new() { ReferenceHandling = ReferenceHandlingMode.All };

    /// <summary>
    /// Options for flat serialization (root level only, no references).
    /// Returns a new instance each time to prevent shared state corruption.
    /// </summary>
    public static AcJsonSerializerOptions FlatCopy => new() { MaxDepth = 0, ReferenceHandling = ReferenceHandlingMode.None, MaxDepthBehavior = MaxDepthBehavior.Truncate};

    /// <summary>
    /// Creates options with specified max depth.
    /// </summary>
    public static AcJsonSerializerOptions WithMaxDepth(byte maxDepth) => new() { MaxDepth = maxDepth };

    /// <summary>
    /// Creates options without reference handling.
    /// </summary>
    public static AcJsonSerializerOptions WithoutReferenceHandling => new() { ReferenceHandling = ReferenceHandlingMode.None };
}