Exemplo n.º 1
0
            public Task DeliverItem(object item, StreamSequenceToken token)
            {
                T typedItem;

                try
                {
                    typedItem = (T)item;
                }
                catch (InvalidCastException)
                {
                    // We got an illegal item on the stream -- close it with a Cast exception
                    throw new InvalidCastException("Received an item of type " + item.GetType().Name + ", expected " + typeof(T).FullName);
                }
                return((localObserver == null)
                    ? TaskDone.Done
                    : localObserver.OnNextAsync(typedItem, token));
            }
Exemplo n.º 2
0
            public async Task <StreamSequenceToken> DeliverItem(object item, StreamSequenceToken token)
            {
                if (dirty)
                {
                    dirty = false;
                    if (expectedToken != null)
                    {
                        return(expectedToken);
                    }
                }

                T typedItem;

                try
                {
                    typedItem = (T)item;
                }
                catch (InvalidCastException)
                {
                    // We got an illegal item on the stream -- close it with a Cast exception
                    throw new InvalidCastException("Received an item of type " + item.GetType().Name + ", expected " + typeof(T).FullName);
                }

                if (localObserver != null)
                {
                    await localObserver.OnNextAsync(typedItem, token);
                }

                if (dirty)
                {
                    dirty = false;
                    if (expectedToken != null)
                    {
                        return(expectedToken);
                    }
                }

                if (token != null && token.Newer(expectedToken))
                {
                    expectedToken = token;
                }

                return(default(StreamSequenceToken));
            }