using RyzStudio.Windows.Forms;
using System.Collections.Generic;
using System.IO;

namespace BookmarkManager
{
    public abstract class SupportedFileBase : ISupportedFile
    {
        protected List<string> supportedExtensions = new List<string>();


        public SupportedFileBase()
        {
        }


        public virtual bool IsEncryptionSupported { get; set; } = false;

        public List<string> SupportedExtensions { get => supportedExtensions; }


        public virtual bool IsSupported(string filename)
        {
            if (string.IsNullOrWhiteSpace(filename))
            {
                return false;
            }

            if (supportedExtensions == null)
            {
                return false;
            }

            if (supportedExtensions.Count <= 0)
            {
                return false;
            }

            return supportedExtensions.Contains(Path.GetExtension(filename)?.Trim()?.ToLower());
        }

        public virtual bool IsEncrypted(string filename) => false;

        public virtual Result Load(BookmarkTreeView treeview, string filename, string password) => Result.Create(false);

        public virtual Result Save(BookmarkTreeView treeview, string filename, string password) => Result.Create(false);

    }
}
