Beispiel #1
0
        private void InitializeData()
        {
            cbRenameType.DataSource = new List<string>() { "RemoveCharacter", "ReplaceCharacter" };

            _renamer = _container.Resolve<IFileRenamer>("RemoveCharacter");

        }
Beispiel #2
0
 public FileRenamerPermitionsChecker(IFileRenamer fileRenamer,
                                     IPermitionsChecker permitionsChecker, Permitions userPermitions = Permitions.Guest)
 {
     this.fileRenamer       = fileRenamer;
     this.permitionsChecker = permitionsChecker;
     this.userPermitions    = userPermitions;
 }
Beispiel #3
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);
            }
        }
Beispiel #4
0
 public RenamerWithPermissionCheck(IFileRenamer renamer, IPermissionChecker checker, UserRole role)
 {
     _renamer = renamer;
     _checker = checker;
     _role    = role;
 }
Beispiel #5
0
        private void cbRenameType_SelectionChangeCommitted(object sender, EventArgs e)
        {
            string name = ((ComboBox)sender).Text;

            this._renamer = _container.Resolve<IFileRenamer>(name);
        }
Beispiel #6
0
 public static bool TryWithFileRenamer(this IFile model, out IFileRenamer feature)
 {
     Ensure.NotNull(model, "model");
     return(model.TryWith <IFileRenamer>(out feature));
 }
Beispiel #7
0
 public FileRenamerTimeMeasure(IFileRenamer fileRenamer)
 {
     this.fileRenamer = fileRenamer;
     stopwatch        = new Stopwatch();
 }
Beispiel #8
0
 public RenamerWithTimeCounter(IFileRenamer renamer)
 {
     _renamer = renamer;
     watch    = new Stopwatch();
 }