WayneBrantley wrote:
It is just much easier to use the lambdas. With the introduction of Lambdas no one uses or needs delegates anymore.
No that's not true. Delegates are often used in apis, as they dictate method signatures. The thing is that with ref parameters, the value returned has to end up somewhere, and a lambda doesn't cut it, as where is the value going? So you have to supply your own method which calls the proc.
Anyway, delegates and lambda's are close friends
I can do this:
UnitOfWork2 uow = new UnitOfWork2();
ActionProcedures.ClearTestRunDataCallBack del = (a,b)=>ActionProcedures.ClearTestRunData(a, b);
uow.AddCallBack(del, UnitOfWorkCallBackScheduleSlot.PreEntityDelete, true, new object[1] { _testRunID });
Here I define a lambda, and assign it to a variable which has as type the delegate to pass. Then I pass the delegate to the AddCallBack, et viola
Equivalent without a lambda:
UnitOfWork2 uow = new UnitOfWork2();
uow.AddCallBack(new ActionProcedures.ClearTestRunDataCallBack(ActionProcedures.ClearTestRunData), UnitOfWorkCallBackScheduleSlot.PreEntityDelete, true, new object[1] {_testRunID});