다음을 통해 공유


XmlAttributeOverrides.Item[] 속성

정의

재정의 특성의 컬렉션을 나타내는 개체를 가져옵니다.

오버로드

Name Description
Item[Type]

지정된 기본 클래스 형식과 연결된 개체를 가져옵니다.

Item[Type, String]

지정된(기본 클래스) 형식과 연결된 개체를 가져옵니다. 멤버 매개 변수는 재정의되는 기본 클래스 멤버를 지정합니다.

Item[Type]

Source:
XmlAttributeOverrides.cs
Source:
XmlAttributeOverrides.cs
Source:
XmlAttributeOverrides.cs
Source:
XmlAttributeOverrides.cs
Source:
XmlAttributeOverrides.cs

지정된 기본 클래스 형식과 연결된 개체를 가져옵니다.

public:
 property System::Xml::Serialization::XmlAttributes ^ default[Type ^] { System::Xml::Serialization::XmlAttributes ^ get(Type ^ type); };
public System.Xml.Serialization.XmlAttributes this[Type type] { get; }
public System.Xml.Serialization.XmlAttributes? this[Type type] { get; }
member this.Item(Type) : System.Xml.Serialization.XmlAttributes
Default Public ReadOnly Property Item(type As Type) As XmlAttributes

매개 변수

type
Type

검색하려는 특성 컬렉션과 연결된 기본 클래스 Type 입니다.

속성 값

XmlAttributes 재정의 특성의 컬렉션을 나타내는 값입니다.

예제

다음 예제에서는 XmlAttributeOverrides 개체, XmlAttributes 개체 및 개체를 XmlRootAttribute 만듭니다. 이 예제에서는 개체의 속성에 XmlRootXmlAttributes 할당 XmlRootAttribute 하고 개체에 XmlAttributes 개체를 XmlAttributeOverrides 추가합니다. 마지막으로 이 예제에서는 직렬화된 클래스의 개체를 전달 Type 하여 개체를 XmlAttributeOverrides 가져옵니다XmlAttributes. 이 예에서 TypeGroup입니다.

// This is the class that will be serialized.
public class Group
{
   public string GroupName;
   [XmlAttribute]
   public int GroupCode;
}

public class Sample
{
public XmlSerializer CreateOverrider()
{
   // Create an XmlSerializer with overriding attributes.
   XmlAttributes attrs = new XmlAttributes();
   XmlAttributeOverrides xOver = new XmlAttributeOverrides();

   XmlRootAttribute xRoot = new XmlRootAttribute();
   // Set a new Namespace and ElementName for the root element.
   xRoot.Namespace = "http://www.cpandl.com";
   xRoot.ElementName = "NewGroup";
   attrs.XmlRoot = xRoot;

   xOver.Add(typeof(Group), attrs);

   // Get the XmlAttributes object, based on the type.
   XmlAttributes tempAttrs;
   tempAttrs = xOver[typeof(Group)];

   // Print the Namespace and ElementName of the root.
   Console.WriteLine(tempAttrs.XmlRoot.Namespace);
   Console.WriteLine(tempAttrs.XmlRoot.ElementName);

   XmlSerializer xSer = new XmlSerializer(typeof(Group), xOver);
   return xSer;
}
}
' This is the class that will be serialized.
Public Class Group
    Public GroupName As String
    <XmlAttribute()> Public GroupCode As Integer
End Class

Public Class Sample
    
    Public Function CreateOverrider() As XmlSerializer
        ' Create an XmlSerializer with overriding attributes.
        Dim attrs As New XmlAttributes()
        Dim xOver As New XmlAttributeOverrides()
        
        Dim xRoot As New XmlRootAttribute()
        ' Set a new Namespace and ElementName for the root element.
        xRoot.Namespace = "http://www.cpandl.com"
        xRoot.ElementName = "NewGroup"
        attrs.XmlRoot = xRoot
        
        xOver.Add(GetType(Group), attrs)
        
        ' Get the XmlAttributes object, based on the type.
        Dim tempAttrs As XmlAttributes
        tempAttrs = xOver(GetType(Group))
        
        ' Print the Namespace and ElementName of the root.
        Console.WriteLine(tempAttrs.XmlRoot.Namespace)
        Console.WriteLine(tempAttrs.XmlRoot.ElementName)
        
        Dim xSer As New XmlSerializer(GetType(Group), xOver)
        Return xSer
    End Function
End Class

설명

이 오버로드를 사용하여 개체에 XmlTypeAttribute 대한 특성이 포함된 개체를 XmlRootAttribute 반환 XmlAttributes 합니다.

개체에 재정의 XmlAttributes 하는 XmlArrayAttribute개체, XmlArrayItemAttribute, XmlElementAttributeXmlEnumAttribute또는 XmlAttributeAttribute형식을 재정의하는 개체가 포함된 경우 재정의된 멤버와 형식을 지정하는 오버로드를 사용해야 합니다.

추가 정보

적용 대상

Item[Type, String]

