Example #1
0
        public BackendlessUser Register(BackendlessUser user)
        {
            CheckUserToBeProper(user, true);
            user.PutProperties(Invoker.InvokeSync <Dictionary <string, object> >(Invoker.Api.USERSERVICE_REGISTER, new object[] { user.Properties }));

            return(user);
        }
Example #2
0
    public void Register( BackendlessUser user, AsyncCallback<BackendlessUser> callback )
    {
      try
      {
        CheckUserToBeProper( user, true );

        var responder = new AsyncCallback<Dictionary<string, object>>( r =>
            {
              user.PutProperties( r );
              if( callback != null )
                callback.ResponseHandler.Invoke( user );
            }, f =>
                {
                  if( callback != null )
                    callback.ErrorHandler.Invoke( f );
                  else
                    throw new BackendlessException( f );
                } );

        Invoker.InvokeAsync<Dictionary<string, object>>( USER_MANAGER_SERVER_ALIAS, "register",
                                                        new Object[]
                                                                    {
                                                                        Backendless.AppId, Backendless.VersionNum,
                                                                        user.Properties
                                                                    },
                                                        responder );
      }
      catch( System.Exception ex )
      {
        if( callback != null )
          callback.ErrorHandler.Invoke( new BackendlessFault( ex.Message ) );
        else
          throw;
      }
    }
Example #3
0
        private void LoadRelationsToEntity <T>(T entity, T response, IList <string> relations)
        {
            if (typeof(T).Equals(typeof(BackendlessUser)))
            {
                object          source            = entity;
                object          updated           = response;
                BackendlessUser userWithRelations = (BackendlessUser)updated;
                BackendlessUser sourceUser        = (BackendlessUser)source;
                sourceUser.PutProperties(userWithRelations.Properties);
            }
            else
            {
                FieldInfo[] fields = typeof(T).GetFields();
                foreach (var fieldInfo in fields)
                {
                    if (relations.Contains(LOAD_ALL_RELATIONS) == false && relations.Contains(fieldInfo.Name) == false)
                    {
                        continue;
                    }

                    fieldInfo.SetValue(entity, fieldInfo.GetValue(response));
                }
                PropertyInfo[] properties = typeof(T).GetProperties();
                foreach (var propertyInfo in properties)
                {
                    if (relations.Contains(LOAD_ALL_RELATIONS) == false && relations.Contains(propertyInfo.Name) == false)
                    {
                        continue;
                    }

                    propertyInfo.SetValue(entity, propertyInfo.GetValue(response, null), null);
                }
            }
        }
Example #4
0
        public BackendlessUser Register(BackendlessUser user)
        {
            CheckUserToBeProper(user, true);
            user.PutProperties(Invoker.InvokeSync <Dictionary <string, object> >(USER_MANAGER_SERVER_ALIAS, "register",
                                                                                 new Object[] { user.Properties }));

            return(user);
        }
Example #5
0
        public BackendlessUser Update(BackendlessUser user)
        {
            CheckUserToBeProper(user, false);

            if (string.IsNullOrEmpty(user.UserId))
            {
                throw new ArgumentNullException(ExceptionMessage.WRONG_USER_ID);
            }

            user.PutProperties(Invoker.InvokeSync <Dictionary <string, object> >(Invoker.Api.USERSERVICE_UPDATE, new object[] { user.Properties, user.UserId }));

            return(user);
        }
Example #6
0
    public BackendlessUser Register( BackendlessUser user )
    {
      CheckUserToBeProper( user, true );
      user.PutProperties( Invoker.InvokeSync<Dictionary<string, object>>( USER_MANAGER_SERVER_ALIAS, "register",
                                                                        new Object[]
                                                                                  {
                                                                                      Backendless.AppId,
                                                                                      Backendless.VersionNum,
                                                                                      user.Properties
                                                                                  } ) );

      return user;
    }
Example #7
0
        public BackendlessUser Update(BackendlessUser user)
        {
            CheckUserToBeProper(user, false);

            if (string.IsNullOrEmpty(user.ObjectId))
            {
                throw new ArgumentNullException(ExceptionMessage.WRONG_USER_ID);
            }

            user.PutProperties(Invoker.InvokeSync <Dictionary <string, object> >(USER_MANAGER_SERVER_ALIAS, "update",
                                                                                 new object[] { user.Properties }));

            return(user);
        }
