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

ConfigurationElement クラス

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

構成ファイル内の構成要素を表します。

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

Public MustInherit Class
 ConfigurationElement
Dim instance As ConfigurationElement
public abstract class ConfigurationElement
public ref class ConfigurationElement abstract
public abstract class ConfigurationElement
public abstract class ConfigurationElement
解説解説

ConfigurationElement は抽象クラスであるため、インスタンス化できません。これは、構成ファイル内の要素を表します。

メモメモ

構成ファイル内の要素は、基本 XML 要素またはセクションを参照します。基本要素は、関連属性がある場合はその属性付きの単純な XML タグです。最も簡単な形式では、セクションは基本要素と一致します。複雑なセクションには、1 つ以上の基本要素、要素のコレクション、およびその他のセクションが含まれることがあります。

ConfigurationElement は、XML 構成要素を表すクラス (ConfigurationSection など) の基本クラスとして使用されます。

ConfigurationElement クラスを拡張して、ConfigurationSection セクション内の構成要素を表すことができます。また、次の例に示すように、ConfigurationElement 要素の ConfigurationElementCollection コレクションを作成することもできます。

実装時の注意 Configuration は、構成ファイルの編集をプログラムから行うことができるようにするクラスです。Web アプリケーション用の WebConfigurationManager またはクライアント アプリケーション用の ConfigurationManager に用意されているオープン メソッドの 1 つを使用します。これらのメソッドは、Configuration オブジェクトを返します。このオブジェクトにより、基になる構成ファイルを処理するために必要なメソッドとプロパティが提供されます。次に示す方法で、これらのファイルへの読み取りアクセスまたは書き込みアクセスができます。

アプリケーションが独自の構成に対する読み取り専用アクセスを行う必要がある場合は、GetSection のオーバーロード メソッドを使用することをお勧めします (Web アプリケーションの場合)。クライアント アプリケーションの場合は、GetSection メソッドを使用します。 これらのメソッドにより、現在のアプリケーションのキャッシュされた構成値にアクセスできます。こちらの方が、Configuration クラスよりもパフォーマンスが優れています。
メモメモ

パス パラメータを受け取る静的な GetSection メソッドを使用する場合、パス パラメータは、コードを実行しているアプリケーションを参照している必要があります。そうでない場合は、パラメータが無視され、現在実行中のアプリケーションの構成情報が返されます。

継承時の注意 すべての ConfigurationElement オブジェクトは、要素属性、または子要素のコレクションを表す ConfigurationProperty オブジェクトの内部 ConfigurationPropertyCollection コレクションを作成します。 カスタマイズできない情報および機能は、ElementInformation プロパティによって提供される ElementInformation オブジェクトに格納されています。 プログラム コーディング モデルまたは宣言 (属性付き) コーディング モデルのいずれかを使用して、カスタム構成要素を作成できます。

使用例使用例

カスタムの ConfigurationElement を実装する方法を次のコード例に示します。

この要素は、カスタム セクションまたはカスタム要素コレクションを定義するために、カスタム セクションで使用されます。

Imports System
Imports System.Configuration
Imports System.Collections




' Define the UrlConfigElement.

