473,385 Members | 1,772 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,385 software developers and data experts.

C# Reflecion - Is it possible?

Hello,

I want to find all the objects of some type that are currently in memory.

So it is somehow reverse from GetType().

I want to do this:

foreach(MyObject o in AllTheObjectsOfGivenType(typeof(MyObject))
{
...
}
Any suggestions please? Thank you!

David
Nov 17 '05 #1
5 1010
No. I don't think so.
"David Krmpotic" <da************@no-no.si> wrote in message
news:Rm********************@news.siol.net...
Hello,

I want to find all the objects of some type that are currently in memory.

So it is somehow reverse from GetType().

I want to do this:

foreach(MyObject o in AllTheObjectsOfGivenType(typeof(MyObject))
{
...
}
Any suggestions please? Thank you!

David

Nov 17 '05 #2
Smalltalk supports "obj allInstances" and is one of the few that do.
It's normally considered but practice to to rely on the environment for
this, as it may be hard return "all" objects in a multthread, GC'd
environment, and having the system always ready return all instances may
incur constant overhead that you wouldn't want to impose on all programs.
You'll probably need to keep your own collection of objects of the types you
want to track and you may want to use the WeakReference class so that your
collection doesn't keep objects alive that are meant to be reclaimed,
depending on how you're tracking the objects.

m
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:ug**************@TK2MSFTNGP09.phx.gbl...
No. I don't think so.
"David Krmpotic" <da************@no-no.si> wrote in message
news:Rm********************@news.siol.net...
Hello,

I want to find all the objects of some type that are currently in memory.

So it is somehow reverse from GetType().

I want to do this:

foreach(MyObject o in AllTheObjectsOfGivenType(typeof(MyObject))
{
...
}
Any suggestions please? Thank you!

David


Nov 17 '05 #3
Thank you Mike,

Actually I wanted to use this feature just out of convenience. Now I'll
register all the objects manually. I was making a simple Testing framework.
All the classes that derive from the TestingBase now have to register
themselves with TestingManager which runs the tests on all of them on
request. That works fine now. Thank you!
David Krmpotic
http://www.david13.com

"Mike" <vi********@yahoo.com> wrote in message
news:ei*************@TK2MSFTNGP12.phx.gbl...
Smalltalk supports "obj allInstances" and is one of the few that do.
It's normally considered but practice to to rely on the environment for
this, as it may be hard return "all" objects in a multthread, GC'd
environment, and having the system always ready return all instances may
incur constant overhead that you wouldn't want to impose on all programs.
You'll probably need to keep your own collection of objects of the types you want to track and you may want to use the WeakReference class so that your
collection doesn't keep objects alive that are meant to be reclaimed,
depending on how you're tracking the objects.

m
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:ug**************@TK2MSFTNGP09.phx.gbl...
No. I don't think so.
"David Krmpotic" <da************@no-no.si> wrote in message
news:Rm********************@news.siol.net...
Hello,

I want to find all the objects of some type that are currently in memory.
So it is somehow reverse from GetType().

I want to do this:

foreach(MyObject o in AllTheObjectsOfGivenType(typeof(MyObject))
{
...
}
Any suggestions please? Thank you!

David



Nov 17 '05 #4
Ever heard of NUnit? pretty popular testing framework that sound like it
works similar

http://nunit.sourceforge.net/
--
Eric Newton
eric.at.ensoft-software.com
www.ensoft-software.com
C#/ASP.net Solutions developer

"David Krmpotic" <da************@no-no.si> wrote in message
news:rI********************@news.siol.net...
Thank you Mike,

Actually I wanted to use this feature just out of convenience. Now I'll
register all the objects manually. I was making a simple Testing
framework.
All the classes that derive from the TestingBase now have to register
themselves with TestingManager which runs the tests on all of them on
request. That works fine now. Thank you!
David Krmpotic
http://www.david13.com

"Mike" <vi********@yahoo.com> wrote in message
news:ei*************@TK2MSFTNGP12.phx.gbl...
Smalltalk supports "obj allInstances" and is one of the few that do.
It's normally considered but practice to to rely on the environment for
this, as it may be hard return "all" objects in a multthread, GC'd
environment, and having the system always ready return all instances may
incur constant overhead that you wouldn't want to impose on all programs.
You'll probably need to keep your own collection of objects of the types

you
want to track and you may want to use the WeakReference class so that
your
collection doesn't keep objects alive that are meant to be reclaimed,
depending on how you're tracking the objects.

m
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:ug**************@TK2MSFTNGP09.phx.gbl...
> No. I don't think so.
>
>
> "David Krmpotic" <da************@no-no.si> wrote in message
> news:Rm********************@news.siol.net...
>> Hello,
>>
>> I want to find all the objects of some type that are currently in memory. >>
>> So it is somehow reverse from GetType().
>>
>> I want to do this:
>>
>> foreach(MyObject o in AllTheObjectsOfGivenType(typeof(MyObject))
>> {
>> ...
>> }
>>
>>
>> Any suggestions please? Thank you!
>>
>> David
>>
>>
>
>



Nov 17 '05 #5
Thank you - yes I've heard of it, but I didn't use it yet.
I wanted to make a simple one of my own. It took me like a few hours (hehe
it shouldn't even take that).

But now I am going to check NUnit out to get new ideas :)
"Eric Newton" <er**@ensoft-software.com> wrote in message
news:eY**************@tk2msftngp13.phx.gbl...
Ever heard of NUnit? pretty popular testing framework that sound like it
works similar

http://nunit.sourceforge.net/
--
Eric Newton
eric.at.ensoft-software.com
www.ensoft-software.com
C#/ASP.net Solutions developer

"David Krmpotic" <da************@no-no.si> wrote in message
news:rI********************@news.siol.net...
Thank you Mike,

Actually I wanted to use this feature just out of convenience. Now I'll
register all the objects manually. I was making a simple Testing
framework.
All the classes that derive from the TestingBase now have to register
themselves with TestingManager which runs the tests on all of them on
request. That works fine now. Thank you!
David Krmpotic
http://www.david13.com

"Mike" <vi********@yahoo.com> wrote in message
news:ei*************@TK2MSFTNGP12.phx.gbl...
Smalltalk supports "obj allInstances" and is one of the few that do.
It's normally considered but practice to to rely on the environment for
this, as it may be hard return "all" objects in a multthread, GC'd
environment, and having the system always ready return all instances may incur constant overhead that you wouldn't want to impose on all programs. You'll probably need to keep your own collection of objects of the
types you
want to track and you may want to use the WeakReference class so that
your
collection doesn't keep objects alive that are meant to be reclaimed,
depending on how you're tracking the objects.

m
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:ug**************@TK2MSFTNGP09.phx.gbl...
> No. I don't think so.
>
>
> "David Krmpotic" <da************@no-no.si> wrote in message
> news:Rm********************@news.siol.net...
>> Hello,
>>
>> I want to find all the objects of some type that are currently in

memory.
>>
>> So it is somehow reverse from GetType().
>>
>> I want to do this:
>>
>> foreach(MyObject o in AllTheObjectsOfGivenType(typeof(MyObject))
>> {
>> ...
>> }
>>
>>
>> Any suggestions please? Thank you!
>>
>> David
>>
>>
>
>



Nov 17 '05 #6

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

Similar topics

2
by: Bhupesh Naik | last post by:
This is a query regarding my problem to make a spell and grammar check possible in text area of a web page. We have aspx pages which are used to construct letters. The browser based screens...
1
by: AAA | last post by:
hi, I'll explain fastly the program that i'm doing.. the computer asks me to enter the cardinal of a set X ( called "dimX" type integer)where X is a table of one dimension and then to fill it...
25
by: Piotr Nowak | last post by:
Hi, Say i have a server process which listens for some changes in database. When a change occurs i want to refresh my page in browser by notyfinig it. I do not want to refresh my page i.e....
4
by: RSH | last post by:
Okay my math skills aren't waht they used to be... With that being said what Im trying to do is create a matrix that given x number of columns, and y number of possible values i want to generate...
7
by: Robert S. | last post by:
Searching some time now for documents on this but still did not find anything about it: Is it possible to replace the entry screen of MS Office Access 2007 - that one presenting that default...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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,...

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.