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

元の SiteMapNodeCollection と同じ SiteMapNode 要素および構造を持つ読み取り専用 SiteMapNodeCollection

例外

collectionnullです。

次のコード例では、プロパティを IsReadOnly 使用して、コレクションが読み取り専用か変更可能かを SiteMapNodeCollection テストする方法を示します。 変更可能な場合は呼MoveNodeび出されます。それ以外の場合siteNodesは、ベースとして使用してsiteNodes複製SiteMapNodeCollectionが作成されます。

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

注釈

プロパティを確認IsReadOnlyすることで、SiteMapNodeCollectionコレクションが読み取り専用かどうかをテストできます。 このプロパティはIsFixedSize、a SiteMapNodeCollection が読み取り専用の場合も返しますtrue

注意 (継承者)

読み取り専用SiteMapNodeCollectionコレクションは、読み取り操作と検索操作をサポートしますが、既定のAdd(SiteMapNode)インデクサー プロパティの 、Insert(Int32, SiteMapNode)Clear()Remove(SiteMapNode)AddRangeRemoveAt(Int32)およびメソッドもセItem[Int32]ッターもサポートしていません。

適用対象