Esempio n. 1
0
        public MyPageViewModel(ITicketService ticketService, ITicketMapper mapper)
        {
            _ticketService = ticketService;
            _mapper = mapper;

            LoadTickets = new ReactiveAsyncCommand(null, 1, RxApp.DeferredScheduler);

            LoadTickets.RegisterAsyncFunction(x => loadTickets())
                .ToProperty(this, x => x.Tickets);

            Observable.Interval(TimeSpan.FromSeconds(10), RxApp.DeferredScheduler)
                    .InvokeCommand(LoadTickets);
            LoadTickets.Execute(null);

            _redmineBaseUrl = ConfigurationManager.AppSettings["Redmine.BaseRedmineUrl"];

            SortBy = new List<SortByModel>()
            {
                new SortByModel("Project", c => c.Project),
                new SortByModel("Due date", c=> c.DueDate),
                new SortByModel("Priority", c => c.Priority),
            };

            SortByCommand = new ReactiveCommand(this.WhenAny(c => c.Tickets,
                                                                                                            ((tickets) => tickets.Value != null && tickets.Value.Count > 0)));

            SortByCommand.Subscribe(c => sortTickets((SortByModel)c));
        }
Esempio n. 2
0
        public void RAFShouldActuallyRunOnTheTaskpool()
        {
            var deferred = RxApp.DeferredScheduler;
            var taskpool = RxApp.TaskpoolScheduler;

            try {
                var testDeferred = new CountingTestScheduler(Scheduler.Immediate);
                var testTaskpool = new CountingTestScheduler(Scheduler.NewThread);
                RxApp.DeferredScheduler = testDeferred;
                RxApp.TaskpoolScheduler = testTaskpool;

                var fixture = new ReactiveAsyncCommand();
                var result  = fixture.RegisterAsyncFunction(x => {
                    Thread.Sleep(1000);
                    return((int)x * 5);
                });

                fixture.Execute(1);
                Assert.Equal(5, result.First());

                Assert.True(testDeferred.ScheduledItems.Count >= 1);
                Assert.True(testTaskpool.ScheduledItems.Count >= 1);
            } finally {
                RxApp.DeferredScheduler = deferred;
                RxApp.TaskpoolScheduler = taskpool;
            }
        }
Esempio n. 3
0
        public HyperCommand(JsonServiceClient client, Grandsys.Wfm.Services.Outsource.ServiceModel.Link link)
        {
            Content  = link.Name;
            Command  = new ReactiveAsyncCommand();
            Method   = link.Method;
            Request  = link.Request;
            Response = Command.RegisterAsyncFunction(_ => {
                Model.EvaluationItem response;
                if (string.IsNullOrEmpty(Method))
                {
                    return(null);
                }

                switch (Method)
                {
                default:
                    response = client.Send <Model.EvaluationItem>(Method, Request.ToUrl(Method), _ ?? Request);
                    break;

                case "GET":
                    response = client.Get <Model.EvaluationItem>(Request.ToUrl(Method));
                    break;
                }
                return(response);
            });
            Command.ThrownExceptions.Subscribe(ex => Console.WriteLine(ex.Message));
        }
Esempio n. 4
0
        public MyPageViewModel(ITicketService ticketService, ITicketMapper mapper)
        {
            _ticketService = ticketService;
            _mapper        = mapper;

            LoadTickets = new ReactiveAsyncCommand(null, 1, RxApp.DeferredScheduler);

            LoadTickets.RegisterAsyncFunction(x => loadTickets())
            .ToProperty(this, x => x.Tickets);

            Observable.Interval(TimeSpan.FromSeconds(10), RxApp.DeferredScheduler)
            .InvokeCommand(LoadTickets);
            LoadTickets.Execute(null);

            _redmineBaseUrl = ConfigurationManager.AppSettings["Redmine.BaseRedmineUrl"];

            SortBy = new List <SortByModel>()
            {
                new SortByModel("Project", c => c.Project),
                new SortByModel("Due date", c => c.DueDate),
                new SortByModel("Priority", c => c.Priority),
            };

            SortByCommand = new ReactiveCommand(this.WhenAny(c => c.Tickets,
                                                             ((tickets) => tickets.Value != null && tickets.Value.Count > 0)));

            SortByCommand.Subscribe(c => sortTickets((SortByModel)c));
        }
