API.Controllers.TransitApiController.ParseUserLocation C# (CSharp) Method

ParseUserLocation() private static method

Generates a new LatLong based on input. Throws an exception if it can't do it.
private static ParseUserLocation ( string location ) : LatLong?
location string
return LatLong?
        private static LatLong? ParseUserLocation(string location)
        {
            if (string.IsNullOrWhiteSpace(location))
            {
                return null;
            }

            var locationPieces = location.Split(',');
            if (locationPieces.Length != 2)
            {
                throw new FormatException("2 comma-separated numbers must be provided in the location string.");
            }

            return new LatLong(double.Parse(locationPieces[0]),
                               double.Parse(locationPieces[1]));
        }