Пример #1
0
        public void UpdateApiDescription(ApiDescription description)
        {
            var entity =
                DescriptionRepository.GetSatisfiedBy(
                    x => x.HttpMethod == description.Method && x.Url == description.Url);

            entity.DescriptionText = description.Description;

            DescriptionRepository.Update(entity);
        }
Пример #2
0
        private ApiDescription CreateQueryApiDescription(String url, MethodInfo method)
        {
            var inputFormat = String.Join(", ",
                method.GetParameters()
                    .Select(
                        p => String.Format("\"{0}\" : \"{1}\"", p.Name, p.ParameterType.Name)));

            if (!string.IsNullOrWhiteSpace(inputFormat))
                inputFormat = "{" + inputFormat + "}";

            var desc = new ApiDescription
            {
                OutputFormat = FormatType(method.ReturnType, 0, null),
                Method = HttpMethod.Get.Method,
                Name = method.ReturnType.Name.Replace("Response", string.Empty),
                Url = url,
                InputFormat = inputFormat,
            };

            return desc;
        }
Пример #3
0
        private ApiDescription CreateCommandDescription(String url, Type type)
        {
            if (type != null)
            {
                var commandAttrs = type.GetCustomAttributes(typeof(CommandAttribute)).ToArray();
                if (commandAttrs.Any())
                {
                    if (((CommandAttribute)commandAttrs[0]).IsBackground)
                        return null;
                }
            }

            var desc = new ApiDescription
            {
                Url = url,
                Name = type == null ? string.Empty : type.Name,
                Method = HttpMethod.Post.Method,
                InputFormat = FormatType(type, 0, null)
            };

            return desc;
        }