private void DrawConsumer(VizMethodBase vizMethod, Graphics g) { Rectangle consumerBounds = new Rectangle(30, 30, 450, 30); DrawBox(consumerBounds, g, Color.White, Color.FromArgb(210, 255, 230)); DrawStringBold(consumerBounds.X + 30, consumerBounds.Y + 3, "Your consumer code", g); DrawString(consumerBounds.X + 30, consumerBounds.Y + 15, vizMethod.GetCallSample(), g); }
private void DrawBase(VizMethodBase vizMethod, Graphics g,int y) { Rectangle consumerBounds = new Rectangle(30, 00 + y, 450, 30); DrawBox(consumerBounds, g, Color.White, Color.FromArgb(255, 230, 210)); DrawStringBold(consumerBounds.X + 30, consumerBounds.Y + 3, "Provider [Aop Target]", g); DrawString(consumerBounds.X + 30, consumerBounds.Y + 15, vizMethod.GetRealText(), g); }
private void SelectMethod(VizMethodBase vizMethod) { int height = 230 + 70 * vizMethod.Interceptors.Count; foreach (VizInterceptor vizInterceptor in vizMethod.Interceptors) { height += vizInterceptor.ThrowsExceptionTypes.Count * 15; } Bitmap bmp = new Bitmap(800,height ); Graphics g = Graphics.FromImage(bmp); g.Clear(Color.White); g.SmoothingMode = SmoothingMode.AntiAlias; Rectangle consumerBounds = new Rectangle(30, 30, 450, 30); Rectangle bg = consumerBounds; bg.Inflate(30, 20); g.FillRectangle(Brushes.LightYellow, bg); Pen pen = new Pen (Brushes.Silver,5f); pen.EndCap = LineCap.ArrowAnchor; int bottom = height-70; g.DrawLine(pen, 100, 70, 100, bottom); g.DrawLine(pen, 410, bottom, 410, 70); DrawConsumer(vizMethod, g); DrawProxy(vizMethod, g); int y = 170; foreach (VizInterceptor vizInterceptor in vizMethod.Interceptors) { DrawInterceptor(vizInterceptor, g, y); y += 70; y += vizInterceptor.ThrowsExceptionTypes.Count * 15; } DrawBase(vizMethod, g,y); picInterceptors.Image = bmp; g.Dispose(); }
private void DrawProxy(VizMethodBase vizMethod, Graphics g) { Rectangle consumerBounds = new Rectangle(30, 30 + 70, 450, 30); DrawBox(consumerBounds, g, Color.White, Color.FromArgb(255, 210, 230)); DrawStringBold(consumerBounds.X + 30, consumerBounds.Y + 3, "Aop Proxy [Debugger hidden]", g); DrawString(consumerBounds.X + 30, consumerBounds.Y + 15, vizMethod.GetProxyText(), g); }
private void SerializeInterceptors(VizMethodBase vizMethodBase, IList interceptors) { foreach (object interceptor in interceptors) { VizInterceptorType interceptorType = VizInterceptorType.Around; VizInterceptor vizInterceptor = new VizInterceptor(); if (interceptor is IAfterInterceptor) { interceptorType = VizInterceptorType.After; vizInterceptor.Name = interceptor.GetType().Name; } else if (interceptor is IBeforeInterceptor) { interceptorType = VizInterceptorType.Before; vizInterceptor.Name = interceptor.GetType().Name; } else if (interceptor is IAroundInterceptor) { interceptorType = VizInterceptorType.Around; vizInterceptor.Name = interceptor.GetType().Name; } else if (interceptor is AroundDelegate) { interceptorType = VizInterceptorType.Around; Delegate ad = (Delegate) interceptor; vizInterceptor.Name = ad.Method.DeclaringType.Name + "." + ad.Method.Name; } else if (interceptor is AfterDelegate) { interceptorType = VizInterceptorType.After; Delegate ad = (Delegate) interceptor; vizInterceptor.Name = ad.Method.DeclaringType.Name + "." + ad.Method.Name; } else if (interceptor is BeforeDelegate) { interceptorType = VizInterceptorType.Before; Delegate ad = (Delegate) interceptor; vizInterceptor.Name = ad.Method.DeclaringType.Name + "." + ad.Method.Name; } vizInterceptor.TypeName = interceptor.GetType().Name; vizInterceptor.InterceptorType = interceptorType; if (interceptor.GetType().GetCustomAttributes(typeof (MayBreakFlowAttribute), false).Length > 0) { vizInterceptor.MayBreakFlow = true; } if (interceptor.GetType().GetCustomAttributes(typeof (IsRequiredAttribute), false).Length > 0) { vizInterceptor.IsRequired = true; } object[] exceptionTypes = interceptor.GetType().GetCustomAttributes(typeof (ThrowsAttribute), false); foreach (ThrowsAttribute throws in exceptionTypes) { vizInterceptor.ThrowsExceptionTypes.Add(throws.ExceptionType.Name); } vizMethodBase.Interceptors.Add(vizInterceptor); } }
private static void SerializeParameters(VizMethodBase vizMethodBase, ParameterInfo[] paramInfos) { foreach (ParameterInfo paramInfo in paramInfos) { VizParameter vizParameter = new VizParameter(); vizParameter.Name = paramInfo.Name; vizParameter.ParameterTypeName = paramInfo.ParameterType.Name; vizMethodBase.Parameters.Add(vizParameter); } }