public static IEnumerable <IRecordedMessage <TType> > InNamespace <TType>(this IEnumerable <IRecordedMessage <TType> > messages, string namespacePattern) { return(messages .Where(m => m.IsInNamespace(namespacePattern)) .Select(m => NamespaceScopedRecordedMessage.Create(m, namespacePattern))); }
public static IRecordedMessage <TType> SetMessageType <TType>(this IRecordedMessage message) where TType : class { if (message is INamespaceScopedTopicMessage <IRecordedMessage> namespaceScopedMessage) { var innerMessage = namespaceScopedMessage.InnerMessage; var typedMessage = new RecordedMessage <TType>(innerMessage); return(NamespaceScopedRecordedMessage.Create(typedMessage, namespaceScopedMessage.NamespacePattern)); } else { return(new RecordedMessage <TType>(message)); } }
public static IEnumerable <IGrouping <string, IRecordedMessage> > GroupByNamespace(this IEnumerable <IRecordedMessage> messages) { return(messages .SelectMany(m => { return ExpandNamespaces(m.Topic) .Select(ns => new { Namespace = ns, Message = NamespaceScopedRecordedMessage.Create(m, ns) }); }) .GroupBy(x => x.Namespace, x => x.Message)); }