29 lines
1.3 KiB
C#
29 lines
1.3 KiB
C#
using DTS.Common.SharedResource.Strings;
|
|
using System;
|
|
using System.ComponentModel;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace DTS.Common.Attributes
|
|
{
|
|
/// <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>
|
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Interface | AttributeTargets.Delegate | AttributeTargets.Property)]
|
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Minor Code Smell", "S3376:Attribute, EventArgs, and Exception type names should end with the type being extended", Justification = "extebded")]
|
|
public class DisplayAttributeEx : DisplayNameAttribute
|
|
{
|
|
private readonly string _propertyIdString = null;
|
|
public DisplayAttributeEx(string propertyId)
|
|
{
|
|
_propertyIdString = propertyId;
|
|
}
|
|
public override string DisplayName
|
|
{
|
|
get =>StringResources.ResourceManager.GetString(_propertyIdString + "_DisplayName") ?? @"##DisplayNameNotFound##" + _propertyIdString;
|
|
}
|
|
}
|
|
}
|