init
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using System.ComponentModel;
|
||||
using Users.UserSettings;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DTS.Slice.Users.UserSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// this class overrides the DisplayNameAttribute to provide a translated string name, and also
|
||||
/// to allow us to use an enum to create the attribute
|
||||
/// to be translated a string resource should exist in the form of PropertyName_DisplayName
|
||||
/// otherwise ##DisplayNameNotFound## will be returned
|
||||
/// </summary>
|
||||
public class DisplayAttributeEx : DisplayNameAttribute
|
||||
{
|
||||
private readonly PropertyEnums.PropertyIds _propertyId;
|
||||
|
||||
private readonly string _propertyIdString = null;
|
||||
public DisplayAttributeEx(PropertyEnums.PropertyIds propertyId)
|
||||
{
|
||||
_propertyId = propertyId;
|
||||
}
|
||||
public DisplayAttributeEx(string propertyId)
|
||||
{
|
||||
_propertyIdString = propertyId;
|
||||
}
|
||||
public override string DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_propertyIdString))
|
||||
{
|
||||
return StringResources.ResourceManager.GetString(_propertyIdString + "_DisplayName") ?? @"##DisplayNameNotFound##" + _propertyIdString;
|
||||
}
|
||||
return StringResources.ResourceManager.GetString(_propertyId + "_DisplayName") ?? @"##DisplayNameNotFound##" + _propertyId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user