Example #1
0
        public static PropertyColumnMetamodel Create(LambdaExpression property, int width, ColumnWidthMode widthMode, FilterMetamodel filterMetamodel)
        {
            var name    = ObjectHelper.GetPropertyName(property);
            var caption = AttributesHelper.GetPropertyDisplayName(property) ?? property.Name;   // TODO: maybe better to provide explicite caption parameter?

            return(new PropertyColumnMetamodel(name, caption, width, widthMode, property.ReturnType, filterMetamodel));
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var compareProperty = validationContext.ObjectType.GetRuntimeProperty(this.PropertyName);

            if (compareProperty == null)
            {
                return(new ValidationResult(string.Format("unknown property {0}", this.PropertyName)));
            }

            var comparePropertyValue = Double.Parse(compareProperty.GetValue(validationContext.ObjectInstance, null).ToString());
            var thisValue            = Double.Parse(value.ToString());

            if (CompareValue(thisValue, comparePropertyValue) || (this.AllowEqualValues && thisValue == comparePropertyValue))
            {
                return(ValidationResult.Success);
            }

            return(new ValidationResult(string.Format(this.ErrorMessage, validationContext.DisplayName,
                                                      AttributesHelper.GetPropertyDisplayName(validationContext.ObjectType, this.PropertyName))));
        }