Format:
Recent snippets matching tags of ValidationResult
public static IEnumerable<ValidationResult> Validate(object component) { return from descriptor in TypeDescriptor.GetProperties(component).Cast<PropertyDescriptor>() from validation in descriptor.Attributes.OfType<System.ComponentModel.DataAnnotations.ValidationAttribute>() where !validation.IsValid(descriptor.GetValue(component)) select new ValidationResult( validation.ErrorMessage ?? string.Format(CultureInfo.CurrentUICulture, "{0} validation failed.", validation.GetType().Name), new[] { descriptor.Name }); }
277 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
