473,387 Members | 1,520 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.

System.Reflection questions...

Hi all...

Is there any way I can use reflection to get the complete "path" to the
current object?

So e.g. <objectA> creates <objectB> which creates <objectC>.

Then <objectB> executes a method provided by <objectC> which returns
something like "objectA.objectB.objectC".

Similarly, if <objectB> executes the same code on itself (assume it has the
same method defined as <objectC>", it would return "objectA.objectB"

Thanks!
Alex
Nov 22 '05 #1
3 837
I don't think you can. Otherwise even 'top level' objects you create, would
really be under something else. Also, what if objectC is referenced by
multiple objectB's? Maybe in your scenario that wouldn't happen, but you can
certainly imagine the it could in another, and then what would expect to get
for the path?

Typically if an object needs to know its parent, it will have a property for
this.

"Alex" <no****@hotmail.com> wrote in message
news:43***********************@news.zen.co.uk...
Hi all...

Is there any way I can use reflection to get the complete "path" to the
current object?

So e.g. <objectA> creates <objectB> which creates <objectC>.

Then <objectB> executes a method provided by <objectC> which returns
something like "objectA.objectB.objectC".

Similarly, if <objectB> executes the same code on itself (assume it has
the same method defined as <objectC>", it would return "objectA.objectB"

Thanks!
Alex

Nov 22 '05 #2
If you need objectA from objectC there is something wrong with your design
imo but i am not sure that this is what you mean. Anyway you can implement
your own ToString() and in each ToString() you return the base.ToString() +
current objects name

If C derives from B and B derives from A the ToString() of C would give
A.B.C

Gabriel Lozano-Morán

"Alex" <no****@hotmail.com> wrote in message
news:43***********************@news.zen.co.uk...
Hi all...

Is there any way I can use reflection to get the complete "path" to the
current object?

So e.g. <objectA> creates <objectB> which creates <objectC>.

Then <objectB> executes a method provided by <objectC> which returns
something like "objectA.objectB.objectC".

Similarly, if <objectB> executes the same code on itself (assume it has
the same method defined as <objectC>", it would return "objectA.objectB"

Thanks!
Alex

Nov 22 '05 #3
Marina,

Thanks - that's how I'm currently doing it (passing a string into the
constructor of each object, so it knows which parent object "owns" it).

I was just wondering if there was a neater way of doing it...

Alex
Nov 22 '05 #4

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

Similar topics

5
by: Andre | last post by:
I have two questions; 1) When executing the sub routine "TestStructure", I'm trying to update the member "intTyres" in the structure "structureCar" dynamically using System.Reflection. The code...
1
by: Brian | last post by:
I've looked through the previous posts on this one and have verified permissions and location of my Dlls, but I am still getting an exception when I try to Load an assembly. The directory where...
2
by: Doug | last post by:
Hi, I have two questions about Reflection. One I think I know the answer to but will ask anyway. 1) I can delve into a component or executable and get all the way to the method within a...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
1
by: Patrick | last post by:
Has been trying to get an ASP.NET DLL's modification date/time for the "release date/time" to be displayed on the page's footer Using: System.Reflection.Assembly...
1
by: Tom | last post by:
Having some trouble with my assembly running another assembly, and I am starting to suspect this may be a windows bug or a framework bug. Everything works fine on my development workstation (XP...
2
by: @@Worker | last post by:
can someone write a sample here? thanks "Kevin Spencer" <kevin@DIESPAMMERSDIEtakempis.com> дÈëÏûÏ¢ÐÂÎÅ:%23VUjBemeGHA.1204@TK2MSFTNGP02.phx.gbl... > Use the system.Reflection namespce,...
3
by: groovyjman21 | last post by:
Hi, I am using FXCop on my c# project and it is complaining about signing the assembly with a strong name key. All the documentation I can find says to do: using System.Reflection; .... ...
3
by: astruyk | last post by:
Is there a way to add an Attribute to an existing type? Like say I wanted to add a to the List<inttype, how would I go about doing that? Also is there any way to attach Attributes to types at...
16
by: Paul Schwann | last post by:
Hi group, I am relatively new to C# (although I have a lot of programming excperience in other languages like Java and C). Currently I am searching for a solution to this problem: Suppose you...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.