❔ Help with Action syntax for event handler system
I am trying to add a basic event system to my program and would like the syntax to be something like this:
Ideally there is no need for a baseclass or interface. All that should be needed is for the function passed as an action to take the event type as an argument.
I have the following implmentation for the registration:
I would very much like the register syntax to be like this:
but I struggle with how to achive this, and I am not entirely sure if its possible?
5 Replies
x => x.Process
would be the syntax for an action
And, no, it cannot be shortened to x.Process
I see I messed up my post a bit:
This is working:
But the (x,e) syntax is not all that clean. So I would love doing x.Process and have the e implied
I don't think you can do that
I feared so, thanks for clarifying. I dont deal with generics all that much and the rules for when things can be implied or not is still a bit of a mystery to me 🙂
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.