コード例 #1
0
ファイル: Membership.cs プロジェクト: phamy/WP7-Official
 private static void InvokeCallbackWithAuthCodeParameter(AuthentificationCode param)
 {
     Deployment.Current.Dispatcher.BeginInvoke(() =>
     {
         _authCallback.Invoke(param);
     });
 }
コード例 #2
0
 private void AuthentificateUserCallback(IAsyncResult result)
 {
     try
     {
         var request  = (WebRequest)result.AsyncState;
         var response = (WebResponse)request.EndGetResponse(result);
         using (var reader = new StreamReader(response.GetResponseStream()))
         {
             if (reader.ReadToEnd().Equals("OK"))
             {
                 _callback.Invoke(AuthentificationCode.LoginSuccessed);
             }
             else
             {
                 _callback.Invoke(AuthentificationCode.InvalidCredentials);
             }
         }
     }
     catch (Exception ex)
     {
         if (ex is WebException)
         {
             var response = ((HttpWebResponse)((WebException)ex).Response);
             if (response.StatusCode == HttpStatusCode.Unauthorized)
             {
                 _callback.Invoke(AuthentificationCode.InvalidCredentials);
             }
             else
             {
                 _callback.Invoke(AuthentificationCode.ServerNotFound);
             }
         }
         else if (ex is ArgumentException)
         {
             _callback.Invoke(AuthentificationCode.ServerNotFound);
         }
     }
 }