コード例 #1
0
        public SuraDocument(XmlDocument rawDoc)
        {
            htmlDocument = new XmlDocument();
            htmlDocument.LoadXml(rawDoc.LastChild.OuterXml.Replace("xmlns=\"http://www.w3.org/1999/xhtml\"", ""));
            suraSection = htmlDocument.SelectSingleNode("html/body/section");
            Aayas       = new Dictionary <int, Aaya>();

            if (suraSection != null)
            {
                // data-place="Makkah" data-order="5" data-sura="1" data-mushaf="pakistani"
                RevelationPlace = (QuranMushafAPI.RevelationPlace)Enum.Parse(typeof(QuranMushafAPI.RevelationPlace), suraSection.Attributes["data-place"].Value);

                if (XmlFunctions.CheckAndLoadInt(suraSection, "data-sura", -1) > -1)
                {
                    SuraNumber = XmlFunctions.CheckAndLoadInt(suraSection, "data-sura", -1);
                }

                if (XmlFunctions.CheckAndLoadInt(suraSection, "data-order", -1) > -1)
                {
                    RevelationOrder = XmlFunctions.CheckAndLoadInt(suraSection, "data-order", -1);
                }

                CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
                TextInfo    textInfo    = cultureInfo.TextInfo;

                MushafType = (QuranMushafAPI.Mushaf)Enum.Parse(typeof(QuranMushafAPI.Mushaf), textInfo.ToTitleCase(suraSection.Attributes["data-mushaf"].Value));

                Aayas = new Dictionary <int, Aaya>();

                XmlNodeList aayas = suraSection.SelectNodes("span[@data-type='aaya']");
                foreach (XmlNode aaya in aayas)
                {
                    Aaya a = new Aaya(aaya);
                    Aayas.Add(a.AayaNumber, a);
                }
            }
        }
コード例 #2
0
        public Aaya(XmlNode aayaNode)
        {
            if (XmlFunctions.CheckAndLoadInt(aayaNode, "data-aaya", -1) > -1)
            {
                AayaNumber = XmlFunctions.CheckAndLoadInt(aayaNode, "data-aaya", -1);
            }

            if (XmlFunctions.CheckAndLoadInt(aayaNode, "data-juz", -1) > -1)
            {
                Juz = XmlFunctions.CheckAndLoadInt(aayaNode, "data-juz", -1);
            }

            if (XmlFunctions.CheckAndLoadInt(aayaNode, "data-ruku", -1) > -1)
            {
                Ruku = XmlFunctions.CheckAndLoadInt(aayaNode, "data-ruku", -1);
            }

            if (XmlFunctions.CheckAndLoadInt(aayaNode, "data-manzil", -1) > -1)
            {
                Manzil = XmlFunctions.CheckAndLoadInt(aayaNode, "data-manzil", -1);
            }

            EoA = aayaNode.SelectSingleNode("span[@data-type='eoa-sc']").InnerText;
        }