using System;

namespace InABox.Core
{
    public class DFLayoutDocumentFieldProperties : DFLayoutFieldProperties<Guid, Guid?>
    {
        
        [EditorSequence(-995)]
        [NullEditor]
        public override Guid Default { get; set; }
        
        public string? FileMask { get; set; }

        public override string FormatValue(Guid? value)
        {
            return value != null && value != Guid.Empty ? "Yes" : "";
        }

        public override Guid? DeserializeValue(DFLoadStorageEntry entry)
        {
            return entry.GetValue<Guid?>();
        }

        public override void SerializeValue(DFSaveStorageEntry entry, Guid? value)
        {
            entry.SetValue(value);
        }

        public override Guid GetValue(Guid? value)
        {
            return value ?? Default;
        }

        protected override void LoadProperties()
        {
            base.LoadProperties();
            FileMask = GetProperty("FileMask", FileMask);
        }

        protected override void SaveProperties()
        {
            base.SaveProperties();
            SetProperty("FileMask", FileMask);
        }
    }
}