title: TValue.AsType<T> with enum types in Delphi
body: <p>Writing this in Delphi</p>
  
  <pre><code>uses System.Classes;
  ...
  var
    A: TAlignment;
    Value: TValue;
  begin
    Value := 0;
    A := Value.AsType&lt;TAlignment&gt;();
  end;
  </code></pre>
  
  <p>raises EInvalidCast at AsType. </p>
  
  <p>Is there a way to cast to any enumeration type from an integer value with TValue?</p>
  
  <p>This is of course the obvious answer:</p>
  
  <pre><code>A := TAlignment(Value);
  </code></pre>
  
  <p>but I wish to provide a generic function that works with other types as well.</p>