Exemple #1
0
        /// <exception cref="ArgumentNullException"><paramref name="webClient"/> is <see langword="null" />.</exception>
        public SignInViewModel(AnonymousFactorioWebClient webClient)
        {
            if (webClient == null)
            {
                throw new ArgumentNullException("webClient");
            }

            _webClient = webClient;

            this.WhenActivated(() =>
            {
                var disposer = new CompositeDisposable();

                var areFieldsValid = this.WhenAnyValue(
                    viewModel => viewModel.UsernameOrEmail,
                    viewModel => viewModel.Password)
                                     .Select(fields =>
                                             !string.IsNullOrWhiteSpace(fields.Item1) &&
                                             !string.IsNullOrWhiteSpace(fields.Item2));

                // The low level factorio auth observable returns success or throws exception
                // Bad api choice? better would be for expected errors to return AuthResult.ErrorXYZ, unexpected errors call OnError()
                AttemptSignIn = ReactiveCommand.CreateAsyncTask(areFieldsValid, o => Task.FromResult(FactorioUserSession.FactorioAuthResult.None))
                                .AddTo(disposer);

                return(disposer);
            });
        }
Exemple #2
0
        /// <exception cref="ArgumentNullException"><paramref name="webClient"/> is <see langword="null" />.</exception>
        public SignInDialog(AnonymousFactorioWebClient webClient)
        {
            if (webClient == null)
            {
                throw new ArgumentNullException("webClient");
            }

            _form = new SignInView(new SignInViewModel(webClient));
        }