using System;
using System.Globalization;
using System.Reflection;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Models
{
///
/// Represents a Language
///
[Serializable]
[DataContract(IsReference = true)]
public class Language : Entity, ILanguage
{
private string _isoCode;
private string _cultureName;
public Language(string isoCode)
{
IsoCode = isoCode;
}
private static readonly Lazy Ps = new Lazy();
private class PropertySelectors
{
public readonly PropertyInfo IsoCodeSelector = ExpressionHelper.GetPropertyInfo(x => x.IsoCode);
public readonly PropertyInfo CultureNameSelector = ExpressionHelper.GetPropertyInfo(x => x.CultureName);
}
///
/// Gets or sets the Iso Code for the Language
///
[DataMember]
public string IsoCode
{
get { return _isoCode; }
set { SetPropertyValueAndDetectChanges(value, ref _isoCode, Ps.Value.IsoCodeSelector); }
}
///
/// Gets or sets the Culture Name for the Language
///
[DataMember]
public string CultureName
{
get { return _cultureName; }
set { SetPropertyValueAndDetectChanges(value, ref _cultureName, Ps.Value.CultureNameSelector); }
}
///
/// Returns a object for the current Language
///
[IgnoreDataMember]
public CultureInfo CultureInfo
{
get { return CultureInfo.GetCultureInfo(IsoCode); }
}
}
}