Amqp.Session.AddRemoteLink C# (CSharp) Method

AddRemoteLink() private method

private AddRemoteLink ( uint remoteHandle, Link link ) : void
remoteHandle uint
link Link
return void
        internal void AddRemoteLink(uint remoteHandle, Link link)
        {
            lock (this.ThisLock)
            {
                int count = this.remoteLinks.Length;
                if (count - 1 < remoteHandle)
                {
                    int size = (int)Math.Min(count * 2 - 1, this.handleMax) + 1;
                    Link[] expanded = new Link[size];
                    Array.Copy(this.remoteLinks, expanded, count);
                    this.remoteLinks = expanded;
                }

                var remoteLink = this.remoteLinks[remoteHandle];
                if (remoteLink != null)
                {
                    throw new AmqpException(ErrorCode.HandleInUse,
                        Fx.Format(SRAmqp.AmqpHandleInUse, remoteHandle, remoteLink.Name));
                }

                this.remoteLinks[remoteHandle] = link;
            }
        }