public static void WriteQuranXML(Quran quran, string path) { SerializableQuran serializable = quran.ConvertToSerializable(); System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(SerializableQuran)); using (System.IO.FileStream stream = new System.IO.FileStream(path, System.IO.FileMode.Create, System.IO.FileAccess.Write)) { serializer.Serialize(stream, serializable); } }
public Quran ConvertToQuran(QuranType type) { Quran quran = null; if (type == QuranType.Concurrent) { quran = new ConcurrentQuran(); } else { quran = new Quran(); } foreach (SerializableSurah surah in Suwar) { quran.Suwar[surah.Index] = surah.ConvertToSurah(type); } return(quran); }
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); } } } }