Exemplo n.º 1
0
 public AssemblyTreeViewModel(RepresentationType nodeType, string name, SerializableVertex vertex, AssemblyTreeViewModel parent)
 {
     this.NodeType = nodeType;
     this.Name     = name;
     this.Vertex   = vertex;
     this.Parent   = parent;
     Children      = new List <AssemblyTreeViewModel>();
     Mediator.Instance.Register(this);
 }
Exemplo n.º 2
0
        private void AddTypes(IGrouping <String, Type> types, AssemblyTreeViewModel parent)
        {
            TypeReflector.RequiredBindings          = SeperateAppDomainAssemblyLoader.requiredBindings;
            TypeReflector.ShowConstructorParameters = SeperateAppDomainAssemblyLoader.showConstructorParameters;
            TypeReflector.ShowFieldTypes            = SeperateAppDomainAssemblyLoader.showFieldTypes;
            TypeReflector.ShowPropertyTypes         = SeperateAppDomainAssemblyLoader.showPropertyTypes;
            TypeReflector.ShowInterfaces            = SeperateAppDomainAssemblyLoader.showInterfaces;
            TypeReflector.ParseMethodBodyIL         = SeperateAppDomainAssemblyLoader.parseMethodBodyIL;
            TypeReflector.ShowMethodArguments       = SeperateAppDomainAssemblyLoader.showMethodArguments;
            TypeReflector.ShowMethodReturnValues    = SeperateAppDomainAssemblyLoader.showMethodReturnValues;
            TypeReflector.ShowGetMethodForProperty  = SeperateAppDomainAssemblyLoader.showGetMethodForProperty;
            TypeReflector.ShowSetMethodForProperty  = SeperateAppDomainAssemblyLoader.showSetMethodForProperty;
            TypeReflector.ShowEvents = SeperateAppDomainAssemblyLoader.showEvents;
            TypeReflector.IncludeConstructorParametersAsAssociations = SeperateAppDomainAssemblyLoader.includeConstructorParametersAsAssociations;
            TypeReflector.IncludePropertyTypesAsAssociations         = SeperateAppDomainAssemblyLoader.includePropertyTypesAsAssociations;
            TypeReflector.IncludeFieldTypesAsAssociations            = SeperateAppDomainAssemblyLoader.includeFieldTypesAsAssociations;
            TypeReflector.IncludeMethodArgumentAsAssociations        = SeperateAppDomainAssemblyLoader.includeMethodArgumentAsAssociations;


            //Load ILReaader Globals
            MethodBodyReader.LoadOpCodes();



            foreach (var t in types)
            {
                TypeReflector typeReflector = new TypeReflector(t);
                typeReflector.ReflectOnType();


                SerializableVertex vertex = new SerializableVertex(
                    typeReflector.Name,
                    typeReflector.ShortName,
                    typeReflector.Constructors,
                    typeReflector.Fields,
                    typeReflector.Properties,
                    typeReflector.Interfaces,
                    typeReflector.Methods,
                    typeReflector.Events,
                    new List <string>(typeReflector.Associations),
                    typeReflector.HasConstructors,
                    typeReflector.HasFields,
                    typeReflector.HasProperties,
                    typeReflector.HasInterfaces,
                    typeReflector.HasMethods,
                    typeReflector.HasEvents);

                AssemblyTreeViewModel newNode =
                    new AssemblyTreeViewModel(RepresentationType.Class, t.Name, vertex, parent);
                parent.Children.Add(newNode);
            }
        }
        public Task <GraphResults> CreateGraph()
        {
            Task <GraphResults> task = Task.Factory.StartNew <GraphResults>(() =>
            {
                //for each item in selectedTreeItems
                //1. Create all PocVertex, and are them to Reflect() which will store an internal
                //   List<Name> which are the Associations needed by that Vertex
                //2. Go through each PocVertex Associations and see if we have that Association
                //   Vertex and if so create a new PocEdge


                List <PocVertex> vertices = new List <PocVertex>();
                Parallel.For(0, selectedTreeValues.Count, (i) =>
                {
                    SerializableVertex serializableVertex = selectedTreeValues[i].Vertex;
                    PocVertex vertex = new PocVertex(
                        serializableVertex.Name,
                        serializableVertex.ShortName,
                        serializableVertex.Constructors,
                        serializableVertex.Fields,
                        serializableVertex.Properties,
                        serializableVertex.Interfaces,
                        TranslateMethods(serializableVertex.Methods),
                        serializableVertex.Events,
                        serializableVertex.Associations,
                        serializableVertex.HasConstructors,
                        serializableVertex.HasFields,
                        serializableVertex.HasProperties,
                        serializableVertex.HasInterfaces,
                        serializableVertex.HasMethods,
                        serializableVertex.HasEvents);


                    vertices.Add(vertex);
                });

                List <PocEdge> edges = new List <PocEdge>();
                Parallel.ForEach(vertices, (x) =>
                {
                    PocVertex vertex1 = x;

                    foreach (String associationName in vertex1.Associations)
                    {
                        var matchinVertices = from vert in vertices
                                              where vert.Name == associationName
                                              select vert;
                        PocVertex vertex2 = matchinVertices.SingleOrDefault();

                        if (vertex2 != null)
                        {
                            if (vertex1.Name != vertex2.Name)
                            {
                                //TODO : Need to make sure both of these are in the
                                //list of selected items in the tree before they are added
                                edges.Add(AddNewGraphEdge(vertex1, vertex2));
                                vertex1.NumberOfEdgesFromThisVertex += 1;
                                vertex2.NumberOfEdgesToThisVertex   += 1;
                            }
                        }
                    }
                });


                return(new GraphResults(vertices, edges));
            });

            return(task);
        }