Public Class UrlConfigElement
    Inherits ConfigurationElement
    
    ' Test flag.
    Private Shared _displayIt _
    As Boolean = False
    
    
    Public Sub New(ByVal
 newName As String, _
    ByVal newUrl As String,
 _
    ByVal newPort As Integer)
        Name = newName
        Url = newUrl
        Port = newPort

    End Sub 'New
     
    Public Sub New() 
    
    End Sub 'New
    
    
    Public Sub New(ByVal
 elementName As String) 
        Name = elementName
    
    End Sub 'New
    
    
    <ConfigurationProperty("name", _
    DefaultValue:="Microsoft", _
    IsRequired:=True, _
    IsKey:=True)> _
    Public Property Name() As
 String
        Get
            Return CStr(Me("name"))
        End Get
        Set(ByVal value As
 String)
            Me("name") = value
        End Set
    End Property


    <ConfigurationProperty("url", _
    DefaultValue:="http://www.microsoft.com", _
    IsRequired:=True), _
    RegexStringValidator("\w+:\/\/[\w.]+\S*")>
 _
    Public Property Url() As
 String
        Get
            Return CStr(Me("url"))
        End Get
        Set(ByVal value As
 String)
            Me("url") = value
        End Set
    End Property


    <ConfigurationProperty("port", _
    DefaultValue:=0, _
    IsRequired:=False), _
    IntegerValidator(MinValue:=0, _
    MaxValue:=8080, ExcludeRange:=False)> _
    Public Property Port() As
 Integer
        Get
            Return Fix(Me("port"))
        End Get
        Set(ByVal value As
 Integer)
            Me("port") = value
        End Set
    End Property
    
    
    Protected Overrides Sub
 DeserializeElement(ByVal reader _
    As System.Xml.XmlReader, _
    ByVal serializeCollectionKey As Boolean)
        MyBase.DeserializeElement(reader, _
        serializeCollectionKey)

        ' Enter your custom processing code here.
        If _displayIt Then
            Console.WriteLine( _
            "UrlConfigElement.DeserializeElement({0}, {1}) called",
 _
            IIf(reader Is Nothing, "null",
 _
            reader.ToString()), _
            serializeCollectionKey.ToString())
        End If

    End Sub 'DeserializeElement
    
    
    Protected Overrides Function
 SerializeElement(ByVal writer _
    As System.Xml.XmlWriter, _
    ByVal serializeCollectionKey As Boolean)
 As Boolean

        Dim ret As Boolean
 = _
        MyBase.SerializeElement(writer, _
        serializeCollectionKey)

        ' Enter your custom processing code here.
        If _displayIt Then
            Console.WriteLine( _
            "UrlConfigElement.SerializeElement({0}, {1}) called
 = {2}", _
            IIf(writer Is Nothing, "null",
 _
            writer.ToString()), _
            serializeCollectionKey.ToString(), _
            ret.ToString())
        End If

        Return ret

    End Function 'SerializeElement
     
    
    Protected Overrides Function
 IsModified() As Boolean 
        Dim ret As Boolean
 = MyBase.IsModified()
        
        ' Enter your custom processing code here.
        Console.WriteLine("UrlConfigElement.IsModified() called.")
        
        Return ret
    
    End Function 'IsModified

using System;
using System.Configuration;
using System.Collections;


namespace Samples.AspNet
{

    // Define the UrlConfigElement.
    public class UrlConfigElement :
        ConfigurationElement
    {

        // Test flag.
        private static bool
 _displayIt = false;

        public UrlConfigElement(String newName,
            String newUrl, int newPort)
        {
            Name = newName;
            Url = newUrl;
            Port = newPort;

        }

        public UrlConfigElement()
        {

        }

        public UrlConfigElement(string elementName)
        {
            Name = elementName;
        }

        [ConfigurationProperty("name", 
            DefaultValue = "Microsoft",
            IsRequired = true, 
            IsKey = true)]
        public string Name
        {
            get
            {
                return (string)this["name"];
            }
            set
            {
                this["name"] = value;
            }
        }

        [ConfigurationProperty("url",
            DefaultValue = "http://www.microsoft.com",
            IsRequired = true)]
        [RegexStringValidator(@"\w+:\/\/[\w.]+\S*")]
        public string Url
        {
            get
            {
                return (string)this["url"];
            }
            set
            {
                this["url"] = value;
            }
        }

        [ConfigurationProperty("port",
            DefaultValue = (int)0,
            IsRequired = false)]
        [IntegerValidator(MinValue = 0,
            MaxValue = 8080, ExcludeRange = false)]
        public int Port
        {
            get
            {
                return (int)this["port"];
            }
            set
            {
                this["port"] = value;
            }
        }

        protected override void DeserializeElement(
           System.Xml.XmlReader reader, 
            bool serializeCollectionKey)
        {
            base.DeserializeElement(reader, 
                serializeCollectionKey);

            // Enter your custom processing code here.
            if (_displayIt)
            {
                Console.WriteLine(
                   "UrlConfigElement.DeserializeElement({0}, {1}) called"
,
                   (reader == null) ? "null"
 : reader.ToString(),
                   serializeCollectionKey.ToString());
            }
        }


        protected override bool SerializeElement(
            System.Xml.XmlWriter writer, 
            bool serializeCollectionKey)
        {
            bool ret = base.SerializeElement(writer,
 
                serializeCollectionKey);

            // Enter your custom processing code here.

            if (_displayIt)
            {
                Console.WriteLine(
                    "UrlConfigElement.SerializeElement({0}, {1}) called = {2}"
,
                    (writer == null) ? "null"
 : writer.ToString(),
                    serializeCollectionKey.ToString(), ret.ToString());
            }
            return ret;

        }


        protected override bool IsModified()
        {
            bool ret = base.IsModified();

            // Enter your custom processing code here.

            Console.WriteLine("UrlConfigElement.IsModified() called.");

            return ret;
        }


    }
}

