using System.ComponentModel; using Users.UserSettings; // ReSharper disable once CheckNamespace namespace DTS.Slice.Users.UserSettings { /// /// 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 /// 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; } } } }