Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
StateType.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.Linq;
5 
6 namespace SiliconStudio.Shaders.Ast.Hlsl
7 {
8  /// <summary>
9  /// A State type.
10  /// </summary>
11  public class StateType : ObjectType
12  {
13  #region Constants and Fields
14 
15  /// <summary>
16  /// A BlendState.
17  /// </summary>
18  public static readonly StateType BlendState = new StateType("BlendState");
19 
20  /// <summary>
21  /// A DepthStencilState.
22  /// </summary>
23  public static readonly StateType DepthStencilState = new StateType("DepthStencilState");
24 
25  /// <summary>
26  /// A RasterizerState
27  /// </summary>
28  public static readonly StateType RasterizerState = new StateType("RasterizerState");
29 
30  private static readonly StateType[] StateTypes = new[] { BlendState, DepthStencilState, RasterizerState };
31 
32  #endregion
33 
34  /// <summary>
35  /// Initializes a new instance of the <see cref="StateType"/> class.
36  /// </summary>
37  public StateType()
38  {
39  IsBuiltIn = true;
40  }
41 
42  /// <summary>
43  /// Initializes a new instance of the <see cref="StateType"/> class.
44  /// </summary>
45  /// <param name="name">
46  /// The name.
47  /// </param>
48  public StateType(string name)
49  : base(name)
50  {
51  IsBuiltIn = true;
52  }
53 
54  /// <inheritdoc/>
55  public bool Equals(StateType other)
56  {
57  return base.Equals(other);
58  }
59 
60  /// <inheritdoc/>
61  public override bool Equals(object obj)
62  {
63  if (ReferenceEquals(null, obj))
64  {
65  return false;
66  }
67  if (ReferenceEquals(this, obj))
68  {
69  return true;
70  }
71  return Equals(obj as StateType);
72  }
73 
74  /// <inheritdoc/>
75  public override int GetHashCode()
76  {
77  return base.GetHashCode();
78  }
79 
80  /// <summary>
81  /// Implements the operator ==.
82  /// </summary>
83  /// <param name="left">The left.</param>
84  /// <param name="right">The right.</param>
85  /// <returns>
86  /// The result of the operator.
87  /// </returns>
88  public static bool operator ==(StateType left, StateType right)
89  {
90  return Equals(left, right);
91  }
92 
93  /// <summary>
94  /// Implements the operator !=.
95  /// </summary>
96  /// <param name="left">The left.</param>
97  /// <param name="right">The right.</param>
98  /// <returns>
99  /// The result of the operator.
100  /// </returns>
101  public static bool operator !=(StateType left, StateType right)
102  {
103  return !Equals(left, right);
104  }
105 
106  /// <summary>
107  /// Parses the specified name.
108  /// </summary>
109  /// <param name="name">The name.</param>
110  /// <returns></returns>
111  public static StateType Parse(string name)
112  {
113  return StateTypes.FirstOrDefault(stateType => string.Compare(name, stateType.Name.Text, true) == 0);
114  }
115  }
116 }
static StateType Parse(string name)
Parses the specified name.
Definition: StateType.cs:111
StateType(string name)
Initializes a new instance of the StateType class.
Definition: StateType.cs:48
StateType()
Initializes a new instance of the StateType class.
Definition: StateType.cs:37
override bool Equals(object obj)
Definition: StateType.cs:61