Esempio n. 5
0
        public LoginFormViewModel(IAuthenticator authenticator)
        {
            // push the initial values in the observables
            // so that everyone subscribing before the user logs in for the first time
            // sees that the user is not there

            bool initialCredentialsOK = authenticator.TryLoginFromStoredCredentials();

            if (initialCredentialsOK)
            {
                userDataSubject.OnNext(authenticator.UserData);
                UsernameField = authenticator.UserData.Username;
            }
            else
            {
                userDataSubject.OnNext(UserData.NoUser);
                UsernameField = "";
            }


            UserLoggedInObservable = UserDataObservable.Select(x => x != UserData.NoUser);
            _UserLoggedIn          = UserLoggedInObservable.ToProperty(this, x => x.UserLoggedIn);

            LogIn = new ReactiveAsyncCommand(UserLoggedInObservable.Select(x => !x), 1);
            LogIn.RegisterAsyncFunction(_ =>
            {
                bool logicSuccessful = authenticator.Login(UsernameField, PasswordField,
                                                           true);

                if (logicSuccessful)
                {
                    //collapse if the login was successfull
                    IsLoginFormExpanded = false;
                }
                else
                {
                    // if login failed, return the focus to the username field
                    IsUsernameFieldFocused = true;
                }

                return(authenticator.UserData);
            }).Subscribe(userDataSubject.OnNext);

            LogOut = new ReactiveAsyncCommand(UserLoggedInObservable, 1);
            LogOut.RegisterAsyncFunction(_ =>
            {
                authenticator.Logout();
                IsPasswordFieldFocused = true;
                return(authenticator.UserData);
            }).Subscribe(userDataSubject.OnNext);

            _UserData = UserDataObservable.ToProperty(this, x => x.UserData);
        }
Esempio n. 6
0
        public MainViewModel()
        {
            IsInProgress = Visibility.Collapsed;

            LoginCommand = new ReactiveAsyncCommand(this.WhenAny(t => t.UserName, t => t.Password, (x, y) => !string.IsNullOrEmpty(x.Value) && !string.IsNullOrEmpty(y.Value)));

            LoginCommand.ItemsInflight.Select(x => x > 0 ? Visibility.Visible : Visibility.Collapsed).Subscribe(x => IsInProgress = x);
            LoginCommand.RegisterAsyncFunction(_ => _gitHubService.Login(UserName, Password)).Subscribe(
                u => LoggedInUser = u);

            this.ObservableForProperty(x => x.LoggedInUser,
                                       user => user == null ? Visibility.Hidden : Visibility.Visible).Subscribe(v => IsUserLoggedIn = v);

            _cache = new MemoizingMRUCache<User, Repository[]>((user,_) =>
                                                                          _gitHubService.GetRepositories(user), 3);

            this.WhenAny(t => t.LoggedInUser, u => u.Value != null).Where(filter => filter).Subscribe(_ =>

                    Repositories = new ReactiveCollection<Repository>(_cache.Get(LoggedInUser))
            );
        }
Esempio n. 7
0
        public MainViewModel()
        {
            IsInProgress = Visibility.Collapsed;

            LoginCommand = new ReactiveAsyncCommand(this.WhenAny(t => t.UserName, t => t.Password, (x, y) => !string.IsNullOrEmpty(x.Value) && !string.IsNullOrEmpty(y.Value)));

            LoginCommand.ItemsInflight.Select(x => x > 0 ? Visibility.Visible : Visibility.Collapsed).Subscribe(x => IsInProgress = x);
            LoginCommand.RegisterAsyncFunction(_ => _gitHubService.Login(UserName, Password)).Subscribe(
                u => LoggedInUser = u);

            this.ObservableForProperty(x => x.LoggedInUser,
                                       user => user == null ? Visibility.Hidden : Visibility.Visible).Subscribe(v => IsUserLoggedIn = v);


            _cache = new MemoizingMRUCache <User, Repository[]>((user, _) =>
                                                                _gitHubService.GetRepositories(user), 3);

            this.WhenAny(t => t.LoggedInUser, u => u.Value != null).Where(filter => filter).Subscribe(_ =>

                                                                                                      Repositories = new ReactiveCollection <Repository>(_cache.Get(LoggedInUser))
                                                                                                      );
        }
