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