コード例 #1
0
        /// <summary>
        /// Proxy a call to WCF
        /// </summary>
        public virtual void Call <I>(WcfCall <I> call, string endpointOverrideAddress) where I : class
        {
            IChannelWrapper <I> wrapper = null;
            bool abort = true;

            try
            {
                bool skipCall = false;
                wrapper = CreateProxy <I>(endpointOverrideAddress);
                if (wrapper.IsRealProxy && wrapper.CacheCount > 0)
                {
                    // retry one time
                    try
                    {
                        // turn off every call logging
                        //Log(string.Format("Calling {0} with cached proxy", typeof(I).Name));
                        call.Invoke(wrapper.Instance);
                        skipCall = true;
                    }
                    catch (Exception ex)
                    {
                        LogException("First call exception with a cached proxy", ex);
                        CloseProxy <I>(wrapper, true);
                        wrapper = CreateProxy <I>(endpointOverrideAddress);
                    }
                }

                if (!skipCall)
                {
                    call.Invoke(wrapper.Instance);
                    abort = false;
                }

                if (wrapper != null)
                {
                    wrapper.LastUse = DateTime.Now;
                }
            }
            catch (CommunicationException cex)
            {
                if (HandleCommunicationException <I>(cex, wrapper) == HandleExceptionAction.ThrowException)
                {
                    throw;
                }
            }
            catch (TimeoutException tex)
            {
                if (HandleTimeoutException <I>(tex, wrapper) == HandleExceptionAction.ThrowException)
                {
                    throw;
                }
            }
            catch (Exception ex)
            {
                if (HandleException <I>(ex, wrapper) == HandleExceptionAction.ThrowException)
                {
                    throw;
                }
            }
            finally
            {
                if (wrapper != null)
                {
                    try
                    {
                        CloseProxy <I>(wrapper, abort);
                    }
                    catch
                    { }
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Proxy a call to WCF
 /// </summary>
 public virtual void Call <I>(WcfCall <I> call) where I : class
 {
     Call <I>(call, null);
 }