Beispiel #1
0
        /// <summary>
        /// Provides response to the request.
        /// </summary>
        /// <param name = "requestId">An id the client received in requestPaused event.</param>
        /// <param name = "responseCode">An HTTP response code.</param>
        /// <param name = "responseHeaders">Response headers.</param>
        /// <param name = "binaryResponseHeaders">Alternative way of specifying response headers as a \0-separated
        public async System.Threading.Tasks.Task <DevToolsMethodResponse> FulfillRequestAsync(string requestId, int responseCode, System.Collections.Generic.IList <CefSharp.DevTools.Fetch.HeaderEntry> responseHeaders = null, byte[] binaryResponseHeaders = null, byte[] body = null, string responsePhrase = null)
        {
            ValidateFulfillRequest(requestId, responseCode, responseHeaders, binaryResponseHeaders, body, responsePhrase);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("requestId", requestId);
            dict.Add("responseCode", responseCode);
            if ((responseHeaders) != (null))
            {
                dict.Add("responseHeaders", responseHeaders.Select(x => x.ToDictionary()));
            }

            if ((binaryResponseHeaders) != (null))
            {
                dict.Add("binaryResponseHeaders", ToBase64String(binaryResponseHeaders));
            }

            if ((body) != (null))
            {
                dict.Add("body", ToBase64String(body));
            }

            if (!(string.IsNullOrEmpty(responsePhrase)))
            {
                dict.Add("responsePhrase", responsePhrase);
            }

            var methodResult = await _client.ExecuteDevToolsMethodAsync("Fetch.fulfillRequest", dict);

            return(methodResult);
        }
Beispiel #2
0
        /// <summary>
        /// Continues the request, optionally modifying some of its parameters.
        /// </summary>
        /// <param name = "requestId">An id the client received in requestPaused event.</param>
        /// <param name = "url">If set, the request url will be modified in a way that's not observable by page.</param>
        /// <param name = "method">If set, the request method is overridden.</param>
        /// <param name = "postData">If set, overrides the post data in the request.</param>
        /// <param name = "headers">If set, overrides the request headers.</param>
        /// <returns>returns System.Threading.Tasks.Task&lt;DevToolsMethodResponse&gt;</returns>
        public async System.Threading.Tasks.Task <DevToolsMethodResponse> ContinueRequestAsync(string requestId, string url = null, string method = null, string postData = null, System.Collections.Generic.IList <CefSharp.DevTools.Fetch.HeaderEntry> headers = null)
        {
            ValidateContinueRequest(requestId, url, method, postData, headers);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("requestId", requestId);
            if (!(string.IsNullOrEmpty(url)))
            {
                dict.Add("url", url);
            }

            if (!(string.IsNullOrEmpty(method)))
            {
                dict.Add("method", method);
            }

            if (!(string.IsNullOrEmpty(postData)))
            {
                dict.Add("postData", postData);
            }

            if ((headers) != (null))
            {
                dict.Add("headers", headers.Select(x => x.ToDictionary()));
            }

            var methodResult = await _client.ExecuteDevToolsMethodAsync("Fetch.continueRequest", dict);

            return(methodResult);
        }
Beispiel #3
0
        /// <summary>
        /// Returns the snapshot identifier.
        /// </summary>
        /// <param name = "tiles">An array of tiles composing the snapshot.</param>
        /// <returns>returns System.Threading.Tasks.Task&lt;LoadSnapshotResponse&gt;</returns>
        public async System.Threading.Tasks.Task <LoadSnapshotResponse> LoadSnapshotAsync(System.Collections.Generic.IList <CefSharp.DevTools.LayerTree.PictureTile> tiles)
        {
            ValidateLoadSnapshot(tiles);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("tiles", tiles.Select(x => x.ToDictionary()));
            var methodResult = await _client.ExecuteDevToolsMethodAsync("LayerTree.loadSnapshot", dict);

            return(methodResult.DeserializeJson <LoadSnapshotResponse>());
        }