前述の例で使用されている構成の抜粋を次に示します。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="MyUrls" type="Samples.AspNet.Configuration.UrlsSection, ConfigurationElement,
 Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" allowDefinition="Everywhere"
 allowExeDefinition="MachineToApplication" restartOnExternalChanges="true" />
  </configSections>
  <MyUrls lockAllElementsExcept="urls">
    <simple 
      name="Microsoft" url="http://www.microsoft.com" port="0" />
      <urls>
        <clear />
        <add 
          name="Microsoft" url="http://www.microsoft.com" port="0"
          lockAllAttributesExcept="port" />
        <add 
          name="Contoso" url="http://www.contoso.com/" port="8080"
          lockAllAttributesExcept="port" lockItem="true" />
      </urls>
  </MyUrls>
</configuration>

既に定義されている要素を格納するカスタムの ConfigurationElementCollection を実装する方法を次のコード例に示します。

Imports System
Imports System.Configuration
Imports System.Collections



' Define the UrlsCollection that contains 
' UrlsConfigElement elements.

Public Class UrlsCollection
    Inherits ConfigurationElementCollection
    
    Public Sub New() 
        Dim url As UrlConfigElement = _
        CType(CreateNewElement(), UrlConfigElement)
        ' Add the element to the collection.
        Add(url)
    
    End Sub 'New

    Public Overrides ReadOnly
 Property CollectionType() _
    As ConfigurationElementCollectionType
        Get
            Return ConfigurationElementCollectionType.AddRemoveClearMap
        End Get
    End Property
    

    Protected Overloads Overrides
 Function CreateNewElement() _
    As ConfigurationElement
        Return New UrlConfigElement()

    End Function 'CreateNewElement
    
    
    Protected Overloads Overrides
 Function CreateNewElement( _
    ByVal elementName As String)
 _
    As ConfigurationElement
        Return New UrlConfigElement(elementName)

    End Function 'CreateNewElement
    
    
    Protected Overrides Function
 GetElementKey( _
    ByVal element As ConfigurationElement)
 As [Object]
        Return CType(element, UrlConfigElement).Name

    End Function 'GetElementKey
    
    
    Public Shadows Property
 AddElementName() As String 
        Get
            Return MyBase.AddElementName
        End Get 
        Set
            MyBase.AddElementName = value
        End Set 
    End Property

    
    Public Shadows Property
 ClearElementName() As String 
        Get
            Return MyBase.ClearElementName
        End Get 
        Set
            MyBase.AddElementName = value
        End Set 
    End Property

    
    Public Shadows ReadOnly
 Property RemoveElementName() As String
 
        Get
            Return MyBase.RemoveElementName
        End Get 
    End Property 

    Public Shadows ReadOnly
 Property Count() As Integer
 
        
        Get
            Return MyBase.Count
        End Get 
    End Property
    
    Default Public Shadows
 Property Item( _
    ByVal index As Integer)
 As UrlConfigElement
        Get
            Return CType(BaseGet(index), UrlConfigElement)
        End Get
        Set(ByVal value As
 UrlConfigElement)
            If Not (BaseGet(index) Is
 Nothing) Then
                BaseRemoveAt(index)
            End If
            BaseAdd(index, value)
        End Set
    End Property

    Default Public Shadows
 ReadOnly Property Item( _
    ByVal Name As String)
 As UrlConfigElement
        Get
            Return CType(BaseGet(Name), UrlConfigElement)
        End Get
    End Property
    

    Public Function IndexOf( _
    ByVal url As UrlConfigElement) As
 Integer
        Return BaseIndexOf(url)

    End Function 'IndexOf
    

    Public Sub Add(ByVal
 url As UrlConfigElement) 
        BaseAdd(url)
        ' Add custom code here.
    End Sub 'Add
     

    Protected Overrides Sub
 BaseAdd( _
    ByVal element As ConfigurationElement)
        BaseAdd(element, False)
        ' Add custom code here.
    End Sub 'BaseAdd

    Public Overloads Sub
 Remove( _
    ByVal url As UrlConfigElement)
        If BaseIndexOf(url) >= 0 Then
            BaseRemove(url.Name)
        End If

    End Sub 'Remove

    Public Sub RemoveAt(ByVal
 index As Integer) 
        BaseRemoveAt(index)
    
    End Sub 'RemoveAt

    Overloads Public Sub
 Remove(ByVal name As String)
 
        BaseRemove(name)
    
    End Sub 'Remove    

    Public Sub Clear() 
        BaseClear()
    
    End Sub 'Clear ' Add custom
 code here.
End Class 'UrlsCollection

using System;
using System.Configuration;
using System.Collections;


namespace Samples.AspNet
{
    // Define the UrlsCollection that contains 
    // UrlsConfigElement elements.
    public class UrlsCollection :
        ConfigurationElementCollection
    {
        public UrlsCollection()
        {
            UrlConfigElement url =
                (UrlConfigElement)CreateNewElement();
            // Add the element to the collection.
            Add(url);
        }

        public override 
            ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return 
                    ConfigurationElementCollectionType.AddRemoveClearMap;
            }
        }

        protected override 
            ConfigurationElement CreateNewElement()
        {
            return new UrlConfigElement();
        }


        protected override 
            ConfigurationElement CreateNewElement(
            string elementName)
        {
            return new UrlConfigElement(elementName);
        }


        protected override Object 
            GetElementKey(ConfigurationElement element)
        {
            return ((UrlConfigElement)element).Name;
        }


        public new string
 AddElementName
        {
            get
            { return base.AddElementName; }

            set
            { base.AddElementName = value; }

        }

        public new string
 ClearElementName
        {
            get
            { return base.ClearElementName;
 }

            set
            { base.AddElementName = value; }

        }

        public new string
 RemoveElementName
        {
            get
            { return base.RemoveElementName;
 }


        }

        public new int Count
        {

            get { return base.Count;
 }

        }


        public UrlConfigElement this[int
 index]
        {
            get
            {
                return (UrlConfigElement)BaseGet(index);
            }
            set
            {
                if (BaseGet(index) != null)
                {
                    BaseRemoveAt(index);
                }
                BaseAdd(index, value);
            }
        }

        new public UrlConfigElement this[string
 Name]
        {
            get
            {
                return (UrlConfigElement)BaseGet(Name);
            }
        }

        public int IndexOf(UrlConfigElement
 url)
        {
            return BaseIndexOf(url);
        }

        public void Add(UrlConfigElement url)
        {
            BaseAdd(url);

            // Add custom code here.
        }

        protected override void 
            BaseAdd(ConfigurationElement element)
        {
            BaseAdd(element, false);
            // Add custom code here.
        }

        public void Remove(UrlConfigElement
 url)
        {
            if (BaseIndexOf(url) >= 0)
                BaseRemove(url.Name);
        }

        public void RemoveAt(int
 index)
        {
            BaseRemoveAt(index);
        }

        public void Remove(string
 name)
        {
            BaseRemove(name);
        }

        public void Clear()
        {
            BaseClear();
            // Add custom code here.
        }
    }
}

