abstract class Plugin<T>
{
public abstract T Modify(T param);
}
sealed class CompoundPlugin<T> : Plugin<T> {
private readonly IReadOnlyList<Plugin<T>> plugins;
public CompoundPlugin(IReadOnlyList<Plugin<T>> plugins) {
Contract.Requires<ArgumentNullException>(plugins != null, "arg");
Contract.Requires<ArgumentException>(plugins.Count > 0);
this.plugins = plugins;
}
public override T Modify(T param) {
return plugins.Aggregate(param, (arg1, plugin) => plugin.Modify(arg1));
}
}