As far as I know you have to do that yourself. Here is what I did:
- Created IsDeepValid()
- Created DeepValidate()
- Created DeepBrokenRuleList()
Now I know that IsDeepValid and DeepBrokenRuleList should be properties not methods, I needed something fast and this works for me. I'll probably change it later when I'm optimizing the code. So pay attention when you use the base BrokenRuleList and IsValid as they are not methods.
public void DeepValidate()
{
this.Validate();
foreach (SomeObject1 item in this.SomeObject1Collection)
item.Validate(); // or item.DeepValidate() if you have multiple levels
foreach (SomeObject2 item in this.Some2ObjectCollection)
item.Validate();
}
public bool IsDeepValid()
{
if (this.IsValid)
{
foreach (SomeObject1 item in this.SomeObject1Collection)
if (!item.IsValid()) // or item.IsDeepValid()
return false;
foreach (SomeObject2 item in this.Some2ObjectCollection)
if (!item.IsValid()) // or item.IsDeepValid()
return false;
}
else
return false;
return true;
}
public Validation.BrokenRulesList DeepBrokenRulesList()
{
Validation.BrokenRulesList brokenRules = new Validation.BrokenRulesList();
foreach (Validation.BrokenRule rule in this.BrokenRulesList)
brokenRules.Add(rule);
foreach (SomeObject1 item in this.SomeObject1Collection)
foreach (Validation.BrokenRule rule in item.BrokenRulesList) // or item.DeepBrokenRulesList()
brokenRules.Add(rule);
foreach (SomeObject2 item in this.SomeObject2Collection)
foreach (Validation.BrokenRule rule in item.BrokenRulesList)
brokenRules.Add(rule);
return brokenRules;
}