protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider) { SerializedProxy data = (SerializedProxy)objectProvider.GetObject(); //MessageBox.Show(data.ProxyType.FullName); AopProxyVisualizerForm form = new AopProxyVisualizerForm(); form.Proxy = data; windowService.ShowDialog(form); }
public override void GetData(object target, System.IO.Stream outgoingData) { ISerializableProxy realProxy = target as ISerializableProxy; SerializedProxy serializedProxy = realProxy.GetSerializedProxy(); base.GetData(serializedProxy, outgoingData); }
/// <summary> /// /// </summary> /// <returns></returns> public SerializedProxy GetSerializedProxy() { SerializedProxy proxy = new SerializedProxy(); VizType vizType = new VizType(); vizType.Name = target.GetType().Name; vizType.FullName = target.GetType().FullName; Type tmp = target.GetType(); while (typeof(IAopProxy).IsAssignableFrom(tmp)) { tmp = tmp.BaseType; } vizType.BaseName = tmp.Name; IList mixins = (IList)MethodCache.mixinsLookup[target.GetType()]; foreach (Type mixinType in mixins) { VizMixin vizMixin = new VizMixin(); vizMixin.TypeName = mixinType.Name; vizMixin.FullTypeName = mixinType.FullName; vizType.Mixins.Add(vizMixin); } IList aspects = (IList)MethodCache.aspectsLookup[target.GetType()]; foreach (IAspect aspect in aspects) { IGenericAspect tmpAspect; if (aspect is IGenericAspect) { tmpAspect = (IGenericAspect)aspect; } else { tmpAspect = TypedToGenericConverter.Convert((ITypedAspect)aspect); } VizAspect vizAspect = new VizAspect(); vizAspect.Name = tmpAspect.Name; } IList methods = (IList)MethodCache.methodsLookup[target.GetType()]; foreach (string methodId in methods) { MethodBase methodBase = (MethodBase)MethodCache.methodLookup[methodId]; if (methodBase is ConstructorInfo) { ConstructorInfo constructor = (ConstructorInfo)methodBase; VizConstructor vizConstructor = new VizConstructor(); vizConstructor.Name = constructor.Name; ParameterInfo[] paramInfos = constructor.GetParameters(); SerializeParameters(vizConstructor, paramInfos); IList interceptors = (IList)MethodCache.methodInterceptorsLookup[methodId]; SerializeInterceptors(vizConstructor, interceptors); vizConstructor.OwnerType = vizType; vizType.Methods.Add(vizConstructor); } else if (methodBase is MethodInfo) { MethodInfo method = (MethodInfo)methodBase; VizMethod vizMethod = new VizMethod(); vizMethod.Name = method.Name; vizMethod.ReturnType = method.ReturnType.Name; ParameterInfo[] paramInfos = method.GetParameters(); SerializeParameters(vizMethod, paramInfos); IList interceptors = (IList)MethodCache.methodInterceptorsLookup[methodId]; SerializeInterceptors(vizMethod, interceptors); vizMethod.OwnerType = vizType; vizType.Methods.Add(vizMethod); } } proxy.ProxyType = vizType; return(proxy); }