public void ApplyChanges(IAccountConfiguration accountConfigurations)
        {
            //// maintain integrity with GetDummyAccount()
            //MailAccountConfiguration configuration = (MailAccountConfiguration)accountConfigurations;

            //this.text_IdentityName.Text = configuration.AccountName;
            //this.text_Name.Text = configuration.EmailAddress.Name;
            //this.text_Email.Text = configuration.EmailAddress.Address;

            //LoadAuthenticationSettings(configuration);

            //this.check_IncludeInGlobalOperations.Checked = configuration.IncludeInGlobalOperations;
            //this.checkEncryptMessages.Checked = configuration.EncryptMessages;
            //this.checkIncludeCertificates.Checked = configuration.IncludeCertificates;
            //this.checkSignMessages.Checked = configuration.SignMessages;

            //selectedCalendarFolder = Program.AccountManager.GetFolder(configuration.DefaultSchedulingFolderPath);
            //text_General_CalendarFolder.Text = selectedCalendarFolder == null ? string.Empty : selectedCalendarFolder.DisplayPath;
            //selectedTaskFolder = Program.AccountManager.GetFolder(configuration.DefaultTaskFolderPath);
            //text_General_TaskFolder.Text = selectedTaskFolder == null ? string.Empty : selectedTaskFolder.DisplayPath;
            //selectedContactFolder = Program.AccountManager.GetFolder(configuration.DefaultContactFolderPath);
            //text_General_ContactFolder.Text = selectedContactFolder == null ? string.Empty : selectedContactFolder.DisplayPath;

            //aliases = configuration.Aliases;
            //useAliasesFromSubaccounts = configuration.UseAliasesFromSubaccounts;
            //this.text_AutoBCC.Text = string.Empty;
            //this.text_AutoBCC.AddMailAddresses(configuration.AutoBcc, false);

            //int index = 0;
            //foreach (OptionsControl control in this.optionControls.Values)
            //	if (control is IAccountConfigurationSource)
            //		((IAccountConfigurationSource)control).ApplyChanges(configuration.AccountConfigurations[index++]);
        }
 private bool CanChangeEnabled(IAccountConfiguration item)
 {
     if (!item.Enabled)
     {
         return(true);
     }
     //if (Program.AccountManager.DefaultLocalAccount == this.account)
     //	return (item.AccountType & AccountType.Mail) == 0;
     return(true);
 }
        /// <summary>
        /// Updates account configuration settings using Alpaca REST API endpoint.
        /// </summary>
        /// <param name="accountConfiguration">New account configuration object for updating.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <returns>Mutable version of updated account configuration object.</returns>
        public async Task <IAccountConfiguration> PatchAccountConfigurationAsync(
            IAccountConfiguration accountConfiguration,
            CancellationToken cancellationToken = default)
        {
            await _alpacaRestApiThrottler.WaitToProceed(cancellationToken).ConfigureAwait(false);

            using var request = new HttpRequestMessage(_httpMethodPatch,
                                                       new Uri("account/configurations", UriKind.RelativeOrAbsolute))
                  {
                      Content = toStringContent(accountConfiguration)
                  };

            using var response = await _httpClient.SendAsync(request, cancellationToken)
                                 .ConfigureAwait(false);

            return(await response.DeserializeAsync <IAccountConfiguration, JsonAccountConfiguration>()
                   .ConfigureAwait(false));
        }
示例#4
0
        /// <summary>
        /// Updates account configuration settings using Alpaca REST API endpoint.
        /// </summary>
        /// <param name="accountConfiguration">New account configuration object for updating.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <returns>Mutable version of updated account configuration object.</returns>
        public async Task <IAccountConfiguration> PatchAccountConfigurationAsync(
            IAccountConfiguration accountConfiguration,
            CancellationToken cancellationToken = default)
        {
            await _alpacaRestApiThrottler.WaitToProceed(cancellationToken).ConfigureAwait(false);

            using (var request = new HttpRequestMessage(_httpMethodPatch,
                                                        new Uri("account/configurations", UriKind.RelativeOrAbsolute)))
            {
                var serializer = new JsonSerializer();
                using (var stringWriter = new StringWriter())
                {
                    serializer.Serialize(stringWriter, accountConfiguration);
                    request.Content = new StringContent(stringWriter.ToString());
                }

                using (var response = await _alpacaHttpClient.SendAsync(request, cancellationToken)
                                      .ConfigureAwait(false))
                {
                    return(await deserializeAsync <IAccountConfiguration, JsonAccountConfiguration>(response)
                           .ConfigureAwait(false));
                }
            }
        }
 /// <inheritdoc />
 public Task <IAccountConfiguration> PatchAccountConfigurationAsync(
     IAccountConfiguration accountConfiguration,
     CancellationToken cancellationToken = default) =>
 _httpClient.PatchAsync <IAccountConfiguration, JsonAccountConfiguration, IAccountConfiguration>(
     "v2/account/configurations", accountConfiguration, cancellationToken);