当前位置: 首页>>代码示例>>C#>>正文


C# RestRequest.AddQueryParameter方法代码示例

本文整理汇总了C#中RestSharp.RestRequest.AddQueryParameter方法的典型用法代码示例。如果您正苦于以下问题:C# RestRequest.AddQueryParameter方法的具体用法?C# RestRequest.AddQueryParameter怎么用?C# RestRequest.AddQueryParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RestSharp.RestRequest的用法示例。


在下文中一共展示了RestRequest.AddQueryParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SignIn

        public RedirectResult SignIn(string login, string password, string appId, 
            string redirectUri, string state)
        {
            var client = new RestClient(SiteConn.AuthWebApiServer);
           

            var signInRequest = new RestRequest("Auth/SignIn");

            signInRequest.AddQueryParameter("login",login);
            signInRequest.AddQueryParameter("password",password);
            signInRequest.AddQueryParameter("appId",appId);
            signInRequest.AddQueryParameter("redirectUri", redirectUri);
            signInRequest.AddQueryParameter("state","666");

            var response = client.Post(signInRequest);
            if (response == null) return new RedirectResult(redirectUri);

            //получаю куки с токеном
            if (response.Cookies != null)
            {
                return new RedirectResult(redirectUri);
            }
            
            return null;
        }
开发者ID:Trigun27,项目名称:rsoi_lab3.FrontEnd,代码行数:25,代码来源:AuthMvcController.cs

示例2: Request

 public string Request(RestSharp.Method method, string endPoint, Dictionary<string,object> headers, Dictionary<string, object> parameters, Dictionary<string, object> queryParameters, string body)
 {
     RestClient client = new RestClient(baseURL);
     RestRequest request = new RestRequest(endPoint, method);
     client.Authenticator = authenticator;
     foreach (var key in headers.Keys)
     {
         if(headers[key].GetType().ToString().StartsWith("System.Collections.Generics.List"))
         {
             request.AddHeader(key,JsonConvert.SerializeObject(headers[key]));
         }
         else
         {
             request.AddHeader(key,headers[key].ToString());
         }
     }
     foreach (var key in parameters.Keys)
     {
         request.AddParameter(key, parameters[key]);
     }
     foreach (var key in queryParameters.Keys)
     {
         if (headers[key].GetType().ToString().StartsWith("System.Collections.Generics.List"))
         {
             request.AddQueryParameter(key, JsonConvert.SerializeObject(queryParameters[key]));
         }
         else
         {
             request.AddQueryParameter(key, queryParameters[key].ToString());
         }
     }
     var response = client.Execute(request);
     return response.Content;
 }
开发者ID:pittNearsoft,项目名称:RestAPIClientGenerator,代码行数:34,代码来源:GenericAPICall.cs

示例3: Translate

        public string Translate(string resource, string locale, string targetLocale)
        {
            var restClient = new RestClient(_baseUrl);
            var request = new RestRequest("Translate") { OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; } };
            request.AddQueryParameter("text", resource);
            request.AddQueryParameter("from", locale);
            request.AddQueryParameter("to", targetLocale);
            request.AddHeader("Authorization", $"Bearer {_accessToken.access_token}");

            var response = restClient.Get(request);
            return response.Content.Replace("\"", "");
        }
开发者ID:thesheps,项目名称:lemonade,代码行数:12,代码来源:BingResourceTranslator.cs

示例4: SignIn

        public RedirectResult SignIn(string login, string password, string appId, 
            string redirectUri, string state)
        {
            var client = new RestClient("http://localhost:9999/api/");
            var signInRequest = new RestRequest("Auth/SignIn");

            signInRequest.AddQueryParameter("login",login);
            signInRequest.AddQueryParameter("password",password);
            signInRequest.AddQueryParameter("appId",appId);
            signInRequest.AddQueryParameter("redirectUri", redirectUri);
            signInRequest.AddQueryParameter("state","666");

            var response = client.Post(signInRequest);
            var url = response.ResponseUri.ToString();

            var urlArr = url.Split('?', '=', '&');
            var user = Auth(login, password);
            if (user == null)
                throw new ArgumentException("Неверная пара логин/пароль");

            var app = _appDataReposytory.AppDatas.FirstOrDefault(e => e.Id.ToString() == appId);
            if (app == null)
                throw new Exception("Нет приложения с таким appId");


            _codes.Add(urlArr[2], user.Id);

            //_sessionHelper.CreateNewSession(user, app);

            return new RedirectResult(url);
        }
