/// <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); }
private void lstMethods_DrawItem(object sender, DrawItemEventArgs e) { bool selected = (e.State & DrawItemState.Selected) != 0; if (selected) { Color c1 = SystemColors.ActiveCaption; Color c2 = Color.White; Color bgColor = Tools.MixColors(c1, c2); bgColor = Tools.MixColors(bgColor, c2); SolidBrush bgBrush = new SolidBrush(bgColor); e.Graphics.FillRectangle(bgBrush, e.Bounds); Rectangle borderBounds = e.Bounds; borderBounds.Width--; borderBounds.Height--; e.Graphics.DrawRectangle(SystemPens.ActiveCaption, borderBounds); } else { e.Graphics.FillRectangle(Brushes.White, e.Bounds); } if (e.Index < 0) { return; } VizMethodBase method = (VizMethodBase)lstMethods.Items[e.Index]; if (method is VizConstructor) { VizConstructor ctor = (VizConstructor)method; imlIcons.Draw(e.Graphics, 3, e.Bounds.Y + 2, 1); string text = string.Format("ctor: {0} ({1})", ctor.OwnerType.Name, ctor.GetParamTypes()); e.Graphics.DrawString(text, lstMethods.Font, Brushes.Black, 25, e.Bounds.Y + 3); } Brush fgBrush = Brushes.Black; if (method is VizMethod) { if (method.Name.StartsWith("get_")) { imlIcons.Draw(e.Graphics, 3, e.Bounds.Y + 3, 2); string text = string.Format("getter: {0}", method.Name.Substring(4)); e.Graphics.DrawString(text, lstMethods.Font, Brushes.Black, 25, e.Bounds.Y + 3); } else if (method.Name.StartsWith("set_")) { imlIcons.Draw(e.Graphics, 3, e.Bounds.Y + 3, 2); string text = string.Format("setter: {0}", method.Name.Substring(4)); e.Graphics.DrawString(text, lstMethods.Font, Brushes.Black, 25, e.Bounds.Y + 3); } else { VizMethod meth = (VizMethod)method; imlIcons.Draw(e.Graphics, 3, e.Bounds.Y + 2, 0); string text = string.Format("{0} {1} ({2})", meth.ReturnType, meth.Name, meth.GetParamTypes()); e.Graphics.DrawString(text, lstMethods.Font, Brushes.Black, 25, e.Bounds.Y + 3); } } }