Example #1
0
 public DefaultTransientFaultHandler(
     Func <T> func,
     ITransientFaultDetecter <Exception> detecter,
     int retryThreshold)
 {
     this.Function       = func;
     this.Detecter       = detecter;
     this.RetryThreshold = retryThreshold;
 }
Example #2
0
        public static T Execute(
            Func <T> func,
            ITransientFaultDetecter <Exception> detecter,
            int retryThreshold)
        {
            var handler = new DefaultTransientFaultHandler <T>(
                func,
                detecter,
                retryThreshold);

            return(handler.Execute());
        }
Example #3
0
 public static T GetResponse <T>(
     this string uri,
     Func <string, T> funcDeserialize,
     Func <HttpWebRequest, HttpWebRequest> funcSetCustomSettings = null,
     Encoding defaultEncoding = null,
     ITransientFaultDetecter <Exception> faultDetecter = null,
     int retryThreshold = 5)
 {
     return(funcDeserialize(uri.GetResponse(
                                funcSetCustomSettings,
                                defaultEncoding,
                                faultDetecter,
                                retryThreshold)));
 }
Example #4
0
 public static T GetResponseForJson <T>(
     this string uri,
     Func <HttpWebRequest, HttpWebRequest> funcSetCustomSettings = null,
     Encoding defaultEncoding = null,
     ITransientFaultDetecter <Exception> faultDetecter = null,
     int retryThreshold = 5)
 {
     return(uri.GetResponse(
                JsonExtension.DeserializeToObject <T>,
                funcSetCustomSettings,
                defaultEncoding,
                faultDetecter,
                retryThreshold));
 }
Example #5
0
        public static string GetResponse(
            this string uri,
            Func <HttpWebRequest, HttpWebRequest> funcSetCustomSettings = null,
            Encoding defaultEncoding = null,
            ITransientFaultDetecter <Exception> faultDetecter = null,
            int retryThreshold = 5)
        {
            var faultHandler = new DefaultTransientFaultHandler <string>(
                () => { return(GetUriContentDirectly(uri, funcSetCustomSettings, defaultEncoding)); },
                faultDetecter ?? new DefaultHttpTransientFaultDetecter(),
                retryThreshold);

            return(faultHandler.Execute());
        }