开发者ID:Trigun27,项目名称:rsoi_lab2,代码行数:31,代码来源:AuthMvcController.cs

示例5: NoRecentPlay

        /// <summary>
        /// Check if the plexIdleTimeout has elapsed since the last play
        /// </summary>
        /// <returns>true if no videos were marked watched since the timer interval</returns>
        public bool NoRecentPlay()
        {
            int plexIdleTimeout;
            int.TryParse(Properties.Settings.Default.PlexIdleTimeout, out plexIdleTimeout);

            if (string.IsNullOrEmpty(_user.authenticationToken))
            {
                throw new Exception("No authentication token.");
            }

            var client = new RestClient("http://localhost:32400/status/sessions/history/all");
            var request = new RestRequest(Method.GET);
            request.AddQueryParameter("X-Plex-Token", _user.authenticationToken);
            request.AddQueryParameter("X-Plex-Container-Start", "0");
            request.AddQueryParameter("X-Plex-Container-Size", "1");
            IRestResponse<PlexHistoryObjects.MediaContainer> response = client.Execute<PlexHistoryObjects.MediaContainer>(request);

            if (response.Data.Video != null)
            {
                var lastStream = response.Data.Video;
                DateTime lastStreamDateTime = UnixTimeStampToDateTime(double.Parse(lastStream.ViewedAt));
                TimeSpan timeSpan = DateTime.Now - lastStreamDateTime;
                var msSinceLastStream = timeSpan.TotalMilliseconds;
                Trace.WriteLine("Last stream: " + lastStream.GrandparentTitle + " at " +
                                lastStreamDateTime.ToUniversalTime());

                return msSinceLastStream >= (plexIdleTimeout * Global.Minutes);
            }
            else
            {
                return true;
            }
        }
开发者ID:kariudo,项目名称:PlexPowerSaver,代码行数:37,代码来源:PlexAccess.cs

示例6: GetTimetable

        public TimetableModel GetTimetable(string operatorName, string stopIdentifier, int numResults)
        {
            var request = new RestRequest("v1/timetables", Method.GET);
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.AddQueryParameter("OperatorName", operatorName);
            request.AddQueryParameter("StopIdentifier", stopIdentifier);
            request.AddQueryParameter("NumResults", numResults.ToString());


            var response = Client.Execute<TimetableModel>(request);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                if (response.Data == null || response.Data.Operator == null || response.Data.StopName == null || response.Data.TimetableEntry == null) 
                {
                    return null;
                }

                return response.Data;
            }
            else
            {
                Logger.Instance.Write("GetTimetable", LogLevel.Medium, "Call failed with status code " + response.StatusCode);
                return null;
            }
        }
开发者ID:hendrikdelarey,项目名称:appcampus,代码行数:26,代码来源:TimetableComponent.cs

示例7: GetObject

            public object GetObject(string resourceKey, CultureInfo culture)
            {
                var locale = (culture ?? GetCurrentUserCulture()).ToString();
                var key = $"Resource{_applicationName}|{_resourceSet}|{resourceKey}|{locale}";

                return _cacheProvider.GetValue(key, () =>
                {
                    var restRequest = new RestRequest("/api/resource") { OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; } };
                    restRequest.AddQueryParameter("application", _applicationName);
                    restRequest.AddQueryParameter("resourceSet", _resourceSet);
                    restRequest.AddQueryParameter("resourceKey", resourceKey);
                    restRequest.AddQueryParameter("locale", locale);

                    try
                    {
                        var response = _restClient.Get<Resource>(restRequest);

                        if (response.ErrorMessage == "Unable to connect to the remote server")
                            throw new HttpConnectionException(string.Format(Errors.UnableToConnect, _restClient.BaseUrl), response.ErrorException);

                        if (response.StatusCode == HttpStatusCode.InternalServerError)
                            throw new HttpConnectionException(Errors.ServerError, response.ErrorException);

                        return response.Data.Value;
                    }
                    catch (Exception)
                    {
                        return resourceKey;
                    }
                });
            }
开发者ID:thesheps,项目名称:lemonade,代码行数:31,代码来源:HttpResourceResolver.cs

示例8: BuildRestRequestForMatchHistoryBySequenceNumber

 private static IRestRequest BuildRestRequestForMatchHistoryBySequenceNumber(int sequenceNumber,
     int matchesRequested)
 {
     var request = new RestRequest(RequestPaths.Dota2.Match.MatchHistoryBySequenceNumber);
     if (sequenceNumber > 0)
         request.AddQueryParameter("start_at_match_seq_num", sequenceNumber);
     if (matchesRequested > 0)
         request.AddQueryParameter("matches_requested", matchesRequested);
     return request;
 }
