/// <summary> /// Gets the parsed configuration. /// </summary> /// <param name="profiles">The profiles.</param> /// <param name="startupProjects">The startup projects.</param> /// <param name="currentStartupProjects">The current startup projects.</param> /// <returns>The parsed configuration.</returns> private ParsedConfiguration GetParsedConfiguration(ICollection <Profile> profiles, ICollection <string> startupProjects, ICollection <string> currentStartupProjects) { var parseConfigurationEventArgs = new ParseConfigurationEventArgs(profiles, startupProjects, currentStartupProjects); ParseConfiguration?.Invoke(this, parseConfigurationEventArgs); return(parseConfigurationEventArgs.ParsedConfiguration); }
public void TestCurrentConfig() { ParseConfiguration config = Client.GetCurrentConfiguration(); Assert.AreEqual("testValue", config["testKey"]); Assert.AreEqual("testValue", config.Get <string>("testKey")); }
public void SetUp() { Trigger = new AutoResetEvent(false); if (NeedAServer) { Server = new FakeServer(); ParseConfiguration.Configure("the-app-id", "shhh", c => c.ConnectTo("http://localhost:" + FakeServer.Port + "/")); } BeforeEachTest(); }
public async Task Test_AngleSharpParser_OnFullReadFile_And_Count_ResultTexts() { var fileName = Path.Combine(TestContext.CurrentContext.GetTestProjectPath(), @"SampleFiles\Создаем программное обеспечение для бизнеса - SimbirSoft.html"); var fileContent = await File.ReadAllTextAsync(fileName); var configuration = ParseConfiguration.Default(); var parser = new AngleSharpParser(configuration.ExcludeTags); var texts = (await parser.ParseAsync(fileContent)).ToList(); Assert.AreEqual(290, texts.Count); }
public void Test_ManualParser_OnFullReadFile_And_Count_ResultTexts() { var fileName = Path.Combine(TestContext.CurrentContext.GetTestProjectPath(), @"SampleFiles\Создаем программное обеспечение для бизнеса - SimbirSoft.html"); var fileContent = File.ReadAllText(fileName); var configuration = ParseConfiguration.Default(); var parser = new ManualParser(configuration.ExcludeTags); parser.ParseBlock(fileContent); Assert.AreEqual(250, parser.ResultTexts.Count()); }
protected override bool Handle(ParseCommand command) { if (!File.Exists(command.InputPath)) { _logger.Error("Incorrect input path"); return(false); } string path = Path.GetDirectoryName(command.InputPath); if (path == null) { _logger.Error("Can't get parent directory"); return(false); } _logger.Info("==================================================="); _logger.Info(" PARSING"); _logger.Info("==================================================="); _logger.Info("SETUP"); _logger.Info($"Deserializing {Path.GetFileName(command.InputPath)}..."); ParseConfiguration configuration = JsonConvert.DeserializeObject <ParseConfiguration>(File.ReadAllText(command.InputPath)); if (configuration == null) { _logger.Error($"Failed to deserialize {Path.GetFileName(command.InputPath)}"); return(false); } DateTime start = DateTime.Now; foreach (Parser parser in _parsers) { _logger.Info("---------------------------------------------------"); parser.Parse(configuration, path); } _logger.Info("==================================================="); TimeSpan timeElapsed = DateTime.Now - start; _logger.Info($"Parsing finished in {(timeElapsed.TotalMinutes >= 1 ? timeElapsed.Minutes + "mn " : string.Empty)}{timeElapsed.Seconds}s"); _logger.Info("==================================================="); return(true); }
public IEnumerable <Event> Parse(ParseConfiguration config) { var cities = config.City.Split(' '); foreach (var city in cities) { var events = GetEvents(city); foreach (var eventNode in events) { if (!CanParse(eventNode)) { continue; } if (IsTypeAndCostNull(config.Type, config.Cost)) { AddParsedEvent(eventNode, city); } else if (IsCostNull(config.Type, config.Cost)) { if (NodeDesc(eventNode).Contains(config.Type)) { AddParsedEvent(eventNode, city); } } else if (IsTypeNull(config.Type)) { if (NodeCost(eventNode).Contains(config.Cost)) { AddParsedEvent(eventNode, city); } } else { if (NodeCost(eventNode).Contains(config.Cost) && NodeDesc(eventNode).Contains(config.Type)) { AddParsedEvent(eventNode, city); } } } } return(_eventsList); }
public async Task Test_RunFullReadStraregy_OnFullReadFile_And_Count_Output_Lines() { var fileName = Path.Combine(TestContext.CurrentContext.GetTestProjectPath(), @"SampleFiles\Создаем программное обеспечение для бизнеса - SimbirSoft.html"); var fileContent = await File.ReadAllTextAsync(fileName); var configuration = ParseConfiguration.Default(); var sb = new StringBuilder(); configuration.TextWriter = new StringWriter(sb); var strategy = new PartialReadParseStrategy(configuration); await strategy.Parse(fileContent); var outResult = sb.ToString(); var tokens = outResult.Split("\n"); Assert.AreEqual(729, tokens.Length); }
public async Task Test_RunPartialReadStraregy_OnFileStream_And_Count_Output_Lines() { var fileName = Path.Combine(TestContext.CurrentContext.GetTestProjectPath(), @"SampleFiles\Метаданные HTML-документа.html"); using var streamReader = new StreamReader(fileName); var configuration = ParseConfiguration.Default(); var sb = new StringBuilder(); configuration.TextWriter = new StringWriter(sb); var strategy = new PartialReadParseStrategy(configuration); await strategy.Parse(streamReader); var outResult = sb.ToString(); var tokens = outResult.Split("\n"); Assert.AreEqual(502, tokens.Length); }
public FullReadParseStrategy(ParseConfiguration configuration) : base(configuration) { }
public void GetConfigServers_NpgsqlTest_ReturnIsNotNull() { ParseConfiguration parseConfiguration = new ParseConfiguration(); Assert.IsNotNull(parseConfiguration.GetConfigServers_Npgsql()); }
protected ParseStrategyBase(ParseConfiguration configuration) { Configuration = configuration; }
protected ParseStrategyBase() { Configuration = ParseConfiguration.Default(); }