We should probably return a new list or enumerable - not return the original list of BrokenRules so anyone on the outside might alter the list.
So my proposal:
public interface ICheckRules
{
/// <summary>
/// Sets value indicating no rule methods will be invoked.
/// </summary>
void SuppressRuleChecking();
/// <summary>
/// Resets value indicating all rule methods will be invoked.
/// </summary>
void ResumeRuleChecking();
/// <summary>
/// Invokes all rules for the business type.
/// </summary>
void CheckRules();
/// <summary>
/// Gets the broken rules collection
/// </summary>
/// <returns></returns>
IEnumerable<BrokenRule> GetBrokenRules();
}
And implementation in Core\BusinessBase.cs:
IEnumerable<BrokenRule> ICheckRules.GetBrokenRules()
{
return Enumerable.ToArray(BrokenRulesCollection);
}
Copyright (c) Marimer LLC