public void Execute(Dictionary<string, string> parameters, Processor processor) { var currDate = DateTime.Now; processor.AddDomain("DateTimePreprocessor"); processor.GetDomain("DateTimePreprocessor").Add("CURRENT_DATE", currDate.ToShortDateString()); processor.GetDomain("DateTimePreprocessor").Add("CURRENT_TIME", currDate.ToShortTimeString()); }
public void FormatCollector(Dictionary<string, string> parameters, Dictionary<string, string> collectorDict, System.Xml.Linq.XElement collectorElement, Type collectorType, Processor processor) { CollectorHelpers.IsCollectorFormatterValid(collectorType, "NasuTek.Monitoring.Service.BuiltIn.Collectors.FileCollector"); switch (collectorType.FullName) { case "NasuTek.Monitoring.Service.BuiltIn.Collectors.FileCollector": { string[] files = collectorDict["Files"].Split(','); var dictRet = new Dictionary<string, Dictionary<string, string>>(); foreach (var file in files) { var xmlDoc = XDocument.Load(file); foreach (var xmlRefVal in collectorElement.Elements("XmlRefToKeyValue")) { processor.AddDomain(xmlRefVal.Attribute("domain").Value, Path.GetFileName(file)); XElement ele = xmlDoc.XPathSelectElement(xmlRefVal.Attribute("name").Value); if (ele != null) processor.GetDomain(xmlRefVal.Attribute("domain").Value, Path.GetFileName(file))[xmlRefVal.Attribute("domain_key").Value] = ele.Value; } } } break; } }
public void TestFormatter() { var processor = new Processor(); processor.AddDomain("TestDomain"); processor.AddDomain("TestDomain", "SubDomain"); processor.GetDomain("TestDomain").Add("TestKey", "This is a test."); processor.GetDomain("TestDomain", "SubDomain").Add("TestKey", "This is a subdomain test."); var formatStr1 = "##TestDomain.TestKey##"; var formatOut1 = processor.FormatString(formatStr1); var formatStr2 = "##TestDomain:SubDomain.TestKey##"; var formatOut2 = processor.FormatString(formatStr2); var formatStr3 = "##TestDomain.TestKey####TestDomain:SubDomain.TestKey##"; var formatOut3 = processor.FormatString(formatStr3); Assert.AreEqual("This is a test.", formatOut1); Assert.AreEqual("This is a subdomain test.", formatOut2); Assert.AreEqual("This is a test.This is a subdomain test.", formatOut3); }
public void TestFormatterWithNewlineOptionsAndSameReplacers() { var processor = new Processor(); processor.AddDomain("TestDomain"); processor.GetDomain("TestDomain").Add("TestKey", "This is a test."); var formatStr = @"<@<% TestOption test=""Parameter"" %>@> ##TestDomain.TestKey##<% TestOption test=""Parameter"" %>##TestDomain.TestKey##"; var formatOut = processor.FormatString(formatStr); Assert.AreEqual("This is a test.This is a test.", formatOut); }
public void Execute(Dictionary<string, string> parameters, Processor processor) { var storageDomain = processor.GetStorageDomain(parameters["storageDomain"]); processor.AddDomain(parameters["domain"]); var domain = processor.GetDomain(parameters["domain"]); var xmlDocument = XDocument.Load(parameters["xmlFile"]); foreach (var xmlDefines in storageDomain) { var path = xmlDefines.Value.Split(':'); var element = xmlDocument.XPathSelectElement(path[0]); if (element == null) continue; domain.Add(xmlDefines.Key, path.Length == 2 ? element.Attribute(path[1]).Value : element.Value); } }
public void TestFormatterWithConvertersAndOptions() { var processor = new Processor(); processor.AddDomain("TestDomain"); processor.GetDomain("TestDomain").Add("TestKey", "This is a test."); var formatStr = @"<@ <% Import dll=""NasuTek.Preprocessor.ProcessingLibrary.Tests.dll"" %> <% Import namespace=""NasuTek.Preprocessor.ProcessingLibrary.Tests"" %> @> ##TestDomain.TestKey(TestConverter[Demo=""Demo Testing "",Demo2=""Is Awesome.""])##"; processor.ExecuteProcessors(formatStr); var formatOut = processor.FormatString(formatStr); Assert.AreEqual("Demo Testing Is Awesome.", formatOut); }
public void Execute(Dictionary<string, string> parameters, Processor processor) { processor.AddDomain(parameters["domain"]); var head = File.ReadAllLines(Path.Combine(".git", "HEAD"))[0]; var headRegex = new Regex(@"ref: refs/(?<RefLocation>.*)/(?<Branch>.*)"); var headRegexMatch = headRegex.Match(head); var branch = headRegexMatch.Groups["Branch"].Value; var revNumber = File.ReadAllText(Path.Combine(".git", "logs", "refs", headRegexMatch.Groups["RefLocation"].Value, branch)) .Split('\n') .Length; var hash = File.ReadAllLines(Path.Combine(".git", "refs", headRegexMatch.Groups["RefLocation"].Value, branch))[0]; var domain = processor.GetDomain(parameters["domain"]); domain.Add("RevNumber", revNumber.ToString(CultureInfo.InvariantCulture)); domain.Add("Branch", branch); domain.Add("Hash", hash); }