Пример #1
0
        public static void AddQueryParameter(this IRequest request, string key, IHttpHeaderBuilder builder)
        {
            if (builder == null)
            {
                return;
            }

            request.AddQueryParameter(key, builder.Build());
        }
Пример #2
0
        public static void AddQueryParameter <T>(this IRequest request, string key, T value) where T : struct, Enum
        {
            if (value.Equals(default(T)))
            {
                return;
            }

            request.AddQueryParameter(key, ValueHelper.EnumToString(value));
        }
Пример #3
0
        public static void AddQueryParameter(this IRequest request, string key, bool?value)
        {
            if (value == null)
            {
                return;
            }

            request.AddQueryParameter(key, ValueHelper.BoolToString(value.Value));
        }
Пример #4
0
        public static void AddQueryParameter(this IRequest request, string key, DateTimeOffset?date, DateTimeFormat format)
        {
            if (date == null)
            {
                return;
            }

            switch (format)
            {
            case DateTimeFormat.Iso8601DateTime:
                request.AddQueryParameter(key, date.Value.ToString(DateTimeFormats.Iso8601DateTime, DateTimeFormatInfo.InvariantInfo));
                break;

            case DateTimeFormat.Rfc1123:
                request.AddQueryParameter(key, date.Value.ToString(DateTimeFormats.Rfc1123, DateTimeFormatInfo.InvariantInfo));
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(format), format, null);
            }
        }