title: Converting an string to a enum type using TValue?
body: <p>I want to convert an string to an enum type using TValue, I googled but I didn't find how to do that.</p>
  
  <pre><code>type 
    TEnumTest = (etFirst, etSecond);
  
  var 
    D: TEnumTest;
  begin
    D := StrToENumTest('etFirst');
  end;
  
  function StrToEnumTest(pStr:String):TEnumTest;
  var 
    V: TValue;
  begin
    V := TValue.From&lt;String&gt;(pstr);
    Result := V.AsType&lt;TEnumTest&gt;;
  end;
  </code></pre>
  
  <p>It doesn't work. That's must be something stupid I'm not seeing - but I didn't
  found it. What I made wrong?</p>
  
  <p>I know how to use GetEnumValue. </p>
  
  <p>EDIT: @Warren, it goes here as this is easier to post code:</p>
  
  <pre><code>  TEnumUtils = class
      class function GetAs&lt;T&gt;(pValor: String): T;
    end;
  
  class function TEnumUtils.GetAs&lt;T&gt;(pValor: String): T;
  var
    Tipo: PTypeInfo;
    Temp: Integer;
    PTemp: Pointer;
  
  begin
     Tipo := TypeInfo(T);
     Temp := GetEnumValue(Tipo, pValor);
     PTemp := @Temp;
     Result := T(PTemp^);
  end;
  </code></pre>
  
  <p>Usage:</p>
  
  <pre><code>type 
    TEnumTest = (etFirst, etSecond);
  
  var 
    D: TEnumTest;
  begin
    D := TEnumUtils.GetAs&lt;TEnumTest&gt;('etFirst');
  end;  
  </code></pre>