Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>1) the Action delegates </p> <pre><code>(Action, Action&lt;T&gt;, Action&lt;T, T2&gt; ...) </code></pre> <p>are general purpose delegate to avoid the creation of to many delegate in your application. The idea is :</p> <pre><code>//- Action =&gt; void method with 0 args //- Action&lt;T&gt; =&gt; void method with 1 arg of type T //- Action&lt;T, T2&gt; =&gt; void method with 2 args of type T et T2 //... </code></pre> <p>2) that dictionary stores for each 'SomeEnum' values, a method wicth match this signature :</p> <pre><code>void MethodExample (User arg); </code></pre> <p>Here is an example : </p> <pre><code>public Init() { deleteUserMethodsByStatus = new Dictionary&lt;SomeEnum, Action&lt;User&gt;&gt;(); deleteUserMethodsByStatus.Add(UserStatus.Active, user =&gt; { throw new BusinessException("Cannot delete an active user."); }); deleteUserMethodsByStatus.Add(UserStatus.InActive, DoUserDeletion}); } //This is how you could use this dictionary public void DeleteUser(int userId) { User u = DaoFactory.User.GetById(userId); deleteUserMethodsByStatus[u.Status](u); } //the actual deletion process protected internal DoUserDeletion(User u) { DaoFactory.User.Delete(u); } </code></pre> <p>3) Difference between Action , Function ,Predicate : - an action is a void method(no return value) - a function is a non void method (has a return value) - a predicate must return a boolean value and take 1 argument (it basically answere yes or no to question that take 1 argument)</p> <p>I hope this help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload