private static void ApplyTilesProxy(this TileManager tiles, AppConfig config) { if (config.TilesUseProxy) { if (config.TilesAutoDetectProxy) { tiles.AutodetectProxy(); } else { var parts = config.TilesProxyAddress.Split(':'); if (parts.Length == 2) { int port; if (int.TryParse(parts[1], out port)) { tiles.SetProxy(parts[0], port); } } } tiles.SetProxyAuthentication(config.TilesProxyUserName, config.TilesProxyPassword, string.Empty); } else { tiles.SetProxy(string.Empty, 80); tiles.ClearProxyAuthorization(); } }