Esempio n. 8
0
        public MainWindowViewModel()
        {
            var noneInFlight  = new BehaviorSubject <bool>(false);
            var updateManager = default(UpdateManager);

            this.WhenAny(x => x.UpdatePath, x => x.Value)
            .Where(x => !String.IsNullOrWhiteSpace(x))
            .Throttle(TimeSpan.FromMilliseconds(700), RxApp.DeferredScheduler)
            .Subscribe(x => updateManager = new UpdateManager(UpdatePath, "SampleUpdatingApp", FrameworkVersion.Net40));

            CheckForUpdate = new ReactiveAsyncCommand(noneInFlight);
            CheckForUpdate.RegisterAsyncFunction(_ => {
                using (updateManager.AcquireUpdateLock()) {
                    return(updateManager.CheckForUpdate().Last());
                }
            }).Subscribe(x => { UpdateInfo = x; DownloadedUpdateInfo = null; });

            DownloadReleases = new ReactiveAsyncCommand(noneInFlight.Where(_ => UpdateInfo != null));
            DownloadReleases.RegisterAsyncFunction(_ => {
                using (updateManager.AcquireUpdateLock()) {
                    return(updateManager.DownloadReleases(UpdateInfo.ReleasesToApply).Last());
                }
            }).Subscribe(_ => DownloadedUpdateInfo = UpdateInfo);

            ApplyReleases = new ReactiveAsyncCommand(noneInFlight.Where(_ => DownloadedUpdateInfo != null));
            ApplyReleases.RegisterAsyncFunction(_ => {
                using (updateManager.AcquireUpdateLock()) {
                    return(updateManager.ApplyReleases(DownloadedUpdateInfo).Last());
                }
            });

            Observable.CombineLatest(
                CheckForUpdate.ItemsInflight.StartWith(0),
                DownloadReleases.ItemsInflight.StartWith(0),
                ApplyReleases.ItemsInflight.StartWith(0),
                this.WhenAny(x => x.UpdatePath, _ => 0),
                (a, b, c, _) => a + b + c
                ).Select(x => x == 0 && UpdatePath != null).Multicast(noneInFlight).Connect();
        }
Esempio n. 9
0
        public MainWindowViewModel()
        {
            var noneInFlight = new BehaviorSubject<bool>(false);
            var updateManager = default(UpdateManager);

            this.WhenAny(x => x.UpdatePath, x => x.Value)
                .Where(x => !String.IsNullOrWhiteSpace(x))
                .Throttle(TimeSpan.FromMilliseconds(700), RxApp.DeferredScheduler)
                .Subscribe(x => updateManager = new UpdateManager(UpdatePath, "SampleUpdatingApp", FrameworkVersion.Net40));

            CheckForUpdate = new ReactiveAsyncCommand(noneInFlight);
            CheckForUpdate.RegisterAsyncFunction(_ => {
                using (updateManager.AcquireUpdateLock()) {
                    return updateManager.CheckForUpdate().Last();
                }
            }).Subscribe(x => { UpdateInfo = x; DownloadedUpdateInfo = null; });

            DownloadReleases = new ReactiveAsyncCommand(noneInFlight.Where(_ => UpdateInfo != null));
            DownloadReleases.RegisterAsyncFunction(_ => {
                using (updateManager.AcquireUpdateLock()) {
                    return updateManager.DownloadReleases(UpdateInfo.ReleasesToApply).Last();
                }
            }).Subscribe(_ => DownloadedUpdateInfo = UpdateInfo);

            ApplyReleases = new ReactiveAsyncCommand(noneInFlight.Where(_ => DownloadedUpdateInfo != null));
            ApplyReleases.RegisterAsyncFunction(_ => {
                using (updateManager.AcquireUpdateLock()) {
                    return updateManager.ApplyReleases(DownloadedUpdateInfo).Last();
                }
            });

            Observable.CombineLatest(
                CheckForUpdate.ItemsInflight.StartWith(0),
                DownloadReleases.ItemsInflight.StartWith(0),
                ApplyReleases.ItemsInflight.StartWith(0),
                this.WhenAny(x => x.UpdatePath, _ => 0),
                (a, b, c, _) => a + b + c
            ).Select(x => x == 0 && UpdatePath != null).Multicast(noneInFlight).Connect();
        }
        public void RAFShouldActuallyRunOnTheTaskpool()
        {
            var deferred = RxApp.DeferredScheduler;
            var taskpool = RxApp.TaskpoolScheduler;

            try {
                var testDeferred = new CountingTestScheduler(Scheduler.Immediate);
                var testTaskpool = new CountingTestScheduler(Scheduler.NewThread);
                RxApp.DeferredScheduler = testDeferred; RxApp.TaskpoolScheduler = testTaskpool;

                var fixture = new ReactiveAsyncCommand();
                var result = fixture.RegisterAsyncFunction(x => { Thread.Sleep(1000); return (int)x * 5; });

                fixture.Execute(1);
                Assert.Equal(5, result.First());

                Assert.True(testDeferred.ScheduledItems.Count >= 1);
                Assert.True(testTaskpool.ScheduledItems.Count >= 1);
            } finally {
                RxApp.DeferredScheduler = deferred;
                RxApp.TaskpoolScheduler = taskpool;
            }
        }
