///<summary> /// Returns true if the business object matches ///</summary> ///<param name="businessObject"></param> ///<param name="usePersistedValue"></param> ///<typeparam name="T"></typeparam> ///<returns></returns> ///<exception cref="ArgumentNullException"></exception> ///<exception cref="InvalidOperationException"></exception> public virtual bool IsMatch <T>(T businessObject, bool usePersistedValue) where T : class, IBusinessObject { if (businessObject == null) { throw new ArgumentNullException("businessObject", "The IsMatch cannot be called for null object"); } if (IsComposite()) { switch (LogicalOperator) { case LogicalOp.And: return(LeftCriteria.IsMatch(businessObject, usePersistedValue) && RightCriteria.IsMatch(businessObject, usePersistedValue)); case LogicalOp.Or: return(LeftCriteria.IsMatch(businessObject, usePersistedValue) || RightCriteria.IsMatch(businessObject, usePersistedValue)); case LogicalOp.Not: return(!RightCriteria.IsMatch(businessObject, usePersistedValue)); } } object leftValue; if (Field.Source != null && Field.Source.ChildSource != null) { if (usePersistedValue) { leftValue = businessObject.GetPersistedPropertyValue(Field.Source.ChildSource, Field.PropertyName); } else { leftValue = businessObject.GetPropertyValue(Field.Source.ChildSource, Field.PropertyName); } } else { if (usePersistedValue) { leftValue = businessObject.GetPersistedPropertyValue(null, Field.PropertyName); } else { leftValue = businessObject.GetPropertyValue(null, Field.PropertyName); } } string className = businessObject.GetType().FullName; return(CheckValueAgainstSingleCriteria(leftValue, className)); }
/// <summary> /// Evaluates the <see cref="BusinessObjectDTO"/> passed in to see if it matches the criteria that have been set up /// </summary> /// <param name="dto">The <see cref="BusinessObjectDTO"/> to check for a match against the criteria</param> /// <returns>True if the <see cref="BusinessObjectDTO"/> matches the criteria, false if it does not</returns> public virtual bool IsMatch(BusinessObjectDTO dto) { if (IsComposite()) { switch (LogicalOperator) { case LogicalOp.And: return(LeftCriteria.IsMatch(dto) && RightCriteria.IsMatch(dto)); case LogicalOp.Or: return(LeftCriteria.IsMatch(dto) || RightCriteria.IsMatch(dto)); case LogicalOp.Not: return(!RightCriteria.IsMatch(dto)); } } object leftValue = dto.Props[Field.PropertyName.ToUpper()]; string className = dto.ClassDefName; return(CheckValueAgainstSingleCriteria(leftValue, className)); }