Beispiel #1
0
        /// <summary>Reads a remote exception from the stream.</summary>
        /// <returns>The remote exception.</returns>
        public RemoteException ReadException()
        {
            Push(InstanceType.Exception);
            Debug.Assert(_current != null);

            RemoteException?remoteEx = null;

            do
            {
                // Read the slice header; an exception's type ID cannot be null.
                string typeId = ReadSliceHeaderIntoCurrent() !;
                ReadIndirectionTableIntoCurrent(); // we read the indirection table immediately

                if (Communicator.FindRemoteExceptionFactory(typeId) is IRemoteExceptionFactory factory)
                {
                    remoteEx = factory.Read(this);
                }
                else if (SkipSlice()) // Slice off what we don't understand.
                {
                    remoteEx = new RemoteException(GetSlicedData() !.Value);
                }
            }while (remoteEx == null);

            Pop(null);
            return(remoteEx);
        }