public static OptionsConfigurer AddStandardHeaderConverter(this OptionsConfigurer configurer,
                                                            IStandardHeaderOptions standardHeaderOptions = null)
 {
     standardHeaderOptions = standardHeaderOptions ?? new DefaultStandardHeaderOptions();
     // The steps are executed in the order they are registered.
     return(configurer
            .HandleMessageAddStandardHeaders(standardHeaderOptions));
 }
 public static OptionsConfigurer HandleMessageAddStandardHeaders(this OptionsConfigurer configurer, IStandardHeaderOptions standardHeaderOptions)
 {
     return(configurer
            .RegisterIncomingStep(new HandleStandardAdapterIncomingStep(standardHeaderOptions),
                                  anchorStep: typeof(DeserializeIncomingMessageStep))
            .RegisterOutgoingStep(new HandleStandardAdapterOutgoingStep(standardHeaderOptions)));
 }
 public HandleStandardAdapterOutgoingStep(IStandardHeaderOptions standardHeaderOptions)
 {
     StandardHeaderOptions = standardHeaderOptions;
 }
 public static bool IsUsableOnIncoming(TransportMessage transportMessage, IStandardHeaderOptions standardHeaderOptions)
 {
     return(transportMessage.Headers.Keys.Any(k => k.StartsWith(standardHeaderOptions.StandardHeaderPrefix)));
 }
        public static TransportMessage ConvertOutgoingTransportMessage(TransportMessage outgoingTransportMessage, IStandardHeaderOptions standardHeaderOptions)
        {
            var standardHeaders         = HeaderConverter.ConvertToStandardHeaders(outgoingTransportMessage.Headers, standardHeaderOptions);
            var updatedTransportMessage = new TransportMessage(standardHeaders, outgoingTransportMessage.Body);

            return(updatedTransportMessage);
        }
        public static TransportMessage ConvertIncomingTransportMessage(TransportMessage incomingTransportMessage, IStandardHeaderOptions standardHeaderOptions)
        {
            var standardHeaders         = incomingTransportMessage.Headers;
            var rebusHeaders            = HeaderConverter.ConvertToRebusHeaders(standardHeaders, standardHeaderOptions);
            var updatedTransportMessage = new TransportMessage(rebusHeaders, incomingTransportMessage.Body);

            return(updatedTransportMessage);
        }
Beispiel #7
0
        public static Dictionary <string, string> ConvertToRebusHeaders(Dictionary <string, string> standardHeaders, IStandardHeaderOptions standardHeaderOptions)
        {
            var rebusHeaders       = new Dictionary <string, string>(standardHeaders);
            var standardToRebusMap = standardHeaderOptions.RebusToStandardMap.ToDictionary(k => k.Value, v => v.Key);

            foreach (var header in standardHeaders
                     .Where(h => standardToRebusMap.ContainsKey(h.Key)))
            {
                rebusHeaders[standardToRebusMap[header.Key]] = header.Value;
            }

            var standardIntentKey = standardHeaderOptions.StandardIntentOptions.StandardIntentKey;

            if (standardIntentKey != null && rebusHeaders.ContainsKey(standardIntentKey))
            {
                rebusHeaders[Headers.Intent] =
                    IntentConverter.ConvertToRebusIntent(rebusHeaders[standardIntentKey], standardHeaderOptions.StandardIntentOptions);
            }

            var standardTimeSentKey = standardHeaderOptions.StandardDateTimeConverter.StandardTimeSentKey;

            if (standardTimeSentKey != null && rebusHeaders.ContainsKey(standardTimeSentKey))
            {
                rebusHeaders[Headers.SentTime] =
                    standardHeaderOptions.StandardDateTimeConverter.ToRebusHeaderValidString(rebusHeaders[standardTimeSentKey]);
            }

            return(rebusHeaders);
        }
Beispiel #8
0
        public static Dictionary <string, string> ConvertToStandardHeaders(Dictionary <string, string> rebusHeaders, IStandardHeaderOptions standardHeaderOptions)
        {
            var standardHeaders = new Dictionary <string, string>(rebusHeaders);

            foreach (var header in rebusHeaders
                     .Where(h => standardHeaderOptions.RebusToStandardMap.ContainsKey(h.Key)))
            {
                standardHeaders[standardHeaderOptions.RebusToStandardMap[header.Key]] = header.Value;
            }

            var standardIntentKey = standardHeaderOptions.StandardIntentOptions.StandardIntentKey;

            if (standardIntentKey != null && standardHeaders.ContainsKey(standardIntentKey))
            {
                standardHeaders[standardIntentKey] =
                    IntentConverter.ConvertToStandardIntent(standardHeaders[standardIntentKey], standardHeaderOptions.StandardIntentOptions);
            }

            var standardTimeSentKey = standardHeaderOptions.StandardDateTimeConverter.StandardTimeSentKey;

            if (standardTimeSentKey != null)
            {
                standardHeaders[standardTimeSentKey] =
                    standardHeaderOptions.StandardDateTimeConverter.ToStandardHeaderValidString(DateTime.UtcNow);
            }

            return(standardHeaders);
        }