Пример #1
0
 public FileRenamerPermitionsChecker(IFileRenamer fileRenamer,
                                     IPermitionsChecker permitionsChecker, Permitions userPermitions = Permitions.Guest)
 {
     this.fileRenamer       = fileRenamer;
     this.permitionsChecker = permitionsChecker;
     this.userPermitions    = userPermitions;
 }
Пример #2
0
        public void Process(string[] args, MP3File[] files, Permitions userPermitions = Permitions.Guest)
        {
            if (files == null || files.Length == 0)
            {
                throw new ArgumentException("No files to process");
            }

            ArgumentsParser parser    = new ArgumentsParser();
            Arguments       arguments = parser.ParseArguments(args);

            foreach (var file in files)
            {
                string       message     = file.Path;
                IFileRenamer fileRenamer = new FileRenamer();

                if (arguments.IsCheckPermitions)
                {
                    IFileRenamer       oldFileRenamer = fileRenamer;
                    IPermitionsChecker checker        = new PermitionsChecker();
                    fileRenamer = new FileRenamerPermitionsChecker(oldFileRenamer, checker, userPermitions);
                }

                if (arguments.IsTimeMeasure)
                {
                    IFileRenamer oldFileRenamer = fileRenamer;
                    fileRenamer = new FileRenamerTimeMeasure(oldFileRenamer);
                }

                fileRenamer.Rename(file);

                message += " successfully renamed to " + file.Path;
                if (arguments.IsTimeMeasure)
                {
                    message += " in " + ((FileRenamerTimeMeasure)fileRenamer).ElapsedTime;
                }

                Console.WriteLine(message);
            }
        }
Пример #3
0
 public bool Check(MP3File file, Permitions permitions)
 {
     return(file.FilePermitions <= permitions);
 }
Пример #4
0
 public MP3File(string path, Permitions permitions) : this(path)
 {
     FilePermitions = permitions;
 }
Пример #5
0
 public MP3File(string path)
 {
     Path           = path;
     FilePermitions = Permitions.Guest;
 }