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 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); }