namespace ZionFoundation.Components
{
    public class File : IComponent
    {
        #region Private properties
        private string name;
        private string extension;
        private string status;
        private string path;
        #endregion

        #region Public properties
        public string Name { get => name; set => name = value; }
        public string Extension { get => extension; set => extension = value; }
        public string Status { get => status; set => status = value; }
        public string Path { get => path; set => path = value; }
        #endregion

        #region Custom properties
        public string FullPath
        {
            get
            {
                return string.Format(@"{0}\{1}.{2}", path, name, extension);
            }
        }

        public string FullName
        {
            get
            {
                return string.Format(@"{0}.{1}", name, extension);
            }
        }

        public string Directory
        {
            get
            {
                return string.Format(@"{0}", path);
            }
        }
        public bool Exists
        {
            get => System.IO.File.Exists(FullPath);
        }
        #endregion

        public void Move(string folder)
        {
            System.IO.File.Move(
                FullPath,
                System.IO.Path.Combine(folder, FullName)
                );
        }

        #region Constructors
        public File(string path)
        {
            System.IO.FileInfo info = new System.IO.FileInfo(path);
            this.name = info.Name.Replace(info.Extension, "");
            this.extension = info.Extension.Trim('.');
            this.path = info.DirectoryName;
        }
        public File(string name, string extension, string path)
        {
            Name = name;
            Extension = extension;
            Path = path;
        }
        #endregion
    }
}
