Пример #1
0
        public async Task RemoveAccountAsync(string clientID, IAccount account)
        {
            if (!IsBrokerInstalledAndInvokable())
            {
                _logger.Error("Android broker is not installed so no accounts will be removed.");
                return;
            }

            Dictionary <string, string> brokerPayload = new Dictionary <string, string>();

            brokerPayload.Add(BrokerParameter.ClientId, clientID);
            brokerPayload.Add(BrokerConstants.Environment, account.Environment);
            brokerPayload.Add(BrokerParameter.HomeAccountId, account.HomeAccountId.Identifier);

            try
            {
                await _brokerHelper.InitiateBrokerHandshakeAsync(_activity).ConfigureAwait(false);

                _brokerHelper.RemoveBrokerAccountInAccountManager(brokerPayload);
            }
            catch (Exception ex)
            {
                _logger.Error("Failed to remove Android broker account from the broker.");
                HandleBrokerOperationError(ex);
                throw;
            }
        }
        public async Task RemoveAccountAsync(IApplicationConfiguration applicationConfiguration, IAccount account)
        {
            using (_logger.LogMethodDuration())
            {
                if (!IsBrokerInstalledAndInvokable())
                {
                    _logger.Warning("Android broker is either not installed or not reachable so no accounts will be removed. ");
                    return;
                }

                try
                {
                    await _brokerHelper.InitiateBrokerHandshakeAsync(_parentActivity).ConfigureAwait(false);

                    _brokerHelper.RemoveBrokerAccountInAccountManager(applicationConfiguration.ClientId, account);
                }
                catch (Exception ex)
                {
                    _logger.Error("Failed to remove Android broker account from the broker. ");
                    HandleBrokerOperationError(ex);
                    throw;
                }
            }
        }