예제 #1
0
        private XmlNode CreateNamespace(ClassMembers classMembers)
        {
            XmlNode namespaceNode = _xmlDocument.CreateElement("namespace");

            CreateAttribute("name", classMembers.Namespace, namespaceNode);
            return(namespaceNode);
        }
예제 #2
0
        private XmlNode CreateClassName(ClassMembers classMembers)
        {
            XmlNode classNode = _xmlDocument.CreateElement("class");

            classNode.InnerText = classMembers.ClassName;
            return(classNode);
        }
예제 #3
0
        private XmlNode CreateXmlNode(ClassMembers classMembers)
        {
            XmlNode classNode = CreateNamespace(classMembers);

            classNode.AppendChild(CreateClassName(classMembers));
            classNode.AppendChild(CreateInheritors(classMembers));
            classNode.AppendChild(CreateClassFields(classMembers));
            classNode.AppendChild(CreateMethods(classMembers));
            return(classNode);
        }
예제 #4
0
        private XmlNode CreateInheritors(ClassMembers classMembers)
        {
            XmlNode inheritorsNode = _xmlDocument.CreateElement("inheritors");

            foreach (var inheritorName in classMembers.Inheritors)
            {
                XmlNode inheritorNode = _xmlDocument.CreateElement("inheritor");
                inheritorNode.InnerText = inheritorName;
                inheritorsNode.AppendChild(inheritorNode);
            }
            return(inheritorsNode);
        }
예제 #5
0
        private IEnumerable <XmlNode> CreateUsualFieldsNodes(ClassMembers classMembers)
        {
            var list = new List <XmlNode>();

            foreach (var usualField in classMembers.UsualFields)
            {
                XmlNode usualFieldNode = _xmlDocument.CreateElement("field");
                CreateAttribute("name", usualField.Name, usualFieldNode);
                CreateAttribute("type", usualField.Type.Name, usualFieldNode);
                CreateAttribute("access_modifier", usualField.AccessModifier, usualFieldNode);
                list.Add(usualFieldNode);
            }
            return(list);
        }
예제 #6
0
        public IEnumerable <ClassMembers> Create()
        {
            var classes = new List <ClassMembers>();

            foreach (var type in _types)
            {
                if (!_isMentioned[type])
                {
                    ClassMembers classMembers = CreateClassInfo(type);
                    if (classMembers != null)
                    {
                        classes.Add(classMembers);
                    }
                }
            }
            return(classes);
        }
예제 #7
0
        private XmlNode CreateClassFields(ClassMembers classMembers)
        {
            XmlNode fieldsNode       = _xmlDocument.CreateElement("fields");
            var     usualFieldsNodes = CreateUsualFieldsNodes(classMembers);

            foreach (var usualNode in usualFieldsNodes)
            {
                fieldsNode.AppendChild(usualNode);
            }
            var childClassFieldsNodes = CreateChildClassFieldsNodes(classMembers);

            foreach (var childClassNode in childClassFieldsNodes)
            {
                fieldsNode.AppendChild(childClassNode);
            }
            return(fieldsNode);
        }
예제 #8
0
        private IEnumerable <XmlNode> CreateChildClassFieldsNodes(ClassMembers classMembers)
        {
            var list = new List <XmlNode>();

            foreach (var childClassField in classMembers.ChildClassFields)
            {
                XmlNode childClassFieldNode = _xmlDocument.CreateElement("field");
                CreateAttribute("name", childClassField.Name, childClassFieldNode);
                CreateAttribute("access_modifier", childClassField.AccessModifier, childClassFieldNode);
                if (childClassField.Type != null)
                {
                    var childClassNode = CreateXmlNode(childClassField.Type);
                    childClassFieldNode.AppendChild(childClassNode);
                }
                list.Add(childClassFieldNode);
            }
            return(list);
        }
예제 #9
0
        private ClassMembers CreateClassInfo(Type type)
        {
            if (!type.IsClass || type.GetCustomAttribute(typeof(ExportXML)) == null || _isMentioned[type])
            {
                return(null);
            }

            _isMentioned[type] = true;

            var classMembers = new ClassMembers
            {
                Namespace  = type.Namespace,
                ClassName  = type.Name,
                Inheritors = GetInheritors(type),
                Methods    = GetMethods(type)
            };

            GetClassFields(classMembers, type);

            return(classMembers);
        }
예제 #10
0
        private XmlNode CreateMethods(ClassMembers classMembers)
        {
            XmlNode methodsNode = _xmlDocument.CreateElement("methods");

            foreach (var method in classMembers.Methods)
            {
                XmlNode methodNode = _xmlDocument.CreateElement("method");
                CreateAttribute("name", method.Name, methodNode);
                CreateAttribute("access_modifier", method.AccessModifier, methodNode);
                CreateAttribute("return_type", method.ReturnType.Name, methodNode);
                XmlNode paramsNode = _xmlDocument.CreateElement("params");
                foreach (var param in method.Params)
                {
                    XmlNode paramNode = _xmlDocument.CreateElement("param");
                    CreateAttribute("name", param.Name, paramNode);
                    CreateAttribute("type", param.Type.Name, paramNode);
                    paramsNode.AppendChild(paramNode);
                }
                methodNode.AppendChild(paramsNode);
                methodsNode.AppendChild(methodNode);
            }
            return(methodsNode);
        }
예제 #11
0
        private void GetClassFields(ClassMembers classMembers, Type type)
        {
            var usualFields      = new List <ClassMembers.UsualField>();
            var childClassFields = new List <ClassMembers.ChildClassField>();

            foreach (var field in type.GetFields(BindingFlags.NonPublic | BindingFlags.Public |
                                                 BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static))
            {
                if (field.FieldType.IsClass && _types.Contains(field.FieldType))
                {
                    ClassMembers cm = CreateClassInfo(field.FieldType);
                    if (cm != null)
                    {
                        var rf = new ClassMembers.ChildClassField
                        {
                            Name           = field.Name,
                            AccessModifier = field.Attributes.ToString(),
                            Type           = cm
                        };

                        childClassFields.Add(rf);
                        continue;
                    }
                }

                var vf = new ClassMembers.UsualField
                {
                    Name           = field.Name,
                    Type           = field.FieldType,
                    AccessModifier = field.Attributes.ToString()
                };

                usualFields.Add(vf);
            }
            classMembers.UsualFields      = usualFields;
            classMembers.ChildClassFields = childClassFields;
        }