maybe IndexOf("Proxy") == BaseType.Name.Length could give wee bit more
robustness


On Thu, Jan 29, 2009 at 10:49 PM, Tyler Burd <[email protected]> wrote:

>  Well, right now I'm trying to support proxied and non-proxied classes, as
> well as interface proxies.  So here is my current logic (from the hip pseudo
> code), in case anyone else has any need for it or any comments on it:
>
>
>
> //first check for interface proxy
>
> var interfaceProxy = possibleProxyInstance as IProxyTargetAccessor;
>
> If (interfaceProxy != null)
>
>             return interfaceProxy.DynProxyGetTarget().GetType();
>
>
>
> //next check for class proxy
>
> var possibleProxyType = possibleProxyInstance.GetType();
>
>
>
> if (possibleProxyType.Name.Contains("Proxy"))
>
>             return possibleProxyType.BaseType;
>
> else
>
>             return possibleProxyType;
>
>
>
>
>
> It's the 'possibleProxyType.Name.Contains("Proxy")' line that I'm not
> terribly fond of, but it works for my purposes.
>
>
>
> Thank you all for your help!
>
>
>  ------------------------------
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Tuna Toksoz
> *Sent:* Thursday, January 29, 2009 12:18 PM
> *To:* [email protected]
> *Subject:* Re: get underlying type of proxy?
>
>
>
> casting to IProxyTargetAccessor ?
>
>
> Tuna Toksöz
> http://tunatoksoz.com
> http://twitter.com/tehlike
>
> Typos included to enhance the readers attention!
>
>
>  On Thu, Jan 29, 2009 at 9:16 PM, Ayende Rahien <[email protected]> wrote:
>
> well, if you are proxying a real type
>
> If you are proxying an interface, that is harder.
>
>
>
> On Thu, Jan 29, 2009 at 2:16 PM, Ayende Rahien <[email protected]> wrote:
>
> yes
>
>
>
> On Thu, Jan 29, 2009 at 1:08 PM, Ken Egozi <[email protected]> wrote:
>
> not sure.
>
> would
>                  .GetType().BaseType
> do the trick?
>
>
>
> On Thu, Jan 29, 2009 at 4:48 AM, Tyler Burd <[email protected]> wrote:
>
> I have a proxied instance of an object.  Is there a way to determine the
> "real" type that is being proxied at runtime?
>
>
>
> So given the following:
>
>
>
> Real Type:  MyType
>
> Proxy Type:  MyTypeProxy124934553rikgnoi2
>
>
>
> If I have an instance of MyTypeProxy124934553rikgnoi2, how can I determine
> programmatically that it wraps MyType?
>
>
>
> Thanks!
>
>
>
> Tyler
>
>
>
>
>
>
>
>
> --
>
> Ken Egozi.
> http://www.kenegozi.com/blog
> http://www.delver.com
> http://www.musicglue.com
> http://www.castleproject.org
> http://www.gotfriends.co.il
>
>
>
>
>
>
>
>
>
>
>
>
> >
>


-- 
Ken Egozi.
http://www.kenegozi.com/blog
http://www.delver.com
http://www.musicglue.com
http://www.castleproject.org
http://www.gotfriends.co.il

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to