private LinkConsumerBuilder(
     LinkConsumerBuilder prev,
     TimeSpan?recoveryInterval = null,
     ushort?prefetchCount      = null,
     bool?autoAck            = null,
     int?priority            = null,
     bool?cancelOnHaFailover = null,
     bool?exclusive          = null,
     ILinkConsumerErrorStrategy errorStrategy = null,
     LinkConsumerMessageHandlerBuilder messageHandlerBuilder = null,
     ILinkConsumerTopologyHandler topologyHandler            = null,
     LinkStateHandler <LinkConsumerState> stateHandler       = null,
     LinkStateHandler <LinkChannelState> channelStateHandler = null,
     ILinkSerializer serializer          = null,
     LinkTypeNameMapping typeNameMapping = null
     ) : this
     (
         prev._link,
         recoveryInterval ?? prev._reconveryInterval,
         serializer ?? prev._serializer,
         prefetchCount ?? prev._prefetchCount,
         autoAck ?? prev._autoAck,
         priority ?? prev._priority,
         cancelOnHaFailover ?? prev._cancelOnHaFailover,
         exclusive ?? prev._exclusive,
         errorStrategy ?? prev._errorStrategy,
         messageHandlerBuilder ?? prev._messageHandlerBuilder,
         topologyHandler ?? prev._topologyHandler,
         stateHandler ?? prev._stateHandler,
         channelStateHandler ?? prev._channelStateHandler,
         typeNameMapping ?? prev._typeNameMapping
     )
 {
 }
        public LinkConsumerBuilder(
            Link link,
            TimeSpan recoveryInterval,
            ILinkSerializer serializer,
            ushort?prefetchCount    = null,
            bool?autoAck            = null,
            int?priority            = null,
            bool?cancelOnHaFailover = null,
            bool?exclusive          = null,
            ILinkConsumerErrorStrategy errorStrategy = null,
            LinkConsumerMessageHandlerBuilder messageHandlerBuilder = null,
            ILinkConsumerTopologyHandler topologyHandler            = null,
            LinkStateHandler <LinkConsumerState> stateHandler       = null,
            LinkStateHandler <LinkChannelState> channelStateHandler = null,
            LinkTypeNameMapping typeNameMapping = null
            )
        {
            _link = link ?? throw new ArgumentNullException(nameof(link));

            _reconveryInterval     = recoveryInterval;
            _prefetchCount         = prefetchCount ?? 1;
            _autoAck               = autoAck ?? false;
            _priority              = priority ?? 0;
            _cancelOnHaFailover    = cancelOnHaFailover ?? false;
            _exclusive             = exclusive ?? false;
            _errorStrategy         = errorStrategy ?? new LinkConsumerDefaultErrorStrategy();
            _messageHandlerBuilder = messageHandlerBuilder;
            _topologyHandler       = topologyHandler;
            _stateHandler          = stateHandler ?? ((old, @new) => { });
            _channelStateHandler   = channelStateHandler ?? ((old, @new) => { });
            _serializer            = serializer;
            _typeNameMapping       = typeNameMapping ?? new LinkTypeNameMapping();
        }
        public ILinkConsumerBuilder Handler(LinkConsumerMessageHandlerDelegate <object> value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            return(new LinkConsumerBuilder(
                       this,
                       messageHandlerBuilder: LinkConsumerMessageHandlerBuilder.Create(value)
                       ));
        }
        public ILinkConsumerBuilder Handler <TBody>(LinkConsumerMessageHandlerDelegate <TBody> value) where TBody : class
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (typeof(TBody) == typeof(byte[]))
            {
                return(Handler(value as LinkConsumerMessageHandlerDelegate <byte[]>));
            }

            if (typeof(TBody) == typeof(object))
            {
                return(Handler(value as LinkConsumerMessageHandlerDelegate <object>));
            }

            return(new LinkConsumerBuilder(
                       this,
                       messageHandlerBuilder: LinkConsumerMessageHandlerBuilder.Create(value)
                       ));
        }