using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace skyscraper5.DNS.Protocol.ResourceRecords.Records
{
	public class TextResourceRecord : BaseResourceRecord, SimpleDnsRecord
	{
		public TextResourceRecord(IResourceRecord record) :
			base(record)
		{
			TextData = CharacterString.GetAllFromArray(Data, 0);
		}

		public IList<CharacterString> TextData { get; }

		public string GetDataAsString()
		{
			string[] strings = TextData.Select(x => x.ToUTF8()).ToArray();
			string value = JsonSerializer.Serialize(strings);
			return value;
		}
	}
}
