Files
Umbraco-CMS/src/Umbraco.Core/Models/DictionaryTranslation.cs
sitereactor a9bc0addfb Implements ILocalizationService for U4-1075
Refactoring DictionaryItem, DictionaryTranslation and Language to use the same interface implementations as the rest of the db driven repos and services.
2012-10-24 12:22:52 -02:00

62 lines
1.8 KiB
C#

using System;
using System.Reflection;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Models
{
/// <summary>
/// Represents a translation for a <see cref="DictionaryItem"/>
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
public class DictionaryTranslation : Entity, IDictionaryTranslation
{
private ILanguage _language;
private string _value;
public DictionaryTranslation(ILanguage language, string value)
{
_language = language;
_value = value;
}
public DictionaryTranslation(ILanguage language, string value, Guid uniqueId)
{
_language = language;
_value = value;
Key = uniqueId;
}
private static readonly PropertyInfo LanguageSelector = ExpressionHelper.GetPropertyInfo<DictionaryTranslation, ILanguage>(x => x.Language);
private static readonly PropertyInfo ValueSelector = ExpressionHelper.GetPropertyInfo<DictionaryTranslation, string>(x => x.Value);
/// <summary>
/// Gets or sets the <see cref="Language"/> for the translation
/// </summary>
[DataMember]
public ILanguage Language
{
get { return _language; }
set
{
_language = value;
OnPropertyChanged(LanguageSelector);
}
}
/// <summary>
/// Gets or sets the translated text
/// </summary>
[DataMember]
public string Value
{
get { return _value; }
set
{
_value = value;
OnPropertyChanged(ValueSelector);
}
}
}
}