Ejemplo n.º 1
0
        public CopyWorker(IFileSystem fileSystem, IFileHelper fileHelper, IContext uiContext, IBackgroundWorker backgroundWorker, IUniqueCharsGenerator charsGenerator)
        {
            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }
            if (fileHelper == null)
            {
                throw new ArgumentNullException("fileHelper");
            }
            if (uiContext == null)
            {
                throw new ArgumentNullException("uiContext");
            }
            if (backgroundWorker == null)
            {
                throw new ArgumentNullException("backgroundWorker");
            }
            if (charsGenerator == null)
            {
                throw new ArgumentNullException("charsGenerator");
            }

            _fileSystem       = fileSystem;
            _fileHelper       = fileHelper;
            _uiContext        = uiContext;
            _backgroundWorker = backgroundWorker;
            _charsGenerator   = charsGenerator;
        }
Ejemplo n.º 2
0
        public string GenerateUniqueFileName(AppFile file, IUniqueCharsGenerator generator, UniqueCharsPosition position)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (generator == null)
            {
                throw new ArgumentNullException("generator");
            }

            string uniqueID = generator.Generate();

            StringBuilder sb = new StringBuilder();

            if (position == UniqueCharsPosition.Prefix)
            {
                sb.AppendFormat("{0}_", uniqueID);
            }

            sb.AppendFormat("{0}", file.FileNameWithoutExtension);

            if (position == UniqueCharsPosition.Suffix)
            {
                sb.AppendFormat("_{0}", uniqueID);
            }

            sb.AppendFormat("{0}", file.FileExtension);

            return(sb.ToString());
        }
Ejemplo n.º 3
0
        public string GenerateUniqueFileName(AppFile file, IUniqueCharsGenerator generator, UniqueCharsPosition position)
        {
            if (file == null) { throw new ArgumentNullException("file"); }
            if (generator == null) { throw new ArgumentNullException("generator"); }

            string uniqueID = generator.Generate();

            StringBuilder sb = new StringBuilder();

            if (position == UniqueCharsPosition.Prefix)
            {
                sb.AppendFormat("{0}_", uniqueID);
            }

            sb.AppendFormat("{0}", file.FileNameWithoutExtension);

            if (position == UniqueCharsPosition.Suffix)
            {
                sb.AppendFormat("_{0}", uniqueID);
            }

            sb.AppendFormat("{0}", file.FileExtension);

            return sb.ToString();
        }
Ejemplo n.º 4
0
        public CopyWorker(IFileSystem fileSystem, IFileHelper fileHelper, IContext uiContext, IBackgroundWorker backgroundWorker, IUniqueCharsGenerator charsGenerator)
        {
            if (fileSystem == null) throw new ArgumentNullException("fileSystem");
            if (fileHelper == null) throw new ArgumentNullException("fileHelper");
            if (uiContext == null) throw new ArgumentNullException("uiContext");
            if (backgroundWorker == null) throw new ArgumentNullException("backgroundWorker");
            if (charsGenerator == null) throw new ArgumentNullException("charsGenerator");

            _fileSystem = fileSystem;
            _fileHelper = fileHelper;
            _uiContext = uiContext;
            _backgroundWorker = backgroundWorker;
            _charsGenerator = charsGenerator;
        }