获取基础类型代理对象

问题描述:

我使用的是城堡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()