using System; using System.ComponentModel; using System.Reflection; namespace CUETools.Codecs; /// /// Localized description attribute /// [AttributeUsage(AttributeTargets.All)] public class SRDescriptionAttribute : DescriptionAttribute { /// /// Resource manager to use; /// readonly Type SR; /// /// Store a flag indicating whether this has been localized /// bool localized; /// /// Construct the description attribute /// /// public SRDescriptionAttribute(Type SR, string text) : base(text) { localized = false; this.SR = SR; } /// /// Override the return of the description text to localize the text /// public override string Description { get { if(!localized) { localized = true; DescriptionValue = SR.InvokeMember(DescriptionValue, BindingFlags.GetProperty | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, null, []) as string; } return base.Description; } } }