/////////////////////////////////////////////////////////// // LocaleList.cs // Implementation of Class LocaleList // CSLA type: Read only collection // Created on: 08-Jun-2004 1:11:03 PM // Object design: Joyce // Coded: John 08-Jun-2004 /////////////////////////////////////////////////////////// using System; using System.Data; using CSLA.Data; using GZTW.Data; using CSLA; namespace GZTW.AyaNova.BLL { /// /// Lightweight read only list of objects representing all the locale (languages) defined in AyaNova /// [Serializable] public class LocaleList : ReadOnlyCollectionBase { /// /// Properties /// [Serializable] public struct LocaleListInfo { internal string mLocale; /// /// Locale (language) /// public string Locale { get { return mLocale; } } /// /// public bool Equals(LocaleListInfo obj) { return this.Locale.Equals(obj.Locale); } }//end LocaleListInfo #region Attributes #endregion /// /// /// protected LocaleList() { } /// /// Get item by index /// /// public LocaleListInfo this[int Item]{ get { return (LocaleListInfo) List[Item]; } } /// /// Check if item in collection /// /// public bool Contains(LocaleListInfo obj) { foreach (LocaleListInfo child in List) { if(child.Equals(obj)) return true; } return false; } /// /// Check if item in collection /// /// String display name of locale, is case sensitive public bool Contains(string LocaleName) { foreach (LocaleListInfo child in List) { if(child.mLocale.Equals(LocaleName)) return true; } return false; } #region DAL DATA ACCESS /// /// protected override void DataPortal_Fetch(object Criteria) { SafeDataReader dr = null; try { dr=DBUtil.GetReaderFromSQLString( //************************************************************ "SELECT DISTINCT aLocale FROM aLocalizedText ORDER BY aLocale" //************************************************************ ); while(dr.Read()) { //******************************************* LocaleListInfo info=new LocaleListInfo(); info.mLocale=dr.GetString("aLocale"); InnerList.Add(info); //******************************************* } } finally { if(dr!=null) dr.Close(); } } #endregion /// /// Fetch list /// /// list of objects public static LocaleList GetList() { return (LocaleList) DataPortal.Fetch(new Criteria()); } #region criteria /// /// Criteria for identifying existing object /// [Serializable] private class Criteria { // public Guid ID; // public Criteria(Guid _ID) // { // ID=_ID; // } // } #endregion }//end LocaleList }//end namespace GZTW.AyaNova.BLL