public async void LoginAsync(AuthenticationProvider provider, Action<AzureResponse<Bitrave.Azure.MobileServiceUser>> callback ) { #if !WINDOWS_PHONE await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () => #else // Deployment.Current.Dispatcher.BeginInvoke( async () => #endif // There is an issue with Unity building out the WP8 // version using the MobileServices UI DLL // so removing this for build reasons. #if !WINDOWS_PHONE { try { var authProvider = (MobileServiceAuthenticationProvider)provider; var user = await _mobileClient.LoginAsync(authProvider); var unityUser = new Bitrave.Azure.MobileServiceUser(user.UserId) { MobileServiceAuthenticationToken = user.MobileServiceAuthenticationToken }; var response = new AzureResponse<Bitrave.Azure.MobileServiceUser>(AzureResponseStatus.Success, unityUser); callback(response); } catch (InvalidOperationException e) { var response = new AzureResponse<MobileServiceUser>(e); callback(response); } }); #endif }
private void CheckError(IRestResponse restResponse) { if (restResponse.ResponseStatus != ResponseStatus.Completed) { var error = new AzureResponse <object>(restResponse); Debug.LogError("Rest Error:" + restResponse.ErrorMessage); } }
private void CheckError(IRestResponse restResponse) { if (restResponse.ResponseStatus != ResponseStatus.Completed) { var error = new AzureResponse <object>(restResponse.ErrorException);; OnError(error); } }
public void LoginAsync(AuthenticationProvider provider, Action <AzureResponse <MobileServiceUser> > callback) { Debug.Log("Azure Mobile Services authentication is not supported in Unity editor."); var response = new AzureResponse <MobileServiceUser>(AzureResponseStatus.Success, new MobileServiceUser("1234_USER_ID") { MobileServiceAuthenticationToken = "ABCD_TOKEN" }); callback(response); }
// "https://bitraveservices.azure-mobile.net/", "ePYhutMVmiUPWhFAJaRYTJsPFTiuAB20" public AzureMobileServices(string url, string token) { try { _mobileClient = new MobileServiceClient(url, token); } catch (Exception e) { var response = new AzureResponse<object>(e); if (OnError != null) OnError(response); } }
public async void Update<T>(T item) where T : class { try { await _mobileClient.GetTable<T>().UpdateAsync(item); } catch (Exception e) { Debug.LogError("ERROR:" + e); var response = new AzureResponse<object>(e); if (OnError != null) OnError(response); } }
public async void Read<T>(Action<AzureResponse<List<T>>> callback) where T : class { try { var value = await _mobileClient.GetTable<T>().ReadAsync(); var response = new AzureResponse<List<T>>(AzureResponseStatus.Success, value.ToList()); callback(response); } catch (Exception e) { var response = new AzureResponse<List<T>>(e); callback(response); } }
public async void Lookup<T>(int id, Action<AzureResponse<T>> callback) where T : class { try { var value = await _mobileClient.GetTable<T>().LookupAsync(id); var response = new AzureResponse<T>(AzureResponseStatus.Success, value); callback(response); } catch (Exception e) { var response = new AzureResponse<T>(e); callback(response); } }
public async void Where<T>(System.Linq.Expressions.Expression<Func<T, bool>> predicate, Action<AzureResponse<List<T>>> callback) where T : class { try { var list = await _mobileClient.GetTable<T>().Where(predicate).ToListAsync(); var response = new AzureResponse<List<T>>(AzureResponseStatus.Success, list); callback(response); } catch (Exception e) { var response = new AzureResponse<List<T>>(e); callback(response); } }
private static AzureResponse <List <T> > DeserialiseObjectList(IRestResponse restResponse) { AzureResponse <List <T> > response; if (restResponse.ResponseStatus == ResponseStatus.Completed) { var obj = JsonConvert.DeserializeObject <List <T> >(restResponse.Content); response = new AzureResponse <List <T> >(AzureResponseStatus.Success, obj); } else { response = new AzureResponse <List <T> >(restResponse.ErrorException); } return(response); }
private static AzureResponse <X> DeserialiseObject <X>(IRestResponse restResponse) { AzureResponse <X> response; if (restResponse != null && restResponse.ResponseStatus == ResponseStatus.Completed && restResponse.StatusCode == HttpStatusCode.OK || restResponse.StatusCode == HttpStatusCode.Created) { var obj = JsonConvert.DeserializeObject <X>(restResponse.Content); response = new AzureResponse <X>(AzureResponseStatus.Success, obj); } else if (restResponse != null) { Debug.Log("Response is: " + restResponse.StatusCode); response = new AzureResponse <X>(restResponse); } else { response = new AzureResponse <X>(new Exception("Response was null from REST libraries.")); } return(response); }
public void DefaultHandler(AzureResponse <object> response) { return; }