XObject.RemoveAnnotations 메서드

정의

오버로드

Name Description
RemoveAnnotations(Type)

지정된 형식의 주석을 이 XObject주석에서 제거합니다.

RemoveAnnotations<T>()

지정된 형식의 주석을 이 XObject주석에서 제거합니다.

RemoveAnnotations(Type)

Source:
XObject.cs
Source:
XObject.cs
Source:
XObject.cs
Source:
XObject.cs
Source:
XObject.cs

지정된 형식의 주석을 이 XObject주석에서 제거합니다.

public:
 void RemoveAnnotations(Type ^ type);
public void RemoveAnnotations(Type type);
member this.RemoveAnnotations : Type -> unit
Public Sub RemoveAnnotations (type As Type)

매개 변수

type
Type

제거할 주석의 형식입니다.

예제

다음 예제에서는 네 개의 주석이 있는 요소를 만듭니다. 그런 다음 이 메서드를 사용하여 두 메서드를 제거합니다.

public class MyAnnotation {
    private string tag;
    public string Tag {get{return tag;} set{tag=value;}}
    public MyAnnotation(string tag) {
        this.tag = tag;
    }
}

class Program
{
    static void Main(string[] args)
    {
        XElement root = new XElement("Root", "content");
        root.AddAnnotation(new MyAnnotation("T1"));
        root.AddAnnotation(new MyAnnotation("T2"));
        root.AddAnnotation("abc");
        root.AddAnnotation("def");

        Console.WriteLine("Count before removing: {0}", root.Annotations<object>().Count());
        root.RemoveAnnotations(typeof(MyAnnotation));
        Console.WriteLine("Count after removing: {0}", root.Annotations<object>().Count());
    }
}
Public Class MyAnnotation
    Private _tag As String

    Property Tag() As String
        Get
            Return Me._tag
        End Get
        Set(ByVal Value As String)
            Me._tag = Value
        End Set
    End Property

    Public Sub New(ByVal tag As String)
        Me._tag = tag
    End Sub
End Class

Module Module1
    Sub Main()
        Dim root As XElement = <Root>content</Root>
        root.AddAnnotation(New MyAnnotation("T1"))
        root.AddAnnotation(New MyAnnotation("T2"))
        root.AddAnnotation("abc")
        root.AddAnnotation("def")

        Console.WriteLine("Count before removing: {0}", root.Annotations(Of Object)().Count())
        root.RemoveAnnotations(GetType(MyAnnotation))
        Console.WriteLine("Count after removing: {0}", root.Annotations(Of Object)().Count())
    End Sub
End Module

이 예제는 다음과 같은 출력을 생성합니다.

Count before removing: 4
Count after removing: 2

추가 정보

적용 대상

RemoveAnnotations<T>()

Source:
XObject.cs
Source:
XObject.cs
Source:
XObject.cs
Source:
XObject.cs
Source:
XObject.cs

지정된 형식의 주석을 이 XObject주석에서 제거합니다.

public:
generic <typename T>
 where T : class void RemoveAnnotations();
public void RemoveAnnotations<T>() where T : class;
member this.RemoveAnnotations : unit -> unit (requires 'T : null)
Public Sub RemoveAnnotations(Of T As Class) ()

형식 매개 변수

T

제거할 주석의 형식입니다.

예제

다음 예제에서는 네 개의 주석이 있는 요소를 만듭니다. 그런 다음 이 메서드를 사용하여 두 메서드를 제거합니다.

public class MyAnnotation {
    private string tag;
    public string Tag {get{return tag;} set{tag=value;}}
    public MyAnnotation(string tag) {
        this.tag = tag;
    }
}

class Program {
    static void Main(string[] args) {
        XElement root = new XElement("Root", "content");
        root.AddAnnotation(new MyAnnotation("T1"));
        root.AddAnnotation(new MyAnnotation("T2"));
        root.AddAnnotation("abc");
        root.AddAnnotation("def");

        Console.WriteLine("Count before removing: {0}", root.Annotations<object>().Count());
        root.RemoveAnnotations<MyAnnotation>();
        Console.WriteLine("Count after removing: {0}", root.Annotations<object>().Count());
    }
}
Public Class MyAnnotation
    Private _tag As String

    Property Tag() As String
        Get
            Return Me._tag
        End Get
        Set(ByVal Value As String)
            Me._tag = Value
        End Set
    End Property

    Public Sub New(ByVal tag As String)
        Me._tag = tag
    End Sub
End Class

Module Module1
    Sub Main()
        Dim root As XElement = <Root>content</Root>
        root.AddAnnotation(New MyAnnotation("T1"))
        root.AddAnnotation(New MyAnnotation("T2"))
        root.AddAnnotation("abc")
        root.AddAnnotation("def")

        Console.WriteLine("Count before removing: {0}", root.Annotations(Of Object)().Count())
        root.RemoveAnnotations(Of MyAnnotation)()
        Console.WriteLine("Count after removing: {0}", root.Annotations(Of Object)().Count())
    End Sub
End Module

이 예제는 다음과 같은 출력을 생성합니다.

Count before removing: 4
Count after removing: 2

추가 정보

적용 대상