Exemplo n.º 1
0
 public Lyrics(string properTitle = null, string meter = null, IReadOnlyCollection<Attribution> sources = null, BibleReferenceList scriptureBasis = null, Section prelude = null, IReadOnlyCollection<Section> verses = null, Section refrain = null, Section coda = null)
 {
     ProperTitle = properTitle;
     Meter = meter;
     Sources = sources;
     ScriptureBasis = scriptureBasis;
     Prelude = prelude;
     Verses = verses;
     Refrain = refrain;
     Coda = coda;
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var xml = XDocument.Load("hymnal.xml");

            var entryNodes = xml.Descendants("HymnEntry");
            var objects = new List<HymnalEntry>();

            foreach (var node in entryNodes)
            {
                var number = node.AttributeText("HymnNumber").ToUnsignedShort();
                var title = node.ChildText("Title").PossibleSubstringLeftOf("(").Trim();
                var lyricalMeter = node.Child("Hymn").AttributeText("Meter");

                var authors = node.Descendants("Author").Union(node.Descendants("AddlAuthor"));

                var lyricAttributions = new List<Attribution>();
                var bibleReferences = new BibleReferenceList();
                foreach (var author in authors)
                {
                    string firstName = null;
                    string middleName = null;
                    string lastName = null;
                    string suffix = null;
                    string source = null;

                    if (author.IsLikelyAScriptureReference())
                    {
                        try
                        {
                            //TODO: This is really ugly... Need to do something about the BibleReferenceList class...
                            var references = author.ChildText("Last").ParseBibleReferenceList();
                            if (references != null)
                            {
                                bibleReferences = new BibleReferenceList(bibleReferences.Union(references));
                                continue; //next iteration of for loop
                            }
                        }
                        catch (ArgumentException) {}
                    }

                    var year = author.AttributeText("Year").ParseUnsignedShortOrNull();

                    var description = author.ChildText("Descrip");

                    if (author.IsLikelyASourceAndNotAPerson())
                    {
                        source = author.ChildText("Last");
                    }
                    else
                    {
                        firstName = author.ChildText("First");
                        middleName = author.ChildText("Middle");
                        lastName = author.ChildText("Last");
                        suffix = author.ChildText("Suffix");
                    }

                    var role = author.ChildText("Role");

                    var sections = author.ChildTextList("Element");

                    var person = new Person(firstName, middleName, lastName, suffix);
                    var attribution = new Attribution(person, role, source, year, sections);

                    lyricAttributions.Add(attribution);
                }

                var lyrics = new Lyrics(null, lyricalMeter, lyricAttributions, bibleReferences, null, null, null, null);

                //var obj = new HymnalEntry(number, title, , )
            }
        }