Change C# action/delegate target: hierarchical calls
<p>Suppose I have </p>

<pre><code>public IList&lt;Entity&gt; Children { get; set; }

public NotifyChildren(Func&lt;object, bool&gt; action, object data)
{
   foreach (var child in Children)
       if (action(data))
           /// &lt;-- !!!! need action to work on child this time, not on the original target
           //child.NofifyChildren(action, data); &lt;- this doesn't work because of the above requirement
           child.NotifyChildren(action.ChangeTargetTo(child), data); // &lt;&lt; pseudocode!
}

public void SomeChangeOccured()
{
   var changedChild;
   NotifyChildren(x =&gt; x.SomeHandler(), "somedata");
}
</code></pre>

<p>How do I change the target of the action? I'm OK to pass a delegate instead of action but its .Target is read-only, too.
Currently I think doing </p>

<pre><code>public NotifyChildren(Expression&lt;Func&lt;Entity, bool&gt;&gt; action, object data)
{
     // so that I can do method.Invoke(newtarget, new object[]{data});
     NotifyChildren(((MethodCallExpression)action).Method, data);
}
</code></pre>

<p>that is, switch from action to reflected method call... but it's a <strong>bit</strong> ugly, isn't it?</p>

<p>I have a feeling that the solution is very simple and I used to know it... just forgot.</p>

<p>Hm, one solution would be to have static delegate that accepts Entity as first parameter, but I wouldn't want to go this way.</p>
