コード例 #1
0
        void ReadHadith(XElement hadithNode)
        {
            var reference           = MultiPartReference.ParseXml(hadithNode.Element("reference"));
            var secondaryReferences = ReadSecondaryReferences(hadithNode.Element("secondaryReferences"));
            var verseReferences     = ReadVerseReferences(hadithNode.Element("verseReferences"));
            var englishTextNode     = hadithNode.Element("english");
            var englishText         = englishTextNode.Elements("text").Select(x => x.Value);
            var arabicTextNode      = hadithNode.Element("arabic");
            var arabicText          = arabicTextNode.Elements("text").Select(x => x.Value);

            HashSet <VerseRangeReference> additionalVerseReferences;

            if (VersesByHadith.TryGetValue(reference, out additionalVerseReferences))
            {
                verseReferences = verseReferences.Concat(additionalVerseReferences);
            }

            var hadith = new Hadith(
                reference: reference,
                otherReferences: secondaryReferences,
                arabicText: arabicText,
                englishText: englishText,
                verseReferences: verseReferences
                );

            Collection.AddHadith(hadith);
        }
コード例 #2
0
        void ReadHadith(XElement hadithNode)
        {
            var references      = ReadReferences(hadithNode.Element("references"));
            var verseReferences = ReadVerseReferences(hadithNode.Element("verseReferences"));
            var englishTextNode = hadithNode.Element("english");
            var englishText     = englishTextNode.Elements("text").Select(x => x.Value);
            var arabicTextNode  = hadithNode.Element("arabic");
            var arabicText      = arabicTextNode.Elements("text").Select(x => x.Value);

            foreach (HadithReference reference in references)
            {
                HashSet <VerseRangeReference> additionalVerseReferences;
                if (VersesByHadith.TryGetValue(reference, out additionalVerseReferences))
                {
                    verseReferences = verseReferences.Concat(additionalVerseReferences);
                    break;
                }
            }

            var hadith = new Hadith(
                collection: Collection,
                references: references,
                arabicText: arabicText,
                englishText: englishText,
                verseReferences: verseReferences);

            Collection.AddHadith(hadith);
        }