Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ConditionalExpression.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;
5 using System.Collections.Generic;
6 
7 namespace SiliconStudio.Shaders.Ast
8 {
9  /// <summary>
10  /// A Conditional expression
11  /// </summary>
13  {
14  /// <summary>
15  /// Initializes a new instance of the <see cref="ConditionalExpression"/> class.
16  /// </summary>
18  {
19  }
20 
21  /// <summary>
22  /// Initializes a new instance of the <see cref="ConditionalExpression"/> class.
23  /// </summary>
24  /// <param name="condition">The condition.</param>
25  /// <param name="left">The left.</param>
26  /// <param name="right">The right.</param>
27  public ConditionalExpression(Expression condition, Expression left, Expression right)
28  {
29  Condition = new ParenthesizedExpression(condition);
30  Left = left;
31  Right = right;
32  }
33 
34  #region Public Properties
35 
36  /// <summary>
37  /// Gets or sets the condition.
38  /// </summary>
39  /// <value>
40  /// The condition.
41  /// </value>
42  public Expression Condition { get; set; }
43 
44  /// <summary>
45  /// Gets or sets the left.
46  /// </summary>
47  /// <value>
48  /// The left.
49  /// </value>
50  public Expression Left { get; set; }
51 
52  /// <summary>
53  /// Gets or sets the right.
54  /// </summary>
55  /// <value>
56  /// The right.
57  /// </value>
58  public Expression Right { get; set; }
59 
60  #endregion
61 
62  #region Public Methods
63 
64  /// <inheritdoc />
65  public override IEnumerable<Node> Childrens()
66  {
67  ChildrenList.Clear();
68  ChildrenList.Add(Condition);
69  ChildrenList.Add(Left);
70  ChildrenList.Add(Right);
71  return ChildrenList;
72  }
73 
74  /// <inheritdoc />
75  public override string ToString()
76  {
77  return string.Format("{0} ? {1} : {2}", Condition, Left, Right);
78  }
79 
80  #endregion
81  }
82 }
override IEnumerable< Node > Childrens()
Gets the child nodes. An enumeration of child nodes
An expression surrounded by parenthesis.
ConditionalExpression(Expression condition, Expression left, Expression right)
Initializes a new instance of the ConditionalExpression class.
ConditionalExpression()
Initializes a new instance of the ConditionalExpression class.