本文整理汇总了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);
}
}
}