Files
DP44/Common/DTS.Common/Attributes/DescriptionAttributeEx.cs

30 lines
1.4 KiB
C#
Raw Normal View History

2026-04-17 14:55:32 -04:00
using DTS.Common.SharedResource.Strings;
using System;
using System.ComponentModel;
// ReSharper disable once CheckNamespace
namespace DTS.Common.Attributes
{
/// <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>
[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 DescriptionAttributeEx : DescriptionAttribute
{
private readonly string _propertyIdString = null;
public DescriptionAttributeEx(string propertyId)
{
_propertyIdString = propertyId;
}
public override string Description
{
get => StringResources.ResourceManager.GetString(_propertyIdString + "_Description") ?? @"##DescriptionNotFound##" + _propertyIdString;
}
}
}