public async Task<AuthorizationResult> AuthorizeAsync(AuthorizationParameters parameters)
        {
            _taskCompletionSource = new TaskCompletionSource<AuthorizationResult>();

            if (parameters == null)
                throw new NullReferenceException("Параметры авторизации не могут иметь значение null");

            if (_form != null)
            {
                _form.Close();
                _taskCompletionSource = new TaskCompletionSource<AuthorizationResult>();
            }

            _form = new AuthorizationForm(parameters.Culture, parameters.AuthUri, parameters.BlankUri,
                parameters.AvailableHostNames);

            if (parameters.AuthorizationTitle != null)
                _form.SetTitle(parameters.AuthorizationTitle);

            if (parameters.PageErrorText != null)
                _form.PageErrorText = parameters.PageErrorText;

            _form.Authorized += Authorized;
            _form.Closing += Closing;

            if (_form.Visibility != Visibility.Visible)
                _form.ShowDialog();

            return await _taskCompletionSource.Task;
        }
Exemple #2
0
        public async Task<AuthorizationResult> AuthorizeAsync()
        {
            var culture = _appConfig.Language.GetCultureInfo();
            var parameters = new AuthorizationParameters(culture, _apiClient.OAuthUrl, VkApiClient.BlankOAuthUrl,
                new List<string>
                {
                    VkApiClient.LoginHostName,
                    _apiClient.OAuthHostName
                })
            {
                AuthorizationTitle = _languageRepository.Data.AppView.HeaderView.GetLabel("AuthorizationTitle"),
                PageErrorText = _languageRepository.Data.AppView.HeaderView.GetLabel("PageError")
            };

            return await _oAuthAuthorizer.AuthorizeAsync(parameters);
        }