예제 #1
0
        private static IConnectionFactory CreateDefaultConnectionFactory(ClusterElement cluster)
        {
            List <EndPoint> endpoints = new List <EndPoint>();

            foreach (EndPointElement ep in cluster.EndPoints)
            {
                IPAddress ip;
                if (IPAddress.TryParse(ep.Address, out ip))
                {
                    endpoints.Add(new IPEndPoint(ip, ep.Port));
                }
                else
                {
                    endpoints.Add(new DnsEndPoint(ep.Address, ep.Port));
                }
            }

            var connectionFactory = new DefaultConnectionFactory(endpoints);

            if (!String.IsNullOrEmpty(cluster.AuthorizationKey))
            {
                connectionFactory.AuthorizationKey = cluster.AuthorizationKey;
            }

            if (cluster.DefaultLogger != null && cluster.DefaultLogger.Enabled)
            {
                connectionFactory.Logger = new DefaultLogger(cluster.DefaultLogger.Category, Console.Out);
            }

            return(connectionFactory);
        }
예제 #2
0
        private static IConnectionFactory CreateDefaultConnectionFactory(ClusterElement cluster)
        {
            List<EndPoint> endpoints = new List<EndPoint>();
            foreach (EndPointElement ep in cluster.EndPoints)
            {
                IPAddress ip;
                if (IPAddress.TryParse(ep.Address, out ip))
                    endpoints.Add(new IPEndPoint(ip, ep.Port));
                else
                    endpoints.Add(new DnsEndPoint(ep.Address, ep.Port));
            }

            var connectionFactory = new NewtonsoftConnectionFactory(endpoints);

            if (!String.IsNullOrEmpty(cluster.AuthorizationKey))
                connectionFactory.AuthorizationKey = cluster.AuthorizationKey;

            if (cluster.DefaultLogger != null && cluster.DefaultLogger.Enabled)
                connectionFactory.Logger = new DefaultLogger(cluster.DefaultLogger.Category, Console.Out);

            return connectionFactory;
        }