LocalFileSettingsProvider.SetPropertyValues(SettingsContext, SettingsPropertyValueCollection) Método

Definição

Define os valores do grupo especificado de configurações de propriedade.Sets the values of the specified group of property settings.

public:
 override void SetPropertyValues(System::Configuration::SettingsContext ^ context, System::Configuration::SettingsPropertyValueCollection ^ values);
public override void SetPropertyValues (System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyValueCollection values);
override this.SetPropertyValues : System.Configuration.SettingsContext * System.Configuration.SettingsPropertyValueCollection -> unit
Public Overrides Sub SetPropertyValues (context As SettingsContext, values As SettingsPropertyValueCollection)

Parâmetros

context
SettingsContext

Um SettingsContext que descreve o uso do aplicativo atual.A SettingsContext describing the current application usage.

values
SettingsPropertyValueCollection

Um SettingsPropertyValueCollection que representa o grupo de configurações de propriedade a ser definido.A SettingsPropertyValueCollection representing the group of property settings to set.

Exceções

Foi encontrada uma configuração de escopo do usuário, mas a configuração atual dá suporte apenas a configurações de escopo do aplicativo.A user-scoped setting was encountered but the current configuration only supports application-scoped settings.

- ou --or-

Houve uma falha geral ao salvar as configurações para o arquivo de configuração.There was a general failure saving the settings to the configuration file.

Comentários

Uma classe de wrapper de configurações, derivada de ApplicationSettingsBase , contém o Save método, que é chamado para persistir os valores de todas as suas propriedades de configurações.A settings wrapper class, derived from ApplicationSettingsBase, contains the Save method, which is called to persist the values of all of its settings properties. Esse método enumera todos os provedores de configurações associados às suas propriedades de configurações e chama o SetPropertyValues método para cada um SettingsProvider para executar a operação de serialização real.This method enumerates through all the settings providers associated with its settings properties, and calls the SetPropertyValues method for each SettingsProvider to perform the actual serialization operation.

SetPropertyValues o serializa individualmente cada propriedade de configurações de aplicativo no escopo do usuário para sua configuração de aplicativo correspondente no user.config arquivo de configuração apropriado.SetPropertyValues individually serializes each user-scoped application settings property to its corresponding application setting in the appropriate user.config configuration file.

Por padrão, o SetPropertyValues método usa a seguinte sequência lógica para determinar o esquema de serialização, dependendo do tipo da propriedade de configurações:By default, the SetPropertyValues method uses the following logical sequence to determine the serialization scheme, depending on type of the settings property:

  1. Se o tipo tiver um associado a TypeConverter uma ConvertToString implementação de método, essa conversão será usada.If the type has an associated TypeConverter with a ConvertToString method implementation, this conversion is used.

  2. A serialização XML é usada.XML serialization is used.

No entanto, você pode especificar um mecanismo de serialização preferencial usando o SettingsSerializeAsAttribute .However, you can specify a preferred serialization mechanism by using the SettingsSerializeAsAttribute. LocalFileSettingsProvider não oferece suporte à serialização binária no Visual Studio 2005.LocalFileSettingsProvider does not support binary serialization in Visual Studio 2005.

Se uma propriedade de configurações no escopo do usuário for definida de volta para seu valor padrão explicitamente, o provedor de configurações do arquivo local removerá a entrada da configuração associada do arquivo de configuração do usuário.If a user-scoped settings property is set back to its default value explicitly, then the local file settings provider will remove the entry for the associated setting from the user configuration file. O próximo acesso de leitura para essa propriedade usará simplesmente o valor padrão.The next read access for this property will simply use the default value.

Cuidado

LocalFileSettingsProvider Não usa criptografia para manter as configurações.LocalFileSettingsProvider does not use encryption to persist any settings. Portanto, não armazene senhas de texto sem formatação ou outras informações confidenciais usando esse provedor sem tomar precauções adicionais, como criptografar separadamente as informações no arquivo de configuração.Therefore, do not store plain text passwords or other sensitive information using this provider without taking additional precautions, such as separately encrypting the information within the configuration file. Para obter mais informações, consulte Criptografando informações de configuração usando a configuração protegida.For more information, see Encrypting Configuration Information Using Protected Configuration.

Aplica-se a

Confira também