开发者

Find objects of a specific type in an object graph

开发者 https://www.devze.com 2023-03-24 05:16 出处:网络
Given an object instance, how can I recurse its members (i.e. the whole object graph) for an object of a specific type, or one that inherits from a specific type?

Given an object instance, how can I recurse its members (i.e. the whole object graph) for an object of a specific type, or one that inherits from a specific type?

For e开发者_开发百科xample, I want to find all objects in session that may have deep indirect references to System.Web.UI.Control.


Don't know exactly how to do it but i'm quite sure you have to use Reflection to iterate over all properties of an object. Google and you will most likely find an example. Like this one http://wiki.asp.net/page.aspx/474/how-to-iterate-through-all-properties-of-a-class/

With that you can probably figure out how to do the recursion yourself.

0

精彩评论

暂无评论...
验证码 换一张
取 消