예제 #1
0
        /// <summary>
        /// Paese http request method and headers.
        /// </summary>
        private void ParseMethodAttributes()
        {
            foreach (var attr in MethodAttributes)
            {
                if (attr is GetAttribute)
                {
                    ParseMethodNameAndPath("GET", ((GetAttribute)attr).Value);
                }
                else if (attr is DeleteAttribute)
                {
                    ParseMethodNameAndPath("DELETE", ((DeleteAttribute)attr).Value);
                }
                else if (attr is PostAttribute)
                {
                    ParseMethodNameAndPath("POST", ((PostAttribute)attr).Value, true);
                }
                else if (attr is PatchAttribute)
                {
                    ParseMethodNameAndPath("PATCH", ((PatchAttribute)attr).Value, true);
                }
                else if (attr is PutAttribute)
                {
                    ParseMethodNameAndPath("PUT", ((PutAttribute)attr).Value, true);
                }
                else if (attr is OptionsAttribute)
                {
                    ParseMethodNameAndPath("OPTIONS", ((OptionsAttribute)attr).Value);
                }
                else if (attr is HeadAttribute)
                {
                    ParseMethodNameAndPath("HEAD", ((OptionsAttribute)attr).Value);
                }
                else if (attr is HeadersAttribute)
                {
                    HeadersToParse = HeadersToParse.Concat((attr as HeadersAttribute).Value).ToArray();

                    if (HeadersToParse.Length == 0)
                    {
                        throw new ArgumentException("Headers is empty");
                    }
                }
                else if (attr is MultipartAttribute)
                {
                    if (IsFormEncoded)
                    {
                        throw new ArgumentException("Only one encoding annotation is allowed.");
                    }
                    IsMultipart = true;
                }
                else if (attr is FormUrlEncodedAttribute)
                {
                    if (IsMultipart)
                    {
                        throw new ArgumentException("Only one encoding annotation is allowed.");
                    }
                    IsFormEncoded = true;
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Process all about interface layer attributes.
 /// </summary>
 private void ProcessService()
 {
     foreach (var attr in ServiceAttributes)
     {
         if (attr is HeadersAttribute)
         {
             HeadersToParse = HeadersToParse.Concat((attr as HeadersAttribute).Value).ToArray();
         }
     }
 }