NameValueConfigurationCollectionとは? わかりやすく解説

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

NameValueConfigurationCollection クラス

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

NameValueConfigurationElement オブジェクトコレクション格納します。このクラス継承できません。

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

Public NotInheritable Class
 NameValueConfigurationCollection
    Inherits ConfigurationElementCollection
Dim instance As NameValueConfigurationCollection
public sealed class NameValueConfigurationCollection
 : ConfigurationElementCollection
public ref class NameValueConfigurationCollection
 sealed : public ConfigurationElementCollection
public final class NameValueConfigurationCollection
 extends ConfigurationElementCollection
public final class NameValueConfigurationCollection
 extends ConfigurationElementCollection
解説解説

NameValueConfigurationCollection クラス使用すると、NameValueConfigurationElement オブジェクトコレクションプログラムかアクセスできます

使用例使用例

NameValueConfigurationCollection 型を使用する方法次のコード例示します

Imports System
Imports System.Configuration
Imports System.Web.Configuration
Imports System.Collections
Imports System.Text

Namespace Samples.AspNet
  Class UsingNameValueConfigurationCollection
    Public Shared Sub Main()
      Try
        ' Set the path of the config file.
        Dim configPath As String
 = ""

        ' Get the Web application configuration object.
        Dim config As System.Configuration.Configuration
 = _
         WebConfigurationManager.OpenWebConfiguration(configPath)

        ' Get the section related object.
        Dim configSection As _
        AnonymousIdentificationSection = _
         CType(config.GetSection("system.web/anonymousIdentification"),
 _
         AnonymousIdentificationSection)

        ' Display title and info.
        Console.WriteLine("Configuration Info")
        Console.WriteLine()

        ' Display Config details.
        Console.WriteLine("File Path: {0}", _
          config.FilePath)
        Console.WriteLine("Section Path: {0}", _
          configSection.SectionInformation.Name)
        Console.WriteLine()

        ' Create a NameValueConfigurationCollection object.
        Dim myNameValConfigCollection As NameValueConfigurationCollection
 = _
        New NameValueConfigurationCollection()

        For Each propertyItem As
 PropertyInformation In _
         configSection.ElementInformation.Properties
          Dim nameValConfigElement As NameValueConfigurationElement
 = _
           New NameValueConfigurationElement _
           (propertyItem.Name.ToString(), propertyItem.Value.ToString())
          ' Add a NameValueConfigurationElement
          ' to the collection.
          myNameValConfigCollection.Add(nameValConfigElement)
        Next

        ' Count property.
        Console.WriteLine("Collection Count: {0}",
 _
         myNameValConfigCollection.Count)

        ' Item property.
        Console.WriteLine("Value of property
 'enabled': {0}", _
         myNameValConfigCollection.Item("enabled").Value)

        ' Display the contents of the collection.
        For Each configItem As
 NameValueConfigurationElement In _
         myNameValConfigCollection
          Console.WriteLine()
          Console.WriteLine("Configuration Details:")
          Console.WriteLine("Name: {0}", configItem.Name)
          Console.WriteLine("Value: {0}", configItem.Value)
        Next

        ' Remove method.
        Dim myConfigElement As NameValueConfigurationElement
 = _
         myNameValConfigCollection.Item("domain")
        myNameValConfigCollection.Remove(myConfigElement)

        ' Clear method.
        myNameValConfigCollection.Clear()

      Catch e As Exception
        ' Unknown error.
        Console.WriteLine(e.ToString())
      End Try

      ' Display and wait.
      Console.ReadLine()
    End Sub
  End Class
End Namespace
#region Using directives

using System;
using System.Configuration;
using System.Web.Configuration;
using System.Collections;
using System.Text;

#endregion

