Beispiel #1
0
        private static void HandleState(MainWindowModel model, AuthenticationState state)
        {
            switch (state)
            {
            case AuthenticationState.WaitingLoginAndPassword:
            case AuthenticationState.Authenticating:
                GoToAuthenticationPage(model);
                break;

            case AuthenticationState.Authenticated:
                GoToWorkspacePage(model);
                break;

            default:
                throw new Exception($"Unknown authentication state: {state}");
            }
        }
Beispiel #2
0
        public static IDisposable BindAuthentication(
            this MainWindowModel model,
            IAuthenticator authenticator)
        {
            var disposable = new CompositeDisposable();

            var stateUpdates = authenticator
                               .ObserveState()
                               .SubscribeOn(RxApp.TaskpoolScheduler)
                               .ObserveOn(RxApp.MainThreadScheduler);

            stateUpdates
            .Accept(state => HandleState(model, state))
            .DisposeWith(disposable);

            return(disposable);
        }
Beispiel #3
0
        public static IDisposable BindPopup(
            this MainWindowModel model,
            IPopupController popupController)
        {
            model.PopupModel = PopupModel.Hidden();

            var trigger = (popupController as PopupController)?.Trigger;

            if (trigger != null)
            {
                return(trigger
                       .SubscribeOn(RxApp.TaskpoolScheduler)
                       .ObserveOn(RxApp.MainThreadScheduler)
                       .Accept(context =>
                {
                    model.PopupModel = context == null
                            ? PopupModel.Hidden()
                            : new PopupModel(context);
                }));
            }

            return(Disposable.Empty);
        }