I have a class EqualCondition
which implements my own interface ICondition
, which has only one method: SatisfiedBy(Something)
.
public class EqualCondition : ICondition {
private Something m_Something;
public HelloCondition(Something something) {
m_Something = something;
}
// Magic!!!
public bool SatisfiedBy(Something something) {
return something == m_Something;
}
}
So ICondition
is very simple to implement. Now I'm trying to create a CombinationCondition
which also implements it. The idea is that CombinationCondition
which will contain a list of ICondition
s which will determine whether SatisfiedBy
will be successful or not.
My first thought was to make CombinationCondition
implement IList<Something>
but I quickly realized that I was only duplicating List<Something>
. So why not just subclass it?
That idea sounded fine until I started thinking again about how to implement SatisfiedBy
if I just subclassed List<Something>
. I need to do:
return innerList.All(x => x.SatisfiedBy(something))
But how do I access the inner list?