How do I build an Action action in a loop? to explain (sorry it\'s so lengthy)
I have the following:
public interface ISomeInterface {
void MethodOn
It's really easy, because delegates are already multicast:
Action<ISomeInterface> action1 = z => z.MethodOne();
Action<ISomeInterface> action2 = z => z.MethodTwo("relativeFolderName");
builder.BuildMap(action1 + action2, "IAnotherInterfaceName");
Or if you've got a collection of them for some reason:
IEnumerable<Action<ISomeInterface>> actions = GetActions();
Action<ISomeInterface> action = null;
foreach (Action<ISomeInterface> singleAction in actions)
{
action += singleAction;
}
Or even:
IEnumerable<Action<ISomeInterface>> actions = GetActions();
Action<ISomeInterface> action = (Action<ISomeInterface>)
Delegate.Combine(actions.ToArray());