19 using System.Collections.Generic;
20 using System.Diagnostics;
22 using System.Text.RegularExpressions;
27 public class EnumMap<T> : Dictionary<string, T>
29 public void Load(
string resource)
31 Stream file = typeof(T).Assembly.GetManifestResourceStream(typeof(SiliconStudio.Paradox.VisualStudio.Resources).Namespace +
".NShader.Common." + resource);
34 while ((line = textReader.ReadLine()) != null )
36 int indexEqu = line.IndexOf(
'=');
39 string enumName = line.Substring(0, indexEqu);
40 string value = line.Substring(indexEqu + 1, line.Length - indexEqu-1).Trim();
41 string[] values = Regex.Split(value,
@"[\t ]+");
42 T enumValue = (T)Enum.Parse(typeof(T), enumName);
43 foreach (
string token
in values)
45 if (!ContainsKey(token))
47 Add(token, enumValue);
50 Trace.WriteLine(string.Format(
"Warning: token {0} for enum {1} already added for {2}", token, enumValue,
this[token]));
void Load(string resource)