示例#1
0
        private void Start()
        {
            if (PathsSelected())
            {
                ResultText = string.Empty;
                IList <JournalArticle> sources = new List <JournalArticle>();

                // Convert from text to objects:
                try
                {
                    var parser = new JournalArticleParser();
                    sources = parser.ParseFromFile(InputPath);
                }
                catch (ParsingException e)
                {
                    ResultText = e.Message;
                    return;
                }
                catch (Exception)
                {
                    ResultText = "BŁĄD odczytu wybranego pliku .txt";
                    return;
                }

                // Convert from objects to MS Office bibliography XML file:
                try
                {
                    var XMLCreator = new XMLBibliographyCreator();
                    XMLCreator.Initialize(OutputPath);
                    foreach (Source source in sources)
                    {
                        XMLCreator.AddSource(source);
                    }
                    XMLCreator.ApplyChanges();
                }
                catch (Exception)
                {
                    ResultText = "BŁĄD zapisu pliku .xml";
                    return;
                }
            }
            else
            {
                ResultText = "BŁĄD! Najpierw wybierz plik wejściowy i wyjściowy.";
                return;
            }

            ResultText = "Plik przekonwertowany pomyślnie! :)";

            bool PathsSelected() => !string.IsNullOrEmpty(InputPath) && !string.IsNullOrEmpty(OutputPath);
        }
 public void InitializeTest()
 {
     parser = new JournalArticleParser();
 }