Beispiel #4
0
        /// <summary>
        /// start violation reporting.
        /// </summary>
        /// <param name = "config">Configuration for violations.</param>
        /// <returns>returns System.Threading.Tasks.Task&lt;DevToolsMethodResponse&gt;</returns>
        public async System.Threading.Tasks.Task <DevToolsMethodResponse> StartViolationsReportAsync(System.Collections.Generic.IList <CefSharp.DevTools.Log.ViolationSetting> config)
        {
            ValidateStartViolationsReport(config);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("config", config.Select(x => x.ToDictionary()));
            var methodResult = await _client.ExecuteDevToolsMethodAsync("Log.startViolationsReport", dict);

            return(methodResult);
        }
Beispiel #5
0
        /// <summary>
        /// Sets given cookies.
        /// </summary>
        /// <param name = "cookies">Cookies to be set.</param>
        /// <returns>returns System.Threading.Tasks.Task&lt;DevToolsMethodResponse&gt;</returns>
        public async System.Threading.Tasks.Task <DevToolsMethodResponse> SetCookiesAsync(System.Collections.Generic.IList <CefSharp.DevTools.Network.CookieParam> cookies)
        {
            ValidateSetCookies(cookies);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("cookies", cookies.Select(x => x.ToDictionary()));
            var methodResult = await _client.ExecuteDevToolsMethodAsync("Network.setCookies", dict);

            return(methodResult);
        }
Beispiel #6
0
        /// <summary>
        /// Enables target discovery for the specified locations, when `setDiscoverTargets` was set to
        /// `true`.
        /// </summary>
        /// <param name = "locations">List of remote locations.</param>
        /// <returns>returns System.Threading.Tasks.Task&lt;DevToolsMethodResponse&gt;</returns>
        public async System.Threading.Tasks.Task <DevToolsMethodResponse> SetRemoteLocationsAsync(System.Collections.Generic.IList <CefSharp.DevTools.Target.RemoteLocation> locations)
        {
            ValidateSetRemoteLocations(locations);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("locations", locations.Select(x => x.ToDictionary()));
            var methodResult = await _client.ExecuteDevToolsMethodAsync("Target.setRemoteLocations", dict);

            return(methodResult);
        }
Beispiel #7
0
        /// <summary>
        /// Applies specified style edits one after another in the given order.
        /// </summary>
        /// <param name = "edits">edits</param>
        /// <returns>returns System.Threading.Tasks.Task&lt;SetStyleTextsResponse&gt;</returns>
        public async System.Threading.Tasks.Task <SetStyleTextsResponse> SetStyleTextsAsync(System.Collections.Generic.IList <CefSharp.DevTools.CSS.StyleDeclarationEdit> edits)
        {
            ValidateSetStyleTexts(edits);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("edits", edits.Select(x => x.ToDictionary()));
            var methodResult = await _client.ExecuteDevToolsMethodAsync("CSS.setStyleTexts", dict);

            return(methodResult.DeserializeJson <SetStyleTextsResponse>());
        }
