SiteMapProvider.Initialize メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SiteMapProvider.Initialize メソッドの意味・解説 

SiteMapProvider.Initialize メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

SiteMapProvider 実装初期化します。対象には、サイト マップ データ永続ストレージから読み込むために必要なリソースがすべて含まれます。

名前空間: System.Web
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Overrides Sub Initialize
 ( _
    name As String, _
    attributes As NameValueCollection _
)
Dim instance As SiteMapProvider
Dim name As String
Dim attributes As NameValueCollection

instance.Initialize(name, attributes)
public void Initialize (
    String name, 
    NameValueCollection attributes
)

パラメータ

name

初期化する Name プロバイダの名前。

attributes

プロバイダ初期化支援する追加属性を含む NameValueCollection。これらの属性は、Web.config ファイルサイト マップ プロバイダ構成から読み取られます。

解説解説
使用例使用例

Initialize メソッドオーバーライドして、Microsoft Access データベース接続準備する方法次のコード例示します

OleDbConnection オブジェクト接続文字列は、Initialize メソッドNameValueCollection パラメータとして渡されます。この場合接続文字列は Web.config ファイルプロバイダ固有のセクション指定されています。accessSiteMapConnectionString には、サイト マップ データホストする Microsoft Access データベース接続文字列指定されています。

<siteMap defaultProvider="AccessSiteMapProvider">
  <providers>
     <add
       name="AccessSiteMapProvider"
       type="Samples.AspNet.AccessSiteMapProvider,Samples.AspNet"
       accessSiteMapConnectionString="PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=\\SomeUNCShare\\sitemap.mdb"/>
  </providers> 
 </siteMap>

このコード例は、SiteMapProvider クラストピック取り上げているコード例一部分です。

' Initialize is used to initialize the properties and any state that
 the
' AccessProvider holds, but is not used to build the site map.
' The site map is built when the BuildSiteMap method is called.
Public Overrides Sub Initialize(ByVal
 name As String, ByVal
 attributes As NameValueCollection)
    If IsInitialized Then
        Return
    End If
    MyBase.Initialize(name, attributes)

    ' Create and test the connection to the Microsoft Access database.
    ' Retrieve the Value of the Access connection string from the
    ' attributes NameValueCollection.
    Dim connectionString As String
 = attributes(AccessConnectionStringName)

    If Nothing = connectionString OrElse
 connectionString.Length = 0 Then
        Throw New Exception("The
 connection string was not found.")
    Else
        accessConnection = New OleDbConnection(connectionString)
    End If
    initialized = True
End Sub 'Initialize
// Initialize is used to initialize the properties and any state that
 the
// AccessProvider holds, but is not used to build the site map.
// The site map is built when the BuildSiteMap method is called.
public override void Initialize(string
 name, NameValueCollection attributes) {
    if (IsInitialized)
        return;

    base.Initialize(name, attributes);

    // Create and test the connection to the Microsoft Access database.

    // Retrieve the Value of the Access connection string from the
    // attributes NameValueCollection.
    string connectionString = attributes[AccessConnectionStringName];

    if (null == connectionString || connectionString.Length
 == 0)
        throw new Exception ("The connection string
 was not found.");
    else
        accessConnection = new OleDbConnection(connectionString);

    initialized = true;
}
   // Initialize is used to initialize the properties and any state that
 the
   // AccessProvider holds, but is not used to build the site map.
   // The site map is built when the BuildSiteMap method is called.
   virtual void Initialize( String^ name, NameValueCollection^
 attributes ) override
   {
      if ( IsInitialized )
            return;

      StaticSiteMapProvider::Initialize( name, attributes );
      
      // Create and test the connection to the Microsoft Access database.
      // Retrieve the Value of the Access connection string from the
      // attributes NameValueCollection.
      String^ connectionString = attributes[ AccessConnectionStringName ];
      if ( nullptr == connectionString || connectionString->Length
 == 0 )
            throw gcnew Exception( "The connection string
 was not found." );
      else
            accessConnection = gcnew OleDbConnection( connectionString );

      initialized = true;
   }


protected:

// Initialize is used to initialize the properties and any state that
 the
// AccessProvider holds, but is not used to build the site map.
// The site map is built when the BuildSiteMap method is called.
public void Initialize(String name, NameValueCollection
 attributes) 
    throws Exception
{
    if (get_IsInitialized())
    {
        return;
    }

    super.Initialize(name, attributes);
    // Create and test the connection to the Microsoft Access database.
    // Retrieve the Value of the Access connection string from the
    // attributes NameValueCollection.
    String connectionString = attributes.get_Item(
        accessConnectionStringName);

    if (null == connectionString || connectionString.get_Length()
 == 0)
    {
        throw new Exception("The connection string
 was not found.");
    }
    else
    {
        accessConnection = new OleDbConnection(connectionString);
    }
    initialized = true;
} //Initialize
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SiteMapProvider クラス
SiteMapProvider メンバ
System.Web 名前空間
ProviderBase
BuildSiteMap
Clear


このページでは「.NET Framework クラス ライブラリ リファレンス」からSiteMapProvider.Initialize メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からSiteMapProvider.Initialize メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からSiteMapProvider.Initialize メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

SiteMapProvider.Initialize メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SiteMapProvider.Initialize メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS