예제 #1
0
        public static Envelope[] ReceiveItemsOfType <T>(
            this TelemetryHttpListenerObservable listener,
            int timeOut)
        {
            var result = listener
                         .Where(item => (item is T))
                         .TakeUntil(DateTimeOffset.UtcNow.AddMilliseconds(timeOut))
                         .ToEnumerable()
                         .ToArray();

            return(result);
        }
예제 #2
0
        public static Envelope[] ReceiveItems(
            this TelemetryHttpListenerObservable listener,
            int timeOut)
        {
            if (null == listener)
            {
                throw new ArgumentNullException("listener");
            }

            var result = listener
                         .TakeUntil(DateTimeOffset.UtcNow.AddMilliseconds(timeOut))
                         .ToEnumerable()
                         .ToArray();

            return(result);
        }
예제 #3
0
        private bool StartListener(string listenerConnectionString)
        {
            output.WriteLine(string.Format("{0}: Starting listener at: {1}", DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"), this.httpListenerConnectionString));

            this.listener = new TelemetryHttpListenerObservable(listenerConnectionString, this.output);
            try
            {
                this.listener.Start();
                output.WriteLine(string.Format("{0}: Started listener", DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt")));
            }
            catch (HttpListenerException ex)
            {
                output.WriteLine(string.Format("{0}: Error starting listener.ErrorCode {1} Native Code {2}", DateTime.Now.ToString("G"), ex.ErrorCode, ex.NativeErrorCode));
                return(false);
            }

            return(true);
        }
예제 #4
0
        public static Envelope[] ReceiveItemsOfType <T>(
            this TelemetryHttpListenerObservable listener,
            int count,
            int timeOut)
        {
            var result = listener
                         .Where(item => (item is T))
                         .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);
        }