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