init
This commit is contained in:
29
Common/DTS.Common/Attributes/DescriptionAttributeEx.cs
Normal file
29
Common/DTS.Common/Attributes/DescriptionAttributeEx.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user