Пример #1
0
        public Surah ConvertToSurah(QuranType type)
        {
            Surah s = new Surah(Index, EN_Name, AR_Name, Bismillah, Juz);

            if (type == QuranType.Concurrent)
            {
                s.Ayaat = new ConcurrentDictionary <int, Ayat>();
            }
            else
            {
                s.Ayaat = new Dictionary <int, Ayat>();
            }

            foreach (Ayat ayat in Ayaat)
            {
                s.Ayaat[ayat.Index] = ayat;
            }

            return(s);
        }
Пример #2
0
 public static void AddProperties(Properties toSet, ref Quran quran)
 {
     foreach (Property p in toSet.List)
     {
         object toChange = null;
         if (p.Type == PropertyType.Surah)
         {
             if (quran.Suwar.ContainsKey(p.Index))
             {
                 toChange = quran.Suwar[p.Index];
             }
             else
             {
                 Surah s = null;
                 if (quran.Type == QuranType.Concurrent)
                 {
                     s = new ConcurrentSurah();
                 }
                 else
                 {
                     s = new Surah();
                 }
                 quran.Suwar[p.Index] = s;
                 toChange             = s;
             }
         }
         else if (p.Type == PropertyType.Ayat)
         {
             if (quran.Suwar.ContainsKey(p.Index))
             {
                 Surah s = quran.Suwar[p.Index];
                 if (s.Ayaat.ContainsKey(p.AyatIndex))
                 {
                     toChange = s.Ayaat[p.AyatIndex];
                 }
                 else
                 {
                     Ayat a = new Ayat();
                     s.Ayaat[p.AyatIndex] = a;
                     toChange             = a;
                 }
             }
             else
             {
                 Surah s = null;
                 if (quran.Type == QuranType.Concurrent)
                 {
                     s = new ConcurrentSurah();
                 }
                 else
                 {
                     s = new Surah();
                 }
                 Ayat a = new Ayat();
                 s.Ayaat[p.AyatIndex] = a;
                 quran.Suwar[p.Index] = s;
                 toChange             = a;
             }
         }
         else if (p.Type == PropertyType.Quran)
         {
             toChange = quran;
         }
         if (toChange != null)
         {
             PropertyInfo info = toChange.GetType().GetProperty(p.Name, BindingFlags.Public | BindingFlags.Instance);
             if (null != info && info.CanWrite)
             {
                 info.SetValue(toChange, p.Value);
             }
         }
     }
 }