Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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)));
        }
Esempio n. 4
0
		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;
		}
Esempio n. 5
0
		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));
		}