Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Turbocharged.Beanstalk
- {
- public class ExtendConnectionConfiguration
- {
- public string Hostname { get; set; }
- public int Port { get; set; }
- public string ProxyHostname { get; set; }
- public int ProxyPort { get; set; }
- public string ProxyUsername { get; set; }
- public string ProxyPassword { get; set; }
- public IJobSerializer JobSerializer { get; set; }
- public ExtendConnectionConfiguration()
- {
- JobSerializer = new NewtonsoftJsonJobSerializer();
- }
- public static ExtendConnectionConfiguration Parse(string hostConnectionString)
- {
- return ExtendConnectionConfiguration.Parse(hostConnectionString, "");
- }
- public static ExtendConnectionConfiguration Parse(string hostConnectionString, string proxyConnectionString)
- {
- var hostParts = hostConnectionString.Split(':');
- var proxyParts = proxyConnectionString.Split(':');
- return new ExtendConnectionConfiguration
- {
- Hostname = hostParts[0].Trim(),
- Port = Convert.ToInt32(hostParts[1].Trim()),
- ProxyHostname = (proxyParts.Length > 0 && proxyParts[0] != null) ? proxyParts[0] : "",
- ProxyPort = (proxyParts.Length > 1 && proxyParts[1] != null) ? Convert.ToInt32(proxyParts[1].Trim()) : 0,
- ProxyUsername = (proxyParts.Length > 2 && proxyParts[2] != null) ? proxyParts[2] : "",
- ProxyPassword = (proxyParts.Length > 3 && proxyParts[3] != null) ? proxyParts[3] : ""
- };
- }
- public override string ToString()
- {
- return "Host={0}:{1}; Proxy={2}:{3}; ProxyCredential={4}:{5}; JobSerializer={6}".FormatWith(
- Hostname,
- Port,
- ProxyHostname,
- ProxyPort,
- ProxyUsername,
- ProxyPassword,
- JobSerializer == null ? "null" : JobSerializer.GetType().Name);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement