using Quadarax.Foundation.Core.IO.FileSystem.Memory;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.Abstractions;
namespace Quadarax.Foundation.Core.IO.FileSystem.Memory
{

    public class MemoryFileInfo : IFileInfo
    {
        private readonly MemoryFileSystem _fileSystem;
        private readonly string _path;

        public MemoryFileInfo(MemoryFileSystem fileSystem, string path)
        {
            _fileSystem = fileSystem;
            _path = path;
        }

         public bool Exists => _fileSystem.FileSystemDictionary.ContainsKey(_path);

    public string Name => Path.GetFileName(_path);

    public string FullName => _path;

    public bool IsSymbolicLink
    {
        get
        {
            if (_fileSystem.FileSystemDictionary.TryGetValue(_path, out var entry))
            {
                return entry.IsSymbolicLink;
            }
            return false;
        }
    }

    public string? LinkTarget
    {
        get
        {
            if (_fileSystem.FileSystemDictionary.TryGetValue(_path, out var entry) && entry.IsSymbolicLink)
            {
                return entry.SymbolicLinkTarget;
            }
            return null;
        }
    }

        public IDirectoryInfo? Directory => throw new NotImplementedException();

        public string? DirectoryName => throw new NotImplementedException();

        public bool IsReadOnly { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

        public long Length => throw new NotImplementedException();

        public IFileSystem FileSystem => throw new NotImplementedException();

        public FileAttributes Attributes { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
        public DateTime CreationTime { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
        public DateTime CreationTimeUtc { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

        public string Extension => throw new NotImplementedException();

        public DateTime LastAccessTime { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
        public DateTime LastAccessTimeUtc { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
        public DateTime LastWriteTime { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
        public DateTime LastWriteTimeUtc { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

        public UnixFileMode UnixFileMode { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

        public StreamWriter AppendText()
        {
            throw new NotImplementedException();
        }

        public IFileInfo CopyTo(string destFileName)
        {
            throw new NotImplementedException();
        }

        public IFileInfo CopyTo(string destFileName, bool overwrite)
        {
            throw new NotImplementedException();
        }

        public FileSystemStream Create()
        {
            throw new NotImplementedException();
        }

        public void CreateAsSymbolicLink(string pathToTarget)
        {
            throw new NotImplementedException();
        }

        public StreamWriter CreateText()
        {
            throw new NotImplementedException();
        }

        public void Decrypt()
        {
            throw new NotImplementedException();
        }

        public void Delete()
        {
            throw new NotImplementedException();
        }

        public void Encrypt()
        {
            throw new NotImplementedException();
        }

        public void MoveTo(string destFileName)
        {
            throw new NotImplementedException();
        }

        public void MoveTo(string destFileName, bool overwrite)
        {
            throw new NotImplementedException();
        }

        public FileSystemStream Open(FileMode mode)
        {
            throw new NotImplementedException();
        }

        public FileSystemStream Open(FileMode mode, FileAccess access)
        {
            throw new NotImplementedException();
        }

        public FileSystemStream Open(FileMode mode, FileAccess access, FileShare share)
        {
            throw new NotImplementedException();
        }

        public FileSystemStream Open(FileStreamOptions options)
        {
            throw new NotImplementedException();
        }

        public FileSystemStream OpenRead()
        {
            throw new NotImplementedException();
        }

        public StreamReader OpenText()
        {
            throw new NotImplementedException();
        }

        public FileSystemStream OpenWrite()
        {
            throw new NotImplementedException();
        }

        public void Refresh()
        {
            throw new NotImplementedException();
        }

        public IFileInfo Replace(string destinationFileName, string? destinationBackupFileName)
        {
            throw new NotImplementedException();
        }

        public IFileInfo Replace(string destinationFileName, string? destinationBackupFileName, bool ignoreMetadataErrors)
        {
            throw new NotImplementedException();
        }

        public IFileSystemInfo? ResolveLinkTarget(bool returnFinalTarget)
        {
            throw new NotImplementedException();
        }

        // Implement other properties and methods as needed
    }

   
    public class MemoryFileInfoFactory : IFileInfoFactory
    {
        private readonly MemoryFileSystem _fileSystem;

        public MemoryFileInfoFactory(MemoryFileSystem fileSystem)
        {
            _fileSystem = fileSystem;
        }

        public IFileSystem FileSystem => throw new NotImplementedException();

        public IFileInfo New(string fileName)
        {
            return new MemoryFileInfo(_fileSystem, fileName);
        }

        [return: NotNullIfNotNull("fileInfo")]
        public IFileInfo? Wrap(FileInfo? fileInfo)
        {
            throw new NotImplementedException();
        }
    }

    public class MemoryDirectoryInfoFactory : IDirectoryInfoFactory
    {
        private readonly MemoryFileSystem _fileSystem;

        public MemoryDirectoryInfoFactory(MemoryFileSystem fileSystem)
        {
            _fileSystem = fileSystem;
        }

        public IFileSystem FileSystem => throw new NotImplementedException();

        public IDirectoryInfo New(string path)
        {
            return new MemoryDirectoryInfo(_fileSystem, path);
        }

        [return: NotNullIfNotNull("directoryInfo")]
        public IDirectoryInfo? Wrap(DirectoryInfo? directoryInfo)
        {
            throw new NotImplementedException();
        }
    }
}