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()); }
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); }
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); }