protected string ComputeReceiveLocationName(IReceiveLocation <TNamingConvention> receiveLocation) { if (receiveLocation == null) { throw new ArgumentNullException(nameof(receiveLocation)); } if (receiveLocation.ReceivePort == null) { throw new NamingConventionException($"'{receiveLocation.GetType().Name}' ReceiveLocation is not bound to any receive port."); } if (Equals(Party, default(TParty))) { Party = receiveLocation.ReceivePort.Name.Party; } if (Equals(Party, default(TParty))) { throw new NamingConventionException($"'{receiveLocation.GetType().Name}' ReceiveLocation's Party is required."); } if (!Equals(Party, receiveLocation.ReceivePort.Name.Party)) { throw new NamingConventionException( $"'{receiveLocation.GetType().Name}' ReceiveLocation's Party, '{Party}', does not match its ReceivePort's one, '{receiveLocation.ReceivePort.Name.Party}'."); } if (Equals(Subject, default(TSubject))) { throw new NamingConventionException($"'{receiveLocation.GetType().Name}' ReceiveLocation's Subject is required."); } if (MessageFormat == null) { throw new NamingConventionException("A non null MessageFormat is required."); } var aggregate = ComputeAggregateName(receiveLocation.GetType()); var receivePortAggregate = ComputeAggregateName(receiveLocation.ReceivePort.GetType()); if (aggregate.IsNullOrEmpty() && !receivePortAggregate.IsNullOrEmpty()) { aggregate = receivePortAggregate; } if (!receivePortAggregate.IsNullOrEmpty() && receivePortAggregate != aggregate) { throw new NamingConventionException( $"'{receiveLocation.GetType().Name}' ReceiveLocation's Aggregate, '{aggregate}', does not match its ReceivePort's one, '{receivePortAggregate}'."); } return(string.Format( CultureInfo.InvariantCulture, "{0}{1}.RL{2}.{3}.{4}.{5}{6}", receiveLocation.ReceivePort.ApplicationBinding.ResolveName(), aggregate.IsNullOrEmpty() ? string.Empty : $".{aggregate}", receiveLocation.ReceivePort.IsTwoWay ? "2" : "1", Party, Subject, ComputeAdapterName(receiveLocation.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))); }