Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Usage:
- // salesforce.TryExecute<string, QueryResult<Deal>, System.Exception>(
- // "select Id, Name from Deal__c",
- // (svc, qry) => { return svc.Query<Deal>(qry); },
- // (ex) => { System.Diagnostics.Trace.WriteLine(ex.Message); },
- // 3);
- public static TOut TryExecute<TIn, TOut, TException>(this ISalesforceService service, TIn arg, Func<ISalesforceService, TIn, TOut> executeHandler, Action<TException> errorHandler, int retryCount) where TException : System.Exception
- {
- TOut result = default(TOut);
- try
- {
- result = executeHandler(service, arg);
- }
- catch (TException e)
- {
- if (retryCount == 0)
- {
- errorHandler(e);
- }
- service.TryExecute<TIn, TOut, TException>(arg, executeHandler, errorHandler, --retryCount);
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment