using System.Text;

namespace SabreTools.Serialization.Writers
{
    public partial class XMID : IStringWriter<Data.Models.Xbox.XMID>
    {
        /// <inheritdoc/>
        public bool Debug { get; set; } = false;

        /// <inheritdoc cref="IStringWriter.Serialize(T?)"/>
        public static string? SerializeString(Data.Models.Xbox.XMID? obj)
        {
            var deserializer = new XMID();
            return deserializer.Serialize(obj);
        }

        /// <inheritdoc/>
        public string? Serialize(Data.Models.Xbox.XMID? obj)
        {
            if (obj is null)
                return null;

            var sb = new StringBuilder();

            sb.Append(obj.PublisherIdentifier);
            sb.Append(obj.GameID);
            sb.Append(obj.VersionNumber);
            sb.Append(obj.RegionIdentifier);

            return sb.ToString();
        }
    }
}