开发者ID:kbrimble,项目名称:Dota2.Client,代码行数:10,代码来源:MatchClient.cs

示例9: AuthenticateUser

        /// <summary>
        /// Authenticate user by given username and password.
        /// </summary>
        /// <param name="username">Account username or email</param>
        /// <param name="password">Account password</param>
        /// <returns></returns>
        public TokenResult AuthenticateUser(string username, string password)
        {
            var request = new RestRequest();
            request.Resource = "tokens";
            request.Method = Method.POST;

            request.AddQueryParameter("username", username);
            request.AddQueryParameter("password", password);

            return Execute<TokenResult>(request);
        }
开发者ID:foufure,项目名称:textmagic-rest-csharp,代码行数:17,代码来源:User.cs

示例10: ExecuteQuery

        public string ExecuteQuery(string input,string page)  
        {
            var request = new RestRequest(Resource);
            request.AddParameter("connectorId", ConnectorID, ParameterType.UrlSegment);

            if (!String.IsNullOrEmpty(input))
                request.AddQueryParameter("input", input);

            if (!String.IsNullOrEmpty(page))
                request.AddQueryParameter("page", page);

            return Execute(request);
        }
开发者ID:cakriwut,项目名称:ItsZap.ImportIO,代码行数:13,代码来源:ImportIoQuery.cs

示例11: GetScheduledLeagueGames

        public IEnumerable<ScheduledGame> GetScheduledLeagueGames(DateTime dateMin = default(DateTime), DateTime dateMax = default(DateTime))
        {
            var request = new RestRequest(RequestPaths.Dota2.League.ScheduledLeagueGames);

            var defaultDateTime = default(DateTime);
            if (dateMin != defaultDateTime)
                request.AddQueryParameter("date_min", dateMin.ToUnixTime());
            if (dateMax != defaultDateTime)
                request.AddQueryParameter("date_max", dateMax.ToUnixTime());

            var response = Execute<ScheduledLeagueGamesResponseWrapper>(request);
            return Mapper.Map<List<ScheduledGame>>(response.Games);
        }
开发者ID:kbrimble,项目名称:Dota2.Client,代码行数:13,代码来源:LeagueClient.cs

示例12: GetGiphy

        private string GetGiphy(string search)
        {
            var request = new RestRequest("/v1/gifs/translate", Method.GET);
            request.AddQueryParameter("s", search);
            request.AddQueryParameter("rating", Rating);
            request.AddQueryParameter("api_key", GiphyApiKey);

            var response = _client.Execute<dynamic>(request);

            var url = response.Data["data"]["images"]["fixed_height"]["url"];

            return url;
        }
开发者ID:RocketChat,项目名称:Rocket.Chat.Net,代码行数:13,代码来源:GiphyResponse.cs

示例13: Apply

        internal void Apply(RestRequest request)
        {
            // offset and and limit
            request.AddQueryParameter("offset", _offset.ToString());
            request.AddQueryParameter("limit", _limit.ToString());

            // filter if needed
            if (_filter != null)
                _filter.Apply(request);

            // marker if needed
            if (_marker != null)
                _marker.Apply(request);
        }
开发者ID:tvhnet2014,项目名称:stream-net,代码行数:14,代码来源:GetOptions.cs

示例14: Main

        static void Main()
        {
            var client = new RestClient("http://localhost:2741/api/calculator");
            var request = new RestRequest("distance", Method.POST);

            request.AddQueryParameter("startX", "5");
            request.AddQueryParameter("startY", "5");
            request.AddQueryParameter("endX", "10");
            request.AddQueryParameter("endY", "10");

            RestResponse response = (RestResponse)client.Execute(request);
            var content = response.Content;

            Console.WriteLine(content);
        }
开发者ID:zerefel,项目名称:Web-Services-And-Cloud,代码行数:15,代码来源:RESTClient.cs

示例15: GetMatch

 public MatchDetail GetMatch(string matchId)
 {
     var request = new RestRequest(RequestPaths.Dota2.Match.MatchDetails, Method.GET);
     request.AddQueryParameter("match_id", matchId);
     var response = Execute<MatchDetailResponse>(request);
     return Mapper.Map<MatchDetail>(response);
 }
开发者ID:kbrimble,项目名称:Dota2.Client,代码行数:7,代码来源:MatchClient.cs


注:本文中的RestSharp.RestRequest.AddQueryParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。