public static void Parse() { if (!File.Exists(MainFilePath)) { return; } var content = File.ReadAllText(MainFilePath); if (!content.Contains("options")) { return; } var model = new BindModel { Active = false }; model = BindParser.ParseOptions(model, content); model = BindParser.ParseControl(model, content); model = BindParser.ParseKeySecret(model, content); model = BindParser.ParseLogging(model, content); var acls = BindParser.ParseAcl(content).ToArray(); model.AclList = acls; var simpleZone = BindParser.ParseSimpleZones(content).ToList(); var complexZone = BindParser.ParseComplexZones(content).ToList(); complexZone.AddRange(simpleZone); model.Zones = complexZone; var includes = BindParser.ParseInclude(content).ToArray(); model.IncludeFiles = includes; Application.CurrentConfiguration.Services.Bind = model; ConsoleLogger.Log("[bind] import existing configuration"); }
private void btnOk_Click(object sender, EventArgs e) { this.DNSRecords = new List <DNSRecord>(); StringBuilder errors = new StringBuilder(); foreach (string line in tbInput.Lines) { try { if (line.Trim() == "") { continue; } DNSRecord record = BindParser.ParseLine(line); this.DNSRecords.Add(record); } catch (Exception E) { errors.Append(line); errors.Append(Environment.NewLine); } } this.Errors = errors.ToString(); this.DialogResult = DialogResult.OK; this.Close(); }
private static BindConfigurationModel Parse(string text) { var model = new BindConfigurationModel { IsActive = false }; model = BindParser.ParseOptions(model, text); model = BindParser.ParseControl(model, text); model = BindParser.ParseKeySecret(model, text); model = BindParser.ParseLogging(model, text); var acls = BindParser.ParseAcl(text).ToList(); model.AclList = acls; var simpleZone = BindParser.ParseSimpleZones(text).ToList(); var complexZone = BindParser.ParseComplexZones(text).ToList(); complexZone.AddRange(simpleZone); model.Zones = complexZone; var includes = BindParser.ParseInclude(text).ToList(); model.IncludeFiles = includes; if (Directory.Exists(MainZonesPath)) { model.ZoneFiles = Directory.EnumerateFiles(MainZonesPath, "*.db").Select(_ => new BindConfigurationZoneFileModel { Name = _ }).ToList(); ParseZoneFile(""); } return(model); }
public static bool Parse(SyntaxContext context, int position) { var list = context.list; var offset = 0; var index = position; var count = 0; var isMissed = false; count = 0; while (true) { while (ReturnParser.Parse(context, index)) { ; } while (BreakParser.Parse(context, index)) { ; } while (DoParser.Parse(context, index)) { ; } while (WhileParser.Parse(context, index)) { ; } while (ForNParser.Parse(context, index)) { ; } while (ForParser.Parse(context, index)) { ; } while (ForEachParser.Parse(context, index)) { ; } while (FunctionNParser.Parse(context, index)) { ; } while (FunctionSParser.Parse(context, index)) { ; } while (IfParser.Parse(context, index)) { ; } while (IfElseParser.Parse(context, index)) { ; } while (DefineNParser.Parse(context, index)) { ; } while (CallParser.Parse(context, index)) { ; } while (BindParser.Parse(context, index)) { ; } while (BindNParser.Parse(context, index)) { ; } if (context.isMissed) { context.isMissed = false; offset += 1; index = position + offset; count += 1; break; } if (!list[index].isStatement) { break; } else { // ignored } offset += 1; index = position + offset; count += 1; } if (count == 0) { return(false); } context.Insert(position, ExpressionCreator.CreateModule(list, position, offset)); context.Remove(position + 1, offset); return(true); }