SiteMapNodeCollection.ReadOnly(SiteMapNodeCollection) Yöntem

Tanım

Belirtilen SiteMapNodeCollection koleksiyondaki düğümleri içeren salt okunur bir koleksiyon döndürür.

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

Parametreler

collection
SiteMapNodeCollection

SiteMapNodeCollection Salt SiteMapNodeokunur öğesine eklenecek nesneleri içeren SiteMapNodeCollection .

Döndürülenler

Özgün SiteMapNodeCollectionile aynı SiteMapNode öğelere ve yapıya sahip salt SiteMapNodeCollection okunur.

Özel durumlar

collection, null'e eşittir.

Örnekler

Aşağıdaki kod örneği, bir IsReadOnly koleksiyonun SiteMapNodeCollection salt okunur mu yoksa değiştirilebilir mi olduğunu test etmek için özelliğinin nasıl kullanılacağını gösterir. DeğiştirilebilirsesiteNodes, MoveNode üzerinde çağrılır; aksi takdirde, temel olarak kullanılarak SiteMapNodeCollection bir kopya siteNodes oluşturulur.

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

Açıklamalar

Özelliğini denetleyerek SiteMapNodeCollection bir IsReadOnly koleksiyonun salt okunur olup olmadığını test edebilirsiniz. özelliğiIsFixedSize, salt okunur olduğunda true da döndürürSiteMapNodeCollection.

Devralanlara Notlar

Salt SiteMapNodeCollection okunur koleksiyon okuma ve arama işlemlerini destekler, ancak , Add(SiteMapNode), AddRange, Clear(), Insert(Int32, SiteMapNode)ve Remove(SiteMapNode) yöntemlerini veya varsayılan dizin oluşturucu özelliğindeki RemoveAt(Int32)ayarlayıcıyı desteklemezItem[Int32].

Şunlara uygulanır