我正在努力學習tweetinvi
證書外,所以我有以下UI如何使用VAR任何功能
這些2方法,initAuthentication
和startAuthentication
private void initAuthentication()
{
var appCredentials = new TwitterCredentials(consumerKey, consumerSecret);
var authenticationContext = AuthFlow.InitAuthentication(appCredentials);
Process.Start(authenticationContext.AuthorizationURL);
//i am commenting the following code
//var userCredentials = AuthFlow.CreateCredentialsFromVerifierCode(textBox1.Text, authenticationContext);
//Auth.SetCredentials(userCredentials);
//so the user have some time to copy the pinCode
//paste them into available textbox
// and continue executing startAuthentication() by clicking authenticate button.
}
private void startAuthentication (string pinCode)
{
//if we split like this, the authenticationContext is error, because it doesn't exist in current context
var userCredentials = AuthFlow.CreateCredentialsFromVerifierCode(pinCode, authenticationContext);
Auth.SetCredentials(userCredentials);
}
如果我們加入兩個部分在一個功能,沒有時間讓用戶複製粘貼PIN碼到文本框中。
然而,如果我們分開兩部分,不同的功能,有一段時間,用戶複製粘貼PIN碼到文本框,但似乎authenticationContext
了錯誤,因爲it doesn't exist in current context
有什麼辦法如何解決這個問題?
你只能在局部範圍內使用var而不是globar – Mostafiz
@MostafizurRahman同意,但如何繞過或使我的代碼像我期望的那樣工作? – Cignitor
您想使對話框爲模態,然後在按下驗證按鈕之前它不會返回到應用程序。 – Hogan