From 612d57c00abddd9951bec13a46d25a6ec9cab99e Mon Sep 17 00:00:00 2001 From: "Morten@Thinkpad-X220" Date: Thu, 4 Oct 2012 07:06:01 -0200 Subject: [PATCH] Adds Dictionary and Language implementations for U4-929 and U4-930 --- src/Umbraco.Core/Models/DictionaryItem.cs | 55 +++++++++++++++++++ .../Models/DictionaryTranslation.cs | 48 ++++++++++++++++ src/Umbraco.Core/Models/Language.cs | 45 +++++++++++++++ src/Umbraco.Core/Umbraco.Core.csproj | 3 + 4 files changed, 151 insertions(+) create mode 100644 src/Umbraco.Core/Models/DictionaryItem.cs create mode 100644 src/Umbraco.Core/Models/DictionaryTranslation.cs create mode 100644 src/Umbraco.Core/Models/Language.cs diff --git a/src/Umbraco.Core/Models/DictionaryItem.cs b/src/Umbraco.Core/Models/DictionaryItem.cs new file mode 100644 index 0000000000..3790711ce1 --- /dev/null +++ b/src/Umbraco.Core/Models/DictionaryItem.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using Umbraco.Core.Models.EntityBase; + +namespace Umbraco.Core.Models +{ + public class DictionaryItem : Entity + { + private Guid _parentId; + private string _itemKey; + private IEnumerable _translations; + + public DictionaryItem(Guid parentId, string itemKey) + { + _parentId = parentId; + _itemKey = itemKey; + _translations = new List(); + } + + private static readonly PropertyInfo ParentIdSelector = ExpressionHelper.GetPropertyInfo(x => x.ParentId); + private static readonly PropertyInfo ItemKeySelector = ExpressionHelper.GetPropertyInfo(x => x.ItemKey); + private static readonly PropertyInfo TranslationsSelector = ExpressionHelper.GetPropertyInfo>(x => x.Translations); + + public Guid ParentId + { + get { return _parentId; } + set + { + _parentId = value; + OnPropertyChanged(ParentIdSelector); + } + } + + public string ItemKey + { + get { return _itemKey; } + set + { + _itemKey = value; + OnPropertyChanged(ItemKeySelector); + } + } + + public IEnumerable Translations + { + get { return _translations; } + set + { + _translations = value; + OnPropertyChanged(TranslationsSelector); + } + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Models/DictionaryTranslation.cs b/src/Umbraco.Core/Models/DictionaryTranslation.cs new file mode 100644 index 0000000000..c705face90 --- /dev/null +++ b/src/Umbraco.Core/Models/DictionaryTranslation.cs @@ -0,0 +1,48 @@ +using System; +using System.Reflection; +using Umbraco.Core.Models.EntityBase; + +namespace Umbraco.Core.Models +{ + public class DictionaryTranslation : Entity + { + private Language _language; + private string _value; + + public DictionaryTranslation(Language language, string value) + { + _language = language; + _value = value; + } + + public DictionaryTranslation(Language language, string value, Guid uniqueId) + { + _language = language; + _value = value; + Key = uniqueId; + } + + private static readonly PropertyInfo LanguageSelector = ExpressionHelper.GetPropertyInfo(x => x.Language); + private static readonly PropertyInfo ValueSelector = ExpressionHelper.GetPropertyInfo(x => x.Value); + + public Language Language + { + get { return _language; } + set + { + _language = value; + OnPropertyChanged(LanguageSelector); + } + } + + public string Value + { + get { return _value; } + set + { + _value = value; + OnPropertyChanged(ValueSelector); + } + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Models/Language.cs b/src/Umbraco.Core/Models/Language.cs new file mode 100644 index 0000000000..27ce5de7f8 --- /dev/null +++ b/src/Umbraco.Core/Models/Language.cs @@ -0,0 +1,45 @@ +using System.Globalization; +using System.Reflection; +using Umbraco.Core.Models.EntityBase; + +namespace Umbraco.Core.Models +{ + public class Language : Entity + { + private string _isoCode; + private string _cultureName; + + public Language(string isoCode) + { + IsoCode = isoCode; + } + + private static readonly PropertyInfo IsoCodeSelector = ExpressionHelper.GetPropertyInfo(x => x.IsoCode); + private static readonly PropertyInfo CultureNameSelector = ExpressionHelper.GetPropertyInfo(x => x.CultureName); + + public string IsoCode + { + get { return _isoCode; } + set + { + _isoCode = value; + OnPropertyChanged(IsoCodeSelector); + } + } + + public string CultureName + { + get { return _cultureName; } + set + { + _cultureName = value; + OnPropertyChanged(CultureNameSelector); + } + } + + public CultureInfo CultureInfo + { + get { return CultureInfo.CreateSpecificCulture(IsoCode); } + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 5296c38054..fbf011e9c8 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -62,6 +62,9 @@ + + +