private static void SerializeAspect(PresentationAspect aspect, XmlDocument xmlDoc, XmlNode configNode) { XmlNode aspectNode = xmlDoc.CreateElement("aspect"); if (aspect.Name != "") { XmlAttribute nameAttrib = xmlDoc.CreateAttribute("name"); nameAttrib.Value = aspect.Name; aspectNode.Attributes.Append(nameAttrib); } configNode.AppendChild(aspectNode); foreach (PresentationAspectTarget target in aspect.Targets) { SerializeAspectTarget(target, xmlDoc, aspectNode); } foreach (PresentationMixin mixin in aspect.Mixins) { SerializeMixin(mixin, xmlDoc, aspectNode); } foreach (PresentationPointcut pointcut in aspect.Pointcuts) { SerializePointcut(pointcut, xmlDoc, aspectNode); } }
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(""); }
private void AddPointcut(PresentationAspect aspect) { PresentationPointcut pointcut = new PresentationPointcut(aspect); pointcut.Name = "New Pointcut"; aspect.Pointcuts.Add(pointcut); RefreshAll(); }
private void AddAspectTarget(PresentationAspect aspect) { PresentationAspectTarget aspectTarget = new PresentationAspectTarget(aspect); aspectTarget.Signature = "[New Aspect Target]"; aspectTarget.TargetType = AspectTargetType.Signature; aspect.Targets.Add(aspectTarget); RefreshAll(); }
private void AddMixin(PresentationAspect aspect) { PresentationMixin mixin = new PresentationMixin(aspect); mixin.TypeName = "[New Mixin]"; aspect.Mixins.Add(mixin); RefreshAll(); }
private void removeAspectToolStripMenuItem_Click(object sender, EventArgs e) { PresentationAspect aspect = selected as PresentationAspect; if (aspect != null) { RemoveAspect(aspect); } }
private void addMixinToolStripMenuItem_Click(object sender, EventArgs e) { PresentationAspect aspect = selected as PresentationAspect; if (aspect != null) { AddMixin(aspect); } }
public static PresentationModel CreatePresentationModel(IEngine engine) { PresentationModel model = new PresentationModel(); foreach (IGenericAspect aspect in engine.Configuration.Aspects) { PresentationAspect presAspect = new PresentationAspect(aspect); model.Aspects.Add(presAspect); } return model; }
private PresentationPointcut GetDropPointcut(XmlNode payload) { XmlNode aspectNode = payload.SelectSingleNode("aspect"); XmlNode pointcutNode = payload.SelectSingleNode("pointcut"); PresentationAspect aspect = model.GetAspect(aspectNode.InnerText); if (aspect != null) { return(aspect.GetPointcut(pointcutNode.InnerText)); } return(null); }
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); } }
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); }
private void ShowAspectTypes(PresentationAspect aspect) { listViewMaster = aspect; applicationListView.BeginUpdate(); applicationListView.Clear(); applicationListView.Columns.Add("Name", 250); applicationListView.Columns.Add("Assembly", 250); foreach (Type type in aspect.AppliedOnTypes) { TypeItem item = new TypeItem(type); applicationListView.Items.Add(item); } applicationListView.EndUpdate(); }
public PresentationPointcut(PresentationAspect aspect, IPointcut pointcut) { this.aspect = aspect; this.Name = pointcut.Name; foreach (PointcutTarget target in pointcut.Targets) { PresentationPointcutTarget presTarget = new PresentationPointcutTarget(this, target); this.Targets.Add(presTarget); } foreach (object interceptor in pointcut.Interceptors) { string typeName = ""; if (interceptor is Type) typeName = ((Type)interceptor).FullName; else typeName = (string)interceptor; PresentationInterceptor presInterceptor = new PresentationInterceptor(this, typeName); this.Interceptors.Add(presInterceptor); } }
private void RemoveAspect(PresentationAspect aspect) { model.Aspects.Remove(aspect); RefreshAll(); }
public PresentationPointcut(PresentationAspect aspect) { this.aspect = aspect; }
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(); }
private static void SerializeAspect(PresentationAspect aspect, XmlDocument xmlDoc, XmlNode configNode) { XmlNode aspectNode = xmlDoc.CreateElement("aspect"); if (aspect.Name != "") { XmlAttribute nameAttrib = xmlDoc.CreateAttribute("name"); nameAttrib.Value = aspect.Name; aspectNode.Attributes.Append(nameAttrib); } configNode.AppendChild(aspectNode); foreach (PresentationAspectTarget target in aspect.Targets) SerializeAspectTarget(target, xmlDoc, aspectNode); foreach (PresentationMixin mixin in aspect.Mixins) SerializeMixin(mixin, xmlDoc, aspectNode); foreach (PresentationPointcut pointcut in aspect.Pointcuts) SerializePointcut(pointcut, xmlDoc, aspectNode); }