public static TReturn Invoke <TClient, TReturn>(this TClient proxy, Func <TClient, TReturn> func) where TClient : class, ICommunicationObject { TReturn returnValue = default(TReturn); try { returnValue = func(proxy); } catch (FaultException ex) { proxy.Abort(); var e = new InvokeFaultEventArgs(ex); OnHandleFault(proxy, e); if (e.Throw) { throw; } } catch (SystemException) { proxy.Abort(); throw; } return(returnValue); }
private static void OnHandleFault(ICommunicationObject sender, InvokeFaultEventArgs e) { if (HandleFault != null) { HandleFault(sender, e); } }
public static void Invoke <TClient>(this TClient proxy, Action <TClient> action) where TClient : class, ICommunicationObject { try { action(proxy); } catch (FaultException ex) { proxy.Abort(); var e = new InvokeFaultEventArgs(ex); OnHandleFault(proxy, e); if (e.Throw) { throw; } } catch (SystemException) { proxy.Abort(); throw; } }