internal bool TryCreateRemoteLink()

in src/AmqpSession.cs [436:480]


        internal bool TryCreateRemoteLink(Attach attach, out AmqpLink link)
        {
            link = null;
            if (this.linkFactory == null)
            {
                return false;
            }

            AmqpLinkSettings linkSettings = AmqpLinkSettings.Create(attach);
            Exception error = null;

            try
            {
                link = this.LinkFactory.CreateLink(this, linkSettings);
            }
            catch (Exception exception) when (!Fx.IsFatal(exception))
            {
                AmqpException amqpException = exception as AmqpException;
                if (amqpException != null &&
                    amqpException.Error != null &&
                    (amqpException.Error.Condition.Equals(AmqpErrorCode.ResourceLimitExceeded) ||
                     amqpException.Error.Condition.Equals(AmqpErrorCode.ResourceLocked)))
                {
                    // out of handle or link name exists
                    throw;
                }

                AmqpTrace.Provider.AmqpLogError(this, "CreateLink", exception);

                // detach requires a handle so the error link has to be attached first
                link = new ErrorLink(this, linkSettings);
                error = exception;
            }

            link.RemoteHandle = attach.Handle;
            this.linksByRemoteHandle.Add(attach.Handle.Value, link);

            if (error != null)
            {
                link.SafeClose(error);
                return false;
            }

            return true;
        }