public void LoadTemplate(string templateFileName, Action<FsDirectives, string, Exception> onComplete) { var exception = null as Exception; var fsDirectives = null as FsDirectives; var txt = null as string; var path = Path.Combine(_dir, templateFileName); if (File.Exists(path)) { try { var fsd = new FsDirectives(); txt = File.ReadAllText(path); fsd.ParseText(txt); fsDirectives = fsd; } catch (Exception xe) { exception = xe; } } if (onComplete != null) { onComplete(fsDirectives, txt, exception); } }
public void TestFsDirectives1() { var fsDirectives = new FsDirectives(); var text1 = @"src/**/*.cs"; fsDirectives.ParseText(text1); Assert.IsNotNull(fsDirectives.Directives); Assert.AreEqual(fsDirectives.Directives.Count, 1); var outputs = new Dictionary<Directive, List<string>>(); var path1 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\"); var repository = Path.GetFullPath(path1); fsDirectives.Execute(repository, ref outputs); Assert.AreNotEqual(outputs.Count, 0); foreach (var i in outputs) { TestContext.WriteLine(i.Key.Pattern); TestContext.WriteLine(new string('-', 80)); foreach (var j in i.Value) { TestContext.WriteLine(j); } if (i.Value.Count == 0) { TestContext.WriteLine("Pass"); } TestContext.WriteLine(Environment.NewLine); } }