Example #8
0
        public void Update(BackendlessUser user, AsyncCallback <BackendlessUser> callback)
        {
            try
            {
                CheckUserToBeProper(user, false);

                if (string.IsNullOrEmpty(user.ObjectId))
                {
                    throw new ArgumentNullException(ExceptionMessage.WRONG_USER_ID);
                }

                var responder = new AsyncCallback <Dictionary <string, object> >(r =>
                {
                    user.PutProperties(r);
                    if (callback != null)
                    {
                        callback.ResponseHandler.Invoke(user);
                    }
                }, f =>
                {
                    if (callback != null)
                    {
                        callback.ErrorHandler.Invoke(f);
                    }
                    else
                    {
                        throw new BackendlessException(f);
                    }
                });

                Invoker.InvokeAsync(USER_MANAGER_SERVER_ALIAS, "update",
                                    new object[] { user.Properties }, responder);
            }
            catch (System.Exception ex)
            {
                if (callback != null)
                {
                    callback.ErrorHandler.Invoke(new BackendlessFault(ex.Message));
                }
                else
                {
                    throw;
                }
            }
        }
        public object createObject(IAdaptingType argument)
        {
            if (argument is NamedObject)
            {
                argument = ((NamedObject)argument).TypedObject;
            }

            if (argument is NullType)
            {
                return(null);
            }

            Dictionary <string, object> props           = (Dictionary <string, object>)argument.adapt(typeof(Dictionary <string, object>));
            BackendlessUser             backendlessUser = new BackendlessUser();

            backendlessUser.PutProperties(props);
            return(backendlessUser);
        }
Example #10
0
        public void Register(BackendlessUser user, AsyncCallback <BackendlessUser> callback)
        {
            try
            {
                CheckUserToBeProper(user, true);

                var responder = new AsyncCallback <Dictionary <string, object> >(r =>
                {
                    user.PutProperties(r);
                    if (callback != null)
                    {
                        callback.ResponseHandler.Invoke(user);
                    }
                }, f =>
                {
                    if (callback != null)
                    {
                        callback.ErrorHandler.Invoke(f);
                    }
                    else
                    {
                        throw new BackendlessException(f);
                    }
                });

                Invoker.InvokeAsync <Dictionary <string, object> >(USER_MANAGER_SERVER_ALIAS, "register",
                                                                   new Object[] { user.Properties }, responder);
            }
            catch (System.Exception ex)
            {
                if (callback != null)
                {
                    callback.ErrorHandler.Invoke(new BackendlessFault(ex.Message));
                }
                else
                {
                    throw;
                }
            }
        }
Example #11
0
        public void Update(BackendlessUser user, AsyncCallback<BackendlessUser> callback)
        {
            try
              {
            CheckUserToBeProper(user, false);

            if (string.IsNullOrEmpty(user.UserId))
              throw new ArgumentNullException(ExceptionMessage.WRONG_USER_ID);

            var responder = new AsyncCallback<Dictionary<string, object>>(r =>
            {
              user.PutProperties(r);
              if (callback != null)
                callback.ResponseHandler.Invoke(user);
            }, f =>
                {
                  if (callback != null)
                    callback.ErrorHandler.Invoke(f);
                  else
                    throw new BackendlessException(f);
                });

            Invoker.InvokeAsync<Dictionary<string, object>>(Invoker.Api.USERSERVICE_UPDATE, new object[] { user.Properties, user.UserId }, responder);
              }
              catch (System.Exception ex)
              {
            if (callback != null)
              callback.ErrorHandler.Invoke(new BackendlessFault(ex.Message));
            else
              throw;
              }
        }
Example #12
0
        public BackendlessUser Update(BackendlessUser user)
        {
            CheckUserToBeProper(user, false);

              if (string.IsNullOrEmpty(user.UserId))
            throw new ArgumentNullException(ExceptionMessage.WRONG_USER_ID);

              user.PutProperties(Invoker.InvokeSync<Dictionary<string, object>>(Invoker.Api.USERSERVICE_UPDATE, new object[] { user.Properties, user.UserId }));

              return user;
        }
Example #13
0
        public void Register(BackendlessUser user, AsyncCallback<BackendlessUser> callback)
        {
            try
              {
            CheckUserToBeProper(user, true);

            var responder = new AsyncCallback<Dictionary<string, object>>(r =>
            {
              user.PutProperties(r);
              if (callback != null)
                callback.ResponseHandler.Invoke(user);
            }, f =>
                {
                  if (callback != null)
                    callback.ErrorHandler.Invoke(f);
                  else
                    throw new BackendlessException(f);
                });
            Invoker.InvokeAsync<Dictionary<string, object>>(Invoker.Api.USERSERVICE_REGISTER, new object[] { user.Properties }, responder);
              }
              catch (System.Exception ex)
              {
            if (callback != null)
              callback.ErrorHandler.Invoke(new BackendlessFault(ex.Message));
            else
              throw;
              }
        }
Example #14
0
        public BackendlessUser Register(BackendlessUser user)
        {
            CheckUserToBeProper(user, true);
              user.PutProperties(Invoker.InvokeSync<Dictionary<string, object>>(Invoker.Api.USERSERVICE_REGISTER, new object[] { user.Properties }));

              return user;
        }
Example #15
0
    public BackendlessUser Update( BackendlessUser user )
    {
      CheckUserToBeProper( user, false );

      if( string.IsNullOrEmpty( user.UserId ) )
        throw new ArgumentNullException( ExceptionMessage.WRONG_USER_ID );

      user.PutProperties( Invoker.InvokeSync<Dictionary<string, object>>( USER_MANAGER_SERVER_ALIAS, "update",
                                                                        new object[]
                                                                                  {
                                                                                      Backendless.AppId,
                                                                                      Backendless.VersionNum,
                                                                                      user.Properties
                                                                                  } ) );

      return user;
    }