title: Dynamic delegates in Polly’s Fallback
body: <p>I have the following policy in a PolicyRegistry to be reused globally:</p>
  
  <pre><code>var fallbackPolicy = Policy
          .Handle&lt;DrmException&gt;().OrInner&lt;DrmException&gt;()
          .Fallback(
              fallbackAction: () =&gt; { //should commit or dispose the transaction here using a passed in Func or Action },
              onFallback: (exception) =&gt; { Log.Error().Exception(exception).Message($"Exception occurred, message: {exception.Message}.").Write(); }
          );
  </code></pre>
  
  <p>I have the following code which I want to implement the <code>fallbackPolicy</code> in:</p>
  
  <pre><code>   if(Settings.DRM_ENABLED)
         drmManager.ExecuteAsync(new DeleteUser(123).Wait();//HTTP Call, throws DrmException if unsuccessful
  
         //in some cases, there is an if(transaction == null) here (if transaction was passed as a parameter and needs to be committed here)
         transaction.Commit();//if not thrown - commits the transaction
  </code></pre>
  
  <p>I would like it to look something like this:</p>
  
  <pre><code>var fallbackPolicy = Policy
              .Handle&lt;DrmException&gt;().OrInner&lt;DrmException&gt;()
              .Fallback(
                  fallbackAction: (transaction) =&gt; { transaction.Dispose(); },
                  onFallback: (exception) =&gt; { Log.Error().Exception(exception).Message($"Exception occurred, message: {exception.Message}.").Write(); }
              );    
  
  fallbackPolicy.Execute(() =&gt; drmManager.ExecuteAsync(new DeleteUser(123).Wait(), transaction)
  </code></pre>
  
  <p>As far as I understand the <code>fallbackPolicy.Execute</code> takes Action/Func to be carried out which either succeeds, in which case the <code>fallbackPolicy</code> is not hit, or fails, in which case the <code>fallbackPolicy</code> kicks in with some predefined <code>fallbackAction</code>.</p>
  
  <p>What I would like to do is to pass in two handlers (<code>onFail(transaction)</code> which disposes the transaction and <code>onSuccess(transaction)</code> which commits the transaction) when executing the policy. Is there an easier way of doing it instead of wrapping it or using a Polly's context?</p>