Ejemplo n.º 1
0
        public MethodDescriptor(MethodInfo info, List<ApiCodeAttribute> attrs,bool needAuth)
            : base(info.Name)
        {
            _info = info;
            var paras = info.GetParameters();
            _params = new List<ParamDescriptor>(paras.Length);
            _paramsDic = new Dictionary<string, ParamDescriptor>(paras.Length, StringComparer.CurrentCultureIgnoreCase);
            foreach (var paramInfo in paras)
            {
                var item = new ParamDescriptor(paramInfo);
                _params.Add(item);
                _paramsDic.Add(paramInfo.Name, item);
            }

            _responseParameterInfo = info.ReturnParameter;

            Type t;
            if (info.ReturnParameter.ParameterType == typeof(void)) t = typeof(Response);
            else t = typeof(Response<>).MakeGenericType(info.ReturnParameter.ParameterType);

            _responseParam = new TypeDescriptor(null, t, -1);
            _responseParam.Container = Container;

            foreach (ApiCodeAttribute attr in info.GetCustomAttributes(typeof(ApiCodeAttribute), true))
            {
                attrs.Add(attr);
            }

            _responseCodes = from attr in attrs orderby attr.Category,attr.Code select attr;
            _needAuth = needAuth;
        }
Ejemplo n.º 2
0
        private string GetParamDocumentation(MethodDescriptor methodDescriptor, ParamDescriptor paramDescriptor)
        {
            XPathNavigator methodNode = GetMethodNode(methodDescriptor);

            if (methodNode != null)
            {
                string         parameterName = paramDescriptor.ParameterInfo.Name;
                XPathNavigator parameterNode = methodNode.SelectSingleNode(String.Format(CultureInfo.InvariantCulture, ParameterExpression, parameterName));
                if (parameterNode != null)
                {
                    return(parameterNode.InnerXml.Trim());
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
        public MethodDescriptor(MethodInfo info, List <ApiCodeAttribute> attrs, bool needAuth)
            : base(info.Name)
        {
            _info = info;
            var paras = info.GetParameters();

            _params    = new List <ParamDescriptor>(paras.Length);
            _paramsDic = new Dictionary <string, ParamDescriptor>(paras.Length, StringComparer.CurrentCultureIgnoreCase);
            foreach (var paramInfo in paras)
            {
                var item = new ParamDescriptor(paramInfo);
                _params.Add(item);
                _paramsDic.Add(paramInfo.Name, item);
            }

            _responseParameterInfo = info.ReturnParameter;

            Type t;

            if (info.ReturnParameter.ParameterType == typeof(void))
            {
                t = typeof(Response);
            }
            else
            {
                t = typeof(Response <>).MakeGenericType(info.ReturnParameter.ParameterType);
            }

            _responseParam           = new TypeDescriptor(null, t, -1);
            _responseParam.Container = Container;

            foreach (ApiCodeAttribute attr in info.GetCustomAttributes(typeof(ApiCodeAttribute), true))
            {
                attrs.Add(attr);
            }

            _responseCodes = from attr in attrs orderby attr.Category, attr.Code select attr;
            _needAuth      = needAuth;
        }
Ejemplo n.º 4
0
 private string GetParamDocumentation(MethodDescriptor methodDescriptor, ParamDescriptor paramDescriptor)
 {
     XPathNavigator methodNode = GetMethodNode(methodDescriptor);
     if (methodNode != null)
     {
         string parameterName = paramDescriptor.ParameterInfo.Name;
         XPathNavigator parameterNode = methodNode.SelectSingleNode(String.Format(CultureInfo.InvariantCulture, ParameterExpression, parameterName));
         if (parameterNode != null)
         {
             return parameterNode.InnerXml.Trim();
         }
     }
     return null;
 }