<commit_before>using System.Collections.Generic;
using Castle.Core.Configuration;

namespace Rhino.ServiceBus.Hosting
{
    public class HostConfiguration
    {
        private string Endpoint { get; set; }
        private int ThreadCount { get; set; }
        private int NumberOfRetries { get; set; }
        private string LoadBalancerEndpoint { get; set; }
        protected string LogEndpoint { get; set; }
        private IDictionary<string, string> Messages { get; set; }

        public HostConfiguration()
        {
            ThreadCount = 1;
            NumberOfRetries = 5;
            Messages = new Dictionary<string, string>();
        }

        public HostConfiguration Bus(string endpoint)
        {
            Endpoint = endpoint;
            return this;
        }

        public HostConfiguration Threads(int threadCount)
        {
            ThreadCount = threadCount;
            return this;
        }

        public HostConfiguration Retries(int numberOfRetries)
        {
            NumberOfRetries = numberOfRetries;
            return this;
        }

        public HostConfiguration LoadBalancer(string endpoint)
        {
            LoadBalancerEndpoint = endpoint;
            return this;
        }

        public HostConfiguration Logging(string endpoint)
        {
            LogEndpoint = endpoint;
            return this;
        }

        public HostConfiguration Receive(string messageName, string endpoint)
        {
            Messages.Add(messageName, endpoint);
            return this;
        }

        public IConfiguration ToIConfiguration()
        {
            var config = new MutableConfiguration("rhino.esb");

            var busConfig = config.CreateChild("bus")
                .Attribute("endpoint", Endpoint)
                .Attribute("threadCount", ThreadCount.ToString())
                .Attribute("numberOfRetries", NumberOfRetries.ToString());

            if (string.IsNullOrEmpty(LoadBalancerEndpoint) == false)
                busConfig.Attribute("loadBalancerEndpoint", LoadBalancerEndpoint);

            if (string.IsNullOrEmpty(LogEndpoint) == false)
                busConfig.Attribute("logEndpoint", LogEndpoint);

            var messagesConfig = config.CreateChild("messages");

            foreach (var message in Messages)
            {
                messagesConfig.CreateChild("add")
                    .Attribute("name", message.Key)
                    .Attribute("endpoint", message.Value);
            }

            return config;
        }
    }
}<commit_msg>Added option to set the bus name in HostConfiguration, so Rhino Queues buses can be configured correctly.<commit_after>using System.Collections.Generic;
using Castle.Core.Configuration;

namespace Rhino.ServiceBus.Hosting
{
    public class HostConfiguration
    {
        private string Name { get; set; }
        private string Endpoint { get; set; }
        private int ThreadCount { get; set; }
        private int NumberOfRetries { get; set; }
        private string LoadBalancerEndpoint { get; set; }
        protected string LogEndpoint { get; set; }
        private IDictionary<string, string> Messages { get; set; }

        public HostConfiguration()
        {
            ThreadCount = 1;
            NumberOfRetries = 5;
            Messages = new Dictionary<string, string>();
        }

        public HostConfiguration Bus(string endpoint)
        {
            Endpoint = endpoint;
            return this;
        }

        public HostConfiguration Bus(string endpoint, string name)
        {
            Bus(endpoint);
            Name = name;
            return this;
        }

        public HostConfiguration Threads(int threadCount)
        {
            ThreadCount = threadCount;
            return this;
        }

        public HostConfiguration Retries(int numberOfRetries)
        {
            NumberOfRetries = numberOfRetries;
            return this;
        }

        public HostConfiguration LoadBalancer(string endpoint)
        {
            LoadBalancerEndpoint = endpoint;
            return this;
        }

        public HostConfiguration Logging(string endpoint)
        {
            LogEndpoint = endpoint;
            return this;
        }

        public HostConfiguration Receive(string messageName, string endpoint)
        {
            Messages.Add(messageName, endpoint);
            return this;
        }

        public IConfiguration ToIConfiguration()
        {
            var config = new MutableConfiguration("rhino.esb");

            var busConfig = config.CreateChild("bus")
                .Attribute("endpoint", Endpoint)
                .Attribute("threadCount", ThreadCount.ToString())
                .Attribute("numberOfRetries", NumberOfRetries.ToString());

            if (string.IsNullOrEmpty(Name) == false)
                busConfig.Attribute("name", Name);

            if (string.IsNullOrEmpty(LoadBalancerEndpoint) == false)
                busConfig.Attribute("loadBalancerEndpoint", LoadBalancerEndpoint);

            if (string.IsNullOrEmpty(LogEndpoint) == false)
                busConfig.Attribute("logEndpoint", LogEndpoint);

            var messagesConfig = config.CreateChild("messages");

            foreach (var message in Messages)
            {
                messagesConfig.CreateChild("add")
                    .Attribute("name", message.Key)
                    .Attribute("endpoint", message.Value);
            }

            return config;
        }
    }
}
{'fraction_non_alphanumeric': 0.07735485002631118, 'fraction_numerical': 0.0007016312927556569, 'mean_word_length': 1.6795112781954886, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5927097', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1259, 'n_words': 319}