private static DirectoryDataModel Adapt(DirectoryInfo directoryInfo, FileSearchParameters parameters)
        {
            var subDirectories = directoryInfo.GetDirectories().Select(di => Adapt(di, parameters)).ToList();

            var fileInfos = directoryInfo.EnumerateFiles("*", SearchOption.TopDirectoryOnly);

            if (!string.IsNullOrEmpty(parameters.FileName))
            {
                fileInfos = fileInfos.Where(f => f.Name.IndexOf(parameters.FileName, StringComparison.OrdinalIgnoreCase) > -1);
            }

            if (parameters.FileType != null)
            {
                fileInfos = fileInfos.Where(f => f.Extension.ToUpperInvariant() == parameters.FileType.Extension);
            }

            var files = fileInfos.Select(
                f => new FileDataModel
            {
                FileExtension = f.Extension,
                FileName      = f.Name,
                FilePath      = f.FullName,
                Content       = string.Empty
            });

            var result = new DirectoryDataModel(
                directoryInfo.FullName,
                directoryInfo.Name,
                subDirectories,
                files.ToList());

            return(result);
        }
        private static Directory AdaptDirectory(DirectoryDataModel directoryDataModel)
        {
            var subDirectories = directoryDataModel.SubDirectories.Select(AdaptDirectory).ToList();
            var files          = directoryDataModel.Files.Select(AdaptFile).ToList();

            var result = new Directory(
                directoryDataModel.Path,
                directoryDataModel.DirectoryName,
                subDirectories,
                files);

            return(result);
        }