Designing a Requirement Satisfaction structure
<p>I'm attempting to implement a 'Requirements' type system into a program. It seemed pretty simple in my head, but actually making it abstract enough to be useful is proving more difficult than anticipated. </p>

<p>Here is what I am trying to do ...</p>

<pre><code>enum Condition {
 Not, Exists, Exceeds
}

abstract class Requirement { 
  // base class
  Condition Condition { get; set; }
}

class ScoreRequirement : Requirement {
  // a specific 'score' is required
}
class TraitRequirement : Requirement {
  // a specific 'trait' is required
}
class SatisfyingObject {
  // this is the class that has to satisfy the requirements
  IDictionary&lt;Trait, int&gt; Traits { get; set; }
}
</code></pre>

<p>If I know the exact thing that has to be satisfied in code-time, this is very simple. But the goal is to let people add requirements later. There will be other types that derive from <code>Requirement</code>, as well. </p>

<p>So a requirement might work like this ...</p>

<pre><code>var obj = new Item { 
 Requirements = new List&lt;Requirement&gt; {
   new ScoreRequirement { Trait = "One", Score = 2, Condition = Condition.Exceeds }
 }
}
</code></pre>

<p>So the concept seems pretty simple. You would call upon an object..</p>

<pre><code>var satisfying = // get the satisfying object;

if( satisfying.Satisfies( obj.Requirements ) )
 return true;
</code></pre>

<p>The problem I am running into is really how to code the <code>Satisfies</code> method - in specific I am not sure how to relate it to the <code>Condition</code> parameter. I'd like people to be able to set up some fairly generic 'requirements', but the logic behind this is very confusing to me. Since the requirements are not known at design time, I cannot really hard code any of them. </p>

<p>Any suggestions?</p>
