Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uses
- TypInfo;
- function StrToCustomType(const Value: string): TCustomType;
- var
- OrdValue: Integer;
- begin
- OrdValue := GetEnumValue(TypeInfo(TCustomType), Value);
- // if the GetEnumValue returns value different from -1, cast this value to the returned type, raise exception otherwise
- if OrdValue <> -1 then
- Result := TCustomType(OrdValue)
- else
- raise EMyException.Create(...);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement