Can I get a instance from type?

  • Thread starter Thread starter ºù«µºÉÌÇæÈí¼þ£­ÕÅн¨
  • Start date Start date
º

ºù«µºÉÌÇæÈí¼þ£­ÕÅн¨

i konw a type(no class),can i get this type`s instance list?
 
ºÇºÇ£¬Ó¢Óï½Ï²î£¬
ÊÇÕâÑùµÄ£¬ÎÒÓÐÒ»¸ö¼Ì³Ð×ÔMarshalByRefµÄÀàSvcController±»×¢²áΪSingleton.
ͬʱ£¬Õâ¸öÀàÔÚ±¾AppDomainÖпÉÄܱ»ÊµÀý»¯Á˶à´Î£¬

ÎÒÏÖÔÚÏëÖªµÀ£¬ÄĸöʵÀýÊDZ»Ô¶³ÌʵÀý»¯µÄ£¬È»ºóÎÒµ÷ÓÃÕâ¸ö±»Ô¶³ÌʵÀý»¯ ʵÀý µÄ·½
·¨£¬ÒÔ´¥·¢Ò»¸öʼþ֪ͨ¿Í»§¡£

²»Äܵ÷ÓÃËùÓÐʵÀýµÄ£¨ÒòΪÈç¹ûµ÷Óñ¾µØµÄʵÀý£¬»áÒýÆðÏûϢѭ»·£©¡£

Ôõô²ÅÄÜÅжÏÄĸöʵÀýÊDZ»Ô¶³ÌʵÀý»¯µÄÄØ£¿
 
Just a question. What encoding do you use for your messages? I am unable to see your text as the encoding isn't specified in the message.
 
SIMPLE CHINESE GB2312

Morten Wennevik said:
Just a question. What encoding do you use for your messages? I am unable
to see your text as the encoding isn't specified in the message.
 
Ah, well, I found a GBK/BG2312 encoding, which will output the text in Chinese, but since I don't know any Chinese beyond "ni hao" I guess it doesn't really matter :)

SIMPLE CHINESE GB2312

Morten Wennevik said:
Just a question. What encoding do you use for your messages? I am unable
to see your text as the encoding isn't specified in the message.
 
No, you can not. There is no way to see what instances of a type exist
in the current app domain. You ^might^ be able to do this through the hooks
that the CLR provides, but I wouldn't recommend it.

If you need this information, I would recommend using a class factory
pattern, where you can keep track of the instances that are created and then
retrieve them when necessary.

Hope this helps.
 
Back
Top