Пример #1
0
        public static Envelope[] ReceiveAllItemsDuringTime(
            this HttpListenerObservable listener,
            int timeOut)
        {
            if (null == listener)
            {
                throw new ArgumentNullException("listener");
            }

            return(listener
                   .Where(item => !(item is TelemetryItem <RemoteDependencyData>))
                   .TakeUntil(DateTimeOffset.UtcNow.AddMilliseconds(timeOut))
                   .ToEnumerable()
                   .ToArray());
        }
Пример #2
0
        public static Envelope[] ReceiveItemsOfTypes <T1, T2>(
            this HttpListenerObservable listener,
            int count,
            int timeOut)
        {
            var result = listener
                         .Where(item => ((item is T1) || (item is T2)))
                         .TakeUntil(DateTimeOffset.UtcNow.AddMilliseconds(timeOut))
                         .Take(count)
                         .ToEnumerable()
                         .ToArray();

            if (result.Length != count)
            {
                throw new InvalidDataException("Incorrect number of items. Expected: " + count + " Received: " + result.Length);
            }

            return(result);
        }
Пример #3
0
        public static Envelope[] ReceiveItems(
            this HttpListenerObservable listener,
            int count,
            int timeOut)
        {
            if (null == listener)
            {
                throw new ArgumentNullException("listener");
            }

            var result = listener
                         .Where(item => !(item is TelemetryItem <RemoteDependencyData>))
                         .TakeUntil(DateTimeOffset.UtcNow.AddMilliseconds(timeOut))
                         .Take(count)
                         .ToEnumerable()
                         .ToArray();

            if (result.Length != count)
            {
                throw new InvalidDataException("Incorrect number of items. Expected: " + count + " Received: " + result.Length);
            }

            return(result);
        }