Ejemplo n.º 1
0
 /// <summary>
 /// Will remove the token as long as the execution is running. Otherwise it will keep
 /// the token for the snapshot
 /// </summary>
 public virtual void Remove(IToken token)
 {
     if (_tokens.Remove(token))
     {
         TokenRemoved?.Invoke(this, token);
     }
 }
Ejemplo n.º 2
0
 public Task Publish_Removed(Space space, Token token, int count, RemoveReason reason)
 {
     return(TokenRemoved.InvokeAsync(new TokenRemovedArgs(gameStateForEventArgs, token, reason)
     {
         Space = space,
         Count = count,
     }));
 }
Ejemplo n.º 3
0
        private void HandleEvent(IActorRef _, TokenRemoved evt)
        {
            var tokens = user.Tokens.Where(x => x.LoginProvider.Equals(evt.LoginProvider) && x.Name.Equals(evt.Name)).ToList();

            foreach (var tkn in tokens)
            {
                user.Tokens.Remove(tkn);
            }
        }
Ejemplo n.º 4
0
        public void TestSerializationOfTokenRemoved()
        {
            var evt = new TokenRemoved("LOGINPROVIDER", "NAME");

            var bytes    = LZ4MessagePackSerializer.Serialize <IEvent>(evt, AspnetIdentityResolver.Instance);
            var eventChk = LZ4MessagePackSerializer.Deserialize <IEvent>(bytes, AspnetIdentityResolver.Instance) as TokenRemoved;

            Assert.Equal(evt.LoginProvider, eventChk.LoginProvider);
            Assert.Equal(evt.Name, eventChk.Name);
        }
Ejemplo n.º 5
0
    public async Task Publish_Moved(Token token, Space from, Space to)
    {
        var args = new TokenMovedArgs {
            Token       = token,
            RemovedFrom = from,
            AddedTo     = to,
            Count       = 1,
            GameState   = this.gameStateForEventArgs
        };

        await TokenMoved.InvokeAsync(args);

        // Also trigger the Added & Removed events
        await TokenAdded.InvokeAsync(args);

        await TokenRemoved.InvokeAsync(args);
    }
Ejemplo n.º 6
0
        private bool TestCommand(RemoveToken evt, out IEvent e)
        {
            e = null;
            if (user == null)
            {
                return(false);
            }

            if (user.Tokens == null)
            {
                return(true);
            }

            var token = user.Tokens.FirstOrDefault(x => x.LoginProvider.Equals(evt.LoginProvider) && x.Name.Equals(evt.Name));

            if (token != default(ImmutableIdentityUserToken))
            {
                e = new TokenRemoved(evt.LoginProvider, evt.Name);
            }

            return(true);
        }