protected string ComputeSendPortName(ISendPort <TNamingConvention> sendPort)
        {
            if (sendPort.ApplicationBinding == null)
            {
                throw new NamingConventionException(
                          string.Format(
                              "'{0}' SendPort is not bound to application's send port collection.",
                              sendPort.GetType().Name));
            }
            if (Equals(Party, default(TParty)))
            {
                throw new NamingConventionException(
                          string.Format(
                              "'{0}' SendPort's Party is required.",
                              sendPort.GetType().Name));
            }
            if (Equals(MessageName, default(TMessageName)))
            {
                throw new NamingConventionException(
                          string.Format(
                              "'{0}' SendPort's MessageName is required.",
                              sendPort.GetType().Name));
            }
            if (MessageFormat == null)
            {
                throw new NamingConventionException("A non null MessageFormat is required.");
            }

            var area = ComputeArea(sendPort.GetType());

            return(string.Format(
                       "{0}{1}.SP{2}.{3}.{4}.{5}{6}",
                       ((ISupportNamingConvention)sendPort.ApplicationBinding).Name,
                       area.IsNullOrEmpty() ? string.Empty : string.Format(".{0}", area),
                       sendPort.IsTwoWay ? "2" : "1",
                       Party,
                       MessageName,
                       ComputeAdapterName(sendPort.Transport.Adapter),
                       MessageFormat.IsNullOrEmpty() ? string.Empty : string.Format(".{0}", MessageFormat)));
        }
        protected string ComputeSendPortName(ISendPort <TNamingConvention> sendPort)
        {
            if (sendPort == null)
            {
                throw new ArgumentNullException(nameof(sendPort));
            }
            if (sendPort.ApplicationBinding == null)
            {
                throw new NamingConventionException($"'{sendPort.GetType().Name}' SendPort is not bound to application's send port collection.");
            }
            if (Equals(Party, default(TParty)))
            {
                throw new NamingConventionException($"'{sendPort.GetType().Name}' SendPort's Party is required.");
            }
            if (Equals(Subject, default(TSubject)))
            {
                throw new NamingConventionException($"'{sendPort.GetType().Name}' SendPort's Subject is required.");
            }
            if (MessageFormat == null)
            {
                throw new NamingConventionException("A non null MessageFormat is required.");
            }

            var aggregate = ComputeAggregateName(sendPort.GetType());

            return(string.Format(
                       CultureInfo.InvariantCulture,
                       "{0}{1}.SP{2}.{3}.{4}.{5}{6}",
                       sendPort.ApplicationBinding.ResolveName(),
                       aggregate.IsNullOrEmpty() ? string.Empty : $".{aggregate}",
                       sendPort.IsTwoWay ? "2" : "1",
                       Party,
                       Subject,
                       ComputeAdapterName(sendPort.Transport.Adapter),
                       MessageFormat.IsNullOrEmpty() ? string.Empty : $".{MessageFormat}"));
        }
        protected string ComputeReceiveLocationName(IReceiveLocation <TNamingConvention> receiveLocation)
        {
            if (receiveLocation.ReceivePort == null)
            {
                throw new NamingConventionException(
                          string.Format(
                              "'{0}' ReceiveLocation is not bound to any receive port.",
                              receiveLocation.GetType().Name));
            }
            if (Equals(Party, default(TParty)))
            {
                Party = receiveLocation.ReceivePort.Name.Party;
            }
            if (Equals(Party, default(TParty)))
            {
                throw new NamingConventionException(
                          string.Format(
                              "'{0}' ReceiveLocation's Party is required.",
                              receiveLocation.GetType().Name));
            }
            if (!Equals(Party, receiveLocation.ReceivePort.Name.Party))
            {
                throw new NamingConventionException(
                          string.Format(
                              "'{0}' ReceiveLocation's Party, '{1}', does not match its ReceivePort's one, '{2}'.",
                              receiveLocation.GetType().Name,
                              Party,
                              receiveLocation.ReceivePort.Name.Party));
            }
            if (Equals(MessageName, default(TMessageName)))
            {
                throw new NamingConventionException(
                          string.Format(
                              "'{0}' ReceiveLocation's MessageName is required.",
                              receiveLocation.GetType().Name));
            }
            if (MessageFormat == null)
            {
                throw new NamingConventionException("A non null MessageFormat is required.");
            }

            var area            = ComputeArea(receiveLocation.GetType());
            var receivePortArea = ComputeArea(receiveLocation.ReceivePort.GetType());

            if (area.IsNullOrEmpty() && !receivePortArea.IsNullOrEmpty())
            {
                area = receivePortArea;
            }
            if (!receivePortArea.IsNullOrEmpty() && receivePortArea != area)
            {
                throw new NamingConventionException(
                          string.Format(
                              "'{0}' ReceiveLocation's Area, '{1}', does not match its ReceivePort's one, '{2}'.",
                              receiveLocation.GetType().Name,
                              area,
                              receivePortArea));
            }

            return(string.Format(
                       "{0}{1}.RL{2}.{3}.{4}.{5}{6}",
                       ((ISupportNamingConvention)receiveLocation.ReceivePort.ApplicationBinding).Name,
                       area.IsNullOrEmpty() ? string.Empty : string.Format(".{0}", area),
                       receiveLocation.ReceivePort.IsTwoWay ? "2" : "1",
                       Party,
                       MessageName,
                       ComputeAdapterName(receiveLocation.Transport.Adapter),
                       MessageFormat.IsNullOrEmpty() ? string.Empty : string.Format(".{0}", MessageFormat)));
        }