Esempio n. 1
0
 public MethodDescription(string url, HttpMethod httpMethod,
                          IEnumerable <HttpStatusCode> expectedCodes,
                          RequestParametersDescriptions parameters)
 {
     Url                 = url;
     HttpMethod          = httpMethod;
     Parameters          = parameters;
     ExpectedStatusCodes = new List <HttpStatusCode>(expectedCodes);
 }
Esempio n. 2
0
        public static MethodDescription Create(MethodInfo method)
        {
            var ma = method.GetCustomAttribute <ApiMethodAttribute>();

            if (ma == null)
            {
                throw new ApiContractException($"An API method must be marked with one of inheritors of '{typeof(ApiContractException).FullName}'");
            }

            return(new MethodDescription(ma.Url, ma.HttpMethod,
                                         method
                                         .GetCustomAttributes <ExpectedCodeAttribute>()
                                         .Select(a => a.ExpectedCode),
                                         RequestParametersDescriptions.Create(method)));
        }