Exemplo n.º 1
0
        public IAsyncReactiveQbservable <TrafficInfo> GetTrafficInfoObservable(TrafficParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            bool hasValidRoute = (!string.IsNullOrEmpty(parameters.StartAddress) && !string.IsNullOrEmpty(parameters.EndAddress)) ||
                                 (!string.IsNullOrEmpty(parameters.RouteId));

            if (!hasValidRoute)
            {
                throw new ArgumentException(string.Format(
                                                "Invalid TrafficParameters: Either [start address:{0} and end address{1}] OR [routeid:{2}] must be provided",
                                                parameters.StartAddress,
                                                parameters.EndAddress,
                                                parameters.RouteId));
            }

            // TODO: Make a note for a design review - this logic won't execute
            //       if the GetTrafficInfoObservable is used in an inner position,
            //       e.g. inside a SelectMany.
            var tuple = new Tuple <string, string, string, int, int>(
                parameters.StartAddress,
                parameters.EndAddress,
                parameters.RouteId,
                parameters.FlowParameters == null ? int.MaxValue : parameters.FlowParameters.NotificationThresholdInSeconds,
                parameters.FlowParameters == null ? int.MaxValue : parameters.FlowParameters.RenotificationThresholdInSeconds);

            return(GetObservable <TrafficParameters, TrafficInfo>(Constants.Observable.Synthetic.TrafficInfo.Uri)(parameters));
        }
Exemplo n.º 2
0
        public IAsyncReactiveQbservable <TrafficInfo> GetRealTrafficInfoObservable(TrafficParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            bool hasValidRoute = (!string.IsNullOrEmpty(parameters.StartAddress) && !string.IsNullOrEmpty(parameters.EndAddress)) ||
                                 (!string.IsNullOrEmpty(parameters.RouteId));

            if (!hasValidRoute)
            {
                throw new ArgumentException(string.Format(
                                                "Invalid TrafficParameters: Either [start address:{0} and end address{1}] OR [routeid:{2}] must be provided",
                                                parameters.StartAddress,
                                                parameters.EndAddress,
                                                parameters.RouteId));
            }

            var tuple = new Tuple <string, string, string, int, int>(
                parameters.StartAddress,
                parameters.EndAddress,
                parameters.RouteId,
                parameters.FlowParameters == null ? int.MaxValue : parameters.FlowParameters.NotificationThresholdInSeconds,
                parameters.FlowParameters == null ? int.MaxValue : parameters.FlowParameters.RenotificationThresholdInSeconds);

            return(GetObservable <TrafficParameters, TrafficInfo>(Constants.Observable.Real.TrafficInfo.Uri)(parameters));
        }
Exemplo n.º 3
0
        public IAsyncReactiveQbservable <FlightStatus> GetFlightStatusObservable(FlightStatusParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            bool hasValidFlightName = !string.IsNullOrWhiteSpace(parameters.FlightName);
            bool hasValidFlightNumberWithAirline = !string.IsNullOrWhiteSpace(parameters.FlightNumber) &&
                                                   (!string.IsNullOrWhiteSpace(parameters.AirlineName) ||
                                                    !string.IsNullOrWhiteSpace(parameters.AirlineCode));

            if (!hasValidFlightName && !hasValidFlightNumberWithAirline)
            {
                throw new ArgumentException(string.Format(
                                                "Invalid FlightStatusParameters: missing flight name {0}, or flight number {1} with airline name {2} or airline code {3}",
                                                parameters.FlightName,
                                                parameters.FlightNumber,
                                                parameters.AirlineName,
                                                parameters.AirlineCode));
            }

            return(GetObservable <FlightStatusParameters, FlightStatus>(Constants.Observable.Real.FlightStatus.Uri)(parameters));
        }
 public IAsyncReactiveQbservable <long> Timer(DateTimeOffset dueTime, TimeSpan period) => GetObservable <DateTimeOffset, TimeSpan, long>(new Uri("rx://observable/timer/period/absolute"))(dueTime, period);
 public IAsyncReactiveQbservable <long> Timer(DateTimeOffset dueTime) => GetObservable <DateTimeOffset, long>(new Uri("rx://observable/timer/single/absolute"))(dueTime);
 public IAsyncReactiveQbservable <long> Timer(TimeSpan dueTime, TimeSpan period) => GetObservable <TimeSpan, TimeSpan, long>(new Uri("rx://observable/timer/period/relative"))(dueTime, period);
 public IAsyncReactiveQbservable <long> Timer(TimeSpan dueTime) => GetObservable <TimeSpan, long>(new Uri("rx://observable/timer/single/relative"))(dueTime);
 public IAsyncReactiveQbservable <TResult> Throw <TResult>(Exception error) => GetObservable <Exception, TResult>(new Uri("rx://observable/throw"))(error);
 public IAsyncReactiveQbservable <TResult> Return <TResult>(TResult value) => GetObservable <TResult, TResult>(new Uri("rx://observable/return"))(value);
Exemplo n.º 10
0
 public IAsyncReactiveQbservable <T> GetIngress <T>(string name) => GetObservable <string, T>(new Uri("reaqtor://shebang/observables/ingress"))(name);
Exemplo n.º 11
0
 public IAsyncReactiveQbservable <DateTimeOffset> SimpleTimer(TimeSpan period) => GetObservable <TimeSpan, DateTimeOffset>(new Uri("reaqtor://shebang/observables/timer"))(period);