SiteMapNodeCollection.ReadOnly(SiteMapNodeCollection) 메서드

정의

지정된 SiteMapNodeCollection 컬렉션에 노드가 포함된 읽기 전용 컬렉션을 반환합니다.

public:
 static System::Web::SiteMapNodeCollection ^ ReadOnly(System::Web::SiteMapNodeCollection ^ collection);
public static System.Web.SiteMapNodeCollection ReadOnly (System.Web.SiteMapNodeCollection collection);
static member ReadOnly : System.Web.SiteMapNodeCollection -> System.Web.SiteMapNodeCollection
Public Shared Function ReadOnly (collection As SiteMapNodeCollection) As SiteMapNodeCollection

매개 변수

collection
SiteMapNodeCollection

읽기 전용 SiteMapNodeCollection에 추가할 SiteMapNode 개체를 포함하는 SiteMapNodeCollection입니다.

반환

SiteMapNodeCollection

원래 SiteMapNodeCollectionSiteMapNode 요소 및 구조가 동일한 읽기 전용 SiteMapNodeCollection입니다.

예외

collection이(가) null인 경우

예제

다음 코드 예제에 사용 하는 방법을 보여 줍니다.는 IsReadOnly 테스트할 속성입니다 여부를 SiteMapNodeCollection 컬렉션은 읽기 전용으로 만들거나 수정 가능 합니다. 경우 siteNodes 는 수정 가능 하며 MoveNode 이 고, 그렇지 않으면 호출에 복제본 SiteMapNodeCollection 를 사용 하 여 만들어집니다 siteNodes 를 기준으로 합니다.

SiteMapNodeCollection siteNodes = SiteMap.RootNode.GetAllNodes();

if ( siteNodes.IsReadOnly ||
     siteNodes.IsFixedSize )
{
    Response.Write("Collection is read-only or has fixed size.<BR>");

    // Create a new, modifiable collection from the existing one.
    SiteMapNodeCollection modifiableCollection =
         new SiteMapNodeCollection(siteNodes);

    // The MoveNode example method moves a node from position one to
    // the last position in the collection.
    MoveNode(modifiableCollection);
}
else {
    MoveNode(siteNodes);
}

Dim siteNodes As SiteMapNodeCollection
siteNodes = SiteMap.RootNode.GetAllNodes()

If siteNodes.IsReadOnly Or siteNodes.IsFixedSize Then

    Response.Write("Collection is read-only or has fixed size.<BR>")

    ' Create a new, modifiable collection from the existing one.
    Dim modifiableCollection As SiteMapNodeCollection
    modifiableCollection = New SiteMapNodeCollection(siteNodes)

    ' The MoveNode example method moves a node from position one to
    ' the last position in the collection.
    MoveNode(modifiableCollection)
Else
    MoveNode(siteNodes)
End If

설명

테스트할 수 있는지 여부를 SiteMapNodeCollection 컬렉션 읽기 전용인 지 확인 하 여를 IsReadOnly 속성. IsFixedSize 또한 속성 반환 true 경우는 SiteMapNodeCollection 읽기 전용인 지 합니다.

상속자 참고

읽기 전용 SiteMapNodeCollection 컬렉션 읽기 및 검색 작업을 지원 하지만 지원 하지 않습니다는 Add(SiteMapNode)AddRange, Clear()Insert(Int32, SiteMapNode)Remove(SiteMapNode), 및 RemoveAt(Int32) 메서드나에서 기본 인덱서 setter 속성을 Item[Int32]입니다.

적용 대상