Esempio n. 1
0
        public void GetAuthorYearFromRefernceFile()
        {
            try
            {
                using (StreamWriter w = new StreamWriter(@"blah.bib"))
                {
                    w.WriteLine(@"Automatically generated by Mendeley Desktop 1.10.1");
                    w.WriteLine(@"Any changes to this file will be lost if it is regenerated by Mendeley.");
                    w.WriteLine(@"BibTeX export options can be customized via Options -> BibTeX in Mendeley Desktop");

                    w.WriteLine(@"@article{Leontief1936,");
                    w.WriteLine(@"author = {Leontief, Wassily W},");
                    w.WriteLine(@"file = {:E$\backslash$:/uni stuff/Papers/Leontief/Leontief\_1936\_Quantitative input and output relations in the economic systems of the United States.pdf:pdf},");
                    w.WriteLine(@"journal = {The Review of economics and Statistics},");
                    w.WriteLine(@"number = {3},");
                    w.WriteLine(@"pages = {105--125},");
                    w.WriteLine(@"title = {{Quantitative input and output relations in the economic systems of the United States}},");
                    w.WriteLine(@"url = {http://www.jstor.org/stable/10.2307/1927837},");
                    w.WriteLine(@"volume = {18},");
                    w.WriteLine(@"year = {1936}");
                    w.WriteLine(@"}");

                    w.WriteLine(@"@book{AmericaClimateChange2010,");
                    w.WriteLine(@"author = {{America's Climate Choices} and {Panel on Advancing the Science of Climate Change} and {National Research Council}},");
                    w.WriteLine(@"isbn = {9780309145886},");
                    w.WriteLine(@"pages = {1},");
                    w.WriteLine(@"publisher = {The National Academies Press},");
                    w.WriteLine(@"title = {{Advancing the Science of Climate Change}},");
                    w.WriteLine(@"url = {http://www.nap.edu/openbook.php?record\_id=12782},");
                    w.WriteLine(@"year = {2010}");
                    w.WriteLine(@"}");
                }

                References r = new References(new FileInfo(@"blah.bib"));

                string ay1 = r.GetAuthorYear("Leontief1936");
                string ay2 = r.GetAuthorYear("AmericaClimateChange2010");

                Assert.AreEqual(ay1, "Leontief, Wassily W, 1936");
                Assert.AreEqual(ay2, @"{America's Climate Choices} and {Panel on Advancing the Science of Climate Change} and {National Research Council}, 2010");
            }
            finally
            {
                // No matter what happens we clean up after ourselves.
                FileInfo f = new FileInfo("blah.bib");
                f.Delete();
            }
        }
Esempio n. 2
0
        public void GetJournalRefernce()
        {
            try
            {
                using (StreamWriter w = new StreamWriter("blah.bib"))
                {
                    w.WriteLine(@"Automatically generated by Mendeley Desktop 1.10.1");
                    w.WriteLine(@"Any changes to this file will be lost if it is regenerated by Mendeley.");
                    w.WriteLine(@"BibTeX export options can be customized via Options -> BibTeX in Mendeley Desktop");

                    w.WriteLine(@"@article{Joshi2000,");
                    w.WriteLine(@"author = {Joshi, Satish},");
                    w.WriteLine(@"file = {:E$\backslash$:/uni stuff/Papers/Joshi/Joshi\_2000\_Life-Cycle Assessment Using Input-Output Techniques.pdf:pdf},");
                    w.WriteLine(@"journal = {Journal of Industrial Ecology},");
                    w.WriteLine(@"keywords = {automobile fuel tanks,design for environment,dfe,input-output analysis},");
                    w.WriteLine(@"number = {2},");
                    w.WriteLine(@"pages = {95--120},");
                    w.WriteLine(@"title = {{Life-Cycle Assessment Using Input-Output Techniques}},");
                    w.WriteLine(@"volume = {3},");
                    w.WriteLine(@"year = {2000}");
                    w.WriteLine(@"}");
                }

                References r = new References(new FileInfo(@"blah.bib"));

                Dictionary<References.RefPart, List<References.RefPartStyle>> style = new Dictionary<References.RefPart, List<References.RefPartStyle>>();

                style.Add(References.RefPart.author, new List<References.RefPartStyle>());
                style.Add(References.RefPart.year, new List<References.RefPartStyle>());
                style.Add(References.RefPart.title, new List<References.RefPartStyle>());
                style.Add(References.RefPart.volume, new List<References.RefPartStyle>());
                style.Add(References.RefPart.number, new List<References.RefPartStyle>());
                style[References.RefPart.year].Add(References.RefPartStyle.RoundBrackets);
                style[References.RefPart.title].Add(References.RefPartStyle.Braces);
                style[References.RefPart.volume].Add(References.RefPartStyle.TrailingColon);

                r.AddRefStylePart(References.RefType.article, style);
                string reference = r.GetReference("Joshi2000");

                Assert.AreEqual(reference, "Joshi, Satish, (2000), {{Life-Cycle Assessment Using Input-Output Techniques}}, 3:2");
            }
            finally
            {
                FileInfo f = new FileInfo("blah.bib");
                f.Delete();
            }
        }