本文整理汇总了C#中IProgress.Begin方法的典型用法代码示例。如果您正苦于以下问题:C# IProgress.Begin方法的具体用法?C# IProgress.Begin怎么用?C# IProgress.Begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProgress
的用法示例。
在下文中一共展示了IProgress.Begin方法的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 destinationDirectory, IProgress progress, CancellationToken cancellationToken)
{
progress.Begin(Discs.Sum(disc => disc.Tracks.Count));
if (!destinationDirectory.Exists)
destinationDirectory.Create();
var artistDirectory = destinationDirectory.CreateSubdirectory(ArtistDirectoryName);
if (artistDirectory.GetDirectories(AlbumDirectoryName).Length != 0)
throw new Exception("Album directory exists!");
var albumDirectory = artistDirectory.CreateSubdirectory(AlbumDirectoryName);
foreach (var disc in Discs)
disc.SaveTo(albumDirectory, progress, cancellationToken);
GeneratePlaylist(albumDirectory);
AlbumDirectory = albumDirectory;
}
示例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;
}
}
}
}