How to make lambda like this
Action<EventHandler<TEventArgs>> adder = vs => GenericEvent += vs
using expression trees. This code doesn't work:
Expression<Func<EventHandler<TEventArgs>>> handler = () => GenericEvent;
var vs = Expression.Parameter(typeof(EventHandler<TEventArgs>), "vs");
var adder = Expression.Lambda<Action<EventHandler<TEventArgs>>>(
Expression.AddAssign(handler.Body, vs), vs).Compile();
Error message:
The binary operator AddAssign is not defined for the types 'System.EventHandler
1[ConsoleApplication.Program+SomeEventArgs]' and 'System.EventHandler
1[ConsoleApplication.Program+SomeEventArgs]'.