using System.Text;
using SabreTools.Text.Extensions;
using static SabreTools.Data.Models.Xbox.Constants;

namespace SabreTools.Wrappers
{
    public partial class XMID : IPrintable
    {
#if NETCOREAPP
        /// <inheritdoc/>
        public string ExportJSON(bool recursive) => System.Text.Json.JsonSerializer.Serialize(Model, _jsonSerializerOptions);
#else
        /// <inheritdoc/>
        public string ExportJSON(bool recursive) => Newtonsoft.Json.JsonConvert.SerializeObject(Model, _jsonSerializerOptions);
#endif

        /// <inheritdoc/>
        public void PrintInformation(StringBuilder builder, bool recursive)
        {
            builder.AppendLine("Xbox Media Identifier Information:");
            builder.AppendLine("-------------------------");
            builder.AppendLine(Model.PublisherIdentifier, "Publisher identifier");
            if (Publishers.TryGetValue(Model.PublisherIdentifier, out var publisher))
                builder.AppendLine(publisher, "Publisher");
            builder.AppendLine(Model.GameID, "Game ID");
            builder.AppendLine(Model.VersionNumber, "Version number");
            builder.AppendLine(Model.RegionIdentifier, "Region identifier");
            if (Regions.TryGetValue(Model.RegionIdentifier, out var region))
                builder.AppendLine(region, "Region");
            builder.AppendLine();
        }
    }
}
