public async Task <JToken> EvalAndWaitForEvent(AsyncFirefoxDriver browserClient, string evalStrAddId, /*int id, */ CancellationToken cancellationToken = new CancellationToken())
        {
            var id = Interlocked.Increment(ref idEvalAndWaitForEvent);

            try
            {
                var evalStr = evalStrAddId.Replace("_AddIdForEventHere_", id.ToString()); //  string.Format(evalStrAddId, id);
                var promise = evalAndWaitForEventAsyncTasks.GetOrAdd(id, i => new TaskCompletionSource <JToken>());

                var res = await browserClient?.Eval(evalStr.Replace("\\", "\\\\"));

                //if (res?["error"] != null)
                //{
                //    return res;
                //}
                //else
                //{
                cancellationToken.ThrowIfCancellationRequested();
                cancellationToken.Register(() => promise.TrySetCanceled(), false);

                var response = await promise.Task.ConfigureAwait(false);

                cancellationToken.ThrowIfCancellationRequested();

                return(response);
                //}
            }
            finally
            {
                evalAndWaitForEventAsyncTasks.TryRemove(id, out TaskCompletionSource <JToken> promise);
            }
        }
Ejemplo n.º 2
0
 public FetchClass(AsyncFirefoxDriver browserClient) : base(browserClient)
 {
 }
Ejemplo n.º 3
0
 public static Task <FetchResult> Fetch(this AsyncFirefoxDriver browserClient, string url)
 => new FetchClass(browserClient).Fetch(url);
 public EvalAndWaitForEventBase(AsyncFirefoxDriver browserClient)
 {
     this.browserClient = browserClient;
 }
Ejemplo n.º 5
0
 public static AddonManager AddonManager(this AsyncFirefoxDriver browserClient)
 {
     return(new AddonManager(browserClient));
 }
Ejemplo n.º 6
0
 public static Task <LiveIpResult> GetLiveIp(this AsyncFirefoxDriver browserClient)
 => new LiveIp(browserClient).GetLiveIp();
Ejemplo n.º 7
0
 public static CacheStorage CacheStorage(this AsyncFirefoxDriver browserClient)
 {
     return(new CacheStorage(browserClient));
 }
Ejemplo n.º 8
0
 public LivePreferences(AsyncFirefoxDriver browserClient)
 {
     this.browserClient = browserClient;
 }
Ejemplo n.º 9
0
 public AddonManager(AsyncFirefoxDriver browserClient) : base(browserClient)
 {
 }
Ejemplo n.º 10
0
 public LiveIp(AsyncFirefoxDriver browserClient) : base(browserClient)
 {
 }
Ejemplo n.º 11
0
 public CacheStorage(AsyncFirefoxDriver browserClient) : base(browserClient)
 {
 }
Ejemplo n.º 12
0
 public static LivePreferences LivePreferences(this AsyncFirefoxDriver browserClient)
 {
     return(new LivePreferences(browserClient));
 }
 public FirefoxDriverActionExecutor(AsyncFirefoxDriver asyncFirefoxDriver)
 {
     this.asyncFirefoxDriver = asyncFirefoxDriver;
 }