Пример #1
0
        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);
        }
Пример #2
0
 private static void OnHandleFault(ICommunicationObject sender, InvokeFaultEventArgs e)
 {
     if (HandleFault != null)
     {
         HandleFault(sender, e);
     }
 }
Пример #3
0
 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;
     }
 }