38 lines
1.5 KiB
Plaintext
38 lines
1.5 KiB
Plaintext
using System.ComponentModel;
|
|
using Users.UserSettings;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace DTS.Slice.Users.UserSettings
|
|
{
|
|
/// <summary>
|
|
/// this class overloads the description attribute to allow us to use an enum
|
|
/// to set the description and to lookup the description in the string resources
|
|
/// to be translated the property should have a string resource in the form of PropertyName_Description
|
|
/// otherwise ##DescriptionNotFound## will be returned as the translated string
|
|
/// </summary>
|
|
public class DescriptionAttributeEx : DescriptionAttribute
|
|
{
|
|
private readonly PropertyEnums.PropertyIds _propertyId;
|
|
private readonly string _propertyIdString = null;
|
|
public DescriptionAttributeEx(PropertyEnums.PropertyIds propertyId)
|
|
{
|
|
_propertyId = propertyId;
|
|
}
|
|
public DescriptionAttributeEx(string propertyId)
|
|
{
|
|
_propertyIdString = propertyId;
|
|
}
|
|
public override string Description
|
|
{
|
|
get
|
|
{
|
|
if (!string.IsNullOrEmpty(_propertyIdString))
|
|
{
|
|
return StringResources.ResourceManager.GetString(_propertyIdString + "_Description") ?? @"##DescriptionNotFound##" + _propertyIdString;
|
|
}
|
|
return StringResources.ResourceManager.GetString(_propertyId + "_Description") ?? @"##DescriptionNotFound##" + _propertyId;
|
|
}
|
|
}
|
|
}
|
|
}
|