ConfigurationElement.IsReadOnly 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
ConfigurationElement 개체가 읽기 전용인지 여부를 나타내는 값을 가져옵니다.
public:
virtual bool IsReadOnly();
public virtual bool IsReadOnly ();
abstract member IsReadOnly : unit -> bool
override this.IsReadOnly : unit -> bool
Public Overridable Function IsReadOnly () As Boolean
반환
ConfigurationElement 개체가 읽기 전용이면 true이고, 그렇지 않으면 false입니다.
예제
다음 예제에서는 IsReadOnly 메서드를 사용하는 방법을 보여 줍니다. 사용자 지정 섹션에서 사용되며 를 반환합니다 false.
// Show how to use IsReadOnly.
// It loops to see if the elements are read only.
static void ReadOnlyElements()
{
try
{
// Get the configuration file.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
// Get the MyUrls section.
UrlsSection myUrlsSection =
config.GetSection("MyUrls") as UrlsSection;
UrlsCollection elements = myUrlsSection.Urls;
IEnumerator elemEnum =
elements.GetEnumerator();
int i = 0;
Console.WriteLine(elements.Count.ToString());
while (elemEnum.MoveNext())
{
Console.WriteLine("The element {0} is read only: {1}",
elements[i].Name,
elements[i].IsReadOnly().ToString());
i += 1;
}
}
catch (ConfigurationErrorsException err)
{
Console.WriteLine("[ReadOnlyElements: {0}]",
err.ToString());
}
}
' Show how to use IsReadOnly.
' It loops to see if the elements are read only.
Shared Sub ReadOnlyElements()
Try
' Get the current configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
' Get the MyUrls section.
Dim myUrlsSection As UrlsSection = _
config.GetSection("MyUrls")
Dim elements As UrlsCollection = _
myUrlsSection.Urls
Dim elemEnum As IEnumerator = _
elements.GetEnumerator()
Dim i As Integer = 0
Console.WriteLine(elements.Count.ToString())
While elemEnum.MoveNext()
Console.WriteLine("The element {0} is read only: {1}", _
elements(i).Name, elements(i).IsReadOnly().ToString())
i += 1
End While
Catch err As ConfigurationErrorsException
Console.WriteLine("[ReadOnlyElements: {0}]", _
err.ToString())
End Try
End Sub
설명
시스템은 수정할 수 없는 구성 요소를 정의합니다.
수정할 수 있는 요소를 확인하려면 메서드를 IsReadOnly 사용합니다.