Пример #1
0
        public MappingDescription(MethodInfo routeHandler, IRouteDetails routeDetails)
        {
            if (routeHandler == null)
            {
                throw new ArgumentNullException(nameof(routeHandler));
            }

            if (routeDetails == null)
            {
                throw new ArgumentNullException(nameof(routeDetails));
            }

            Predicate = CreatePredicateString(routeDetails);
            Handler   = CreateHandlerString(routeHandler);
        }
Пример #2
0
        private string CreatePredicateString(IRouteDetails routeDetails)
        {
            StringBuilder sb = new StringBuilder("{");

            sb.Append("[" + routeDetails.RouteTemplate + "]");

            sb.Append(",methods=");
            sb.Append("[" + CreateRouteMethods(routeDetails.HttpMethods) + "]");

            if (!IsEmpty(routeDetails.Produces))
            {
                sb.Append(",produces=");
                sb.Append("[" + string.Join(" || ", routeDetails.Produces) + "]");
            }

            if (!IsEmpty(routeDetails.Consumes))
            {
                sb.Append(",consumes=");
                sb.Append("[" + string.Join(" || ", routeDetails.Consumes) + "]");
            }

            sb.Append("}");
            return(sb.ToString());
        }