/// <summary> /// Creates the attribute /// </summary> /// <param name="otherProperty">The other property to compare to</param> public CompareValuesAttribute(string otherProperty, CompareValues criteria) { if (otherProperty == null) throw new ArgumentNullException("otherProperty"); OtherProperty = otherProperty; Criteria = criteria; }
protected void FindMaxButton_Click(object sender, EventArgs e) { var vals = TextBox.Text.Split(new char[] { ',' }); var doubleVals = Array.ConvertAll(vals, new Converter <string, double>(FromStringToDouble)); CompareValues compareValues = (xin, yin) => { double x = xin, y = yin; return(x > y ? x : y); }; Label.Text = CompareValuesInList(compareValues, doubleVals[0], doubleVals[1], doubleVals[2]).ToString(); }
public static object GetAttributeArrayMemberValue( MemberInfo reflectionObject, Type attributeType, bool inherit, MemberInfo fieldOrProperty, MemberInfo comparePropertyOrField, object compareToValue, CompareValues comparer) { object[] attributes = reflectionObject.GetCustomAttributes(attributeType, inherit); if (attributes == null || attributes.Length == 0) { return(null); } foreach (Attribute attribute in attributes) { if (comparer(GetFieldOrPropertyValue(attribute, comparePropertyOrField), compareToValue)) { return(GetFieldOrPropertyValue(attribute, fieldOrProperty)); } } return(null); }
public FilterComparableGeneric(Type comparableType, object value, string fieldName, CompareValues compareValues) : base(comparableType, value, fieldName, compareValues) { }
static double CompareValuesInList(CompareValues compFirstTwo, double first, double second, double third) { return(third > compFirstTwo(first, second) ? third : compFirstTwo(first, second)); }