public static NamespacePattern CreateNamespacePattern(this ITopicMessage message, string namespacePattern)
        {
            var scope = new NamespacePattern(namespacePattern);

            if (message is INamespaceScopedTopicMessage namespaceMessage)
            {
                scope = namespaceMessage.NamespacePattern.Concat(scope);
            }

            return(scope);
        }
        public static IRecordedMessage Create(IRecordedMessage recordedMessage, NamespacePattern namespacePattern)
        {
            if (recordedMessage == null)
            {
                return(null);
            }

            if (recordedMessage is INamespaceScopedTopicMessage <IRecordedMessage> namespaceScopedMessage)
            {
                namespacePattern = namespaceScopedMessage.NamespacePattern.Concat(namespacePattern);
                recordedMessage  = namespaceScopedMessage.InnerMessage;
            }

            return(new NamespaceScopedRecordedMessageWrapper(recordedMessage, namespacePattern));
        }
Example #3
0
        public static NamespacePattern Concat(NamespacePattern first, NamespacePattern second)
        {
            if (first == null)
            {
                throw new ArgumentNullException(nameof(first));
            }
            if (second == null)
            {
                throw new ArgumentNullException(nameof(second));
            }

            if (second.IsGlobalPattern)
            {
                throw new InvalidRosNamePatternException(
                          "Cannot append a global namespace pattern to another pattern.");
            }

            var ns = first.Pattern + "/" + second.Pattern;

            return(new NamespacePattern(ns));
        }
Example #4
0
 public NamespacePattern Concat(NamespacePattern other)
 {
     return(Concat(this, other));
 }
Example #5
0
 public bool Equals(NamespacePattern other)
 {
     return(Pattern == other.Pattern);
 }
 public NamespaceScopedRecordedMessageWrapper(IRecordedMessage recordedMessage, NamespacePattern namespacePattern)
 {
     NamespacePattern = namespacePattern ?? throw new ArgumentNullException(nameof(namespacePattern));
     InnerMessage     = recordedMessage ?? throw new ArgumentNullException(nameof(recordedMessage));
 }