/// <exception cref="ArgumentNullException"> /// <paramref name="trainingProviderName"/> or /// <paramref name="host"/> or /// <paramref name="updatesUriOrPath"/> or /// <paramref name="mediaPath"/> is <see langword="null" />.</exception> /// <exception cref="TrainingCatalogInitializationException"></exception> /// <exception cref="DirectoryNotFoundException"><param name="archiveDirectory"></param> not found.</exception> public virtual void Initialize(string trainingProviderName, int trainingProviderId, string host, string updatesUriOrPath, LocationType catalogLocation, IMediaPath mediaPath, string archiveDirectory) { if (trainingProviderName == null) { throw new ArgumentNullException("trainingProviderName"); } if (host == null) { throw new ArgumentNullException("host"); } if (updatesUriOrPath == null) { throw new ArgumentNullException("updatesUriOrPath"); } if (mediaPath == null) { throw new ArgumentNullException("mediaPath"); } if (!FileSystemProxy.IsDirectoryExists(archiveDirectory)) { throw new DirectoryNotFoundException( string.Format(Resources.TrainingCatalogException_ArchiveDirectoryNotFound, archiveDirectory)); } TrainingProviderName = trainingProviderName; TrainingProviderId = trainingProviderId; Host = host; MediaPath = mediaPath; UpdateContentUriOrPath = updatesUriOrPath; UpdateContentLocation = catalogLocation; try { ArchiveFolderPath = Path.Combine(archiveDirectory, TrainingProviderName); var utcNow = DateTime.UtcNow; var currentSaveDirectory = Path.Combine(ArchiveFolderPath, utcNow.ToString("yyyy"), utcNow.ToString("yyyy.MM"), utcNow.ToString("yyyy.MM.dd")); ArchiveCurrentSaveDirectory = Path.Combine(ArchiveFolderPath, currentSaveDirectory); if (!FileSystemProxy.IsDirectoryExists(ArchiveCurrentSaveDirectory)) { FileSystemProxy.CreateDirectory(ArchiveCurrentSaveDirectory); } _mediaContentProcessor = new TrainingCatalogMediaContentProcessor(TrainingProviderId, TrainingProviderName, MediaPath, HttpDownloadManager, FileSystemProxy); IsInitialized = true; } catch (Exception ex) { throw new TrainingCatalogInitializationException(Resources.TrainingCatalogInitializationException_Message, ex); } }
/// <exception cref="ArgumentNullException"><paramref name="mediaContentProcessor"/> is <see langword="null" />.</exception> /// <exception cref="InvalidOperationException">Method must be invoked only after Initialize(...) method</exception> public void SetMediaContentProcessor(ITrainingCatalogMediaContentProcessor mediaContentProcessor) { if (mediaContentProcessor == null) { throw new ArgumentNullException("mediaContentProcessor"); } if (IsInitialized == false) { throw new InvalidOperationException("Method must be invoked only after Initialize(...) method"); } _mediaContentProcessor = mediaContentProcessor; }