Runtime check for a Func delegate
<p>Consider the following code snippet:</p>

<pre><code>class Test
{
    public int Length{ get; set; }
    public Func&lt;List&lt;int&gt;, double&gt; Calculate { get; set; }
    public void DoStuff(List&lt;int&gt; list)
    {
        // ... do some processing here ...
        double ans = Calculate(list);
        // ... do some more stuff ......
    }
}
</code></pre>

<p>Now, I have realized that the the typical anonymous Func delegate that will be attached to the Calculate property, would have something to do with the Length property of the Test class, and the length of the list which is being passed to the delegate. For some relationship between these two lengths (e.g., this.Length &lt; list.Count), I should be able to throw an exception. But, this has to happen at runtime, and I would have no control over what the users of this class would be adding as delegate in the Calculate property. <br /></p>

<p>How to do this? Can I do something in the set method of the Calculate property? How to check at runtime if certain condition involving the Length property of the Test class and the length (count) of the list object passed to the delegate is satisfied? <br /></p>

<p>I would also consider design changes of the Test class to accomplish my objective (of runtime checking), but a way for the users to attach a Func delegate and still accomplish this would be neat.<br />
Thanks.</p>
