473,387 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Deep reflection.

How can I do deep reflection on an object. In other words, if a property of
an object is another object, I want to do reflection on that too and so on
until I arrive at value types (or string). Here is what I got so far, but I
don't know how to tell whether a property is an object or a value type. As
you can tell I am doing the entire thing via recursion.
private string GetObjectInfo(System.Object o)
{
string s;
Type t = o.GetType();
PropertyInfo[] pis = t.GetProperties();

s = "\n\n" + o.ToString();
for (int i=0; i<pis.Length; i++)
{
PropertyInfo pi = (PropertyInfo)pis.GetValue(i);
s += "\n\t" + pi.Name;
s += "=" + pi.GetValue(o, new object[]{});

//HOW DO I FIND OUT WHETHER THIS PROPERTY
//IS AN OBJECT?
if (pi.IsObject)
s += GetObjectInfo (pi)
}
return s;
}
Thanks.

--
Frank
Nov 15 '05 #1
0 1731

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steve - DND | last post by:
Is there any way to easily deep copy an entire object? Maybe something with unsafe code to make a full and completely duplicated copy of an object with no reference ties to the original? I want...
5
by: marcosegurini | last post by:
Hi, the following class describes my actual problem: class DeepCopy<T> { T val_; public void Assign(T newVal) {
13
by: ahaupt | last post by:
Hi all, I'm implementing the Clone() method through the ICloneable interface and don't quite know how deep I need to go for a deep copy. Example: class A: ICloneable { object _val;
1
by: oDDskOOL | last post by:
I realized today that the Hashtable.Clone only produces a shallow copy... that makes me go mad that M$ doesn't even provide a deep copy ctor for the Hashtable class ! mighty tech ducks might...
0
by: see_bees | last post by:
I am running Office 2000, and would like to create a deep clone of a word document object. 1. There is no clone function for the document class. 2. I can't get reflection to give me a list of...
5
by: BenW | last post by:
Hello, What is the easiest way to make "deep copy" of my Hashtable? How about with other Collection classes in C#, any documents available? I don'r actually understand why Framework's...
6
by: AllenGnr | last post by:
There are two objects, instants of two different class, but they has same schema. Class ClientDivision { public string Name { get {}; set {}; }
3
by: Benny | last post by:
I just cant find a good explanation on how to "deep bind" objects, so im hoping someone can help. I have an object that contains another object, for example: Book has a title, pagecount, and an...
3
by: gasfusion | last post by:
Hey guys. I have a little problem trying to clone my object, which is shown below. If you notice below, i am using a generic linked list structure to store byte arrays. The problem is when i use my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.