Beispiel #1
0
        public static IEnumerable <Recorded <INotification <string> > > SerializeObserverMessages <T>(IList <Recorded <INotification <T> > > messages)
        {
            if (messages == null)
            {
                throw new ArgumentNullException(nameof(messages));
            }

            foreach (var message in messages)
            {
                switch (message.Value.Kind)
                {
                case Protocol.NotificationKind.OnCompleted:
                    yield return(ObserverMessage.OnCompleted <string>(message.Time));

                    break;

                case Protocol.NotificationKind.OnError:
                    yield return(ObserverMessage.OnError <string>(message.Time, message.Value.Exception));

                    break;

                case Protocol.NotificationKind.OnNext:
                    var serialized = Serialize <T>(message.Value.Value);
                    yield return(ObserverMessage.OnNext(message.Time, serialized));

                    break;

                default:
                    throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Unexpected notification kind '{0}'.", message.Value.Kind));
                }
            }
        }
Beispiel #2
0
 public void OnNext(string value)
 {
     _messages.Add(ObserverMessage.OnNext <string>(Now, value));
 }