Esempio n. 1
0
        public CompositeComparer(IEnumerable <IComparer <T> > comparers)
        {
            var c = ArgValidation.ThrowIfNull(comparers, "comparers");

            _comparers = c.ToArray();

            if (_comparers.Length == 0)
            {
                throw new ArgumentException("comparers is empty");
            }
        }
Esempio n. 2
0
        private async Task DoDownloadAsync(string id, Stream stream, CancellationToken ct = default(CancellationToken), IProgress <string> progress = null)
        {
            ArgValidation.ThrowIfNull(stream, "stream");

            var driveService = await GetDriveServiceAsync().ConfigureAwait(false);

            try
            {
                var request = driveService.Files.Get(id);
                request.SupportsTeamDrives = true;
                if (progress != null)
                {
                    request.MediaDownloader.ProgressChanged += p =>
                    {
                        switch (p.Status)
                        {
                        case DownloadStatus.Downloading:
                        {
                            progress.Report("Bytes downloaded: " + p.BytesDownloaded);
                            break;
                        }

                        case DownloadStatus.Completed:
                        {
                            progress.Report("Download completed");
                            break;
                        }

                        case DownloadStatus.Failed:
                        {
                            progress.Report("Download failed");
                            break;
                        }
                        }
                    };
                }

                await request.DownloadAsync(stream, ct).ConfigureAwait(false);

                stream.Seek(0, SeekOrigin.Begin);
            }
            catch (Exception ex)
            {
                Logger.Error("Error deleting file {0} - {1}", id, ex);
            }
        }
Esempio n. 3
0
 public DelegateComparer(Func <T, T, int> func)
 {
     _func = ArgValidation.ThrowIfNull(func, "func");
 }
Esempio n. 4
0
 public PriorityComparer(Func <T, int> priorityFunc)
 {
     _priorityFunc = ArgValidation.ThrowIfNull(priorityFunc, "priorityFunc");
 }