예제 #1
0
        public MainViewModel(ISampleDataService sampleDataService)
        {
            this.sampleDataService = sampleDataService;

            this.WhenActivated(d =>
            {
                d(sampleDataService.GetSampleDataAsync()
                  .ToObservable()
                  .Select(root => root.Groups.Select(g => new GroupViewModel(g)))
                  .Select(e => new ReactiveList <GroupViewModel>(e))
                  .ToProperty(this, x => x.Groups, out this.groups, null, RxApp.MainThreadScheduler));

                d(this.WhenAnyValue(x => x.Groups).Where(x => x != null).Select(g => g[0]).ToProperty(this, x => x.FirstGroup, out this.firstGroup, null, RxApp.MainThreadScheduler));
                d(this.WhenAnyValue(x => x.Groups).Where(x => x != null).Select(g => g[1]).ToProperty(this, x => x.SecondGroup, out this.secondGroup, null, RxApp.MainThreadScheduler));
                d(this.WhenAnyValue(x => x.Groups).Where(x => x != null).Select(g => g[2]).ToProperty(this, x => x.ThirdGroup, out this.thirdGroup, null, RxApp.MainThreadScheduler));
                d(this.WhenAnyValue(x => x.Groups).Where(x => x != null).Select(g => g[3]).ToProperty(this, x => x.FourthGroup, out this.fourthGroup, null, RxApp.MainThreadScheduler));

                d(this.Command = ReactiveCommand.Create());
                d(this.Command.Subscribe(_ => this.OpenViewModel <TestViewModel>()));
            });
        }
예제 #2
0
        public async Task <IHttpActionResult> GetSampleData()
        {
            IEnumerable <SampleData> sampleData = await _sampleDataService.GetSampleDataAsync();

            return(Ok(sampleData));
        }