c# - with dynamic, awkward reflection no more? -
Introduces C # 4.0 dynamic keywords, which will appear in run-time
Does this mean we need a weird reflection now? If it does, can you show an example of it?
We still will reflection - Reflection-based dispatcher using 'dynamic' against regular CLR objects
So - we will still reflect, but it will be easy to do.
Here is an example:
// 'dynamic' via dynamic dx = GetSomeCLRObject (); Dx.DoSomething (); Dx.SomeMember = 2; // y reflection object x = getSomeCLRObject (); Type xt = x.GetType (); MemberInfo DoSomethingMethod = xt.GetMethod ("DoSomething"); DoSomethingMethod.Invoke (x, blank); Property Info SomemplateProperty = xt.GetProperty ("Some Member"); SomeMelpPropertySet Values (X, 2); I do not know about you, but I like the pre =)
In both of these cases, I have not checked any compiled periodically, no No Intelligence, no IDE support - but former case is more expressive than later words.
Comments
Post a Comment