예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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 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);
     }
 }
예제 #5
0
        private void lstMethods_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstMethods.SelectedIndex == -1)
            {
                return;
            }

            VizMethodBase vizMethod = (VizMethodBase)lstMethods.SelectedItem;

            SelectMethod(vizMethod);
        }
예제 #6
0
        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 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);
            }
        }
예제 #8
0
        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);
                }
            }
        }