既に定義されている要素を使用するカスタムの ConfigurationSection セクションを実装する方法を次のコード例に示します。

Imports System
Imports System.Configuration
Imports System.Collections




' Define a custom section containing 
' a simple element and a collection of 
' the same element. It uses two custom 
' types: UrlsCollection and 
' UrlsConfigElement.

Public Class UrlsSection
    Inherits ConfigurationSection
    
    ' Test flag.
    Private Shared _displayIt As
 Boolean = False
    
    ' Declare the custom element type.
    ' This element will also be part of
    ' the custom collection.
    Private url As UrlConfigElement
    
    
    Public Sub New() 
        ' Create the element.
        url = New UrlConfigElement()
    
    End Sub 'New
    
    <ConfigurationProperty("name", _
    DefaultValue:="MyFavorites", _
    IsRequired:=True, _
    IsKey:=False), _
    StringValidator( _
    InvalidCharacters:=" ~!@#$%^&*()[]{}/;'""|\",
 _
    MinLength:=1, MaxLength:=60)> _
    Public Property Name() As
 String

        Get
            Return CStr(Me("name"))
        End Get
        Set(ByVal value As
 String)
            Me("name") = value
        End Set
    End Property
    
    ' Declare a simple element of the type
    ' UrlConfigElement. In the configuration
    ' file it corresponds to <simple .... />.
    <ConfigurationProperty("simple")> _
    Public ReadOnly Property
 Simple() _
    As UrlConfigElement
        Get
            Dim url As UrlConfigElement = _
            CType(Me("simple"),
 _
            UrlConfigElement)
            Return url
        End Get
    End Property
    
    ' Declare a collection element represented 
    ' in the configuration file by the sub-section
    ' <urls> <add .../> </urls> 
    ' Note: the "IsDefaultCollection = false" 
    ' instructs the .NET Framework to build a nested 
    ' section like <urls> ...</urls>.
    <ConfigurationProperty("urls", _
    IsDefaultCollection:=False)> _
    Public ReadOnly Property
 Urls() _
    As UrlsCollection
        Get
            Dim urlsCollection _
            As UrlsCollection = _
            CType(Me("urls"), UrlsCollection)
            Return urlsCollection
        End Get
    End Property
    
    
    
    Protected Overrides Sub
 DeserializeSection( _
    ByVal reader As System.Xml.XmlReader)
        MyBase.DeserializeSection(reader)

        ' Enter your custom processing code here.
        If _displayIt Then
            Console.WriteLine( _
            "UrlsSection.DeserializeSection({0}) called",
 _
            IIf(reader Is Nothing, "null",
 _
            reader.ToString()))
        End If
    End Sub 'DeserializeSection

    Protected Overrides Function
 SerializeSection( _
    ByVal parentElement As ConfigurationElement,
 _
    ByVal name As String,
 _
    ByVal saveMode As ConfigurationSaveMode)
 As String
        Dim s As String
 = _
        MyBase.SerializeSection(parentElement, _
        name, saveMode)
        ' Enter your custom processing code here.

        If _displayIt Then
            Console.WriteLine( _
            "UrlsSection.SerializeSection({0}, {1}, {2}) called
 = {3}", _
            parentElement.ToString(), _
            name, saveMode.ToString(), s)
        End If
        Return s

    End Function 'SerializeSection
End Class 'UrlsSection 
using System;
using System.Configuration;
using System.Collections;


