/// <summary> /// When overridden in a derived class, executes the task. /// </summary> /// <returns> /// true if the task successfully executed; otherwise, false. /// </returns> public override bool Execute() { List <string> inputFiles = new List <string>(); foreach (ITaskItem item in InputFiles) { inputFiles.Add(item.ItemSpec); } List <string> outputFiles = new List <string>(); foreach (ITaskItem item in OutputFiles) { outputFiles.Add(item.ItemSpec); } MarkupCleaner cleaner = new MarkupCleaner(); cleaner.OptionFile = OptionFile; cleaner.ErrorFile = ErrorFile; for (int i = 0; i < inputFiles.Count; i++) { if (Verbose) { Console.WriteLine("Cleaning: " + inputFiles[i] + " -> " + outputFiles[i]); } cleaner.CleanFile(inputFiles[i], outputFiles[i]); } return(true); }
protected void btnSave_Click(object sender, EventArgs e) { MarkupCleaner cleaner = new MarkupCleaner(); cleaner.OptionFile = Server.MapPath("~/Controls/tidy.config"); OnContentSaving(EventArgs.Empty); Content = cleaner.CleanContent(Content); OnContentSaved(EventArgs.Empty); }
static void Main(string[] args) { MarkupCleaner cleaner = new MarkupCleaner(); cleaner.ErrorOccured += new EventHandler(cleaner_ErrorOccured); cleaner.OptionFile = "foo.tidy"; //cleaner.ErrorFile = "errors.txt"; cleaner.CleanFile("foo.html", "foo.out.html"); //Console.WriteLine("Press enter to end."); //Console.ReadLine(); }
static void cleaner_ErrorOccured(object sender, EventArgs e) { MarkupCleaner cleaner = (MarkupCleaner)sender; Console.WriteLine("An error has occured: " + cleaner.GetStatusMessage()); }