本文整理匯總了C#中System.Boolean.All方法的典型用法代碼示例。如果您正苦於以下問題:C# Boolean.All方法的具體用法?C# Boolean.All怎麽用?C# Boolean.All使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Boolean
的用法示例。
在下文中一共展示了Boolean.All方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DownloadAlbum
/// <summary>
/// Downloads an album.
/// </summary>
/// <param name="album">The album to download.</param>
/// <param name="downloadsFolder">The downloads folder.</param>
/// <param name="tagTracks">True to tag tracks; false otherwise.</param>
/// <param name="saveCoverArtInTags">True to save cover art in tags; false otherwise.</param>
/// <param name="saveCovertArtInFolder">True to save cover art in the downloads folder; false otherwise.</param>
/// <param name="convertCoverArtToJpg">True to convert the cover art to jpg; false otherwise.</param>
/// <param name="resizeCoverArt">True to resize the covert art; false otherwise.</param>
/// <param name="coverArtMaxSize">The maximum width/height of the cover art when resizing.</param>
private void DownloadAlbum(Album album, String downloadsFolder, Boolean tagTracks, Boolean saveCoverArtInTags,
Boolean saveCovertArtInFolder, Boolean convertCoverArtToJpg, Boolean resizeCoverArt, int coverArtMaxSize) {
if (this.userCancelled) {
// Abort
return;
}
// Create directory to place track files
String directoryPath = downloadsFolder + "\\" + album.Title.ToAllowedFileName() + "\\";
try {
Directory.CreateDirectory(directoryPath);
} catch {
Log("An error occured when creating the album folder. Make sure you have the rights to write files in the folder you chose",
LogType.Error);
return;
}
TagLib.Picture artwork = null;
// Download artwork
if (saveCoverArtInTags || saveCovertArtInFolder) {
artwork = DownloadCoverArt(album, downloadsFolder, saveCovertArtInFolder, convertCoverArtToJpg, resizeCoverArt,
coverArtMaxSize);
}
// Download & tag tracks
Task[] tasks = new Task[album.Tracks.Count];
Boolean[] tracksDownloaded = new Boolean[album.Tracks.Count];
for (int i = 0; i < album.Tracks.Count; i++) {
// Temporarily save the index or we will have a race condition exception when i hits its maximum value
int currentIndex = i;
tasks[currentIndex] = Task.Factory.StartNew(() => tracksDownloaded[currentIndex] =
DownloadAndTagTrack(directoryPath, album, album.Tracks[currentIndex], tagTracks, saveCoverArtInTags, artwork));
}
// Wait for all tracks to be downloaded before saying the album is downloaded
Task.WaitAll(tasks);
if (!this.userCancelled) {
// Tasks have not been aborted
if (tracksDownloaded.All(x => x == true)) {
Log("Successfully downloaded album \"" + album.Title + "\"", LogType.Success);
} else {
Log("Finished downloading album \"" + album.Title + "\". Some tracks could not be downloaded", LogType.Success);
}
}
}