Exemplo n.º 1
0
        private void AddMembers(Node parent, Type type)
        {
            var bindingParam = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly;

            foreach (var field in type.GetFields(bindingParam).Where(f => f.GetCustomAttribute <CompilerGeneratedAttribute>() == null))
            {
                parent.SubNodes.Add(new Node(Types.Field, field.FieldType.Name + " " + field.Name));
            }
            foreach (var property in type.GetProperties(bindingParam))
            {
                parent.SubNodes.Add(new Node(Types.Property, property.PropertyType.Name + " " + property.Name));
            }
            SignatureBilder signatureBilder = new SignatureBilder();

            foreach (var method in type.GetMethods(bindingParam).Where(m => m.GetCustomAttribute <CompilerGeneratedAttribute>() == null))
            {
                if (method.IsDefined(typeof(ExtensionAttribute), false))
                {
                    extensionMethods.Add(method);
                }
                else
                {
                    parent.SubNodes.Add(new Node(Types.Method, signatureBilder.BildSignature(method)));
                }
            }

            foreach (var constructor in type.GetConstructors().Where(constuctor => constuctor.GetCustomAttribute <CompilerGeneratedAttribute>() == null))
            {
                parent.SubNodes.Add(new Node(Types.Constructor, signatureBilder.BildSignature(constructor)));
            }
        }
Exemplo n.º 2
0
        private void ParseExtensionMethods(Dictionary <string, Node> classes)
        {
            Node            tmpNode, newNode;
            SignatureBilder signatureBilder = new SignatureBilder();
            string          exClassName;

            foreach (var method in extensionMethods)
            {
                exClassName = method.GetParameters()[0].ParameterType.Name;
                if (classes.TryGetValue(exClassName, out tmpNode))
                {
                    exClassName = "";
                }
                else
                {
                    if (!classes.TryGetValue(method.DeclaringType.Name, out tmpNode))
                    {
                        continue;
                    }
                    else
                    {
                        exClassName += " ";
                    }
                }
                newNode = new Node(Types.Extension, exClassName + signatureBilder.BildSignature(method));
                tmpNode.SubNodes.Add(newNode);
            }
        }