namespace Samples.AspNet
{
  class UsingNameValueConfigurationCollection
  {
    static void Main(string[]
 args)
    {
      try
      {
        // Set the path of the config file.
        string configPath = "";

        // Get the Web application configuration object.
        Configuration config =
          WebConfigurationManager.OpenWebConfiguration(configPath);

        // Get the section related object.
        AnonymousIdentificationSection configSection =
          (AnonymousIdentificationSection)config.GetSection
          ("system.web/anonymousIdentification");

        // Display title and info.
        Console.WriteLine("Configuration Info");
        Console.WriteLine();

        // Display Config details.
        Console.WriteLine("File Path: {0}",
          config.FilePath);
        Console.WriteLine("Section Path: {0}",
          configSection.SectionInformation.Name);
        Console.WriteLine();

        // Create a NameValueConfigurationCollection object.
        NameValueConfigurationCollection myNameValConfigCollection =
          new NameValueConfigurationCollection();

        foreach (PropertyInformation propertyItem in
          configSection.ElementInformation.Properties)
        {
          NameValueConfigurationElement nameValConfigElement =
            new NameValueConfigurationElement
            (propertyItem.Name.ToString(), propertyItem.Value.ToString());
          // Add a NameValueConfigurationElement
          // to the collection.
          myNameValConfigCollection.Add(nameValConfigElement);
        }

        // Count property.
        Console.WriteLine("Collection Count: {0}",
         myNameValConfigCollection.Count);

        // Item property.
        Console.WriteLine("Value of property 'enabled': {0}",
         myNameValConfigCollection["enabled"].Value);

        // Display the contents of the collection.
        foreach (NameValueConfigurationElement configItem
          in myNameValConfigCollection)
        {
          Console.WriteLine();
          Console.WriteLine("Configuration Details:");
          Console.WriteLine("Name: {0}", configItem.Name);
          Console.WriteLine("Value: {0}", configItem.Value);
        }

        // Remove method.
        NameValueConfigurationElement myConfigElement =
          myNameValConfigCollection["domain"];
        myNameValConfigCollection.Remove(myConfigElement);

        // Clear method.
        myNameValConfigCollection.Clear();
      }

      catch (Exception e)
      {
        // Unknown error.
        Console.WriteLine(e.ToString());
      }

      // Display and wait.
      Console.ReadLine();
    }
  }
}
継承階層継承階層
System.Object
   System.Configuration.ConfigurationElement
     System.Configuration.ConfigurationElementCollection
      System.Configuration.NameValueConfigurationCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NameValueConfigurationCollection メンバ
System.Configuration 名前空間
NameValueConfigurationElement

NameValueConfigurationCollection コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

NameValueConfigurationCollection クラス新しインスタンス初期化します。

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

Dim instance As New NameValueConfigurationCollection
public NameValueConfigurationCollection ()
public:
NameValueConfigurationCollection ()
public NameValueConfigurationCollection ()
public function NameValueConfigurationCollection
 ()
使用例使用例

NameValueConfigurationCollection コンストラクタ使用する方法次のコード例示します。このコード例は、NameValueConfigurationCollection クラストピック取り上げているコード例一部分です。

' Create a NameValueConfigurationCollection object.
Dim myNameValConfigCollection As NameValueConfigurationCollection
 = _
New NameValueConfigurationCollection()
// Create a NameValueConfigurationCollection object.
NameValueConfigurationCollection myNameValConfigCollection =
  new NameValueConfigurationCollection();
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NameValueConfigurationCollection クラス
NameValueConfigurationCollection メンバ
System.Configuration 名前空間

NameValueConfigurationCollection プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ AllKeys NameValueConfigurationCollection に格納されているすべての項目のキー取得します
パブリック プロパティ CollectionType  ConfigurationElementCollection の型を取得します。 ( ConfigurationElementCollection から継承されます。)
パブリック プロパティ Count  コレクション内の要素の数を取得します。 ( ConfigurationElementCollection から継承されます。)
パブリック プロパティ ElementInformation  ConfigurationElement オブジェクトカスタマイズできない情報機能格納する ElementInformation オブジェクト取得します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ EmitClear  コレクション削除されているかどうか指定します。 ( ConfigurationElementCollection から継承されます。)
パブリック プロパティ IsSynchronized  コレクションへのアクセス同期されている (スレッド セーフである) かどうかを示す値を取得します。 ( ConfigurationElementCollection から継承されます。)
パブリック プロパティ Item 指定されパラメータ基づいて、NameValueConfigurationElement オブジェクト取得または設定します
パブリック プロパティ LockAllAttributesExcept  ロックされている属性コレクション取得します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ LockAllElementsExcept  ロックされている要素コレクション取得します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ LockAttributes  ロックされている属性コレクション取得します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ LockElements  ロックされている要素コレクション取得します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ LockItem  要素ロックされているかどうかを示す値を取得または設定します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ SyncRoot  ConfigurationElementCollection へのアクセス同期するために使用するオブジェクト取得します。 ( ConfigurationElementCollection から継承されます。)
参照参照

関連項目

NameValueConfigurationCollection クラス
System.Configuration 名前空間
NameValueConfigurationElement

