IVsApplicationConfiguration.QueryEditConfiguration - метод
Определяет, является ли файл конфигурации может быть изменен.
Пространство имен: Microsoft.VisualStudio.ManagedInterfaces9
Сборка: Microsoft.VisualStudio.ManagedInterfaces.WCF (в Microsoft.VisualStudio.ManagedInterfaces.WCF.dll)
Синтаксис
'Декларация
Function QueryEditConfiguration As Boolean
bool QueryEditConfiguration()
bool QueryEditConfiguration()
abstract QueryEditConfiguration : unit -> bool
function QueryEditConfiguration() : boolean
Возвращаемое значение
Тип: Boolean
true если файл конфигурации может быть изменен; в противном случае значение false.
Заметки
QueryEditFiles вызовы метода QueryEditConfiguration метод, чтобы указать, относится ли файл конфигурации можно изменить. Если файл не существует, то будут созданы файл конфигурации по умолчанию (если на корневом уровне проекта) или пустой файл конфигурации.
Примечание
Если проект находится в системе управления версиями, то это действие создает файл проекта можно извлечь и проект, перезагруженным.
Если метод приводит к в файле конфигурации добавляется в проект, то любой ранее возвращаемый объект конфигурации к просмотру недопустимым. Клиенты, для регистрации обработчика ConfigurationChanged событие получил файл будет добавлен.
Примеры
В следующем примере кода демонстрируется применение QueryEditConfiguration метод, чтобы указать, относится ли файл конфигурации можно изменить.
/// Make sure that our custom WSDL importer extension is registered in /// the Metadata section of the configuration file for the current
/// project hierarchy and serviceProvider that gives access to required
/// services.
private static void EnsureCustomWsdlImporterRegistered
(IVsHierarchy hierarchy, IServiceProvider serviceProvider)
{
/// The IVsApplicationConfigurationManager service returns a
/// System.Configuration.Configuration object corresponding to
/// the given project's app.config or web.config file.
IVsApplicationConfigurationManager cfgMgr =
serviceProvider.GetService(typeof(IVsApplicationConfigurationManager))
as IVsApplicationConfigurationManager;
// Return the current application's configuration file by using
// the IVsApplicationConfiguration APIs. Make sure that the
// instance that is returned is disposed of correctly in order
// to clean up any event hooks or docdatas.
using (IVsApplicationConfiguration appCfg =
cfgMgr.GetApplicationConfiguration(hierarchy,
Microsoft.VisualStudio.VSConstants.VSITEMID_ROOT))
{
System.Configuration.Configuration cfg =
appCfg.LoadConfiguration();
// Check the file out from Source Code Control if it
// exists.
appCfg.QueryEditConfiguration();
/// After a System.Configuration.Configuration object
/// exists, use the"normal" .NET Framework configuration
/// APIs to return the sections that you want to modify.
ServiceModelSectionGroup sg =
ServiceModelSectionGroup.GetSectionGroup(cfg);
Type importerType = typeof(BindingPickerWsdlImportExtension);
if (!IsWsdlImporterRegistered(sg, importerType))
{
// If our custom WSDL importer is not registered, add
// it to the application's configuration file.
sg.Client.Metadata.WsdlImporters.Add(new
WsdlImporterElement(importerType));
cfg.Save();
}
}
}
Безопасность платформы .NET Framework
- Полное доверие для непосредственно вызывающего метода. Этот член не может быть использован частично доверенным кодом. Для получения дополнительной информации см. Использование библиотек из не вполне надежного кода.
См. также
Ссылки
IVsApplicationConfiguration Интерфейс
Microsoft.VisualStudio.ManagedInterfaces9 - пространство имен