Esempio n. 11
0
        public void MultipleSubscribersShouldntDecrementRefcountBelowZero()
        {
            var fixture = new ReactiveAsyncCommand(null, 1);
            var results = new List<int>();
            bool[] subscribers = new[] { false, false, false, false, false };

            var output = fixture.RegisterAsyncFunction(_ => { Thread.Sleep(2000); return 5; });
            output.Subscribe(x => results.Add(x));

            Enumerable.Range(0, 5).Run(x => output.Subscribe(_ => subscribers[x] = true));

            Assert.IsTrue(fixture.CanExecute(null));

            fixture.Execute(null);
            Assert.IsFalse(fixture.CanExecute(null));

            Thread.Sleep(6000);
            Assert.IsTrue(fixture.CanExecute(null));

            Assert.IsTrue(results.Count == 1);
            Assert.IsTrue(results[0] == 5);
            Assert.IsTrue(subscribers.All(x => x == true));
        }
Esempio n. 12
0
        public void RegisterAsyncFunctionSmokeTest()
        {
            var inflight_results = new List<int>();
            var fixture = new ReactiveAsyncCommand(null, 1);
            var results = new List<int>();

            fixture.RegisterAsyncFunction(_ => { Thread.Sleep(2000); return 5; })
                   .Subscribe(x => results.Add(x));

            fixture.ItemsInflight.Subscribe(x => inflight_results.Add(x));

            Assert.IsTrue(fixture.CanExecute(null));

            fixture.Execute(null);
            Assert.IsFalse(fixture.CanExecute(null));

            Thread.Sleep(6000);
            Assert.IsTrue(fixture.CanExecute(null));

            new[] {0,1,0}.Zip(inflight_results, (expected, actual) => new {expected, actual})
                         .Run(x => Assert.AreEqual(x.expected, x.actual));

            Assert.IsTrue(results.Count == 1);
            Assert.IsTrue(results[0] == 5);
        }
