public static void SetupProjectTreeView(TreeView treeView, IList assemblies, PresentationModel model, AspectMatcher aspectMatcher, PointcutMatcher pointcutMatcher)
        {
            treeView.Nodes.Clear();

            AssemblyListNode node = new AssemblyListNode(assemblies, model, aspectMatcher, pointcutMatcher);
            treeView.Nodes.Add(node);
        }
        public TypeNode(Type type, PresentationModel model, AspectMatcher aspectMatcher, PointcutMatcher pointcutMatcher)
            : base(type.FullName)
        {
            this.type = type;
            this.model = model;
            this.aspectMatcher = aspectMatcher;
            this.pointcutMatcher = pointcutMatcher;

            this.ImageIndex = 1;
            this.SelectedImageIndex = 1;

            ArrayList aspects = null;

            if (model != null)
            {
                aspects = (ArrayList)aspectMatcher.MatchAspectsForType(type, model.Aspects);

                foreach (PresentationAspect aspect in aspects)
                    aspect.AppliedOnTypes.Add(type);

                if (aspects.Count > 0)
                {
                    this.ImageIndex = 9;
                    this.SelectedImageIndex = 9;
                }

                //Order is important....
                //aspects.Sort(new AspectComparer());
                foreach (IGenericAspect aspect in aspects)
                {
                    TreeNode aspectNode = new AspectNode(aspect);
                    this.Nodes.Add(aspectNode);
                }
            }

            ArrayList ctors = new ArrayList(type.GetConstructors());
            ctors.Sort(new MethodComparer());
            foreach (MethodBase method in ctors)
            {
                TreeNode methodNode = new MethodNode(this.Type, method, aspects, model, pointcutMatcher);
                this.Nodes.Add(methodNode);
            }

            ArrayList methods = new ArrayList(type.GetMethods());
            methods.Sort(new MethodComparer());
            foreach (MethodBase method in methods)
            {
                if (!method.IsStatic)
                {
                    TreeNode methodNode = new MethodNode(this.Type, method, aspects, model, pointcutMatcher);
                    this.Nodes.Add(methodNode);
                }
            }
        }
        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;
        }
        public ConfigurationNode(PresentationModel model)
            : base("Configuration")
        {
            this.model = model;

            this.ImageIndex = 11;
            this.SelectedImageIndex = 11;

            foreach (IGenericAspect aspect in model.Aspects)
                this.Nodes.Add(new AspectNode(aspect));
        }
Exemple #5
0
        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);
        }
        public AssemblyNode(Assembly assembly, PresentationModel model, AspectMatcher aspectMatcher, PointcutMatcher pointcutMatcher)
            : base(assembly.GetName().Name)
        {
            this.Assembly = assembly;

            ArrayList types = new ArrayList(assembly.GetTypes());
            types.Sort(new TypeComparer());
            foreach (Type type in types)
            {
                if (type.IsClass)
                {
                    TreeNode node = new TypeNode(type, model, aspectMatcher, pointcutMatcher);
                    this.Nodes.Add(node);
                }
            }
        }
        public AssemblyListNode(IList assemblies, PresentationModel model, AspectMatcher aspectMatcher, PointcutMatcher pointcutMatcher)
            : base("Assemblies")
        {
            this.assemblies = assemblies;
            this.model = model;
            this.aspectMatcher = aspectMatcher;
            this.pointcutMatcher = pointcutMatcher;

            this.ImageIndex = 12;
            this.SelectedImageIndex = 12;

            ArrayList sortedAssemblies = new ArrayList(assemblies);
            sortedAssemblies.Sort(new AssemblyComparer());
            foreach (Assembly asm in sortedAssemblies)
                this.Nodes.Add(new AssemblyNode(asm, model, aspectMatcher, pointcutMatcher));
        }
        public static string SerializeConfiguration(PresentationModel model)
        {
            XmlDocument xmlDoc = new XmlDocument();

            XmlNode rootNode = xmlDoc.CreateElement("naspect");
            xmlDoc.AppendChild(rootNode);

            XmlNode configNode = xmlDoc.CreateElement("configuration");
            rootNode.AppendChild(configNode);

            foreach (PresentationAspect aspect in model.Aspects)
                SerializeAspect(aspect, xmlDoc, configNode);

            StringBuilder stringBuilder = new StringBuilder();
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            using (XmlWriter xmlWriter = XmlWriter.Create(stringBuilder, settings))
            {
                xmlDoc.WriteContentTo(xmlWriter);
                xmlWriter.Flush();
                return stringBuilder.ToString() ;
            }
        }
        public MethodNode(Type type, MethodBase method, IList aspects, PresentationModel model, PointcutMatcher pointcutMatcher)
            : base(AopTools.GetMethodSignature(method))
        {
            this.type = type;
            this.method = method;
            this.aspects = aspects;
            this.model = model;
            this.pointcutMatcher = pointcutMatcher;

            this.ImageIndex = 2;
            this.SelectedImageIndex = 2;

            if (CanBeProxied())
            {
                if (aspects != null)
                    if (ShouldProxy())
                        AddInterceptorNodes();
            }
            else
            {
                this.ImageIndex = 13;
                this.SelectedImageIndex = 13;
            }
        }
        public static void SetupAspectTreeView(TreeView treeView, IList assemblies, PresentationModel model, AspectMatcher aspectMatcher, PointcutMatcher pointcutMatcher)
        {
            treeView.Nodes.Clear();

            treeView.Nodes.Add(new ConfigurationNode(model));
        }
        private void OpenProject()
        {
            openFileDialog1.Filter = "Xml files|*.xml|All files|*.*";
            if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
            {
                if (openFileDialog1.FileName != "")
                {
                    try
                    {
                        CloseProject();

                        FileInfo file = new FileInfo(openFileDialog1.FileName);
                        string xml = "";
                        using (StreamReader sr = file.OpenText())
                        {
                            xml = sr.ReadToEnd();
                        }

                        if (xml != "")
                        {
                            Serialization.DeserializeProject(xml, assemblies, ref configFileName);

                            if (configFileName != "")
                            {
                                IEngine engine = EngineFactory.FromFile(configFileName, true);
                                model = PresentationModelManager.CreatePresentationModel(engine);
                            }

                            RefreshAll();
                        }
                    }
                    catch (Exception ex)
                    {
                        HandleException(ex);
                    }
                }
            }
        }
        private void OpenConfiguration()
        {
            openFileDialog1.Filter = "Configuration files|*.config|Xml files|*.xml|All files|*.*";
            if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
            {
                if (openFileDialog1.FileName != "")
                {
                    try
                    {
                        ClearControls();

                        IEngine engine = EngineFactory.FromFile(openFileDialog1.FileName, true);
                        model = PresentationModelManager.CreatePresentationModel(engine);

                        configFileName = openFileDialog1.FileName;

                        RefreshAll();
                    }
                    catch (Exception ex)
                    {
                        HandleException(ex);
                    }
                }
            }
        }
 private void CloseProject()
 {
     ClearControls();
     assemblies.Clear();
     projectFileName = "";
     configFileName = "";
     model = null;
     selected = null;
     listViewMaster = null;
 }