NServiceBus.StaticHeadersConfigExtensions.AddHeaderToAllOutgoingMessages C# (CSharp) Method

AddHeaderToAllOutgoingMessages() public static method

Adds a header that will be attached to all outgoing messages for this endpoint. These headers can not be changed at runtime. Use a outgoing message mutator if you need to apply headers that needs to be dynamic per message. You can also set headers explicitly for a given message using any of the Send/Reply or PublishOptions.
public static AddHeaderToAllOutgoingMessages ( this config, string key, string value ) : void
config this The instance to apply the settings to.
key string The static header key.
value string The static header value.
return void
        public static void AddHeaderToAllOutgoingMessages(this EndpointConfiguration config, string key, string value)
        {
            Guard.AgainstNullAndEmpty(nameof(key), key);

            CurrentStaticHeaders headers;

            if (!config.Settings.TryGet(out headers))
            {
                headers = new CurrentStaticHeaders();

                config.Settings.Set<CurrentStaticHeaders>(headers);
            }


            headers[key] = value;
        }
    }
StaticHeadersConfigExtensions