public void BeforeStartDrag(IEnumerable <ISearchResult> selectedResults, ITargetDirectoryProvider targetDirectoryProvider, out List <string> createdStubFiles) { List <string> files = new List <string>(); // Define an action to create a stub for an IDeployableAudioFile Action <IDeployableAudioFile> createStub = (IDeployableAudioFile file) => { string filePath = targetDirectoryProvider.GetFullPath(file); // Only create stubs for files which don't exist yet if (!System.IO.File.Exists(filePath)) { System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(filePath)); FileStream s = System.IO.File.Create(filePath); s.Close(); files.Add(filePath); } }; // Go through all IDeployableAudioFiles required by the selected ISearchResults and create a stub for each one foreach (ISearchResult result in selectedResults) { if (result is IDeployableAudioFile) { createStub(result as IDeployableAudioFile); } foreach (IDeployableAudioFile file in result.RequiredFiles) { createStub(file); } } // Return a list of stub files that have been created createdStubFiles = files; }
public AudioDeploymentResult Download(IAbsoluteProgressMonitor monitor, ITargetDirectoryProvider targetDirectoryProvider) { string downloadTargetPath = targetDirectoryProvider.GetFullPath(this); // Make sure the target directory exists System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(downloadTargetPath)); // Only download if the target file doesn't exist (or is empty, that is, a stub) if (!System.IO.File.Exists(downloadTargetPath) || new System.IO.FileInfo(downloadTargetPath).Length == 0) { // Download the file (synchronously) client.DownloadFile(new Uri(SourceUrl), downloadTargetPath); // TODO: set additional ID3 information regarding source, author, license, tags etc. on the file } monitor.IncreaseProgress(DownloadSize.GetValueOrDefault(1)); return(AudioDeploymentResult.SUCCESS); }
public AudioDeploymentResult Deploy(IAbsoluteProgressMonitor monitor, ITargetDirectoryProvider targetDirectoryProvider) { ((TestAudioSource)AudioSource).ExtractEmbeddedFile(m_ResourceName, targetDirectoryProvider.GetFullPath(this)); return(AudioDeploymentResult.SUCCESS); }