diff options
-rw-r--r-- | Xamarin.Forms.Platform.Android/ResourceManager.cs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Xamarin.Forms.Platform.Android/ResourceManager.cs b/Xamarin.Forms.Platform.Android/ResourceManager.cs index 147fec88..402e52be 100644 --- a/Xamarin.Forms.Platform.Android/ResourceManager.cs +++ b/Xamarin.Forms.Platform.Android/ResourceManager.cs @@ -74,23 +74,23 @@ namespace Xamarin.Forms.Platform.Android public static void Init(Assembly masterAssembly) { - DrawableClass = masterAssembly.GetTypes().FirstOrDefault(x => x.Name == "Drawable"); - ResourceClass = masterAssembly.GetTypes().FirstOrDefault(x => x.Name == "Id"); + DrawableClass = masterAssembly.GetTypes().FirstOrDefault(x => x.Name == "Drawable" || x.Name == "Resource_Drawable"); + ResourceClass = masterAssembly.GetTypes().FirstOrDefault(x => x.Name == "Id" || x.Name == "Resource_Id"); } internal static int IdFromTitle(string title, Type type) { string name = Path.GetFileNameWithoutExtension(title); int id = GetId(type, name); - return id; // Resources.System.GetDrawable (Resource.Drawable.dashboard); + return id; } - static int GetId(Type type, string propertyName) + static int GetId(Type type, string memberName) { - FieldInfo[] props = type.GetFields(); - FieldInfo prop = props.Select(p => p).FirstOrDefault(p => p.Name == propertyName); - if (prop != null) - return (int)prop.GetValue(type); + object value = type.GetFields().FirstOrDefault(p => p.Name == memberName)?.GetValue(type) + ?? type.GetProperties().FirstOrDefault(p => p.Name == memberName)?.GetValue(type); + if (value is int) + return (int)value; return 0; } } |