Esempio n. 1
0
        public static string ToQueryString(this IEnumerable <PropertyInfo> propertyInfos, object request)
        {
            var parameters = String.Empty;

            foreach (var property in propertyInfos)
            {
                var value = property.GetValue(request, null);
                if (value == null)
                {
                    continue;
                }
                parameters += "&{0}={1}".Fmt(property.Name.ToCamelCase(), RestRoute.FormatQueryParameterValue(value));
            }
            if (!String.IsNullOrEmpty(parameters))
            {
                parameters = parameters.Substring(1);
            }
            return(parameters);
        }
Esempio n. 2
0
        internal static string GetQueryString(object request, IDictionary <string, RouteMember> propertyMap)
        {
            var result = new StringBuilder();

            foreach (var queryProperty in propertyMap)
            {
                var value = queryProperty.Value.GetValue(request, true);
                if (value == null)
                {
                    continue;
                }

                result.Append(queryProperty.Key)
                .Append('=')
                .Append(RestRoute.FormatQueryParameterValue(value))
                .Append('&');
            }

            if (result.Length > 0)
            {
                result.Length -= 1;
            }
            return(result.ToString());
        }