protected void ProcessFile(string fileName) { try { AcomArticle article = new AcomArticle(fileName); // Check author if (this.Author != string.Empty && !article.Author.Contains(this.Author)) { return; // Failed author check; no need to go further with this article. } // Check staleness if (this.Stale || this.StaleWithin > 0) { if (article.PubDate.AddDays(staleDays - this.StaleWithin) > DateTime.Now) { return; // User asked for stale/stalewithin and this article doesn't match criteria. } } WriteObject(article); } catch(Exception ex) { StringBuilder error = new StringBuilder(); error.AppendFormat("[{0}] : {1}", fileName, ex.Message); ThrowTerminatingError(new ErrorRecord(new Exception(error.ToString(), ex), AcomCmdlets.Resources.UnexpectedError, ErrorCategory.InvalidOperation, this)); } }
static void ProcessDirectory(string dirName) { try { // Process current directory foreach (string fileName in Directory.GetFiles(dirName, "*.md")) { Console.WriteLine("Processing {0}", fileName); AcomArticle article = new AcomArticle(fileName); Console.WriteLine(article.Author); } foreach (string subDir in Directory.GetDirectories(dirName)) { ProcessDirectory(subDir); } } catch (System.Exception excpt) { Console.WriteLine(excpt.Message); } }
static void ProcessFile(string fileName) { AcomArticle article = new AcomArticle(fileName); Console.WriteLine(article); }