Skip to content

Instantly share code, notes, and snippets.

@atsushieno
Created February 26, 2013 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atsushieno/4e66da6e492dfb6c1dd0 to your computer and use it in GitHub Desktop.
Save atsushieno/4e66da6e492dfb6c1dd0 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Reflection;
using Android.Runtime;
public static class ResourceIdManager
{
static bool id_initialized;
public static void UpdateIdValues ()
{
if (id_initialized)
return;
var eass = Assembly.GetExecutingAssembly ();
Func<Assembly,Type> f = ass =>
ass.GetCustomAttributes (typeof (ResourceDesignerAttribute), true)
.Select (ca => ca as ResourceDesignerAttribute)
.Where (ca => ca != null && ca.IsApplication)
.Select (ca => ass.GetType (ca.FullName))
.Where (ty => ty != null)
.FirstOrDefault ();
var t = f (eass);
if (t == null)
t = AppDomain.CurrentDomain.GetAssemblies ().Select (ass => f (ass)).Where (ty => ty != null).FirstOrDefault ();
if (t != null)
t.GetMethod ("UpdateIdValues").Invoke (null, new object [0]);
id_initialized = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment