Language

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と同じSiteMapNode要素と構造を持つ読み取り専用の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) メソッド、および既定のインデクサー プロパティのセッター Item[Int32]はサポートしていません。

適用対象