public static bool IsPropertyDefined(string propertyName, IDictionaryAdapter dictionaryAdapter, XPathAdapter xpath) { var key = dictionaryAdapter.GetKey(propertyName); if (key == null) { return(false); } var property = dictionaryAdapter.Meta.Properties[propertyName]; var result = xpath.EvaluateProperty(key, property, dictionaryAdapter); return(result.GetNavigator(false) != null); }
public bool HasProperty(string propertyName, IDictionaryAdapter dictionaryAdapter) { var key = dictionaryAdapter.GetKey(propertyName); if (key == null) { return(false); } PropertyDescriptor property; XmlAccessor accessor; return(dictionaryAdapter.This.Properties.TryGetValue(propertyName, out property) && TryGetAccessor(key, property, false, out accessor) && accessor.IsPropertyDefined(node)); }
public string Validate(IDictionaryAdapter dictionaryAdapter, PropertyDescriptor property) { var key = dictionaryAdapter.GetKey(property.PropertyName); var value = dictionaryAdapter.GetProperty(property.PropertyName, true); var propinfo = property.Property; var context = new ValidationContext(value) { DisplayName = key, MemberName = propinfo.Name }; var attrs = propinfo.GetCustomAttributes(true).OfType <ValidationAttribute>().ToArray(); var results = new System.Collections.Generic.List <ValidationResult>(); return(Validator.TryValidateValue(value, context, results, attrs) ? String.Empty : string.Join(Environment.NewLine, results.Select(x => x.ErrorMessage))); }
public static bool IsPropertyDefined(string propertyName, IDictionaryAdapter dictionaryAdapter, XPathAdapter xpath) { var key = dictionaryAdapter.GetKey(propertyName); if (key == null) return false; var property = dictionaryAdapter.This.Properties[propertyName]; var result = xpath.EvaluateProperty(key, property, dictionaryAdapter); return result.GetNavigator(false) != null; }
public string Validate(IDictionaryAdapter dictionaryAdapter, PropertyDescriptor property) { var key = dictionaryAdapter.GetKey(property.PropertyName); var value = dictionaryAdapter.GetProperty(property.PropertyName, true); var propinfo = property.Property; var context = new ValidationContext(value) { DisplayName = key, MemberName = propinfo.Name }; var attrs = propinfo.GetCustomAttributes(true).OfType<ValidationAttribute>().ToArray(); var results = new System.Collections.Generic.List<ValidationResult>(); return Validator.TryValidateValue(value, context, results, attrs) ? String.Empty : string.Join(Environment.NewLine, results.Select(x => x.ErrorMessage)); }