Ejemplo n.º 1
0
        //Projection for FD, FF, and FA use the DirectoryInfo.FullName, FileInfo.FullName, and / or Path properties
        public static string GetFullName(this IFSEntityAbstract fSEntityAbstract)
        {
            Func <FSEntityDirectory, string> PFD = new Func <FSEntityDirectory, string>((fSEntityDirectory) => {
                return(fSEntityDirectory.DirectoryInfo != null ? fSEntityDirectory.DirectoryInfo.FullName : fSEntityDirectory.Path.Replace('/', '\\'));
            });
            Func <FSEntityFile, string> PFF = new Func <FSEntityFile, string>((fSEntityFile) => {
                return(fSEntityFile.FileInfo != null ? fSEntityFile.FileInfo.FullName : fSEntityFile.Path.Replace('/', '\\'));
            });
            Func <FSEntityArchiveFile, string> PFA = new Func <FSEntityArchiveFile, string>((fSEntityArchiveFile) => {
                return(fSEntityArchiveFile.FileInfo != null ?  fSEntityArchiveFile.FileInfo.FullName : fSEntityArchiveFile.Path.Replace('/', '\\'));
            });

            switch (fSEntityAbstract)
            {
            case FSEntityDirectory directory:
            {
                return(PFD(fSEntityAbstract as FSEntityDirectory));
            }

            case FSEntityArchiveFile file: // Important to handle the more-derived type (subclass) before handling a less-derived type (superclass)
            {
                return(PFA(fSEntityAbstract as FSEntityArchiveFile));
            }

            case FSEntityFile file:
            {
                return(PFF(fSEntityAbstract as FSEntityFile));
            }

            default:
            {
                throw new Exception(string.Format(CultureInfo.CurrentCulture, StringConstants.InvalidTypeInSwitchExceptionMessage, fSEntityAbstract));
            }
            }
        }
Ejemplo n.º 2
0
 // Helper method to reduce code clutter
 // Exceptions that occur when looking at individual directories or files are acceptable, but need to be recorded
 static void HandleAcceptableExceptions(Exception e, IFSEntityAbstract currentVertex, IConvertFileSystemToGraphResult convertFileSystemToGraphResult, IConvertFileSystemToGraphProgress?convertFileSystemToGraphProgress, CancellationToken cancellationToken)
 {
     // Store this exception on the currentFSEntityDirectory and accumulate the exception as part of the Result and Progress
     //currentVertex.Obj.Exception = e;
     currentVertex.Exception = e;
     // Add this exception to the results and progress
     convertFileSystemToGraphResult.AcceptableExceptions.Add(e);
     if (convertFileSystemToGraphProgress != null)
     {
         convertFileSystemToGraphProgress.AcceptableExceptions.Add(e);
     }
 }