public static ApiServiceBuilder <TServiceContract> Build(string apiRoot)
        {
            if (String.IsNullOrWhiteSpace(apiRoot))
            {
                throw new ArgumentException($"A root url must be provided for service {typeof(TServiceContract)}", "apiRoot");
            }

            var builder = new ApiServiceBuilder <TServiceContract>(apiRoot);

            return(builder);
        }
Ejemplo n.º 2
0
        public static ApiServiceBuilder <TServiceContract> AddAuthorizationHeader <TServiceContract>(this ApiServiceBuilder <TServiceContract> builder, Func <String> getToken) where TServiceContract : class
        {
            builder.AddHandler((headers) =>
            {
                var token             = getToken();
                headers.Authorization = new AuthenticationHeaderValue(BearerScheme, token);
            });

            return(builder);
        }
Ejemplo n.º 3
0
        public static ApiServiceBuilder <TServiceContract> AddHeader <TServiceContract>(this ApiServiceBuilder <TServiceContract> builder, String header, Func <String> getValue) where TServiceContract : class
        {
            builder.AddHandler((headers) =>
            {
                var value = getValue();
                headers.Add(header, value);
            });

            return(builder);
        }