I’m working on a simple API that will accept a number of IBehaviours which are then applied in configuration. I am designing this using the params keyword since often there is just one behaviour wanted, but sometimes more.
However, it is very important that behaviours are applied in the correct order.
public void Configure(string wow, params IBehaviour[] behaviours) { ... }
Configure("oh yes", new MustHappenFirst(), new MustHappenSecondly());
Does this
-
Technically imply that
behaviours
occurs in the same order when
enumerating? (as in standard-wise,
not simply practically-wise). -
Semantically and intuitively convey that same behaviour?
Thanks.
The evaluation of the arguments will happen in left-to-right order and they’ll be put into the array in that order.
Note that if “null” is a valid value for a behaviour, you can get into trouble:
calls
not
so be careful with that.