Esempio n. 1
0
        private static void DoAdd(IServiceCollection services, RabbitServiceInfo info, IConfiguration config, ServiceLifetime contextLifetime)
        {
            RabbitProviderConnectorOptions rabbitConfig = new RabbitProviderConnectorOptions(config);
            RabbitProviderConnectorFactory factory      = new RabbitProviderConnectorFactory(info, rabbitConfig);

            services.Add(new ServiceDescriptor(typeof(ConnectionFactory), factory.Create, contextLifetime));
        }
        public RabbitProviderConnectorFactory(RabbitServiceInfo sinfo, RabbitProviderConnectorOptions config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            _info   = sinfo;
            _config = config;
        }
        internal void UpdateConfiguration(RabbitServiceInfo si, RabbitProviderConnectorOptions configuration)
        {
            if (si == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(si.Uri))
            {
                configuration.Port        = si.Port;
                configuration.Username    = si.UserName;
                configuration.Password    = si.Password;
                configuration.Server      = si.Host;
                configuration.VirtualHost = si.Path;
            }
        }
 internal string Configure(RabbitServiceInfo si, RabbitProviderConnectorOptions configuration)
 {
     UpdateConfiguration(si, configuration);
     return(configuration.ToString());
 }