NameValueConfigurationCollection メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Add NameValueConfigurationElement オブジェクトコレクション追加します
パブリック メソッド Clear NameValueConfigurationCollection を消去します。
パブリック メソッド CopyTo  ConfigurationElementCollection の内容配列コピーします。 ( ConfigurationElementCollection から継承されます。)
パブリック メソッド Equals  オーバーロードされますConfigurationElementCollection指定したオブジェクト比較します。 ( ConfigurationElementCollection から継承されます。)
パブリック メソッド GetEnumerator  ConfigurationElementCollection反復処理使用する IEnumerator を取得します。 ( ConfigurationElementCollection から継承されます。)
パブリック メソッド GetHashCode  ConfigurationElementCollection インスタンスを表す一意の値を取得します。 ( ConfigurationElementCollection から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド IsReadOnly  ConfigurationElementCollection オブジェクト読み取り専用かどうかを示す値を取得します。 ( ConfigurationElementCollection から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド Remove オーバーロードされますNameValueConfigurationElement オブジェクトコレクションから削除します
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

NameValueConfigurationCollection クラス
System.Configuration 名前空間
NameValueConfigurationElement

NameValueConfigurationCollection メンバ

NameValueConfigurationElement オブジェクトコレクション格納します。このクラス継承できません。

NameValueConfigurationCollection データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド NameValueConfigurationCollection NameValueConfigurationCollection クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ AllKeys NameValueConfigurationCollection格納されているすべての項目のキー取得します
パブリック プロパティ CollectionType  ConfigurationElementCollection の型を取得します。(ConfigurationElementCollection から継承されます。)
パブリック プロパティ Count  コレクション内の要素の数を取得します。(ConfigurationElementCollection から継承されます。)
パブリック プロパティ ElementInformation  ConfigurationElement オブジェクトカスタマイズできない情報機能格納する ElementInformation オブジェクト取得します。 (ConfigurationElement から継承されます。)
パブリック プロパティ EmitClear  コレクション削除されているかどうか指定します。(ConfigurationElementCollection から継承されます。)
パブリック プロパティ IsSynchronized  コレクションへのアクセス同期されている (スレッド セーフである) かどうかを示す値を取得します。(ConfigurationElementCollection から継承されます。)
パブリック プロパティ Item 指定されパラメータ基づいてNameValueConfigurationElement オブジェクト取得または設定します
パブリック プロパティ LockAllAttributesExcept  ロックされている属性コレクション取得します。(ConfigurationElement から継承されます。)
パブリック プロパティ LockAllElementsExcept  ロックされている要素コレクション取得します。(ConfigurationElement から継承されます。)
パブリック プロパティ LockAttributes  ロックされている属性コレクション取得します。 (ConfigurationElement から継承されます。)
パブリック プロパティ LockElements  ロックされている要素コレクション取得します。(ConfigurationElement から継承されます。)
パブリック プロパティ LockItem  要素ロックされているかどうかを示す値を取得または設定します。(ConfigurationElement から継承されます。)
パブリック プロパティ SyncRoot  ConfigurationElementCollection へのアクセス同期するために使用するオブジェクト取得します。(ConfigurationElementCollection から継承されます。)
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Add NameValueConfigurationElement オブジェクトコレクション追加します
パブリック メソッド Clear NameValueConfigurationCollection消去します。
パブリック メソッド CopyTo  ConfigurationElementCollection の内容配列コピーします。 (ConfigurationElementCollection から継承されます。)
パブリック メソッド Equals  オーバーロードされますConfigurationElementCollection指定したオブジェクト比較します。 (ConfigurationElementCollection から継承されます。)
パブリック メソッド GetEnumerator  ConfigurationElementCollection反復処理使用する IEnumerator を取得します。 (ConfigurationElementCollection から継承されます。)
パブリック メソッド GetHashCode  ConfigurationElementCollection インスタンスを表す一意の値を取得します。 (ConfigurationElementCollection から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド IsReadOnly  ConfigurationElementCollection オブジェクト読み取り専用かどうかを示す値を取得します。 (ConfigurationElementCollection から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド Remove オーバーロードされますNameValueConfigurationElement オブジェクトコレクションから削除します
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

NameValueConfigurationCollection クラス
System.Configuration 名前空間
NameValueConfigurationElement


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

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

辞書ショートカット

すべての辞書の索引

「NameValueConfigurationCollection」の関連用語

NameValueConfigurationCollectionのお隣キーワード
検索ランキング

   

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



NameValueConfigurationCollectionのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS