Files
DP44/DataPRO/Users/UserSettings/CategoryAttributeEx.cs
2026-04-17 14:55:32 -04:00

29 lines
1.1 KiB
C#

using System.ComponentModel;
using Users.UserSettings;
// ReSharper disable once CheckNamespace
namespace DTS.Slice.Users.UserSettings
{
/// <summary>
/// this class overloads the categoryattribute to provide a localized string using our string resources
/// we also overload it so that we can use an enum to set the attribute
/// to be translated the category should exist in the string resources, otherwise you'll get
/// ##ResourceNotFound## as your translated string
/// </summary>
public class CategoryAttributeEx : CategoryAttribute
{
private readonly PropertyEnums.PropertyCategories _category;
public PropertyEnums.PropertyCategories GetCategory() { return _category; }
protected override string GetLocalizedString(string value)
{
return StringResources.ResourceManager.GetString(value) ?? "##ResourceNotFound##" + value;
}
public CategoryAttributeEx(PropertyEnums.PropertyCategories category) : base(category.ToString())
{
_category = category;
}
}
}