/// <summary> /// Converts the specified host name value to a localizable string describing validation /// error if any. /// </summary> /// <param name="value">The value to be converted.</param> /// <param name="targetType">The type to convert source value to.</param> /// <param name="parameter">The converter parameter.</param> /// <param name="culture">The culture to be used for conversion.</param> /// <returns>a localizable string describing validation error if any.</returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var validator = new HostNameValidator(); var result = validator.Validate(value as string); return result.ErrorContent as string; }
/// <summary> /// Converts the specified value to a boolean value indicating if the host name is valid. /// </summary> /// <param name="value">The value to be converted.</param> /// <param name="targetType">The type to convert source value to.</param> /// <param name="parameter">The converter parameter.</param> /// <param name="culture">The culture to be used for conversion.</param> /// <returns>A boolean value indicating if the host name is valid.</returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var validator = new HostNameValidator(); return validator.Validate(value as string).IsValid; }