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.
설명
QueryEditConfiguration 메서드 호출을 QueryEditFiles 구성 파일을 편집할 수 있는지 여부를 확인 하는 방법입니다. 파일이 존재 하지 않는 경우 기본 구성 파일 (루트 수준 프로젝트의 경우) 또는 빈 구성 파일이 만들어집니다.
참고
프로젝트가 소스 제어에서 사용 중인 경우이 작업은 프로젝트 파일을 체크 아웃 하 고 프로젝트 다시 로드를 발생 합니다.
구성 파일을 프로젝트에 추가 되 고 메서드 결과가 나오면 모든 이전에 반환 된 구성 개체가 잘못 된 렌더링 됩니다. 에 대 한 처리기를 등록 한 클라이언트는 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 보안
- 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용를 참조하세요.