mardi 22 septembre 2015

Get an inner class via reflection (Windows 8.1)

I have a class called Languages. It contains several other static classes. For instance:

namespace TryReflection
{
    class Languages
    {
        public static class it
        {
            public static string PLAY = "Gioca";
            public static string START = "Inizia!";
            public static string NEXT = "Prossimo";
            public static string STOP = "Ferma!";
            public static string SCORE = "Punti";
            public static string RESTART = "Per cambiare la difficoltà inizia una nova partita";
        }

        public static class en
        {
            public static string PLAY = "Play";
            public static string START = "Start!";
            public static string NEXT = "Next";
            public static string STOP = "Stop!";
            public static string SCORE = "Score";
            public static string RESTART = "To change difficulty restart your match";
        }
    }
}

Each class contains some static strings. I'd like to access these classes via reflection (and with the system language string that I have). I can access the Languages class this way:

Type tt = Type.GetType("TryReflection.Languages", true); 

And then I'd like to do something like:

tt.GetNestedType();

Unfortunately, it seems that on Windows 8.1 there's no GetNestedTypes method. So, how can I access one of these classes? Thank you.





Aucun commentaire:

Enregistrer un commentaire