获取基础类型代理对象 [英] Getting underlying type of a proxy object

查看:225
本文介绍了获取基础类型代理对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是城堡DynamicProxy和我的ViewModels是一个代理,是这样的:

I'm using Castle DynamicProxy and my ViewModels are a proxy, something like this:


namespace MyApplication.ViewModels
{
   public class MyViewModel : BaseViewModel, IMyViewModel
   {
   }
}

一我的视图模型的代理看起来像这样虽然:

a proxy of my viewmodel looks like this though:

{NAME =IRootViewModelProxyffecb133f590422098ca7c0ac13b8f98全名=IRootViewModelProxyffecb133f590422098ca7c0ac13b8f98}

{Name = "IRootViewModelProxyffecb133f590422098ca7c0ac13b8f98" FullName = "IRootViewModelProxyffecb133f590422098ca7c0ac13b8f98"}

我想是被代理的实际类型的实际类型或命名空间。有没有办法做到这一点?我想要的东西,返回MyApplication.ViewModels.MyViewModel类型。如果我使用concreate类作为代理,BASETYPE返回正在被代理的实际类,但使用接口时,BASETYPE将返回System.Object的。

I want to get the actual type or namespace of the actual type that is being proxied. Is there any way to do this? I want something that returns MyApplication.ViewModels.MyViewModel type. If I'm using concreate class as proxies, BaseType returns the actual class that is being proxied, but when using the interface, BaseType would return System.Object.

推荐答案

看来你可以做以下获得的实际类型:

It seems you can do the following to get the actual type:


(proxy As IProxyTargetAccessor).DynProxyGetTarget().GetType()

这篇关于获取基础类型代理对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