本文整理汇总了C#中IProgress.Advance方法的典型用法代码示例。如果您正苦于以下问题:C# IProgress.Advance方法的具体用法?C# IProgress.Advance怎么用?C# IProgress.Advance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProgress
的用法示例。
在下文中一共展示了IProgress.Advance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Album
public Album(DirectoryInfo sourceDirectory, IProgress progress, CancellationToken cancellationToken, Session session, Context context)
: this(session, context)
{
var discDirectories = new List<DirectoryInfo>();
discDirectories.Add(sourceDirectory);
discDirectories.AddRange(sourceDirectory.GetDirectories());
progress.Begin(discDirectories.Sum(directory => directory.GetFiles("*.mp3").Length));
foreach (var directory in discDirectories)
{
var disc = new Disc(this, _session, _context);
foreach (var file in directory.GetFiles("*.mp3"))
{
cancellationToken.ThrowIfCancellationRequested();
progress.Advance(file.Name);
var track = new Track(file, disc, _session, _context);
disc.Tracks.Add(track);
}
if (disc.Tracks.Count > 0)
Discs.Add(disc);
}
SourceDirectory = sourceDirectory;
}
示例2: SaveTo
public void SaveTo(DirectoryInfo albumDirectory, IProgress progress, CancellationToken cancellationToken)
{
var discDirectory = Album.Discs.Count == 1 ? albumDirectory : albumDirectory.CreateSubdirectory(DirectoryName);
foreach (var track in Tracks)
{
cancellationToken.ThrowIfCancellationRequested();
progress.Advance(string.Format(@"{0}\{1}", FullName, track.Name));
track.SaveTo(discDirectory, progress, cancellationToken);
}
if (_session.Album.Cover != null)
{
var coverFilePath = Path.Combine(discDirectory.FullName, "Cover" + Picture.GetExtensionByMimeType(_session.Album.Cover.MimeType));
File.WriteAllBytes(coverFilePath, _session.Album.Cover.Data);
}
if (Album.Discs.Count > 1)
GeneratePlaylist(discDirectory);
}
示例3: DetectIssues
public IEnumerable<Issue> DetectIssues(IProgress progress, CancellationToken cancellationToken)
{
progress.Begin(2 + Discs.Sum(disc => disc.Tracks.Count + 1)); // Artist Name + Album Name + (Disk Name + Track Count)*
progress.Advance(string.Format("Artist: {0}", ArtistName));
foreach (var validator in _context.GetArtistValidators(this))
{
cancellationToken.ThrowIfCancellationRequested();
foreach (var issue in validator.Validate())
yield return issue;
}
progress.Advance(string.Format("Album: {0}", Name));
foreach (var validator in _context.GetAlbumValidators(this))
{
cancellationToken.ThrowIfCancellationRequested();
foreach (var issue in validator.Validate())
yield return issue;
}
foreach (var disc in Discs)
{
progress.Advance(string.Format("Disc {0} Name: {1}", disc.Index, Name));
foreach (var validator in _context.GetDiscValidators(disc))
{
cancellationToken.ThrowIfCancellationRequested();
foreach (var issue in validator.Validate())
yield return issue;
}
foreach (var track in disc.Tracks)
{
progress.Advance(string.Format(@"Disc {0}\Track {1}: {2}", disc.Index, track.Index, Name));
foreach (var validator in _context.GetTrackValidators(track))
{
cancellationToken.ThrowIfCancellationRequested();
foreach (var issue in validator.Validate())
yield return issue;
}
}
}
}