static void Main(string[] args) { Director.layoutArticle(new BuilderTXT(), "Neurons", "text"); ArticleTXT articleTXT = (ArticleTXT)Director.GetArticle(); Console.WriteLine(articleTXT.Title); Director.convertArticle(new BuilderXML(), articleTXT); ArticleXML articleXML = (ArticleXML)Director.GetArticle(); Console.WriteLine(articleXML.Title); }
// Класс отвечает за конвертациию статьи public static void convertArticle(IBuilder builder, ArticleTXT article_txt) { builder.reset(); builder.setTitle(article_txt.Title); using (FileStream fileStream = File.OpenRead(article_txt.Text.FullName)) { byte[] array = new byte[fileStream.Length]; fileStream.Read(array, 0, array.Length); string textFromFile = System.Text.Encoding.Default.GetString(array); builder.setText(textFromFile); } article = builder.GetArticle(); }
public void reset() { articleTXT = new ArticleTXT(); }