-
Notifications
You must be signed in to change notification settings - Fork 0
/
Noun.cs
33 lines (27 loc) · 920 Bytes
/
Noun.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// <copyright file="Noun.cs" company="Brian Rogers">
// Copyright (c) Brian Rogers. All rights reserved.
// </copyright>
namespace Adventure.Sample
{
using System.Reflection;
internal sealed class Noun
{
public static readonly Noun Coin = new Noun("coin");
public static readonly Noun East = new Noun("east");
public static readonly Noun Table = new Noun("table");
public static readonly Noun West = new Noun("west");
private readonly string noun;
private Noun(string noun)
{
this.noun = noun;
}
public static implicit operator string(Noun n) => n.noun;
public static void Register(Words words)
{
foreach (FieldInfo fi in typeof(Noun).GetFields(BindingFlags.Static | BindingFlags.Public))
{
words.Add((Noun)fi.GetValue(null));
}
}
}
}