Exemple #1
0
 public AsyncFromStringKeyValuePairFilesDataTable(
     ISerializer serializer,
     IDeserializer deserializer,
     IAsyncFileOperations fileOperations,
     IAsyncDirectoryOperations directoryOperations,
     string databasePath,
     string folderName = null)
 {
     if (serializer == null)
     {
         throw new ArgumentNullException("serializer");
     }
     if (deserializer == null)
     {
         throw new ArgumentNullException("deserializer");
     }
     if (fileOperations == null)
     {
         throw new ArgumentNullException("fileOperations");
     }
     if (directoryOperations == null)
     {
         throw new ArgumentNullException("directoryOperations");
     }
     if (string.IsNullOrEmpty(databasePath))
     {
         throw new ArgumentNullException("databasePath");
     }
     _serializer          = serializer;
     _deserializer        = deserializer;
     _fileOperations      = fileOperations;
     _directoryOperations = directoryOperations;
     _databasePath        = databasePath;
     _fullName            = folderName ?? typeof(TValue).FullName;
 }
		public AudioTagsSynchronizer(
			IAsyncFileOperations asyncFileOperations,
			IAudioTagReader audioTagReader,
			IAudioTagWriter audioTagWriter)
		{
			_asyncFileOperations = Guard.ForNull(asyncFileOperations, nameof(asyncFileOperations));
			_audioTagReader = Guard.ForNull(audioTagReader, nameof(audioTagReader));
			_audioTagWriter = Guard.ForNull(audioTagWriter, nameof(audioTagWriter));
		}
		public SymbolicLinkFileSynchronizer(
			MusicMirrorConfiguration configuration,
			IAsyncFileOperations fileOperations,
			IAsyncDirectoryOperations directoryOperations)
		{
			_configuration = Guard.ForNull(configuration, nameof(configuration));
			_fileOperations = Guard.ForNull(fileOperations, nameof(fileOperations));
			_directoryOperations = Guard.ForNull(directoryOperations, nameof(directoryOperations));
		}
		private static IAsyncFileOperations GetFileOperations(NonTranscodingFilesBehavior behavior, IAsyncFileOperations defaultFileOperations)
		{
			switch (behavior)
			{
				case NonTranscodingFilesBehavior.Copy:
					return defaultFileOperations;
				case NonTranscodingFilesBehavior.SymbolicLink:
					return new SymbolicLinkFileOperations(defaultFileOperations);
				default:
					throw new PlatformNotSupportedException();
			}
		}
		public NAudioFileTranscoder(
			IAudioStreamReader audioStreamReader,
			IWaveStreamTranscoder waveStreamTranscoder,
			IAsyncFileOperations asyncFileOperations,
			IAsyncDirectoryOperations asyncDirectoryOperations)
		{
			if (audioStreamReader == null) throw new ArgumentNullException(nameof(audioStreamReader));			
			if (waveStreamTranscoder == null) throw new ArgumentNullException(nameof(waveStreamTranscoder));
			if (asyncFileOperations == null) throw new ArgumentNullException(nameof(asyncFileOperations));
			if (asyncDirectoryOperations == null) throw new ArgumentNullException(nameof(asyncDirectoryOperations));
			_audioStreamReader = audioStreamReader;			
			_waveStreamTranscoder = waveStreamTranscoder;
			_asyncFileOperations = asyncFileOperations;
			_asyncDirectoryOperations = asyncDirectoryOperations;
		}
		public SynchronizeFileService(
			IAsyncFileOperations asyncFileOperations,
			MusicMirrorConfiguration configuration,
			IFileSynchronizer fileSynchronizer,
			ISynchronizedFilesRepository synchronizedFilesRepository)
		{
			if (asyncFileOperations == null) throw new ArgumentNullException(nameof(asyncFileOperations));
			if (configuration == null) throw new ArgumentNullException(nameof(configuration));
			if (fileSynchronizer == null) throw new ArgumentNullException(nameof(fileSynchronizer));
			if (synchronizedFilesRepository == null) throw new ArgumentNullException(nameof(synchronizedFilesRepository));
			_asyncFileOperations = asyncFileOperations;
			_configuration = configuration;
			_fileSynchronizer = fileSynchronizer;
			_synchronizedFilesRepository = synchronizedFilesRepository;
		}
		public SymbolicLinkFileOperations(IAsyncFileOperations defaultAsyncFileOperations)
		{
			this._defaultAsyncFileOperations = Guard.ForNull(defaultAsyncFileOperations, nameof(defaultAsyncFileOperations)); ;
		}
		private static IFileSynchronizer GetSynchronizer(MusicMirrorConfiguration configuration, IAsyncFileOperations fileOperations, IAsyncDirectoryOperations directoryOperations)
		{
			switch (configuration.NonTranscodingFilesBehavior)
			{
				case NonTranscodingFilesBehavior.Copy:
					return new CopyFileSynchronizer(configuration, directoryOperations);
				case NonTranscodingFilesBehavior.SymbolicLink:
					return new SymbolicLinkFileSynchronizer(configuration, fileOperations, directoryOperations);
				default:
					throw new NotSupportedException();
			}
		}