//public static IObservable<StaticViewModel> BuildStaticService(IObservable<IEnumerable<KeyValuePair<DateTime, double>>> observable,IScheduler uischeduler)
        //{
        //    return observable.Select(s =>
        //    {
        //       return BuildStatic(s, uischeduler);

        //    });
        //}



        public static StaticViewModel BuildStatic(/*IObservable<IEnumerable<KeyValuePair<DateTime, double>>> s,*/ IScheduler uischeduler)
        {
            var s = new Filter.Model.Observable <IEnumerable <KeyValuePair <DateTime, double> > >();

            var ts = s.Select(_ => new TimeValueSeriesViewModel(_));


            Action <IEnumerable <KeyValuePair <DateTime, double> > > avi = (a) => s.Publish(a);

            var bds = ButtonDefinitionFactory.Build(avi, typeof(Filter.Service.SignalGenerator));



            var types = Helper.GetInheritingTypes(typeof(Filter.Model.IFilterWrapper));

            var vm = new GenericViewModel <Type>(types.ToObservable(), null, uischeduler);

            var bdds = vm.GetSelectedObjectSteam().Where(a => a != null).Select(_ =>
                                                                                ViewModelSelector(_));

            var dfs = bdds.Select(_ => _.Output).Select(v => v.WithLatestFrom(s, (a, b) => new { a, b }).Select(l => new PredictionsViewModel(l.a.BatchRun(l.b)))).SelectMany(l => l);


            //var xs = new Filter.Model.Observable<Type>();

            //Action<Type> at = (a) => xs.Publish(a);

            //var bds = ButtonDefinitionFactory.Build(avi, typeof(Filter.Service.SignalGenerator));


            //var x = new Filter.Model.Observable<PredictionsViewModel>();

            //Action<IEnumerable<KeyValuePair<DateTime, Tuple<double, double>[]>>> av = (a) => x.Publish(new PredictionsViewModel(a));

            //var defs = s.Select(_ => ButtonDefinitionFactory.Build(av, typeof(Filter.Service.StaticPredictionService), _));

            return(new StaticViewModel(bds, vm, ts, dfs, bdds));
        }
        public static IEnumerable <ButtonDefinition> BuildMeasurements(Filter.Model.Observable <IEnumerable <KeyValuePair <DateTime, double> > > x)
        {
            Action <IEnumerable <KeyValuePair <DateTime, double> > > av = (a) => x.Publish(a);

            return(ButtonDefinitionFactory.Build(av, typeof(Filter.Service.SignalGenerator)));
        }