Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
Node.Extensions.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 using System.IO;
6 using System.Runtime.Serialization.Formatters.Binary;
7 
8 namespace SiliconStudio.Shaders.Ast
9 {
10  /// <summary>
11  /// Extensions for <see cref="Node"/>.
12  /// </summary>
13  public static class NodeExtensions
14  {
15  /// <summary>
16  /// Get descendants for the specified node.
17  /// </summary>
18  /// <param name="node">The node.</param>
19  /// <returns>An enumeration of descendants</returns>
20  private static IEnumerable<Node> DescendantsImpl(this Node node)
21  {
22  if (node != null)
23  {
24  yield return node;
25 
26  foreach (var children in node.Childrens())
27  {
28  if (children != null)
29  foreach (var descendant in children.Descendants())
30  {
31  yield return descendant;
32  }
33  }
34  }
35  }
36 
37  /// <summary>
38  /// Get descendants for the specified node.
39  /// </summary>
40  /// <param name="node">The node.</param>
41  /// <returns>An enumeration of descendants</returns>
42  public static IEnumerable<Node> Descendants(this Node node)
43  {
44  if (node != null)
45  {
46  foreach (var children in node.Childrens())
47  {
48  if (children != null)
49  foreach (var descendant in children.DescendantsImpl())
50  {
51  yield return descendant;
52  }
53  }
54  }
55  }
56  }
57 }
static IEnumerable< Node > Descendants(this Node node)
Get descendants for the specified node.
virtual IEnumerable< Node > Childrens()
Gets the child nodes.
Definition: Node.cs:127
Abstract node.
Definition: Node.cs:15