private void TransactionCallback(Transaction trans) { switch (trans.Result) { case TransactionResult.Fail: { var reqPrms = trans.RequestParams.Clone() as RequestParams; var resPrms = trans.ResponseParams.Clone() as ResponseParams; UseOneAttempt(); StartNewTransaction(reqPrms, resPrms); } break; case TransactionResult.Success: { if (CollectCookie) { SaveCookies(trans.Responce.ResponseUri, trans.Responce.Cookies); } if (trans.ResponseParams.AllowRedirect) { Uri redirect = null; if (CheckRedirect(trans.Responce, ref redirect)) { RedirectWithCookie(trans, redirect); } } } break; default: SessionCallback(); break; } }
private void RedirectWithCookie(Transaction trans, Uri redirect) { var reqPrms = trans.RequestParams.Clone() as RequestParams; reqPrms.Uri = redirect; reqPrms.Cookie = trans.Responce.Cookies; var resPrms = trans.ResponseParams.Clone() as ResponseParams; StartNewTransaction(reqPrms, resPrms); }
private void StartNewTransaction(RequestParams reqPrmsPattern, ResponseParams resPrmsPattern) { Transaction tr = new Transaction(reqPrmsPattern, resPrmsPattern, TransactionCallback); Transactions.Add(tr); if (Attempts > 0) { tr.Begin(); } else { SessionCallback(); } }