Zbiór zmian 854 dla branches/Abonament/Wierszowki/Wierszowki.Services/DataAnnotationsValidationRunner.cs
- Data:
- 2009-10-15 15:45:07 (17 years ago)
- Lokalizacja:
- branches/Abonament
- Pliki:
-
- 2 zmodyfikowane
-
. (zmodyfikowane) (1 prop)
-
Wierszowki/Wierszowki.Services/DataAnnotationsValidationRunner.cs (zmodyfikowane) (1 diff)
Legenda:
- Bez zmian
- Dodane
- Usunięte
-
branches/Abonament
- Property svn:mergeinfo
-
old new 2 2 /branches/ReklamaReorganizacja:568-731 3 3 /tags/BazaReklam_1.1.28:831 4 /trunk:708-758,760-8 384 /trunk:708-758,760-853
-
- Property svn:mergeinfo
-
branches/Abonament/Wierszowki/Wierszowki.Services/DataAnnotationsValidationRunner.cs
r752 r854 12 12 { 13 13 public static IEnumerable<ErrorInfo> GetErrors(object instance) 14 { 15 return from prop in TypeDescriptor.GetProperties(instance).Cast<PropertyDescriptor>() 14 { 15 List<ErrorInfo> errors = new List<ErrorInfo>(); 16 17 IEnumerable<PropertyDescriptor> properties = TypeDescriptor.GetProperties(instance).Cast<PropertyDescriptor>(); 18 foreach (PropertyDescriptor prop in properties) { 19 IEnumerable<ValidationAttribute> attributes = prop.Attributes.OfType<ValidationAttribute>(); 20 21 int empty = 2; 22 object pom = prop.GetValue(instance); 23 if (pom != null) 24 { 25 object typek = pom.GetType(); 26 if (pom.GetType().Name == "Int32") 27 { 28 empty = Convert.ToInt32(pom); 29 } 30 } 31 foreach (ValidationAttribute attribute in attributes) { 32 if (!attribute.IsValid(prop.GetValue(instance)) || empty == 0) { 33 errors.Add(new ErrorInfo(prop.Name, attribute.FormatErrorMessage(string.Empty), instance)); 34 } 35 } 36 } 37 return errors; 38 /* return from prop in TypeDescriptor.GetProperties(instance).Cast<PropertyDescriptor>() 16 39 from attribute in prop.Attributes.OfType<ValidationAttribute>() 17 40 where !attribute.IsValid(prop.GetValue(instance)) 18 41 select new ErrorInfo(prop.Name, attribute.FormatErrorMessage(string.Empty), instance); 42 */ 19 43 } 20 44 }
