XStreamingElement.Add 메서드

정의

지정된 콘텐츠를 이 XStreamingElement에 자식으로 추가합니다.

오버로드

Add(Object)

지정된 콘텐츠를 이 XStreamingElement에 자식으로 추가합니다.

Add(Object[])

지정된 콘텐츠를 이 XStreamingElement에 자식으로 추가합니다.

Add(Object)

지정된 콘텐츠를 이 XStreamingElement에 자식으로 추가합니다.

public:
 void Add(System::Object ^ content);
public void Add (object content);
public void Add (object? content);
member this.Add : obj -> unit
Public Sub Add (content As Object)

매개 변수

content
Object

스트리밍 요소에 추가할 콘텐츠입니다.

예제

다음 예제에서는 새 XStreamingElement를 만듭니다. 그런 다음 스트리밍 요소에 두 개의 쿼리를 추가합니다. 스트리밍 요소가 serialize될 때까지 쿼리가 반복되지 않습니다.

XElement srcTree = new XElement("Root",  
                       new XElement("Child", 1),  
                       new XElement("Child", 2),  
                       new XElement("Child", 3),  
                       new XElement("Child", 4),  
                       new XElement("Child", 5)  
                   );  

XStreamingElement dstTree = new XStreamingElement("NewRoot");  

dstTree.Add(  
    from el in srcTree.Elements()  
    where (int)el <= 1  
    select new XElement("Child", (int)el)  
);  

dstTree.Add(  
    from el in srcTree.Elements()  
    where (int)el >= 3  
    select new XElement("DifferentChild", (int)el)  
);  

Console.WriteLine(dstTree);  
Dim srcTree As XElement = _  
    <Root>  
        <Child>1</Child>  
        <Child>2</Child>  
        <Child>3</Child>  
        <Child>4</Child>  
        <Child>5</Child>  
    </Root>  

Dim dstTree As XStreamingElement = New XStreamingElement("NewRoot")  

dstTree.Add( _  
    From el In srcTree.Elements() _  
    Where el.Value <= 1 _  
    Select <Child><%= el.Value %></Child> _  
)  

dstTree.Add( _  
    From el In srcTree.Elements() _  
    Where el.Value >= 3 _  
    Select <DifferentChild><%= el.Value %></DifferentChild> _  
)  

Console.WriteLine(dstTree)  

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

<NewRoot>  
  <Child>1</Child>  
  <DifferentChild>3</DifferentChild>  
  <DifferentChild>4</DifferentChild>  
  <DifferentChild>5</DifferentChild>  
</NewRoot>  

설명

이 생성자는 지정된 콘텐츠 및 특성을 .에 XStreamingElement추가합니다. 단일 문에서 생성 XStreamingElement 할 수 있는 경우가 많지만 스트리밍 요소에 콘텐츠를 증분 방식으로 추가하는 것이 더 편리한 경우도 있습니다.

쿼리는 serialize될 때까지 XStreamingElement 반복되지 않습니다. 이는 새 XElement쿼리를 생성할 때 쿼리가 반복되는 콘텐츠에 대한 XElement쿼리를 사용하는 것과는 대조적입니다.

이 함수에 전달할 수 있는 유효한 콘텐츠에 대한 자세한 내용은 XElement 및 XDocument 개체의 유효한 콘텐츠를 참조하세요.

추가 정보

적용 대상

Add(Object[])

지정된 콘텐츠를 이 XStreamingElement에 자식으로 추가합니다.

public:
 void Add(... cli::array <System::Object ^> ^ content);
public void Add (params object[] content);
public void Add (params object?[] content);
member this.Add : obj[] -> unit
Public Sub Add (ParamArray content As Object())

매개 변수

content
Object[]

스트리밍 요소에 추가할 콘텐츠입니다.

예제

다음 예제에서는 새 XStreamingElement를 만듭니다. 그런 다음 스트리밍 요소에 두 개의 쿼리를 추가합니다. 스트리밍 요소가 serialize될 때까지 쿼리가 반복되지 않습니다.

XElement srcTree = new XElement("Root",  
                       new XElement("Child", 1),  
                       new XElement("Child", 2),  
                       new XElement("Child", 3),  
                       new XElement("Child", 4),  
                       new XElement("Child", 5)  
                   );  

XStreamingElement dstTree = new XStreamingElement("NewRoot");  

dstTree.Add(  
    from el in srcTree.Elements()  
    where (int)el <= 1  
    select new XElement("Child", (int)el)  
);  

dstTree.Add(  
    from el in srcTree.Elements()  
    where (int)el >= 3  
    select new XElement("DifferentChild", (int)el)  
);  

Console.WriteLine(dstTree);  
Dim srcTree As XElement = _  
    <Root>  
        <Child>1</Child>  
        <Child>2</Child>  
        <Child>3</Child>  
        <Child>4</Child>  
        <Child>5</Child>  
    </Root>  

Dim dstTree As XStreamingElement = New XStreamingElement("NewRoot")  

dstTree.Add( _  
    From el In srcTree.Elements() _  
    Where el.Value <= 1 _  
    Select <Child><%= el.Value %></Child> _  
)  

dstTree.Add( _  
    From el In srcTree.Elements() _  
    Where el.Value >= 3 _  
    Select <DifferentChild><%= el.Value %></DifferentChild> _  
)  

Console.WriteLine(dstTree)  

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

<NewRoot>  
  <Child>1</Child>  
  <DifferentChild>3</DifferentChild>  
  <DifferentChild>4</DifferentChild>  
  <DifferentChild>5</DifferentChild>  
</NewRoot>  

설명

이 생성자는 지정된 콘텐츠 및 특성을 .에 XStreamingElement추가합니다. 단일 문에서 생성 XStreamingElement 할 수 있는 경우가 많지만 스트리밍 요소에 콘텐츠를 증분 방식으로 추가하는 것이 더 편리한 경우도 있습니다.

쿼리는 serialize될 때까지 XStreamingElement 반복되지 않습니다. 이는 새 XElement쿼리를 생성할 때 쿼리가 반복되는 콘텐츠에 대한 XElement쿼리를 사용하는 것과는 대조적입니다.

이 함수에 전달할 수 있는 유효한 콘텐츠에 대한 자세한 내용은 XElement 및 XDocument 개체의 유효한 콘텐츠를 참조하세요.

추가 정보

적용 대상