Exemple #1
0
        public MethodGraph(MethodBase method, TypeGraph parentGraph = null)
            : base(method, parentGraph)
        {
            _parameters = new GraphList <ParameterGraph, MethodGraph>(this);

            if (method != null)
            {
                Attributes = method.Attributes;

                _callingConvention = method.CallingConvention;

                if (method.IsGenericMethod)
                {
                    _genericArguments.AddRange(method.GetGenericArguments());
                }

                new ParameterGraph(method is MethodInfo ? ((MethodInfo)method).ReturnParameter : null, this);

                foreach (var p in method.GetParameters())
                {
                    new ParameterGraph(p, this);
                }

                _instructionList = new InstructionList(_sourceObject);
            }
        }
        public AssemblyGraph(Assembly asm)
            : base(asm)
        {
            _modules = new GraphList <ModuleGraph, AssemblyGraph>(this);
            if (asm != null)
            {
                SetAttributeData(asm.GetCustomAttributesData());

                _assemblyName = asm.GetName();

                foreach (var m in _sourceObject.GetModules(true))
                {
                    new ModuleGraph(m, this);
                }
            }
        }
Exemple #3
0
        public ModuleGraph(Module module, AssemblyGraph parent = null)
            : base(module, parent)
        {
            _typeGraphs = new GraphList <TypeGraph, ModuleGraph>(this);
            if (module != null)
            {
                SetAttributeData(module.GetCustomAttributesData());

                _name = module.Name;

                foreach (var t in module.GetTypes())
                {
                    if (t.DeclaringType == null)
                    {
                        new TypeGraph(t, null, this);
                    }
                }
            }
        }
Exemple #4
0
        public TypeGraph(Type t, TypeGraph parentType = null, ModuleGraph module = null)
            : base(t, parentType)
        {
            if (module != null)
            {
                Module = module;
            }

            _methodGraphs   = new GraphList <MethodGraph, TypeGraph>(this);
            _propertyGraphs = new GraphList <PropertyGraph, TypeGraph>(this);
            _fieldGraphs    = new GraphList <FieldGraph, TypeGraph>(this);
            _eventGraphs    = new GraphList <EventGraph, TypeGraph>(this);
            _typeGraphs     = new GraphList <TypeGraph, TypeGraph>(this);
            if (t != null)
            {
                Attributes = t.Attributes;

                _fullName = t.FullName;
                _baseType = t.BaseType;

                IEnumerable <Type> interfaces = t.GetInterfaces();
                if (t.BaseType != null)// && interfaces.Any())
                {
                    interfaces = interfaces.Except(t.BaseType.GetInterfaces());
                }

                _interfaces.AddRange(interfaces);

                if ((t.Attributes & TypeAttributes.ExplicitLayout) == TypeAttributes.ExplicitLayout && t.IsValueType)
                {
                    _packingSize = PackingSize.Size1;
                    _typeSize    = System.Runtime.InteropServices.Marshal.SizeOf(t);
                }
                else
                {
                    _packingSize = PackingSize.Unspecified;
                    _typeSize    = 0;
                }

                //if (t.DeclaringType != null && module != null)
                //    DeclaringObject = module.TypeGraphs.First(x => x.Source == t);

                foreach (var m in t.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly))
                {
                    if (m is MethodBase)
                    {
                        new MethodGraph(m as MethodBase, this);
                    }
                    else if (m is FieldInfo)
                    {
                        new FieldGraph(m as FieldInfo, this);
                    }
                    else if (m is PropertyInfo)
                    {
                        new PropertyGraph(m as PropertyInfo, this);
                    }
                    else if (m is EventInfo)
                    {
                        new EventGraph(m as EventInfo, this);
                    }
                    else if (m is Type)
                    {
                        new TypeGraph(m as Type, this, module);
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
            }
        }