Beispiel #8
0
        /// <summary>
        /// Calls function with given declaration on the given object. Object group of the result is
        /// inherited from the target object.
        /// </summary>
        /// <param name = "functionDeclaration">Declaration of the function to call.</param>
        /// <param name = "objectId">Identifier of the object to call function on. Either objectId or executionContextId shouldbe specified.</param>
        /// <param name = "arguments">Call arguments. All call arguments must belong to the same JavaScript world as the targetobject.</param>
        /// <param name = "silent">In silent mode exceptions thrown during evaluation are not reported and do not pauseexecution. Overrides `setPauseOnException` state.</param>
        /// <param name = "returnByValue">Whether the result is expected to be a JSON object which should be sent by value.</param>
        /// <param name = "generatePreview">Whether preview should be generated for the result.</param>
        /// <param name = "userGesture">Whether execution should be treated as initiated by user in the UI.</param>
        /// <param name = "awaitPromise">Whether execution should `await` for resulting value and return once awaited promise isresolved.</param>
        /// <param name = "executionContextId">Specifies execution context which global object will be used to call function on. EitherexecutionContextId or objectId should be specified.</param>
        /// <param name = "objectGroup">Symbolic group name that can be used to release multiple objects. If objectGroup is notspecified and objectId is, objectGroup will be inherited from object.</param>
        /// <returns>returns System.Threading.Tasks.Task&lt;CallFunctionOnResponse&gt;</returns>
        public async System.Threading.Tasks.Task <CallFunctionOnResponse> CallFunctionOnAsync(string functionDeclaration, string objectId = null, System.Collections.Generic.IList <CefSharp.DevTools.Runtime.CallArgument> arguments = null, bool?silent = null, bool?returnByValue = null, bool?generatePreview = null, bool?userGesture = null, bool?awaitPromise = null, int?executionContextId = null, string objectGroup = null)
        {
            ValidateCallFunctionOn(functionDeclaration, objectId, arguments, silent, returnByValue, generatePreview, userGesture, awaitPromise, executionContextId, objectGroup);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("functionDeclaration", functionDeclaration);
            if (!(string.IsNullOrEmpty(objectId)))
            {
                dict.Add("objectId", objectId);
            }

            if ((arguments) != (null))
            {
                dict.Add("arguments", arguments.Select(x => x.ToDictionary()));
            }

            if (silent.HasValue)
            {
                dict.Add("silent", silent.Value);
            }

            if (returnByValue.HasValue)
            {
                dict.Add("returnByValue", returnByValue.Value);
            }

            if (generatePreview.HasValue)
            {
                dict.Add("generatePreview", generatePreview.Value);
            }

            if (userGesture.HasValue)
            {
                dict.Add("userGesture", userGesture.Value);
            }

            if (awaitPromise.HasValue)
            {
                dict.Add("awaitPromise", awaitPromise.Value);
            }

            if (executionContextId.HasValue)
            {
                dict.Add("executionContextId", executionContextId.Value);
            }

            if (!(string.IsNullOrEmpty(objectGroup)))
            {
                dict.Add("objectGroup", objectGroup);
            }

            var methodResult = await _client.ExecuteDevToolsMethodAsync("Runtime.callFunctionOn", dict);

            return(methodResult.DeserializeJson <CallFunctionOnResponse>());
        }
Beispiel #9
0
        /// <summary>
        /// Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted
        /// scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful.
        /// Positions array contains positions where blackbox state is changed. First interval isn't
        /// blackboxed. Array should be sorted.
        /// </summary>
        /// <param name = "scriptId">Id of the script.</param>
        /// <param name = "positions">positions</param>
        /// <returns>returns System.Threading.Tasks.Task&lt;DevToolsMethodResponse&gt;</returns>
        public async System.Threading.Tasks.Task <DevToolsMethodResponse> SetBlackboxedRangesAsync(string scriptId, System.Collections.Generic.IList <CefSharp.DevTools.Debugger.ScriptPosition> positions)
        {
            ValidateSetBlackboxedRanges(scriptId, positions);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("scriptId", scriptId);
            dict.Add("positions", positions.Select(x => x.ToDictionary()));
            var methodResult = await _client.ExecuteDevToolsMethodAsync("Debugger.setBlackboxedRanges", dict);

            return(methodResult);
        }
 public async Task<ActionResult> SendCode(string returnUrl, bool rememberMe)
 {
     string userId = await SignInManager.GetVerifiedUserIdAsync();
     if (userId == null)
     {
         return View("Error");
     }
     System.Collections.Generic.IList<string> userFactors = await UserManager.GetValidTwoFactorProvidersAsync(userId);
     System.Collections.Generic.List<SelectListItem> factorOptions = userFactors.Select(purpose => new SelectListItem { Text = purpose, Value = purpose }).ToList();
     return View(new SendCodeViewModel { Providers = factorOptions, ReturnUrl = returnUrl, RememberMe = rememberMe });
 }
        /// <summary>
        /// Extension method for IList.
        /// Generates a string list with all entries (via ToString).
        /// </summary>
        /// <param name="list">IList-instance to ToString.</param>
        /// <returns>String list with all entries (via ToString).</returns>
        public static System.Collections.Generic.List <string> CTToString <T>(this System.Collections.Generic.IList <T> list)
        {
            if (list == null)
            {
                throw new System.ArgumentNullException(nameof(list));
            }

            System.Collections.Generic.List <string> result = new System.Collections.Generic.List <string>(list.Count);
            result.AddRange(list.Select(element => null == element ? "null" : element.ToString()));

            return(result);
        }
