Exemplo n.º 1
0
 public DTO.AssemblyInfo GetAssemblyInfo()
 {
     DTO.AssemblyInfo assemblyInfo = new DTO.AssemblyInfo();
     assemblyInfo.Name = assembly.FullName;
     DTO.NamespaceInfo namespaceInfo;
     foreach (Type type in assembly.GetTypes())
     {
         namespaceInfo = FoundNamespace(assemblyInfo, type.Namespace);
         if (namespaceInfo == null)
         {
             namespaceInfo = new DTO.NamespaceInfo()
             {
                 Name = type.Namespace
             };
             assemblyInfo.Namespaces.Add(namespaceInfo);
         }
         var dataTypeInfo = new DTO.DataTypeInfo();
         dataTypeInfo.Name = type.Name;
         foreach (var memberInfo in type.GetMembers())
         {
             addMemberInfo(memberInfo, dataTypeInfo);
         }
         foreach (var method in type.GetMethods())
         {
             var methodInfo = getMethodInfo(method);
             dataTypeInfo.Methods.Add(methodInfo);
         }
         namespaceInfo.DataTypes.Add(dataTypeInfo);
     }
     return(assemblyInfo);
 }
Exemplo n.º 2
0
        public DTO.AssemblyInfo GetAssemblyInfo()
        {
            DTO.AssemblyInfo assemblyInfo = new DTO.AssemblyInfo();

            assemblyInfo.Name = assembly.FullName;
            DTO.NamespaceInfo namespaceInfo;
            foreach (Type type in assembly.GetTypes())
            {
                namespaceInfo = FoundNamespace(assemblyInfo, type.Namespace);
                if (namespaceInfo == null)
                {
                    namespaceInfo = new DTO.NamespaceInfo()
                    {
                        Name = type.Namespace
                    };
                    assemblyInfo.Namespaces.Add(namespaceInfo);
                }
                var dataTypeInfo = new DTO.DataTypeInfo();
                dataTypeInfo.Name = type.Name;
                foreach (var memberInfo in type.GetMembers())
                {
                    if (memberInfo is FieldInfo)
                    {
                        var fieldInfo = new DTO.FieldInfo();
                        fieldInfo.Name = memberInfo.Name;
                        fieldInfo.Type = ((FieldInfo)memberInfo).FieldType;
                        dataTypeInfo.Fields.Add(fieldInfo);
                    }
                    else if (memberInfo is PropertyInfo)
                    {
                        var propertyInfo = new DTO.PropertyInfo();
                        propertyInfo.Name = memberInfo.Name;
                        propertyInfo.Type = ((PropertyInfo)memberInfo).PropertyType;
                        dataTypeInfo.Properties.Add(propertyInfo);
                    }
                }
                foreach (var method in type.GetMethods())
                {
                    var methodInfo = new DTO.MethodInfo();
                    methodInfo.Name       = method.Name;
                    methodInfo.ReturnType = method.ReturnType;
                    foreach (var parameter in method.GetParameters())
                    {
                        var parameterInfo = new DTO.ParameterInfo()
                        {
                            Name = parameter.Name, Type = parameter.ParameterType
                        };
                        methodInfo.Parameters.Add(parameterInfo);
                    }
                    dataTypeInfo.Methods.Add(methodInfo);
                }
                namespaceInfo.DataTypes.Add(dataTypeInfo);
            }
            return(assemblyInfo);
        }
Exemplo n.º 3
0
 void addMemberInfo(MemberInfo memberInfo, DTO.DataTypeInfo dataTypeInfo)
 {
     if (memberInfo is FieldInfo)
     {
         var fieldInfo = new DTO.FieldInfo();
         fieldInfo.Name = memberInfo.Name;
         fieldInfo.Type = ((FieldInfo)memberInfo).FieldType;
         dataTypeInfo.Fields.Add(fieldInfo);
     }
     else if (memberInfo is PropertyInfo)
     {
         var propertyInfo = new DTO.PropertyInfo();
         propertyInfo.Name = memberInfo.Name;
         propertyInfo.Type = ((PropertyInfo)memberInfo).PropertyType;
         dataTypeInfo.Properties.Add(propertyInfo);
     }
 }