public static IPropertyInfo GetRegisteredProperty(BusinessRules businessRules, string propertyName) { var rules = (IBusinessRules) businessRules; var target = rules.Target; var primaryProperty = PropertyInfoManager.GetRegisteredProperty(target.GetType(), propertyName); if (primaryProperty == null) throw new ArgumentException(string.Format("Unkonwn property. {0} is not a registered field", propertyName)); return primaryProperty; }
/// <summary> /// Adds a lambda rule with fluent coding style /// </summary> /// <typeparam name="T"></typeparam> /// <param name="businessRules">The business rules.</param> /// <param name="primaryProperty">The primary property.</param> /// <param name="ruleHandler">The rule handler.</param> /// <param name="message">The message.</param> public static void AddRule <T>(this BusinessRules businessRules, Csla.Core.IPropertyInfo primaryProperty, Func <T, bool> ruleHandler, string message) where T : BusinessBase { AddRule(businessRules, primaryProperty, ruleHandler, message, RuleSeverity.Error); }
/// <summary> /// Adds a lambda rule with fluent coding style /// </summary> /// <typeparam name="T"></typeparam> /// <param name="businessRules">The business rules.</param> /// <param name="primaryProperty">The primary property.</param> /// <param name="ruleHandler">The rule handler.</param> /// <param name="messageDelegate">The message delegate.</param> public static void AddRule <T>(this BusinessRules businessRules, Csla.Core.IPropertyInfo primaryProperty, Func <T, bool> ruleHandler, Func <string> messageDelegate) where T : BusinessBase { AddRule(businessRules, ApplicationContext.DefaultRuleSet, primaryProperty, ruleHandler, messageDelegate, RuleSeverity.Error); }