blob: e359a7fbab78282bfcf79c38c839cc624bf19d2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DisplayName.cs" company="HandBrake Project (https://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
// A Display Name for an enum value
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrake.Interop.Attributes
{
using System;
using System.Reflection;
public class DisplayName : Attribute
{
public DisplayName(string displayName)
{
this.Name = displayName;
}
public DisplayName(Type resourceManagerProvider, string resourceKey)
{
this.Name = LookupResource(resourceManagerProvider, resourceKey);
}
public string Name { get; }
internal static string LookupResource(Type resourceManagerProvider, string resourceKey)
{
foreach (PropertyInfo staticProperty in resourceManagerProvider.GetProperties(BindingFlags.Static | BindingFlags.Public))
{
if (staticProperty.PropertyType == typeof(System.Resources.ResourceManager))
{
System.Resources.ResourceManager resourceManager = (System.Resources.ResourceManager)staticProperty.GetValue(null, null);
return resourceManager.GetString(resourceKey);
}
}
return resourceKey;
}
}
}
|