using System;

namespace InABox.Core
{
    public class DFLayoutNotesFieldProperties : DFLayoutFieldProperties<string[]>
    {
        public override string FormatValue(object value)
        {
            return string.Join(",", (string[])value);
        }

        public override object? ParseValue(object value)
        {
            if (value is string[])
                return value;
            if (value is string)
                try
                {
                    return Serialization.Deserialize<string[]>((string)value);
                }
                catch (Exception)
                {
                    return null;
                }

            return null;
        }
    }
}