diff options
author | Rob Lyndon <rob.lyndon@gmail.com> | 2017-04-12 11:57:13 +0100 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2017-04-12 11:57:13 +0100 |
commit | b9a94f4b87f2d89a4eda990910f3a69c073c7c95 (patch) | |
tree | c79fe0f79ccf91198c3b891054b8286bb1ebd884 /Xamarin.Forms.Platform.Android | |
parent | dfda41b0bdc0ea80f548e3c919f14e8094c6cb25 (diff) | |
download | xamarin-forms-b9a94f4b87f2d89a4eda990910f3a69c073c7c95.tar.gz xamarin-forms-b9a94f4b87f2d89a4eda990910f3a69c073c7c95.tar.bz2 xamarin-forms-b9a94f4b87f2d89a4eda990910f3a69c073c7c95.zip |
Resource Manager fix for F# File Resources (Bugzilla 53515) (#825)
* Resource Manager fix for F# File Resources (Bugzilla 53515)
* Changed spaces to tabs and changed the argument name in the ResourceManager.GetId() function.
* Improved the type checking in GetId().
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-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; } } |