private async Task ReadForwardingRulesFromFile(string readFromPath = "") { try { var file = _forwardingRulesFile; if (!string.IsNullOrEmpty(readFromPath)) { file = readFromPath; } if (string.IsNullOrEmpty(file)) { return; } if (!File.Exists(file)) { return; } var lines = await File.ReadAllLinesAsync(file); if (lines.Length > 0) { var tmpRules = new List <Rule>(); foreach (var line in lines) { if (line.StartsWith("#")) { continue; } var tmp = line.ToLower().Trim(); if (string.IsNullOrEmpty(tmp)) { continue; } var lineParts = tmp.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (lineParts.Length != 2) { continue; } var rule = new Rule { Key = lineParts[0].Trim(), Value = lineParts[1].Trim() }; tmpRules.Add(rule); } ForwardingRules.Clear(); var orderedTmpRules = tmpRules.OrderBy(r => r.Key); ForwardingRules = new BindableCollection <Rule>(orderedTmpRules); } } catch (Exception exception) { Log.Error(exception); } }
public Task RemoveForwardingRule(int loadBalancerId, ForwardingRules forwardingRules) { var parameters = new List <Parameter> { new Parameter { Name = "id", Value = loadBalancerId, Type = ParameterType.UrlSegment } }; return(_connection.ExecuteRaw("load_balancers/{id}/forwarding_rules", parameters, forwardingRules, Method.DELETE)); }