Source:
XmlAttributeOverrides.cs
Source:
XmlAttributeOverrides.cs
Source:
XmlAttributeOverrides.cs
Source:
XmlAttributeOverrides.cs
Source:
XmlAttributeOverrides.cs

지정된(기본 클래스) 형식과 연결된 개체를 가져옵니다. 멤버 매개 변수는 재정의되는 기본 클래스 멤버를 지정합니다.

public:
 property System::Xml::Serialization::XmlAttributes ^ default[Type ^, System::String ^] { System::Xml::Serialization::XmlAttributes ^ get(Type ^ type, System::String ^ member); };
public System.Xml.Serialization.XmlAttributes this[Type type, string member] { get; }
public System.Xml.Serialization.XmlAttributes? this[Type type, string member] { get; }
member this.Item(Type * string) : System.Xml.Serialization.XmlAttributes
Default Public ReadOnly Property Item(type As Type, member As String) As XmlAttributes

매개 변수

type
Type

원하는 특성 컬렉션과 연결된 기본 클래스 Type 입니다.

member
String

반환할 멤버를 지정하는 재정의된 멤버의 XmlAttributes 이름입니다.

속성 값

XmlAttributes 재정의 특성의 컬렉션을 나타내는 값입니다.

예제

다음 예제에서는 XmlAttributeOverrides 개체, 개체 XmlAttributes및 개체를 XmlAttributeAttribute 만듭니다. 이 예제에서는 개체의 속성에 XmlAttributeXmlAttributes 할당 XmlAttributeAttribute 하고 개체에 XmlAttributes 개체를 XmlAttributeOverrides 추가합니다. 마지막으로 이 예제에서는 직렬화된 클래스 및 멤버 이름을 개체에 전달 Type 하여 개체를 XmlAttributeOverrides 가져옵니다XmlAttributes.

// This is the class that will be serialized.
public class Group
{
   public string GroupName;
   [XmlAttribute]
   public int GroupCode;
}

public class Sample
{
public XmlSerializer CreateOverrider()
{
   // Create an XmlSerializer with overriding attributes.
   XmlAttributeOverrides xOver = new XmlAttributeOverrides();

   /* Create an XmlAttributeAttribute object and set the
   AttributeName property. */
   XmlAttributeAttribute xAtt = new XmlAttributeAttribute();
   xAtt.AttributeName = "Code";

   /* Create a new XmlAttributes object and set the
   XmlAttributeAttribute object to the XmlAttribute property. */
   XmlAttributes attrs = new XmlAttributes();
   attrs.XmlAttribute = xAtt;

   /* Add the XmlAttributes to the XmlAttributeOverrides object. The
   name of the overridden attribute must be specified. */
   xOver.Add(typeof(Group), "GroupCode", attrs);

   // Get the XmlAttributes object for the type and member.
   XmlAttributes tempAttrs;
   tempAttrs = xOver[typeof(Group), "GroupCode"];
   Console.WriteLine(tempAttrs.XmlAttribute.AttributeName);

   // Create the XmlSerializer instance and return it.
   XmlSerializer xSer = new XmlSerializer(typeof(Group), xOver);
   return xSer;
}
}
' This is the class that will be serialized.
Public Class Group
    Public GroupName As String
    <XmlAttribute()> Public GroupCode As Integer
End Class

Public Class Sample
    
    Public Function CreateOverrider() As XmlSerializer
        ' Create an XmlSerializer with overriding attributes.
        Dim xOver As New XmlAttributeOverrides()
        
        ' Create an XmlAttributeAttribute object and set the
        ' AttributeName property. 
        Dim xAtt As New XmlAttributeAttribute()
        xAtt.AttributeName = "Code"
        
        ' Create a new XmlAttributes object and set the
        ' XmlAttributeAttribute object to the XmlAttribute property. 
        Dim attrs As New XmlAttributes()
        attrs.XmlAttribute = xAtt
        
        ' Add the XmlAttributes to the XmlAttributeOverrides object. The
        ' name of the overridden attribute must be specified. 
        xOver.Add(GetType(Group), "GroupCode", attrs)
                
        ' Get the XmlAttributes object for the type and member.
        Dim tempAttrs As XmlAttributes
        tempAttrs = xOver(GetType(Group), "GroupCode")
        Console.WriteLine(tempAttrs.XmlAttribute.AttributeName)
        
        ' Create the XmlSerializer instance and return it.
        Dim xSer As New XmlSerializer(GetType(Group), xOver)
        Return xSer
    End Function
End Class

설명

이 오버로드를 사용하여 , , XmlAttributeAttributeXmlArrayItemAttribute, XmlElementAttribute또는 XmlEnumAttribute를 재정의하는 개체가 포함된 개체를 XmlArrayAttribute반환 XmlAttributes 합니다. 개체에 포함 XmlRootAttribute 되거나 XmlTypeAttribute재정의 XmlAttributes 된 형식만 지정하는 오버로드를 사용해야 합니다.

추가 정보

적용 대상