XmlIgnoreAttribute クラス

定義

Serialize(TextWriter, Object)XmlSerializer メソッドに対して、パブリック フィールドまたはパブリックな読み書き可能プロパティの値をシリアル化しないように指示します。

public ref class XmlIgnoreAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Parameter | System.AttributeTargets.Property | System.AttributeTargets.ReturnValue)]
public class XmlIgnoreAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Parameter | System.AttributeTargets.Property | System.AttributeTargets.ReturnValue)>]
type XmlIgnoreAttribute = class
    inherit Attribute
Public Class XmlIgnoreAttribute
Inherits Attribute
継承
XmlIgnoreAttribute
属性

次の例は、という名前のフィールドを含む 、という Group名前 Commentのクラスを示しています。 この例では、フィールドに割り当て XmlIgnoreAttribute 、クラスのインスタンスを XmlSerializer シリアル化または逆シリアル化するときにフィールドを無視するように指示します。

public ref class Group
{
public:

   // The XmlSerializer ignores this field.

   [XmlIgnore]
   String^ Comment;

   // The XmlSerializer serializes this field.
   String^ GroupName;
};
public class Group
{
   // The XmlSerializer ignores this field.
   [XmlIgnore]
   public string Comment;

   // The XmlSerializer serializes this field.
   public string GroupName;
}
Public Class Group
    ' the XmlSerializer ignores this field.
    <XmlIgnore()> Public Comment As String
    
    ' The XmlSerializer serializes this field.
    Public GroupName As String
End Class

注釈

オブジェクト XmlIgnoreAttribute をシリアル化または逆シリアル化する方法を XmlSerializer 制御する属性のファミリに属します。 クラスの XmlIgnoreAttribute 任意のメンバーに適用する場合、 XmlSerializer クラスのインスタンスをシリアル化または逆シリアル化するときに、メンバーは無視されます。 類似する属性の完全な一覧については、「 XML シリアル化を制御する属性」を参照してください。

オブジェクトを作成し、そのXmlIgnoreプロパティfalseXmlIgnoreAttribute XmlAttributes . クラスのXmlAttributesインスタンスに対するオブジェクトがXmlAttributeOverrides必要Addです。 最後に、オブジェクトをXmlAttributeOverrides使用して、クラスまたはDeserializeメソッドを呼び出す前に、クラスのXmlSerializerインスタンスを構築するSerialize必要があります。

XML スキーマ定義ツール (Xsd.exe) は、XmlIgnoreAttributeスキーマ ファイル (.xsd) からクラスを作成するときに生成される場合があります。 この動作は、値型を設定できないが、すべての XML データ型を null設定できるために発生します。 したがって、値型にマップされる XML 型が検出されると、ツールは 2 つのフィールドを作成します。1 つは値を保持し、fieldnameもう 1 つはフィールドまたはプロパティの名前に置き換えられる形式のfieldnameSpecified特殊なフィールドです。 ただし、この特殊フィールドは、要素に最小出現回数 (minOccurs = "0") がなく、要素に既定値がないことをスキーマで指定した場合にのみ生成されることに注意してください。 XmlSerializerこの特殊フィールドを設定してチェックし、フィールドまたはプロパティに値が設定されているかどうかを判断します。 特殊フィールドはシリアル化してはならないため、ツールによってそのフィールドが XmlIgnoreAttribute 適用されます。

属性の使用の詳細については、「 属性」を参照してください。

注意

長いXmlIgnoreAttribute単語ではなく、コード内でこの単語XmlIgnoreを使用できます。

コンストラクター

XmlIgnoreAttribute()

XmlIgnoreAttribute クラスの新しいインスタンスを初期化します。

プロパティ

TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)

メソッド

Equals(Object)

このインスタンスが、指定されたオブジェクトと等価であるかどうかを示す値を返します。

(継承元 Attribute)
GetHashCode()

このインスタンスのハッシュ コードを返します。

(継承元 Attribute)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
Match(Object)

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象

こちらもご覧ください