From a4a1cd8ea1c60c65080da1ff18326164a6b767cb Mon Sep 17 00:00:00 2001 From: amaitland Date: Sun, 8 Oct 2017 08:34:31 +1000 Subject: [PATCH] Untabify AsyncExtensions --- CefSharp/AsyncExtensions.cs | 166 ++++++++++++++++++------------------ 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/CefSharp/AsyncExtensions.cs b/CefSharp/AsyncExtensions.cs index b1f6896f9d..726389cf14 100644 --- a/CefSharp/AsyncExtensions.cs +++ b/CefSharp/AsyncExtensions.cs @@ -8,65 +8,65 @@ namespace CefSharp { - public static class AsyncExtensions - { - /// - /// Deletes all cookies that matches all the provided parameters asynchronously. - /// If both and are empty, all cookies will be deleted. - /// - /// The cookie URL. If an empty string is provided, any URL will be matched. - /// The name of the cookie. If an empty string is provided, any URL will be matched. - /// Returns -1 if a non-empty invalid URL is specified, or if cookies cannot be accessed; - /// otherwise, a task that represents the delete operation. The value of the TResult will be the number of cookies that were deleted or -1 if unknown. - public static Task DeleteCookiesAsync(this ICookieManager cookieManager, string url = null, string name = null) - { - if(cookieManager == null) - { - throw new NullReferenceException("cookieManager"); - } - - if(cookieManager.IsDisposed) - { - throw new ObjectDisposedException("cookieManager"); - } - - var callback = new TaskDeleteCookiesCallback(); - if(cookieManager.DeleteCookies(url, name, callback)) - { - return callback.Task; - } + public static class AsyncExtensions + { + /// + /// Deletes all cookies that matches all the provided parameters asynchronously. + /// If both and are empty, all cookies will be deleted. + /// + /// The cookie URL. If an empty string is provided, any URL will be matched. + /// The name of the cookie. If an empty string is provided, any URL will be matched. + /// Returns -1 if a non-empty invalid URL is specified, or if cookies cannot be accessed; + /// otherwise, a task that represents the delete operation. The value of the TResult will be the number of cookies that were deleted or -1 if unknown. + public static Task DeleteCookiesAsync(this ICookieManager cookieManager, string url = null, string name = null) + { + if(cookieManager == null) + { + throw new NullReferenceException("cookieManager"); + } + + if(cookieManager.IsDisposed) + { + throw new ObjectDisposedException("cookieManager"); + } + + var callback = new TaskDeleteCookiesCallback(); + if(cookieManager.DeleteCookies(url, name, callback)) + { + return callback.Task; + } //There was a problem deleting cookies return Task.FromResult(-1); - } - - /// - /// Sets a cookie given a valid URL and explicit user-provided cookie attributes. - /// This function expects each attribute to be well-formed. It will check for disallowed - /// characters (e.g. the ';' character is disallowed within the cookie value attribute) and will return false without setting - /// - /// cookie manager - /// The cookie URL. If an empty string is provided, any URL will be matched. - /// the cookie to be set - /// returns false if the cookie cannot be set (e.g. if illegal charecters such as ';' are used); - /// otherwise task that represents the set operation. The value of the TResult parameter contains a bool to indicate success. - public static Task SetCookieAsync(this ICookieManager cookieManager, string url, Cookie cookie) - { - if (cookieManager == null) - { - throw new NullReferenceException("cookieManager"); - } - - if (cookieManager.IsDisposed) - { - throw new ObjectDisposedException("cookieManager"); - } - - var callback = new TaskSetCookieCallback(); - if (cookieManager.SetCookie(url, cookie, callback)) - { - return callback.Task; - } + } + + /// + /// Sets a cookie given a valid URL and explicit user-provided cookie attributes. + /// This function expects each attribute to be well-formed. It will check for disallowed + /// characters (e.g. the ';' character is disallowed within the cookie value attribute) and will return false without setting + /// + /// cookie manager + /// The cookie URL. If an empty string is provided, any URL will be matched. + /// the cookie to be set + /// returns false if the cookie cannot be set (e.g. if illegal charecters such as ';' are used); + /// otherwise task that represents the set operation. The value of the TResult parameter contains a bool to indicate success. + public static Task SetCookieAsync(this ICookieManager cookieManager, string url, Cookie cookie) + { + if (cookieManager == null) + { + throw new NullReferenceException("cookieManager"); + } + + if (cookieManager.IsDisposed) + { + throw new ObjectDisposedException("cookieManager"); + } + + var callback = new TaskSetCookieCallback(); + if (cookieManager.SetCookie(url, cookie, callback)) + { + return callback.Task; + } //There was a problem setting cookies return Task.FromResult(false); @@ -78,13 +78,13 @@ public static Task SetCookieAsync(this ICookieManager cookieManager, strin /// A task that represents the VisitAllCookies operation. The value of the TResult parameter contains a List of cookies /// or null if cookies cannot be accessed. public static Task> VisitAllCookiesAsync(this ICookieManager cookieManager) - { - var cookieVisitor = new TaskCookieVisitor(); + { + var cookieVisitor = new TaskCookieVisitor(); - if(cookieManager.VisitAllCookies(cookieVisitor)) - { - return cookieVisitor.Task; - } + if(cookieManager.VisitAllCookies(cookieVisitor)) + { + return cookieVisitor.Task; + } return Task.FromResult>(null); } @@ -99,34 +99,34 @@ public static Task> VisitAllCookiesAsync(this ICookieManager cookie /// A task that represents the VisitUrlCookies operation. The value of the TResult parameter contains a List of cookies. /// or null if cookies cannot be accessed. public static Task> VisitUrlCookiesAsync(this ICookieManager cookieManager, string url, bool includeHttpOnly) - { - var cookieVisitor = new TaskCookieVisitor(); + { + var cookieVisitor = new TaskCookieVisitor(); - if(cookieManager.VisitUrlCookies(url, includeHttpOnly, cookieVisitor)) - { - return cookieVisitor.Task; - } + if(cookieManager.VisitUrlCookies(url, includeHttpOnly, cookieVisitor)) + { + return cookieVisitor.Task; + } return Task.FromResult>(null); } - /// - /// Flush the backing store (if any) to disk. - /// - /// cookieManager instance - /// A task that represents the FlushStore operation. Result indicates if the flush completed successfully. - /// Will return false if the cookikes cannot be accessed. - public static Task FlushStoreAsync(this ICookieManager cookieManager) - { - var handler = new TaskCompletionCallback(); - - if (cookieManager.FlushStore(handler)) - { - return handler.Task; - } + /// + /// Flush the backing store (if any) to disk. + /// + /// cookieManager instance + /// A task that represents the FlushStore operation. Result indicates if the flush completed successfully. + /// Will return false if the cookikes cannot be accessed. + public static Task FlushStoreAsync(this ICookieManager cookieManager) + { + var handler = new TaskCompletionCallback(); + + if (cookieManager.FlushStore(handler)) + { + return handler.Task; + } //returns null if cookies cannot be accessed. return Task.FromResult(false); } - } + } }