コード例 #1
0
        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);
            }
        }
コード例 #2
0
 public FetchClass(AsyncFirefoxDriver browserClient) : base(browserClient)
 {
 }
コード例 #3
0
 public static Task <FetchResult> Fetch(this AsyncFirefoxDriver browserClient, string url)
 => new FetchClass(browserClient).Fetch(url);
コード例 #4
0
 public EvalAndWaitForEventBase(AsyncFirefoxDriver browserClient)
 {
     this.browserClient = browserClient;
 }
コード例 #5
0
 public static AddonManager AddonManager(this AsyncFirefoxDriver browserClient)
 {
     return(new AddonManager(browserClient));
 }
コード例 #6
0
 public static Task <LiveIpResult> GetLiveIp(this AsyncFirefoxDriver browserClient)
 => new LiveIp(browserClient).GetLiveIp();
コード例 #7
0
 public static CacheStorage CacheStorage(this AsyncFirefoxDriver browserClient)
 {
     return(new CacheStorage(browserClient));
 }
コード例 #8
0
 public LivePreferences(AsyncFirefoxDriver browserClient)
 {
     this.browserClient = browserClient;
 }
コード例 #9
0
 public AddonManager(AsyncFirefoxDriver browserClient) : base(browserClient)
 {
 }
コード例 #10
0
 public LiveIp(AsyncFirefoxDriver browserClient) : base(browserClient)
 {
 }
コード例 #11
0
 public CacheStorage(AsyncFirefoxDriver browserClient) : base(browserClient)
 {
 }
コード例 #12
0
 public static LivePreferences LivePreferences(this AsyncFirefoxDriver browserClient)
 {
     return(new LivePreferences(browserClient));
 }
コード例 #13
0
 public FirefoxDriverActionExecutor(AsyncFirefoxDriver asyncFirefoxDriver)
 {
     this.asyncFirefoxDriver = asyncFirefoxDriver;
 }