/// <inheritdoc />
        public override IEnumerable <FileSystemInfoBase> EnumerateFileSystemInfos()
        {
            if (!_concreteDirectoryInfo.Exists || _depth >= _fsWrapperFactory.MaxRecursionDepth)
            {
                yield break;
            }
            foreach (FileSystemInfo fileSystemInfo in _fsWrapperFactory.SafeEnumerateFileSystemInfos(_concreteDirectoryInfo))
            {
                switch (fileSystemInfo)
                {
                case DirectoryInfo dirInfo:
                    yield return(_fsWrapperFactory.CreateDirectoryInfoWrapper(dirInfo, _depth + 1));

                    break;

                case FileInfo fileInfo:
                    yield return(_fsWrapperFactory.CreateFileInfoWrapper(fileInfo, _depth));

                    break;

                default:
                    // We should NEVER get here, but if we do just continue on
                    break;
                }
            }
        }
 /// <summary>
 /// Safely calculates the parent of this file, swallowing most errors.
 /// </summary>
 private DirectoryInfoBase SafeParentDirectory()
 {
     try
     {
         return(_fsWrapperFactory.CreateDirectoryInfoWrapper(_concreteFileInfo.Directory, _depth));
     }
     catch (DirectoryNotFoundException e)
     {
         _fsWrapperFactory.Logger.WriteHandledException(
             $"Could not get parent of '{_concreteFileInfo.FullName}' due to it being an invalid path",
             e);
     }
     catch (PathTooLongException e)
     {
         _fsWrapperFactory.Logger.WriteHandledException(
             $"Could not get parent of '{_concreteFileInfo.FullName}' due to the path being too long",
             e);
     }
     catch (Exception e) when(e is SecurityException || e is UnauthorizedAccessException)
     {
         _fsWrapperFactory.Logger.WriteHandledException(
             $"Could not get parent of '{_concreteFileInfo.FullName}' due to the path not being accessible",
             e);
     }
     catch (Exception e)
     {
         _fsWrapperFactory.Logger.WriteHandledException(
             $"Could not get parent of '{_concreteFileInfo.FullName}' due to an exception",
             e);
     }
     return(null);
 }