I’m trying to port Delphi code that has lots of calls like this:
raise EMyException.CreateRes(@SomeResourceString); raise EMyException.CreateResFmt(@SomeResourceString, [Parameter1]); raise EMyException.CreateFmt("Some string", [Parameter 1]);
Those constructors are not available in the
Exception class, so I tried writing an extension class for it, like so:
type PResStringRec = ^String; ExceptionExtension = public extension class(Exception) public method CreateRes(AResourceString: PResStringRec): Exception; static; begin self.GetType().GetConstructor(typeOf(String)).Invoke(new Object(AResourceString^)); end; end;
Alas, this does not compile as it tells me I cannot access non static member
GetType. The idea being this construct was to create an instance of the real class, not just a
Would you have any suggestions?