Esempio n. 13
0
        public MediaBrowserViewModel(IMediaLibraryBrowser mediaLibraryBrowser, Settings settings,
                                     LoginFormViewModel loginFormViewModel, IMixViewModelFactory mixViewModelFactory)
        {
            this.settings            = settings;
            this.mixViewModelFactory = mixViewModelFactory;
            this.mediaLibraryBrowser = mediaLibraryBrowser;

            GetRecentlyMadeMixes = new ReactiveAsyncCommand(null, 1);
            GetRecentlyMadeMixes.RegisterAsyncFunction(
                _ => mediaLibraryBrowser.GetRecentlyMadeMixes(CreateMixFilter(Filter)))
            .Subscribe(SetBrowsedMixes);

            GetHotMixes = new ReactiveAsyncCommand(null, 1);
            GetHotMixes.RegisterAsyncFunction(_ => mediaLibraryBrowser.GetHotMixes(CreateMixFilter(Filter))).Subscribe(
                SetBrowsedMixes);

            GetPopularMixes = new ReactiveAsyncCommand(null, 1);
            GetPopularMixes.RegisterAsyncFunction(_ => mediaLibraryBrowser.GetPopularMixes(CreateMixFilter(Filter)))
            .Subscribe(SetBrowsedMixes);

            // command is enabled only if the user is logged in
            GetLikedMixes = new ReactiveAsyncCommand(loginFormViewModel.UserLoggedInObservable, 1);
            GetLikedMixes.RegisterAsyncFunction(_ =>
            {
                var mixFilter   = CreateMixFilter(Filter);
                string userSlug = loginFormViewModel.UserData.UserSlug;
                return(mediaLibraryBrowser.GetLikedMixes(mixFilter, userSlug));
            }).Subscribe(SetBrowsedMixes);

            // command is enabled only if the user is logged in
            GetFeedMixes = new ReactiveAsyncCommand(loginFormViewModel.UserLoggedInObservable, 1);
            GetFeedMixes.RegisterAsyncFunction(_ =>
            {
                var mixFilter   = CreateMixFilter(Filter);
                string userSlug = loginFormViewModel.UserData.UserSlug;
                return(mediaLibraryBrowser.GetFeedMixes(mixFilter, userSlug));
            }).Subscribe(SetBrowsedMixes);

            GetRecommendedMixes = new ReactiveAsyncCommand(loginFormViewModel.UserLoggedInObservable, 1);
            GetRecommendedMixes.RegisterAsyncFunction(_ =>
            {
                var mixFilter   = CreateMixFilter(Filter);
                string userSlug = loginFormViewModel.UserData.UserSlug;
                return(mediaLibraryBrowser.GetRecommendedMixes(mixFilter, userSlug));
            }).Subscribe(SetBrowsedMixes);

            GetHistoryMixes = new ReactiveAsyncCommand(loginFormViewModel.UserLoggedInObservable, 1);
            GetHistoryMixes.RegisterAsyncFunction(_ =>
            {
                var mixFilter   = CreateMixFilter(Filter);
                string userSlug = loginFormViewModel.UserData.UserSlug;
                return(mediaLibraryBrowser.GetHistoryMixes(mixFilter, userSlug));
            }).Subscribe(SetBrowsedMixes);


            BrowsedMixes = new DispatchedReactiveCollection <MixViewModel>();

            ReplaySubject <bool> browsedMixesExistObservable = new ReplaySubject <bool>(1);

            BrowsedMixes.CollectionCountChanged.Select(count => count > 0).Subscribe(browsedMixesExistObservable.OnNext);
            browsedMixesExistObservable.OnNext(false);

            GetMoreMixes = new ReactiveAsyncCommand(browsedMixesExistObservable, 1);
            GetMoreMixes.RegisterAsyncFunction(_ => mediaLibraryBrowser.GetMoreMixes())
            .Subscribe(AddBrowsedMixes);

            // set can execute only if there is something in the list
            SetMixDisplayMode = new ReactiveCommand(browsedMixesExistObservable);
            SetMixDisplayMode.Subscribe(mode => MixDisplayMode = (MixDisplayMode)mode);


            ApplyFilter = new ReactiveCommand();
            ApplyFilter.Where(_ => Filter.Length > 0)
            .Subscribe(_ =>
            {
                // if we only started up the application, by search for Hot mixes
                if (mediaLibraryBrowser.SessionData.IsEmpty)
                {
                    GetHotMixes.Execute(null);
                    return;
                }

                // otherwise, take the same type of mixes as they were before
                switch (mediaLibraryBrowser.SessionData.LastMixesRequest.ViewType)
                {
                case MixesViewType.Hot:      GetHotMixes.Execute(null); break;

                case MixesViewType.Popular:  GetPopularMixes.Execute(null); break;

                case MixesViewType.Recent:   GetRecentlyMadeMixes.Execute(null); break;

                case MixesViewType.Liked:    GetLikedMixes.Execute(null); break;

                case MixesViewType.Feed:     GetFeedMixes.Execute(null); break;

                case MixesViewType.Listened: GetHistoryMixes.Execute(null); break;

                case MixesViewType.Recommended: GetRecommendedMixes.Execute(null); break;

                default:
                    // throw new ArgumentOutOfRangeException();
                    break;
                }
            });


            MixDisplayMode mixDisplayMode;
            string         storedMixDisplayModeString = (string)settings[mixdisplayModeKey];

            Enum.TryParse <MixDisplayMode>(storedMixDisplayModeString, out mixDisplayMode);
            MixDisplayMode = mixDisplayMode;

            MixesViewTypeAsString = String.Empty;
            Filter             = String.Empty;
            MixBrowsingMessage = String.Empty;
        }
        public MapManagementVM(
            IConnectivityService Network,
            IMapTransferService MapService,
            IMapStorageService MapStorage,
            INotificationService Notifications,
            [Dispatcher] IScheduler Dispatcher
            ) {
            Contract.Requires(Network != null);
            Contract.Requires(MapService != null);
            Contract.Requires(MapStorage != null);
            Contract.Requires(Notifications != null);
            this.Network = Network;
            this.MapService = MapService;
            this.MapStorage = MapStorage;



            this.FirstActivation()
                .Subscribe(_ => getMaps.Execute(null));

            MapList = getMaps.RegisterAsyncFunction(_ => MapStorage.getAllMaps().Select(m => new MapVM(m)))
                      .SelectMany(vms => vms.ToList())
                      .ObserveOn(Dispatcher)
                      .CreateCollection();
            MapList.ItemsAdded
                .Subscribe(item => _local_map_register.Add(item.ServerKey, Unit.Default));

            MapList.ItemsRemoved
                .Subscribe(item => _local_map_register.Remove(item.ServerKey));

            SelectMap = new ReactiveCommand<MapVM>(vm => !vm.IsDownloading);
            SelectMap
                .Select(vm => vm as IElementVM<Map>)
                .ToMessage(Messenger, MessageContracts.VIEW);

            SelectMap
                .Select(_ => Page.Previous)
                .ToMessage(Messenger);

            DeleteMap = new ReactiveCommand<MapVM>(vm => !vm.IsDownloading);
            DeleteMap
                .Do(vm => MapList.Remove(vm))
                .Select(vm => vm.Model)
                .Where(map => map != null)
                .Subscribe(map => MapStorage.deleteMap(map));

            _IsOnlineAvailable = this.ObservableToProperty(
                this.OnActivation()
                .SelectMany(Network.WifiAvailable().TakeUntil(this.OnDeactivation()))
                .Do(x => { })
                , x => x.IsOnlineAvailable, false);

            SearchMaps = new ReactiveAsyncCommand(_IsOnlineAvailable);

            _SearchResults = this.ObservableToProperty<MapManagementVM, IReactiveCollection<MapVM>>(
                SearchMaps.RegisterAsyncFunction(s => searchMapsImpl(s as string))
                .ObserveOn(Dispatcher)
                .Select(result => {
                    try {
                        return new ReactiveCollection<MapVM>(result.Select(x => new MapVM(null) { ServerKey = x })) as IReactiveCollection<MapVM>;
                    }
                    catch (Exception) {
                        return null;
                    }
                }),
                x => x.SearchResults);

            DownloadMap = new ReactiveCommand<MapVM>(vm => canBeDownloaded(vm as MapVM), Observable.Empty<Unit>());
            DownloadMap
                .Where(downloadMap.CanExecute)
                .CheckConnectivity(Network, Notifications)
                .Do(vm => vm.IsDownloading = true)
                .Do(_ => CurrentPivot = Pivot.Local)
                .Do(vm => MapList.Add(vm))
                .Subscribe(downloadMap.Execute);

            downloadMap.RegisterAsyncObservable(vm => {
                var vm_t = vm as MapVM;
                if (vm_t == null)
                    return Observable.Empty<System.Tuple<MapVM, Map>>();
                else
                    return MapService.downloadMap(vm_t.ServerKey)
                        .ShowServiceErrorNotifications(Notifications)
                        .Catch((WebException ex) => {
                            Notifications.showNotification(DiversityResources.MapManagement_Message_NoPermissions);

                            return Observable.Empty<Map>();
                        })
                        .Select(map => System.Tuple.Create(vm_t, map));
            })
            .ObserveOn(Dispatcher)
            .Select(t => {
                if (t.Item1 != null) // VM
                    {
                    if (t.Item2 != null) // Map
                        {
                        t.Item1.SetModel(t.Item2);
                    }
                    else {
                        MapList.Remove(t.Item1);
                    }
                }
                return t.Item1;
            }).Subscribe(_ => SelectMap.RaiseCanExecuteChanged());
        }
Esempio n. 15
-1
        public HyperCommand(JsonServiceClient client ,Grandsys.Wfm.Services.Outsource.ServiceModel.Link link)
        {
            Content = link.Name;
            Command = new ReactiveAsyncCommand();
            Method = link.Method;
            Request = link.Request;
            Response = Command.RegisterAsyncFunction(_ => {

                Model.EvaluationItem response;
                if (string.IsNullOrEmpty(Method))
                    return null;

                switch (Method)
                {
                    default:
                        response = client.Send<Model.EvaluationItem>(Method, Request.ToUrl(Method), _ ?? Request);
                        break;
                    case "GET":
                        response = client.Get<Model.EvaluationItem>(Request.ToUrl(Method));
                        break;
                }
                return response;
            });
            Command.ThrownExceptions.Subscribe(ex => Console.WriteLine(ex.Message));
        }