Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
StreamTypeName.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.Globalization;
4 using System.Linq;
5 
6 namespace SiliconStudio.Shaders.Ast.Hlsl
7 {
8  /// <summary>
9  /// A State type.
10  /// </summary>
11  public class StreamTypeName : ObjectType
12  {
13  #region Constants and Fields
14 
15  /// <summary>
16  /// A PointStream
17  /// </summary>
18  public static readonly StreamTypeName PointStream = new StreamTypeName("PointStream");
19 
20  /// <summary>
21  /// A LineStream.
22  /// </summary>
23  public static readonly StreamTypeName LineStream = new StreamTypeName("LineStream");
24 
25  /// <summary>
26  /// A TriangleStream.
27  /// </summary>
28  public static readonly StreamTypeName TriangleStream = new StreamTypeName("TriangleStream");
29 
30  private static readonly StreamTypeName[] StreamTypesName = new[] { PointStream, LineStream, TriangleStream };
31 
32  #endregion
33 
34  /// <summary>
35  /// Initializes a new instance of the <see cref="StreamTypeName"/> class.
36  /// </summary>
37  public StreamTypeName()
38  {
39  IsBuiltIn = true;
40  }
41 
42  /// <summary>
43  /// Initializes a new instance of the <see cref="StreamTypeName"/> class.
44  /// </summary>
45  /// <param name="name">
46  /// The name.
47  /// </param>
48  public StreamTypeName(string name, params string[] altNames)
49  : base(name, altNames)
50  {
51  IsBuiltIn = true;
52  }
53 
54  /// <inheritdoc/>
55  public bool Equals(StreamTypeName 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 StreamTypeName);
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 ==(StreamTypeName left, StreamTypeName 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 !=(StreamTypeName left, StreamTypeName 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 StreamTypeName Parse(string name)
112  {
113  return StreamTypesName.FirstOrDefault(streamType => string.Compare(name, streamType.Name.Text, true, CultureInfo.InvariantCulture) == 0);
114  }
115  }
116 }
StreamTypeName()
Initializes a new instance of the StreamTypeName class.
StreamTypeName(string name, params string[] altNames)
Initializes a new instance of the StreamTypeName class.
static StreamTypeName Parse(string name)
Parses the specified name.