Ejemplo n.º 1
0
 void HandleUserCreatedOrChanged(SinozeUser oldUser, SinozeUser newUser)
 {
     if(oldUser == this && newUser != this)
     {
         _RemovedOrChanged (newUser);
     }
 }
 public string Get(SinozeUser user, string dataSetName, string key)
 {
     var dataSet = GetDataset(user.Identity, dataSetName);
     var result = dataSet.Get(key);
     dataSet.Dispose();
     return result;
 }
Ejemplo n.º 3
0
 private void _RemovedOrChanged(SinozeUser newUser)
 {
     IsRemoved = true;
     if(RemovedOrChanged != null)
     {
         RemovedOrChanged(newUser);
         RemovedOrChanged = null;
     }
 }
    public void Sync(SinozeUser user, string dataSetName, Action<bool> result)
    {
        var dataSet = GetDataset(user.Identity, dataSetName);

        dataSet.OnSyncSuccess += (object sender, SyncSuccessEvent e) =>
        {
            if(result != null)
                result(true);
            dataSet.Dispose ();
        };
        dataSet.OnSyncFailure += (object sender, SyncFailureEvent e) =>
        {
            if(result != null)
                result(false);
            dataSet.Dispose ();
        };

        dataSet.Synchronize();
    }
 public SinozeUserDataSetCollection(SinozeUser owner)
 {
     this.Owner = owner;
 }
 internal void Resync(SinozeUser currentUser, Action<SinozeUser> result)
 {
     EnqueueGetUserAsyncJob(currentUser.Index, (user)=>{ result(user); }, currentUser.ThirdPartyLogins);
 }
            public void Execute()
            {
                if(_isExecutionStarted || _isResultRetrived)
                    throw new InvalidOperationException("GetUserAsyncJob already executed");
                _isExecutionStarted = true;

                // get new userid (or look for existing user)
                parent.parent.GetIdAsync(userIndex, thirdPartyLogins, (userId)=>
                {
                    if(parent.parent._users.ContainsKey(userIndex) && parent.parent._users[userIndex].Identity == userId)
                    {
                        // id unchanged
                        this.UserRetrived(parent.parent._users[userIndex]);
                        return;
                    }

                    // id changed, create new user instance
                    SinozeUser newuser = new SinozeUser(userIndex, userId);
                    this.UserRetrived(newuser);
                });
            }
 private void UserRetrived(SinozeUser user)
 {
     this.result = user;
     _isResultRetrived = true;
 }
 private void StoreUser(SinozeUser user)
 {
     var index = user.Index;
     if(_users.ContainsKey(index))
     {
         var oldUser = _users[index];
         if(oldUser != user)
         {
             _users[index] = user;
             OnUserCreatedOrChanged(oldUser, user);
         }
     }
     else
     {
         _users.Add(index, user);
         OnUserCreatedOrChanged(null, user);
     }
 }
 private void OnUserCreatedOrChanged(SinozeUser oldUser, SinozeUser newUser)
 {
     if(UserCreatedOrChanged != null)
     {
         UserCreatedOrChanged(oldUser, newUser);
     }
 }
 public void Put(SinozeUser user, string dataSetName, string key, string value)
 {
     var dataSet = GetDataset(user.Identity, dataSetName);
     dataSet.Put(key, value);
     dataSet.Dispose ();
 }