Files
2018-06-29 19:47:36 +00:00

168 lines
3.4 KiB
C#

///////////////////////////////////////////////////////////
// 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 {
/// <summary>
/// Lightweight read only list of <see cref="LocaleList.LocaleListInfo"/> objects representing all the locale (languages) defined in AyaNova
/// </summary>
[Serializable]
public class LocaleList : ReadOnlyCollectionBase {
/// <summary>
/// Properties
/// </summary>
[Serializable]
public struct LocaleListInfo {
internal string mLocale;
/// <summary>
/// Locale (language)
/// </summary>
public string Locale
{
get
{
return mLocale;
}
}
///
/// <param name="obj"></param>
public bool Equals(LocaleListInfo obj)
{
return this.Locale.Equals(obj.Locale);
}
}//end LocaleListInfo
#region Attributes
#endregion
/// <summary>
///
/// </summary>
protected LocaleList()
{
}
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public LocaleListInfo this[int Item]{
get
{
return (LocaleListInfo) List[Item];
}
}
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(LocaleListInfo obj)
{
foreach (LocaleListInfo child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="LocaleName">String display name of locale, is case sensitive</param>
public bool Contains(string LocaleName)
{
foreach (LocaleListInfo child in List)
{
if(child.mLocale.Equals(LocaleName)) return true;
}
return false;
}
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
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
/// <summary>
/// Fetch list
/// </summary>
/// <returns>list of <see cref="LocaleList.LocaleListInfo"/> objects</returns>
public static LocaleList GetList()
{
return (LocaleList) DataPortal.Fetch(new Criteria());
}
#region criteria
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[Serializable]
private class Criteria
{
// public Guid ID;
// public Criteria(Guid _ID)
// {
// ID=_ID;
// }
//
}
#endregion
}//end LocaleList
}//end namespace GZTW.AyaNova.BLL