Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight reflection

With ASP.NET, for instance, we could reflect on the assemblies in an AppDomain, or using the type we could get the metadata about the class (props, methods, etc.). What is the technique used to extract metadata on a class, extract dependency properties, etc., in Silverlight?

like image 492
Brian Mains Avatar asked Mar 05 '11 06:03

Brian Mains


2 Answers

Reflection exists in Silverlight, with a subset of the APIs provided in the full .NET Framework.

One notable difference is that you can't reflect onto private members in Silverlight (or maybe you can inside your own assembly, but the boundaries should become apparent pretty quickly). This is a security feature to ensure you don't go messing with the internals of the framework itself.

Other than that (admittedly, rather large) limitation, Reflection should be basically the same.

like image 95
Austin Lamb Avatar answered Oct 01 '22 21:10

Austin Lamb


In addition to what Austin said, the rule with Reflection in Silverlight is that you can only access via reflection whatever you could access via normal code. So it's not just about private members. You can reflect over protected members only in the class itself or in any class inheriting it.

There are numerous missing pieces of the API but in general most things should be possible, even if they require a bit more work than in full .NET

like image 29
Krzysztof Kozmic Avatar answered Oct 01 '22 20:10

Krzysztof Kozmic