Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String to reference static object
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01439141
Message ID:
01439159
Views:
36
>>
>>This works (but maybe there's a shorter way?):
Type t = typeof(LLCommands);
>>            PropertyInfo p =  t.GetProperty("LockDown", BindingFlags.Public | BindingFlags.Static);
>>            RoutedUICommand r = (RoutedUICommand) p.GetValue(LLCommands.LockDown,null);
>>            SupportedCommands.Add(r);
obviously needs a bit of exception handling tho.....
>
>Would this work?
>
>
>var t = typeof(LLCommands);
>var routedCommand = (RoutedUICommand) t.InvokeMember("LockDown", BindingFlags.GetProperty, null, t, new object[0]);
>
Hi,
Much neater. But it throws an exception if the string isn't valid :-{
Previous
Reply
Map
View

Click here to load this message in the networking platform