Ejemplo n.º 1
0
        internal void AddMethodDetails(object T, MethodInfo info, String URI, EndPointAttribute endPtAttr)
        {
            m_obj = T;

            m_methodInfo = info;

            m_Consumes = endPtAttr.Consumes;
            m_Produces = endPtAttr.Produces;

            //m_delegate = Delegate.CreateDelegate(Program.getDelegateFactory().CreateDelegateType(info),
            //    T, info);

            ParameterInfo[] paramInfo = m_methodInfo.GetParameters();

            foreach (ParameterInfo Param in paramInfo)
            {
                object[]      baseAttr = Param.GetCustomAttributes(typeof(BaseAttribute), true);
                BaseAttribute attrib   = null;

                if (0 != baseAttr.Length)
                {
                    attrib = baseAttr[0] as BaseAttribute;
                    attrib.setType(Param.ParameterType);
                }
                else
                {
                    if (Param.ParameterType == typeof(HttpResp))
                    {
                        m_SequenceOfParams.Add(new HttpResp());
                    }

                    continue;
                }


                if (attrib.GetType() == typeof(BodyQueryParam))
                {
                    m_SequenceOfParams.Add(attrib);
                    continue;
                }

                if (attrib.GetType() == typeof(PathQueryVariable))
                {
                    var variable = attrib as PathQueryVariable;
                    variable.setPosInURL(Param.Position);
                    m_SequenceOfParams.Add(variable);
                    continue;
                }

                if (attrib.GetType() == typeof(BodyParam))
                {
                    m_SequenceOfParams.Add(attrib);
                    continue;
                }

                if (attrib.GetType() == typeof(PathVariable))
                {
                    var      variable = attrib as PathVariable;
                    Regex    parser   = new Regex("{" + variable.getName() + "}");
                    String[] splits   = parser.Split(URI);
                    variable.setPosInURL(splits[0].Length);

                    m_SequenceOfParams.Add(variable);

                    continue;
                }

                if (attrib.GetType() == typeof(HeaderParam))
                {
                    var param = attrib as HeaderParam;
                    m_SequenceOfParams.Add(param);
                    continue;
                }
            }
        }