Ejemplo n.º 1
0
 /// <summary>
 /// Help method to fire the RetriveAccessTokenCompleteEvent event.
 /// </summary>
 /// <param name="accessToken">The accesss token string</param>
 /// <param name="ex">Coressponding exception if failed to get the access token.</param>
 /// <param name="callback">callback from event</param>
 protected virtual void OnRetriveAdmAccessTokenComplete(AdmAccessToken accessToken, Exception ex, RetriveAdmAccessTokenComplete callback)
 {
     callback(accessToken, ex);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Retrive new access token from Adm service.
        /// </summary>
        /// <param name="callback">callback from event</param>
        private void RetrieveAccessToken(RetriveAdmAccessTokenComplete callback)
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(this.dataMarketAccessUri);
                request.ContentType = "application/x-www-form-urlencoded";
                request.Method = "POST";

                request.BeginGetRequestStream(new AsyncCallback(this.RequestCallback), new AdmTokenServiceRequestState(callback, request));
            }
            catch (Exception ex)
            {
                this.OnRetriveAdmAccessTokenComplete(null, ex, callback);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the Adm access token string.
 /// </summary>
 /// <param name="callback">callback for the completion of request</param>
 public void GetAccessToken(RetriveAdmAccessTokenComplete callback)
 {
     if (this.NeedToReNew)
     {
         lock (SyncRoot)
         {
             if (this.NeedToReNew)
             {
                 this.RetrieveAccessToken(callback);
             }
             else
             {
                 this.OnRetriveAdmAccessTokenComplete(this.accessToken, null, callback);
             }
         }
     }
     else
     {
         this.OnRetriveAdmAccessTokenComplete(this.accessToken, null, callback);
     }
 }