Exemple #1
0
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is string)
     {
         GeoPoint2 location;
         if (GeoPoint2.TryParse((string)value, out location))
         {
             return(location);
         }
     }
     return(base.ConvertFrom(context, culture, value));
 }
Exemple #2
0
        public static bool TryParse(string s, out GeoPoint2 result)
        {
            result = null;

            var parts = s.Split(',');

            if (parts.Length != 2)
            {
                return(false);
            }

            double latitude, longitude;

            if (double.TryParse(parts[0], out latitude) &&
                double.TryParse(parts[1], out longitude))
            {
                result = new GeoPoint2()
                {
                    Longitude = longitude, Latitude = latitude
                };
                return(true);
            }
            return(false);
        }