namespace Samples.AspNet
{

    // Define a custom section containing 
    // a simple element and a collection of 
    // the same element. It uses two custom 
    // types: UrlsCollection and 
    // UrlsConfigElement.
    public class UrlsSection :
        ConfigurationSection
    {

        // Test flag.
        private static bool
 _displayIt = false;

        // Declare the custom element type.
        // This element will also be part of
        // the custom collection.
        UrlConfigElement url;

        public UrlsSection()
        {
            // Create the element.
            url = new UrlConfigElement();
        }

        [ConfigurationProperty("name", 
            DefaultValue = "MyFavorites",
            IsRequired = true, 
            IsKey = false)]
        [StringValidator(InvalidCharacters = 
            " ~!@#$%^&*()[]{}/;'\"|\\",
            MinLength = 1, MaxLength = 60)]
        public string Name
        {

            get
            {
                return (string)this["name"];
            }
            set
            {
                this["name"] = value;
            }

        }


        // Declare a simple element of the type
        // UrlConfigElement. In the configuration
        // file it corresponds to <simple .... />.
        [ConfigurationProperty("simple")]
        public UrlConfigElement Simple
        {
            get
            {
                UrlConfigElement url =
                (UrlConfigElement)base["simple"];
                return url;
            }
        }

        // Declare a collection element represented 
        // in the configuration file by the sub-section
        // <urls> <add .../> </urls> 
        // Note: the "IsDefaultCollection = false" 
        // instructs the .NET Framework to build a nested 
        // section like <urls> ...</urls>.
        [ConfigurationProperty("urls",
            IsDefaultCollection = false)]
        public UrlsCollection Urls
        {

            get
            {
                UrlsCollection urlsCollection =
                (UrlsCollection)base["urls"];
                return urlsCollection;
            }
        }


        protected override void DeserializeSection(
            System.Xml.XmlReader reader)
        {
            base.DeserializeSection(reader);

            // Enter your custom processing code here.
            if (_displayIt)
            {
                Console.WriteLine(
                    "UrlsSection.DeserializeSection({0}) called",
                    (reader == null) ? "null"
 : reader.ToString());
            }
        }

        protected override string SerializeSection(
            ConfigurationElement parentElement,
            string name, ConfigurationSaveMode saveMode)
        {
            string s =
                base.SerializeSection(parentElement,
                name, saveMode);

            // Enter your custom processing code here.

            if (_displayIt)
            {
                Console.WriteLine(
                   "UrlsSection.SerializeSection({0}, {1}, {2}) called = {3}"
,
                   parentElement.ToString(), name,
                   saveMode.ToString(), s);
            }
            return s;
        }

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

ConfigurationElement コンストラクタ

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

ConfigurationElement クラスの新しいインスタンスを作成します。

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

Dim instance As New ConfigurationElement
protected ConfigurationElement ()
protected:
ConfigurationElement ()
protected ConfigurationElement ()
protected function ConfigurationElement ()
解説解説

たとえば、アプリケーションで関連する ConfigurationElementCollection コレクションに新しい要素を追加する必要があるたびに、ConfigurationElement の新しいインスタンスを作成します。

使用例使用例

カスタマイズされたコンストラクタを使用する例を次に示します。

Public Sub New(ByVal
 newName As String, _
ByVal newUrl As String,
 _
ByVal newPort As Integer)
    Name = newName
    Url = newUrl
    Port = newPort

End Sub 'New
 
public UrlConfigElement(String newName,
    String newUrl, int newPort)
{
    Name = newName;
    Url = newUrl;
    Port = newPort;

}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ConfigurationElement クラス
ConfigurationElement メンバ
System.Configuration 名前空間

ConfigurationElement プロパティ


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

( プロテクト プロパティ も参照)
  名前 説明
パブリック プロパティ ElementInformation ConfigurationElement オブジェクトのカスタマイズできない情報と機能を格納する ElementInformation オブジェクトを取得します。
パブリック プロパティ LockAllAttributesExcept ロックされている属性のコレクションを取得します。
パブリック プロパティ LockAllElementsExcept ロックされている要素のコレクションを取得します。
パブリック プロパティ LockAttributes ロックされている属性のコレクションを取得します。
パブリック プロパティ LockElements ロックされている要素のコレクションを取得します。
パブリック プロパティ LockItem 要素がロックされているかどうかを示す値を取得または設定します。
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ ElementProperty ConfigurationElement オブジェクト自体を表す ConfigurationElementProperty オブジェクトを取得します。
プロテクト プロパティ EvaluationContext ConfigurationElement オブジェクトの ContextInformation オブジェクトを取得します。
プロテクト プロパティ Item オーバーロードされます。 この ConfigurationElement オブジェクトのプロパティ、属性、または子要素を取得または設定します。
プロテクト プロパティ Properties プロパティのコレクションを取得します。
参照参照

関連項目

ConfigurationElement クラス
System.Configuration 名前空間
ElementInformation
ConfigurationElementCollection
ConfigurationElementCollectionType
ConfigurationProperty
ConfigurationPropertyCollection
ConfigurationSection

ConfigurationElement メソッド


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

プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド DeserializeElement 構成ファイルから XML を読み取ります。
プロテクト メソッド Finalize  Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。)
プロテクト メソッド Init ConfigurationElement オブジェクトを初期状態に設定します。
プロテクト メソッド InitializeDefault ConfigurationElement オブジェクトの既定の値セットを初期化するために使用します。
プロテクト メソッド IsModified 派生クラスに実装された場合、この構成要素が最後の保存または読み込み以降に変更されたかどうかを示します。
プロテクト メソッド ListErrors この ConfigurationElement オブジェクトおよびすべてのサブ要素の無効なプロパティのエラーを、渡されたリストに追加します。
プロテクト メソッド MemberwiseClone  現在の Object の簡易コピーを作成します。 ( Object から継承されます。)
プロテクト メソッド OnDeserializeUnrecognizedAttribute 逆シリカル化中に不明な属性が発生したかどうかを示す値を取得します。
プロテクト メソッド OnDeserializeUnrecognizedElement 逆シリカル化中に不明な要素が発生したかどうかを示す値を取得します。
プロテクト メソッド OnRequiredPropertyNotFound 必須プロパティが見つからなかったかどうかを示す値を取得します。
プロテクト メソッド PostDeserialize 逆シリアル化後に呼び出されます。
プロテクト メソッド PreSerialize シリアル化前に呼び出されます。
プロテクト メソッド Reset ConfigurationElement オブジェクトの内部状態 (ロックやプロパティ コレクションなど) をリセットします。
プロテクト メソッド ResetModified 派生クラスに実装された場合、IsModified メソッドの値を false にリセットします。
プロテクト メソッド SerializeElement 派生クラスに実装されている場合、この構成要素の内容を構成ファイルに書き込みます。
プロテクト メソッド SerializeToXmlElement 派生クラスに実装されている場合、この構成要素の外側のタグを構成ファイルに書き込みます。
プロテクト メソッド SetPropertyValue プロパティを指定した値に設定します。
プロテクト メソッド SetReadOnly ConfigurationElement オブジェクトおよびすべてのサブ要素に IsReadOnly プロパティを設定します。
プロテクト メソッド Unmerge 保存しないすべての値を削除するには、ConfigurationElement オブジェクトを変更します。
参照参照

関連項目

ConfigurationElement クラス
System.Configuration 名前空間
ElementInformation
ConfigurationElementCollection
ConfigurationElementCollectionType
ConfigurationProperty
ConfigurationPropertyCollection
ConfigurationSection

ConfigurationElement メンバ

構成ファイル内の構成要素を表します。

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


プロテクト コンストラクタプロテクト コンストラクタ
  名前 説明
プロテクト メソッド ConfigurationElement ConfigurationElement クラスの新しいインスタンスを作成します。
パブリック プロパティパブリック プロパティ
( プロテクト プロパティ も参照)
  名前 説明
パブリック プロパティ ElementInformation ConfigurationElement オブジェクトのカスタマイズできない情報と機能を格納する ElementInformation オブジェクトを取得します。
パブリック プロパティ LockAllAttributesExcept ロックされている属性のコレクションを取得します。
パブリック プロパティ LockAllElementsExcept ロックされている要素のコレクションを取得します。
パブリック プロパティ LockAttributes ロックされている属性のコレクションを取得します。
パブリック プロパティ LockElements ロックされている要素のコレクションを取得します。
パブリック プロパティ LockItem 要素がロックされているかどうかを示す値を取得または設定します。
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ ElementProperty ConfigurationElement オブジェクト自体を表す ConfigurationElementProperty オブジェクトを取得します。
プロテクト プロパティ EvaluationContext ConfigurationElement オブジェクトの ContextInformation オブジェクトを取得します。
プロテクト プロパティ Item オーバーロードされます。 この ConfigurationElement オブジェクトのプロパティ、属性、または子要素を取得または設定します。
プロテクト プロパティ Properties プロパティのコレクションを取得します。
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド DeserializeElement 構成ファイルから XML を読み取ります。
プロテクト メソッド Finalize  Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。)
プロテクト メソッド Init ConfigurationElement オブジェクトを初期状態に設定します。
プロテクト メソッド InitializeDefault ConfigurationElement オブジェクトの既定の値セットを初期化するために使用します。
プロテクト メソッド IsModified 派生クラスに実装された場合、この構成要素が最後の保存または読み込み以降に変更されたかどうかを示します。
プロテクト メソッド ListErrors この ConfigurationElement オブジェクトおよびすべてのサブ要素の無効なプロパティのエラーを、渡されたリストに追加します。
プロテクト メソッド MemberwiseClone  現在の Object の簡易コピーを作成します。 (Object から継承されます。)
プロテクト メソッド OnDeserializeUnrecognizedAttribute 逆シリカル化中に不明な属性が発生したかどうかを示す値を取得します。
プロテクト メソッド OnDeserializeUnrecognizedElement 逆シリカル化中に不明な要素が発生したかどうかを示す値を取得します。
プロテクト メソッド OnRequiredPropertyNotFound 必須プロパティが見つからなかったかどうかを示す値を取得します。
プロテクト メソッド PostDeserialize 逆シリアル化後に呼び出されます。
プロテクト メソッド PreSerialize シリアル化前に呼び出されます。
プロテクト メソッド Reset ConfigurationElement オブジェクトの内部状態 (ロックやプロパティ コレクションなど) をリセットします。
プロテクト メソッド ResetModified 派生クラスに実装された場合、IsModified メソッドの値を false にリセットします。
プロテクト メソッド SerializeElement 派生クラスに実装されている場合、この構成要素の内容を構成ファイルに書き込みます。
プロテクト メソッド SerializeToXmlElement 派生クラスに実装されている場合、この構成要素の外側のタグを構成ファイルに書き込みます。
プロテクト メソッド SetPropertyValue プロパティを指定した値に設定します。
プロテクト メソッド SetReadOnly ConfigurationElement オブジェクトおよびすべてのサブ要素に IsReadOnly プロパティを設定します。
プロテクト メソッド Unmerge 保存しないすべての値を削除するには、ConfigurationElement オブジェクトを変更します。
参照参照

関連項目

ConfigurationElement クラス
System.Configuration 名前空間
ElementInformation
ConfigurationElementCollection
ConfigurationElementCollectionType
ConfigurationProperty
ConfigurationPropertyCollection
ConfigurationSection



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「ConfigurationElement」の関連用語

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

   

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



ConfigurationElementのページの著作権

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

©2026 GRAS Group, Inc.RSS