blob: 31cae3283f72c1bf1b6bb15aeb2e0f8720d901b0 (
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
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DisplayNameLocalized.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>
// Localised version of teh DisplayName attribute.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrake.Interop.Attributes
{
using System;
using System.ComponentModel;
using System.Reflection;
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.All)]
public class DisplayNameLocalized : DisplayNameAttribute
{
public DisplayNameLocalized(Type resourceManagerProvider, string resourceKey)
: base(LookupResource(resourceManagerProvider, resourceKey))
{
}
internal static string LookupResource(Type resourceManagerProvider, string resourceKey)
{
foreach (PropertyInfo staticProperty in resourceManagerProvider.GetProperties(BindingFlags.Static | BindingFlags.NonPublic))
{
if (staticProperty.PropertyType == typeof(System.Resources.ResourceManager))
{
System.Resources.ResourceManager resourceManager = (System.Resources.ResourceManager)staticProperty.GetValue(null, null);
return resourceManager.GetString(resourceKey);
}
}
return resourceKey;
}
}
}
|