/// <summary> /// Runs all property get rules pending invocation for the specified instance. /// </summary> /// <param name="instance"></param> public static void RunPropertyGetRules(this ModelInstance instance, Func <ModelProperty, bool> when) { foreach (Rule rule in instance.GetRules().Where(rule => (rule.InvocationTypes & RuleInvocationType.PropertyGet) > 0 && rule.ReturnValues.Select(p => rule.RootType.Properties[p]).Any(when))) { rule.Invoke(instance, null); } }
internal void RunPendingPropertyGetRules(ModelInstance instance, Func<ModelProperty, bool> when) { // First run all rules for return values associated with properties that have not yet been accessed foreach (Rule rule in instance.GetRules() .Where(rule => (rule.InvocationTypes & RuleInvocationType.PropertyGet) > 0 && rule.ReturnValues.Select(p => rule.RootType.Properties[p]) .Any(p => when(p) && !instance.HasBeenAccessed(p)))) rule.Invoke(instance, null); // Then run any property get rules that are pending invocation due to changes in the model pendingInvocation.RemoveWhere(rule => { if ((rule.InvocationTypes & RuleInvocationType.PropertyGet) > 0 && rule.ReturnValues.Select(p => rule.RootType.Properties[p]).Any(when)) { rule.Invoke(instance, null); return true; } return false; }); }
internal void RunPendingPropertyGetRules(ModelInstance instance, Func <ModelProperty, bool> when) { // First run all rules for return values associated with properties that have not yet been accessed foreach (Rule rule in instance.GetRules() .Where(rule => (rule.InvocationTypes & RuleInvocationType.PropertyGet) > 0 && rule.ReturnValues.Select(p => rule.RootType.Properties[p]) .Any(p => when(p) && !instance.HasBeenAccessed(p)))) { rule.Invoke(instance, null); } // Then run any property get rules that are pending invocation due to changes in the model pendingInvocation.RemoveWhere(rule => { if ((rule.InvocationTypes & RuleInvocationType.PropertyGet) > 0 && rule.ReturnValues.Select(p => rule.RootType.Properties[p]).Any(when)) { rule.Invoke(instance, null); return(true); } return(false); }); }