title: Create enum from an attribute
body: <p>I'm marking my enums with an own entity attribute used to map the enums to the corresponding field in a case management system.</p>
  
  <p>Getting the correct string from an enum value works fine, but how can I generate an enum from a string?</p>
  
  <p>I started by doing this:</p>
  
  <pre><code>foreach (var fieldInfo in enumType.GetFields())
  {
      var attribute = (EntityNameAttribute)fieldInfo
          .GetCustomAttributes(typeof (EntityNameAttribute), false)
          .FirstOrDefault();
  
      if (attribute == null)
          continue;
  
      if (attribute.Name != name)
          continue;
  
      //got a match. But now what?
  }
  </code></pre>
  
  <p>But how do I get the proper value from a field? Can I just use <code>fieldInfo.GetValue</code>? If so, what instance should I use? Should the enum be treated as a static type?</p>