Esempio n. 1
0
        public MVCResultReturn <MVCServiceClassProperty> GetTypeClassProperty(string moduleName)
        {
            var clsType = Type.GetType(moduleName);

            if (clsType == null)
            {
                return(new MVCResultReturn <MVCServiceClassProperty>(new FailResultReturn("不存在指定的类型")));
            }

            var properties = clsType.GetProperties(BindingFlags.Public & BindingFlags.Instance);

            var lst = new List <MVCServiceMethodParameterInfo>();

            foreach (var property in properties)
            {
                var temp = new MVCServiceMethodParameterInfo();
                temp.DefaultValue       = property.PropertyType.GetDefaultValue().ToString();
                temp.ParameterName      = property.Name;
                temp.ValueType          = property.PropertyType.FullName;
                temp.ParameterValueType = getServiceTypeEnumByType(property.PropertyType);
                temp.Summary            = property.GetXmlDocumentation();

                lst.Add(temp);
            }

            var fields = clsType.GetFields(BindingFlags.Public & BindingFlags.Instance);

            foreach (var field in fields)
            {
                var temp = new MVCServiceMethodParameterInfo();
                temp.DefaultValue       = field.FieldType.GetDefaultValue().ToString();
                temp.ParameterName      = field.Name;
                temp.ValueType          = field.FieldType.FullName;
                temp.ParameterValueType = getServiceTypeEnumByType(field.FieldType);
                temp.Summary            = field.GetXmlDocumentation();

                lst.Add(temp);
            }

            var tempClass = new MVCServiceClassProperty();

            tempClass.Summary    = clsType.GetXmlDocumentation();
            tempClass.Properties = lst.ToArray();
            tempClass.Name       = clsType.Name;

            return(new MVCResultReturn <MVCServiceClassProperty>(tempClass));
        }
Esempio n. 2
0
        public MVCResultReturn <MVCServiceModuleInfo> GetModuleByName(string moduleName)
        {
            var type = Type.GetType(moduleName);

            if (type == null)
            {
                return(new MVCResultReturn <MVCServiceModuleInfo>(new ResultReturn(false)));
            }

            var moduleInfoLst = new List <MVCServiceModuleInfo>();

            var methods =
                type.GetMethods(BindingFlags.Public & BindingFlags.Instance)
                .Where(x => x.GetAttribute <MVCServiceNoExportAttribute>() == null);

            if (!methods.HasData())
            {
                return(new MVCResultReturn <MVCServiceModuleInfo>(new ResultReturn(false)));
            }

            var temp = new MVCServiceModuleInfo();

            temp.Name    = type.Name;
            temp.Summary = type.GetXmlDocumentation();

            var methodLst = new List <MVCServiceMethodInfo>();

            foreach (var method in methods)
            {
                var methodSummary = method.GetXmlDocumentation();

                var tempMethod = new MVCServiceMethodInfo();

                tempMethod.Name    = method.Name;
                tempMethod.Summary = methodSummary;

                tempMethod.ReturnType    = method.ReturnType.FullName;
                tempMethod.ReturnSummary = method.ReturnParameter.GetXmlDocumentation();

                methodLst.Add(tempMethod);

                var paramlist = new List <MVCServiceMethodParameterInfo>();

                foreach (var parameterInfo in method.GetParameters())
                {
                    var tempParamter = new MVCServiceMethodParameterInfo();

                    tempParamter.ParameterName      = parameterInfo.Name;
                    tempParamter.Summary            = parameterInfo.GetXmlDocumentation();
                    tempParamter.ValueType          = parameterInfo.ParameterType.FullName;
                    tempParamter.DefaultValue       = parameterInfo.DefaultValue.ToStringEx();
                    tempParamter.ParameterValueType = getServiceTypeEnumByType(parameterInfo.ParameterType);

                    paramlist.Add(tempParamter);
                }

                tempMethod.Parameters = paramlist.ToArray();
            }

            temp.Methods = methodLst.ToArray();
            moduleInfoLst.Add(temp);

            return(new MVCResultReturn <MVCServiceModuleInfo>(temp));
        }