is it possible to easily and dynamically decorate an object?
for example, lets say I have a List<PointF>. this list is actually a plot of the sine function. I’d like to go through these points and add a flag to each PointF of whether it’s a peak or not.
but I don’t want to create a new extended SpecialPointF or whatever, that has a boolean property.
judge me all you want for being lazy, but laziness is how awesome ideas are born (also bad ideas)
Edit: I’ll accept boxing solutions as well as any interesting hack you can come up with. there’s nothing really stopping me from deriving. I just want to know if there’s a more fun way.
If there’s a way you can calculate that per point, you don’t need to add a flag to it, you can use an extension method without having to extend it.
Something like PointF.isPeak();
It works something like:
And voilà, you have your calculation in your PointF class.
By the way, the public static class has to be in the outermost scope, cant be nested.