using System;

namespace InABox.Core
{

    public delegate void EmbeddedListEditorCreateButtons(object sender);
        
    public class EmbeddedListEditor : BaseEditor
    {
        public Type DataType;
        
        public String Label { get; set; }
        
        public bool DirectEdit { get; set; }

        public bool AddRows { get; set; }

        public event EmbeddedListEditorCreateButtons OnCreateButtons;

        public void CreateButtons(object sender) => OnCreateButtons?.Invoke(sender);

        public EmbeddedListEditor(Type dataType)
        {
            if (!typeof(BaseObject).IsAssignableFrom(dataType))
                throw new InvalidCastException("DataType must be of type BaseObject");
            DataType = dataType;
            Label = "Edit";
            DirectEdit = false;
            AddRows = true;
        }

        protected override BaseEditor DoClone() => new EmbeddedListEditor(DataType) { Label = this.Label, DirectEdit = this.DirectEdit, AddRows = this.AddRows };
        
    }
}