Beispiel #12
0
        /// <summary>
        /// Fetches cache entry.
        /// </summary>
        /// <param name = "cacheId">Id of cache that contains the entry.</param>
        /// <param name = "requestURL">URL spec of the request.</param>
        /// <param name = "requestHeaders">headers of the request.</param>
        /// <returns>returns System.Threading.Tasks.Task&lt;RequestCachedResponseResponse&gt;</returns>
        public async System.Threading.Tasks.Task <RequestCachedResponseResponse> RequestCachedResponseAsync(string cacheId, string requestURL, System.Collections.Generic.IList <CefSharp.DevTools.CacheStorage.Header> requestHeaders)
        {
            ValidateRequestCachedResponse(cacheId, requestURL, requestHeaders);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("cacheId", cacheId);
            dict.Add("requestURL", requestURL);
            dict.Add("requestHeaders", requestHeaders.Select(x => x.ToDictionary()));
            var methodResult = await _client.ExecuteDevToolsMethodAsync("CacheStorage.requestCachedResponse", dict);

            return(methodResult.DeserializeJson <RequestCachedResponseResponse>());
        }
Beispiel #13
0
        /// <summary>
        /// Sets given cookies.
        /// </summary>
        /// <param name = "cookies">Cookies to be set.</param>
        /// <param name = "browserContextId">Browser context to use when called on the browser endpoint.</param>
        /// <returns>returns System.Threading.Tasks.Task&lt;DevToolsMethodResponse&gt;</returns>
        public async System.Threading.Tasks.Task <DevToolsMethodResponse> SetCookiesAsync(System.Collections.Generic.IList <CefSharp.DevTools.Network.CookieParam> cookies, string browserContextId = null)
        {
            ValidateSetCookies(cookies, browserContextId);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("cookies", cookies.Select(x => x.ToDictionary()));
            if (!(string.IsNullOrEmpty(browserContextId)))
            {
                dict.Add("browserContextId", browserContextId);
            }

            var methodResult = await _client.ExecuteDevToolsMethodAsync("Storage.setCookies", dict);

            return(methodResult);
        }
Beispiel #14
0
        public async Task <ActionResult> SendCode(string returnUrl = null, bool rememberMe = false)
        {
            ApplicationUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync();

            if (user == null)
            {
                return(View("Error"));
            }
            System.Collections.Generic.IList <string> userFactors = await _userManager.GetValidTwoFactorProvidersAsync(user);

            System.Collections.Generic.List <SelectListItem> factorOptions = userFactors.Select(purpose => new SelectListItem {
                Text = purpose, Value = purpose
            }).ToList();
            return(View(new SendCodeViewModel {
                Providers = factorOptions, ReturnUrl = returnUrl, RememberMe = rememberMe
            }));
        }
