示例#1
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);
        }