public void MultilineListQuotedProperty() { var md = string.Join(Environment.NewLine, "* Key:", " + `SK1`", " + <sk2>", " + SK3 : v3", " + SK4: `v4`", " + `SK5`:`v5`", " + <SK6>: `v6`", " + `SK7`:<v7>", " + `$abc:123$`"); var cfg = new GroupedPropertyCollection(); var parser = new MarkdownPropertyParser(cfg); using (var r = new StringReader(md)) { parser.Parse(r); } Assert.AreEqual(new[] { "SK1", "sk2", "SK3 : v3", "SK4: v4", "SK5:v5", "SK6: v6", "SK7:v7", "$abc:123$" }, cfg.GetValue("Key")); }
public void OneLineListProperty() { var md = "* Key: `ABC`, `XYZ`, `123`"; var cfg = new GroupedPropertyCollection(); var parser = new MarkdownPropertyParser(cfg); using (var r = new StringReader(md)) { parser.Parse(r); } Assert.AreEqual(new[] { "ABC", "XYZ", "123" }, cfg.GetValue("Key")); }
public void QuotedProperties() { var md = "* K1: `Value`\n* K2: <Value2>"; var cfg = new GroupedPropertyCollection(); var parser = new MarkdownPropertyParser(cfg); using (var r = new StringReader(md)) { parser.Parse(r); } Assert.AreEqual("Value", cfg.GetValue("K1")); Assert.AreEqual("Value2", cfg.GetValue("K2")); }
/// <summary> /// Initializes a new instance of <see cref="BenchConfiguration"/> /// loading the specified set of configuration and app library files. /// </summary> /// <param name="benchRootDir">The absolute path to the root directory of Bench.</param> /// <param name="loadAppIndex">A flag to control if app library files are going to be loaded.</param> /// <param name="loadCustomConfiguration">A flag to control if custom configuration files are going to be loaded.</param> /// <param name="loadSiteConfiguration">A flag to control if site configuration files are going to be loaded.</param> public BenchConfiguration(string benchRootDir, bool loadAppIndex, bool loadCustomConfiguration, bool loadSiteConfiguration) { BenchRootDir = benchRootDir; WithAppIndex = loadAppIndex; WithCustomConfiguration = loadCustomConfiguration; WithSiteConfiguration = loadSiteConfiguration; AddResolver(new GroupedVariableResolver(this)); AddResolver(new VariableResolver(this)); AddResolver(new PathResolver(IsPathProperty, GetBaseForPathProperty)); var parser = new MarkdownPropertyParser { Target = this, GroupBeginCue = new Regex("^[\\*\\+-]\\s+ID:\\s*(`?)(?<group>\\S+?)\\1$"), GroupEndCue = new Regex("^\\s*$"), }; var configFile = Path.Combine(benchRootDir, ConfigFile); Debug.WriteLine("Looking for default configuration: " + configFile); if (!File.Exists(configFile)) { throw new FileNotFoundException("The default configuration for Bench was not found.", configFile); } using (var configStream = File.OpenRead(configFile)) { Debug.WriteLine("Reading default configuration ..."); parser.Parse(configStream); } siteConfigFileName = GetStringValue(PropertyKeys.SiteConfigFileName); if (loadCustomConfiguration) { var customConfigFile = GetStringValue(PropertyKeys.CustomConfigFile); Debug.WriteLine("Looking for custom config file: " + customConfigFile); if (File.Exists(customConfigFile)) { using (var customConfigStream = File.OpenRead(customConfigFile)) { Debug.WriteLine("Reading custom configuration ..."); parser.Parse(customConfigStream); } } } if (loadSiteConfiguration) { Debug.WriteLine("Looking for site config file(s): " + siteConfigFileName); var siteConfigFiles = FindSiteConfigFiles(benchRootDir, siteConfigFileName); foreach(var file in siteConfigFiles) { using (var siteConfigStream = File.OpenRead(file)) { Debug.WriteLine("Reading site configuration '" + file + "' ..."); parser.Parse(siteConfigStream); } } } if (loadAppIndex) { var appIndexFile = GetStringValue(PropertyKeys.AppIndexFile); Debug.WriteLine("Looking for application index: " + appIndexFile); if (!File.Exists(appIndexFile)) { throw new FileNotFoundException("The default app index for Bench was not found.", appIndexFile); } using (var appIndexStream = File.OpenRead(appIndexFile)) { Debug.WriteLine("Reading default application index ..."); parser.Parse(appIndexStream); } if (loadCustomConfiguration) { var customAppIndexFile = GetStringValue(PropertyKeys.CustomAppIndexFile); Debug.WriteLine("Looking for custom application index: " + customAppIndexFile); if (File.Exists(customAppIndexFile)) { using (var customAppIndexStream = File.OpenRead(customAppIndexFile)) { Debug.WriteLine("Reading custom application index ..."); parser.Parse(customAppIndexStream); } } } } AddResolver(new AppIndexValueResolver(this)); GroupedDefaultValueSource = new AppIndexDefaultValueSource(this); appIndexFacade = new AppIndexFacade(this); AutomaticConfiguration(); AutomaticActivation(loadCustomConfiguration); RecordResponsibilities(); }
public void SimpleProperty() { var md = "* Key: Value"; var cfg = new GroupedPropertyCollection(); var parser = new MarkdownPropertyParser(cfg); using (var r = new StringReader(md)) { parser.Parse(r); } Assert.AreEqual("Value", cfg.GetValue("Key")); }