Example #1
0
        public static bool DoneReceivingInCurrentState(this ICommunicationObjectInternals communicationObject)
        {
            switch (communicationObject.State)
            {
            case CommunicationState.Created:
            case CommunicationState.Opening:
            {
                communicationObject.ThrowIfDisposedOrNotOpen();
                return(false);
            }

            case CommunicationState.Opened:
            {
                return(false);
            }

            case CommunicationState.Closing:
            case CommunicationState.Closed:
            case CommunicationState.Faulted:
            {
                return(true);
            }

            default:
            {
                communicationObject.ThrowIfDisposedOrNotOpen();
                return(false);
            }
            }
        }
Example #2
0
        internal static void ThrowIfNotOpened(this ICommunicationObjectInternals communicationObject)
        {
            CommunicationState state = communicationObject.State;

            if (state == CommunicationState.Created || state == CommunicationState.Opening)
            {
                communicationObject.ThrowIfDisposedOrNotOpen();
            }
        }
Example #3
0
        internal static Exception GetPendingException(this ICommunicationObjectInternals communicationObject)
        {
            Exception exception;

            try
            {
                communicationObject.ThrowPending();
                exception = null;
            }
            catch (Exception exception2)
            {
                Exception exception1 = exception2;
                if (Fx.IsFatal(exception1))
                {
                    throw;
                }
                exception = exception1;
            }
            return(exception);
        }
Example #4
0
        internal static void ThrowPending(this ICommunicationObjectInternals communicationObject)
        {
            switch (communicationObject.State)
            {
            case CommunicationState.Created:
            case CommunicationState.Opening:
            case CommunicationState.Opened:
            {
                communicationObject.ThrowIfDisposed();
                return;
            }

            case CommunicationState.Closing:
            case CommunicationState.Closed:
            case CommunicationState.Faulted:
            {
                return;
            }
            }
            throw Fx.AssertAndThrow("ThrowIfDisposed: Unknown CommunicationObject.state");
        }