当前位置: 首页>>代码示例>>C#>>正文


C# IProgress.Advance方法代码示例

本文整理汇总了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;
        }
开发者ID:soheilpro,项目名称:Rhapsody,代码行数:29,代码来源:Album.cs

示例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);
        }
开发者ID:soheilpro,项目名称:Rhapsody,代码行数:23,代码来源:Disc.cs

示例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;
                    }
                }
            }
        }
开发者ID:soheilpro,项目名称:Rhapsody,代码行数:50,代码来源:Album.cs


注:本文中的IProgress.Advance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。