Elegant replacement for .NET's TryParse and Enum.Parse methods