Ejemplo n.º 1
0
        private static string GetObjectXml(object obj)
        {
            PresentationAspect aspect = obj as PresentationAspect;

            if (aspect != null)
            {
                return("xml:<aspect><name>" + aspect.Name + "</name></aspect>");
            }
            PresentationPointcut pointcut = obj as PresentationPointcut;

            if (pointcut != null)
            {
                return(String.Format("xml:<pointcut><aspect>{0}</aspect><pointcut>{1}</pointcut></pointcut>",
                                     pointcut.Aspect.Name,
                                     pointcut.Name));
            }
            PresentationInterceptor interceptor = obj as PresentationInterceptor;

            if (interceptor != null)
            {
                return(String.Format("xml:<interceptor><aspect>{0}</aspect><pointcut>{1}</pointcut><type-name>{2}</type-name></interceptor>",
                                     interceptor.Pointcut.Aspect.Name,
                                     interceptor.Pointcut.Name,
                                     interceptor.TypeName));
            }
            return("");
        }
Ejemplo n.º 2
0
        private void AddInterceptor(PresentationPointcut pointcut)
        {
            PresentationInterceptor interceptor = new PresentationInterceptor(pointcut);

            interceptor.TypeName = "[New Interceptor]";
            pointcut.Interceptors.Add(interceptor);
            RefreshAll();
        }
Ejemplo n.º 3
0
        public InterceptorNode(PresentationInterceptor interceptor)
            : base(interceptor.TypeName)
        {
            this.interceptor = interceptor;

            this.ImageIndex         = 7;
            this.SelectedImageIndex = 7;
        }
Ejemplo n.º 4
0
        private void removeInterceptorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PresentationInterceptor interceptor = selected as PresentationInterceptor;

            if (interceptor != null)
            {
                RemoveInterceptor(interceptor);
            }
        }
Ejemplo n.º 5
0
        private static void SerializeInterceptor(PresentationInterceptor interceptor, XmlDocument xmlDoc, XmlNode pointcutNode)
        {
            XmlNode interceptorNode = xmlDoc.CreateElement("interceptor");

            XmlAttribute typeAttrib = xmlDoc.CreateAttribute("type");

            typeAttrib.Value = interceptor.TypeName;
            interceptorNode.Attributes.Append(typeAttrib);

            pointcutNode.AppendChild(interceptorNode);
        }
Ejemplo n.º 6
0
        private void SelectObject(object obj)
        {
            PresentationAspect aspect = obj as PresentationAspect;

            if (aspect != null)
            {
                propertyGrid.SelectedObject = new AspectProperties(aspect);
                ShowAspectTypes(aspect);
            }

            PresentationAspectTarget aspectTarget = obj as PresentationAspectTarget;

            if (aspectTarget != null)
            {
                propertyGrid.SelectedObject = new AspectTargetProperties(aspectTarget);
            }

            PresentationMixin mixin = obj as PresentationMixin;

            if (mixin != null)
            {
                propertyGrid.SelectedObject = new MixinProperties(mixin);
            }

            PresentationPointcut pointcut = obj as PresentationPointcut;

            if (pointcut != null)
            {
                propertyGrid.SelectedObject = new PointcutProperties(pointcut);
                ShowPointcutMethods(pointcut);
            }
            PresentationPointcutTarget pointcutTarget = obj as PresentationPointcutTarget;

            if (pointcutTarget != null)
            {
                propertyGrid.SelectedObject = new PointcutTargetProperties(pointcutTarget);
            }

            PresentationInterceptor interceptor = obj as PresentationInterceptor;

            if (interceptor != null)
            {
                propertyGrid.SelectedObject = new InterceptorProperties(interceptor);
                ShowInterceptorMethods(interceptor);
            }

            Type type = obj as Type;

            if (type != null)
            {
                propertyGrid.SelectedObject = new TypeProperties(type);
            }
        }
Ejemplo n.º 7
0
        private PresentationInterceptor GetDropInterceptor(XmlNode payload)
        {
            XmlNode            aspectNode   = payload.SelectSingleNode("aspect");
            XmlNode            pointcutNode = payload.SelectSingleNode("pointcut");
            XmlNode            typeNameNode = payload.SelectSingleNode("type-name");
            PresentationAspect aspect       = model.GetAspect(aspectNode.InnerText);

            if (aspect != null)
            {
                PresentationPointcut pointcut = aspect.GetPointcutWithNameAndInterceptor(pointcutNode.InnerText, typeNameNode.InnerText);
                if (pointcut != null)
                {
                    PresentationInterceptor interceptor = pointcut.GetInterceptor(typeNameNode.InnerText);
                    return(interceptor);
                }
            }
            return(null);
        }
Ejemplo n.º 8
0
        private void TreeViewDragDrop(TreeView treeView, DragEventArgs e)
        {
            Point pt = treeView.PointToClient(new Point(e.X, e.Y));

            int    x    = pt.X;
            int    y    = pt.Y;
            string data = "";

            NodeBase overNode = (NodeBase)treeView.GetNodeAt(new Point(x, y));

            if (e.Data.GetDataPresent(typeof(string)))
            {
                data = (string)e.Data.GetData(typeof(string));
            }

            if (data == null)
            {
                data = "";
            }

            if (data.Length > 0)
            {
                string  header;
                XmlNode payload = ParseDragData(data, out header);
                if (header == "aspect")
                {
                    PresentationAspect dropAspect = GetDropAspect(payload);
                    if (overNode != null)
                    {
                        if (overNode is TypeNode)
                        {
                            if (dropAspect != null)
                            {
                                dropAspect.AddTypeTarget(((TypeNode)overNode).Type);
                                RefreshAll();
                            }
                        }
                    }
                }
                if (header == "pointcut")
                {
                    PresentationPointcut dropPointcut = GetDropPointcut(payload);
                    if (overNode != null)
                    {
                        if (overNode is TypeNode)
                        {
                            if (dropPointcut != null)
                            {
                                dropPointcut.AddTypeTarget(((TypeNode)overNode).Type);
                                RefreshAll();
                            }
                        }
                        if (overNode is MethodNode)
                        {
                            if (dropPointcut != null)
                            {
                                MethodNode methodNode = overNode as MethodNode;
                                if (methodNode.CanBeProxied())
                                {
                                    dropPointcut.AddMethodTarget(methodNode.MethodBase, methodNode.Type);
                                    RefreshAll();
                                }
                            }
                        }
                    }
                }
                if (header == "interceptor")
                {
                    PresentationInterceptor dropInterceptor = GetDropInterceptor(payload);
                    if (overNode != null)
                    {
                        if (overNode is TypeNode)
                        {
                            if (dropInterceptor != null)
                            {
                                dropInterceptor.AddTypeTarget(((TypeNode)overNode).Type);
                                RefreshAll();
                            }
                        }
                        if (overNode is MethodNode)
                        {
                            if (dropInterceptor != null)
                            {
                                MethodNode methodNode = overNode as MethodNode;
                                if (methodNode.CanBeProxied())
                                {
                                    dropInterceptor.AddMethodTarget(methodNode.MethodBase, methodNode.Type);
                                    RefreshAll();
                                }
                            }
                        }
                    }
                }
            }

            TurnOffTreeDragHilite();
        }
Ejemplo n.º 9
0
        private void ShowInterceptorMethods(PresentationInterceptor interceptor)
        {
            listViewMaster = interceptor;

            ShowAppliedMethods(interceptor.AppliedOnMethods);
        }
Ejemplo n.º 10
0
 private void RemoveInterceptor(PresentationInterceptor interceptor)
 {
     interceptor.Pointcut.Interceptors.Remove(interceptor);
     RefreshAll();
 }
 public InterceptorProperties(PresentationInterceptor interceptor)
 {
     this.interceptor = interceptor;
 }