title: Virtual Method Table
body: <p>I'm using this block:</p>
  
  <pre><code>procedure ExecMethod(Target: TClass; const MethodName: string; const Args: array of TValue);
  var
    LContext: TRttiContext;
    LType: TRttiType;
    LMethod: TRttiMethod;
  begin
    LType := LContext.GetType(Target);
    for LMethod in LType.GetMethods do
      if (LMethod.Parent = LType) and (LMethod.Name = MethodName) then begin
        LMethod.Invoke(Target.Create, Args);
        break;
      end;
  end;
  </code></pre>
  
  <p>like this:</p>
  
  <pre><code>ExecMethod(TFuncClass, 'Test1', []);
  ExecMethod(TFuncClass, 'Test2', ['hey']);
  ExecMethod(TFuncClass, 'Test3', [100]);
  </code></pre>
  
  <p>on this class:</p>
  
  <pre><code>  TFuncClass = class(TObject)
      published
        procedure Test1;
        procedure Test2(const str: string);
        procedure Test3(i: integer);
        // there's more, each one with different prototype
    end;
  
  var
    FuncClass: TFuncClass;
  </code></pre>
  
  <p>but then, i keep getting access violations... or invalid cast pointer class (or whatever)..</p>