Beispiel #15
0
        /// <summary>
        /// Emulates the given media type or media feature for CSS media queries.
        /// </summary>
        /// <param name = "media">Media type to emulate. Empty string disables the override.</param>
        /// <param name = "features">Media features to emulate.</param>
        /// <returns>returns System.Threading.Tasks.Task&lt;DevToolsMethodResponse&gt;</returns>
        public async System.Threading.Tasks.Task <DevToolsMethodResponse> SetEmulatedMediaAsync(string media = null, System.Collections.Generic.IList <CefSharp.DevTools.Emulation.MediaFeature> features = null)
        {
            ValidateSetEmulatedMedia(media, features);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            if (!(string.IsNullOrEmpty(media)))
            {
                dict.Add("media", media);
            }

            if ((features) != (null))
            {
                dict.Add("features", features.Select(x => x.ToDictionary()));
            }

            var methodResult = await _client.ExecuteDevToolsMethodAsync("Emulation.setEmulatedMedia", dict);

            return(methodResult);
        }
Beispiel #16
0
        /// <summary>
        /// Enables issuing of requestPaused events. A request will be paused until client
        /// calls one of failRequest, fulfillRequest or continueRequest/continueWithAuth.
        /// </summary>
        /// <param name = "patterns">If specified, only requests matching any of these patterns will produce
        public async System.Threading.Tasks.Task <DevToolsMethodResponse> EnableAsync(System.Collections.Generic.IList <CefSharp.DevTools.Fetch.RequestPattern> patterns = null, bool?handleAuthRequests = null)
        {
            ValidateEnable(patterns, handleAuthRequests);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            if ((patterns) != (null))
            {
                dict.Add("patterns", patterns.Select(x => x.ToDictionary()));
            }

            if (handleAuthRequests.HasValue)
            {
                dict.Add("handleAuthRequests", handleAuthRequests.Value);
            }

            var methodResult = await _client.ExecuteDevToolsMethodAsync("Fetch.enable", dict);

            return(methodResult);
        }
Beispiel #17
0
        /// <summary>
        /// Dispatches a touch event to the page.
        /// </summary>
        /// <param name = "type">Type of the touch event. TouchEnd and TouchCancel must not contain any touch points, whileTouchStart and TouchMove must contains at least one.</param>
        /// <param name = "touchPoints">Active touch points on the touch device. One event per any changed point (compared toprevious touch event in a sequence) is generated, emulating pressing/moving/releasing pointsone by one.</param>
        /// <param name = "modifiers">Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8(default: 0).</param>
        /// <param name = "timestamp">Time at which the event occurred.</param>
        /// <returns>returns System.Threading.Tasks.Task&lt;DevToolsMethodResponse&gt;</returns>
        public async System.Threading.Tasks.Task <DevToolsMethodResponse> DispatchTouchEventAsync(string type, System.Collections.Generic.IList <CefSharp.DevTools.Input.TouchPoint> touchPoints, int?modifiers = null, long?timestamp = null)
        {
            ValidateDispatchTouchEvent(type, touchPoints, modifiers, timestamp);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("type", type);
            dict.Add("touchPoints", touchPoints.Select(x => x.ToDictionary()));
            if (modifiers.HasValue)
            {
                dict.Add("modifiers", modifiers.Value);
            }

            if (timestamp.HasValue)
            {
                dict.Add("timestamp", timestamp.Value);
            }

            var methodResult = await _client.ExecuteDevToolsMethodAsync("Input.dispatchTouchEvent", dict);

            return(methodResult);
        }
        public ActionResult <string[]> Get(string id, string table)
        {
            if (!memoryCache.TryGetValue(id, out IDataToSent data))
            {
                return(NotFound($"id not found {id}"));
            }
            System.Collections.Generic.IList <ITable> tables = data.Metadata.Tables;
            if (string.IsNullOrWhiteSpace(table))
            {
                return(tables.Select(it => it.Name).ToArray());
            }
            ITable t = tables.FirstOrDefault(it => string.Equals(it.Name, table, StringComparison.InvariantCultureIgnoreCase));

            if (t == null)
            {
                return(NotFound($"table {table} not found"));
            }
            DataTable ret = data.DataToBeSentFurther[t.Id];

            string[] obj = JArray.FromObject(ret).Select(it => it.ToString(Formatting.None)).ToArray();
            return(obj);
        }