internal StaticPaginator(IReadOnlyCollection <SocketUser> users, IReadOnlyDictionary <IEmote, PaginatorAction> emotes, Embed cancelledEmbed, Embed timeoutedEmbed, DeletionOptions deletion, IReadOnlyCollection <Page> pages, int startPage) : base(users, emotes, cancelledEmbed, timeoutedEmbed, deletion, startPage) { Pages = pages; }
public void DeleteFile(string path, DeletionOptions options) { options = options ?? DeletionOptions.TryThreeTimes; if (string.IsNullOrWhiteSpace(path)) return; for (var i = 0; i < options.RetryAttempts; i++) { try { if (File.Exists(path)) { File.Delete(path); } } catch { Thread.Sleep(options.SleepBetweenAttemptsMilliseconds); if (i == options.RetryAttempts - 1) { if (options.ThrowOnFailure) { throw; } break; } } } }
internal LazyPaginator(IReadOnlyCollection <SocketUser> users, IReadOnlyDictionary <IEmote, PaginatorAction> emotes, Embed cancelledEmbed, Embed timeoutedEmbed, DeletionOptions deletion, Func <int, Task <Page> > pageFactory, int startPage, int maxPageIndex) : base(users, emotes, cancelledEmbed, timeoutedEmbed, deletion, startPage) { CachedPages = new ConcurrentDictionary <int, Page>(); PageFactory = pageFactory; MaxPageIndex = maxPageIndex; }
internal Confirmation(Page content, IReadOnlyCollection <SocketUser> users, IEmote confirmEmote, IEmote declineEmote, Embed timeoutedEmbed, Embed cancelledEmbed, DeletionOptions deletion) { Content = content; Users = users; ConfirmEmote = confirmEmote; DeclineEmote = declineEmote; TimeoutedEmbed = timeoutedEmbed; CancelledEmbed = cancelledEmbed; Deletion = deletion; }
internal Paginator(IReadOnlyCollection <SocketUser> users, IReadOnlyDictionary <IEmote, PaginatorAction> emotes, Embed cancelledEmbed, Embed timeoutedEmbed, DeletionOptions deletion, int startPage) { Users = users; Emotes = emotes; CancelledEmbed = cancelledEmbed; TimeoutedEmbed = timeoutedEmbed; Deletion = deletion; CurrentPageIndex = startPage; }
public ReactionSelection(IReadOnlyDictionary <IEmote, TValue> selectables, IReadOnlyCollection <SocketUser> users, Page selectionPage, Page cancelledPage, Page timeoutedPage, bool allowCancel, IEmote cancelEmote, DeletionOptions deletion) : base(users, deletion) { Selectables = selectables; SelectionPage = selectionPage; CancelledPage = cancelledPage; TimeoutedPage = timeoutedPage; AllowCancel = allowCancel; CancelEmote = cancelEmote; }
public MessageSelection(IReadOnlyDictionary <string[], TValue> selectables, IReadOnlyCollection <SocketUser> users, Page selectionPage, Page cancelledPage, Page timeoutedPage, bool allowCancel, string cancelMessage, DeletionOptions deletion) : base(users, deletion) { Selectables = selectables; SelectionPage = selectionPage; CancelledPage = cancelledPage; TimeoutedPage = timeoutedPage; AllowCancel = allowCancel; CancelMessage = cancelMessage; }
protected Selection(IReadOnlyCollection <T> values, IReadOnlyCollection <SocketUser> users, Embed selectionEmbed, Embed cancelledEmbed, Embed timeoutedEmbed, DeletionOptions deletion) { if (typeof(T1) != typeof(SocketReaction) && typeof(T1) != typeof(SocketMessage)) { throw new InvalidOperationException("T2 can ONLY be SocketMessage or SocketReaction!"); } Values = values; Users = users; SelectionEmbed = selectionEmbed; CancelledEmbed = cancelledEmbed; TimeoutedEmbed = timeoutedEmbed; Deletion = deletion; }
public void DeleteFile(string path, DeletionOptions options) { options = options ?? DeletionOptions.TryThreeTimes; if (string.IsNullOrWhiteSpace(path)) return; var firstAttemptFailed = false; for (var i = 0; i < options.RetryAttempts; i++) { try { if (File.Exists(path)) { if (firstAttemptFailed) { File.SetAttributes(path, FileAttributes.Normal); } File.Delete(path); return; } } catch { Thread.Sleep(options.SleepBetweenAttemptsMilliseconds); firstAttemptFailed = true; if (i == options.RetryAttempts - 1) { if (options.ThrowOnFailure) { throw; } break; } } } }
/// <summary> /// Sets what the <see cref="Selection{T, T1}"/> should delete. /// </summary> public ReactionSelectionBuilder <T> WithDeletion(DeletionOptions deletion) { Deletion = deletion; return(this); }
public void DeleteFile(string path, DeletionOptions options) { throw new NotImplementedException(); }
internal ReactionSelection(IReadOnlyCollection <T> values, IReadOnlyCollection <SocketUser> users, Embed selectionEmbed, Embed cancelledEmbed, Embed timeoutedEmbed, DeletionOptions deletion, IReadOnlyCollection <IEmote> emotes, IEmote cancelEmote, bool allowCancel) : base(values, users, selectionEmbed, cancelledEmbed, timeoutedEmbed, deletion) { Emotes = emotes; CancelEmote = cancelEmote; AllowCancel = allowCancel; if (AllowCancel == true) { Emotes = new List <IEmote>(emotes) { CancelEmote } .AsReadOnlyCollection(); } }
void PurgeDirectory(string targetDirectory, Predicate<IFileInfo> include, DeletionOptions options, CancellationToken cancel, bool includeTarget = false) { if (!DirectoryExists(targetDirectory)) { return; } foreach (var file in EnumerateFiles(targetDirectory)) { cancel.ThrowIfCancellationRequested(); if (include != null) { var info = new FileInfoAdapter(new FileInfo(file)); if (!include(info)) { continue; } } DeleteFile(file, options); } foreach (var directory in EnumerateDirectories(targetDirectory)) { cancel.ThrowIfCancellationRequested(); var info = new DirectoryInfo(directory); if ((info.Attributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint) { Directory.Delete(directory); } else { PurgeDirectory(directory, include, options, cancel, includeTarget: true); } } if (includeTarget && DirectoryIsEmpty(targetDirectory)) DeleteDirectory(targetDirectory, options); }
protected BaseReactionSelection(IReadOnlyCollection <SocketUser> users, DeletionOptions deletion) { Users = users; Deletion = deletion; }
public void PurgeDirectory(string targetDirectory, DeletionOptions options, CancellationToken cancel) { PurgeDirectory(targetDirectory, fi => true, options, cancel); }
public void PurgeDirectory(string targetDirectory, Predicate<IFileInfo> include, DeletionOptions options) { PurgeDirectory(targetDirectory, include, options, CancellationToken.None); }
public void DeleteDirectory(string path, DeletionOptions options) { options = options ?? DeletionOptions.TryThreeTimes; if (string.IsNullOrWhiteSpace(path)) return; for (var i = 0; i < options.RetryAttempts; i++) { try { if (Directory.Exists(path)) { var dir = new DirectoryInfo(path); dir.Attributes = dir.Attributes & ~FileAttributes.ReadOnly; dir.Delete(true); } } catch { if (i == options.RetryAttempts - 1) { if (options.ThrowOnFailure) { throw; } break; } Thread.Sleep(options.SleepBetweenAttemptsMilliseconds); } } }
public void PurgeDirectory(string targetDirectory, DeletionOptions options) { PurgeDirectory(targetDirectory, fi => true, options); }
public void DeleteDirectory(string path, DeletionOptions options) { throw new System.NotImplementedException(); }
protected PaginatorBuilder WithDeletion(DeletionOptions deletion) { Deletion = deletion; return(this); }
/// <summary> /// Sets what the <see cref="Paginator"/> should delete. /// </summary> /// <returns></returns> public new LazyPaginatorBuilder WithDeletion(DeletionOptions deletion) => base.WithDeletion(deletion) as LazyPaginatorBuilder;
internal MessageSelection(IReadOnlyCollection <T> values, IReadOnlyCollection <SocketUser> users, Embed selectionEmbed, Embed cancelledEmbed, Embed timeoutedEmbed, DeletionOptions deletion, IReadOnlyCollection <string> possabilies, string cancelDisplayName) : base(values, users, selectionEmbed, cancelledEmbed, timeoutedEmbed, deletion) { Possibilities = possabilies; CancelDisplayName = cancelDisplayName; }
/// <summary> /// Sets what the <see cref="Selection{T, T1}"/> should delete. /// </summary> public MessageSelectionBuilder <T> WithDeletion(DeletionOptions deletion) { Deletion = deletion; return(this); }
/// <summary> /// Sets what the <see cref="Paginator"/> should delete. /// </summary> /// <returns></returns> public new StaticPaginatorBuilder WithDeletion(DeletionOptions deletion) => base.WithDeletion(deletion) as StaticPaginatorBuilder;
public void PurgeDirectory(string targetDirectory, Predicate<IFileInfo> include, DeletionOptions options) { if (!DirectoryExists(targetDirectory)) { return; } foreach (var file in EnumerateFilesRecursively(targetDirectory)) { if (include != null) { var info = new FileInfoAdapter(new FileInfo(file)); if (!include(info)) { continue; } } DeleteFile(file, options); } }