當前位置: 首頁>>代碼示例>>C#>>正文


C# Uri.ParseQueryString方法代碼示例

本文整理匯總了C#中System.Uri.ParseQueryString方法的典型用法代碼示例。如果您正苦於以下問題:C# Uri.ParseQueryString方法的具體用法?C# Uri.ParseQueryString怎麽用?C# Uri.ParseQueryString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Uri的用法示例。


在下文中一共展示了Uri.ParseQueryString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Create

        public Data.PagedDataRequest Create(Uri requestUri)
        {
            int? pageNumber;
            int? pageSize;

            try
            {
                var valueCollection = requestUri.ParseQueryString();

                pageNumber =
                    PrimitiveTypeParser.Parse<int?>(valueCollection[Constants.CommonParameterNames.PageNumber]);

                pageSize = PrimitiveTypeParser.Parse<int?>(valueCollection[Constants.CommonParameterNames.PageSize]);
            }
            catch(Exception e)
            {
                _log.Error("Error Parsing input", e);
                throw new HttpException((int)HttpStatusCode.BadRequest, e.Message);
            }

            pageNumber = pageNumber.GetBoundedValue(Constants.Paging.DefaultPageNumber, Constants.Paging.MinPageNumber);
            pageSize = pageSize.GetBoundedValue(DefaultPageSize, Constants.Paging.MinPageSize, MaxPageSize);


            return new PagedDataRequest(pageNumber.Value, pageSize.Value);
        }
開發者ID:sanghyukp,項目名稱:AngularJSWebAPI2,代碼行數:26,代碼來源:PagedDataRequestFactory.cs

示例2: Execute

 public static Response Execute(Uri url, Func<ISchedulerWrapper> getScheduler)
 {
     var scheduler = getScheduler();
     var p = GetMethodParameters(url.ParseQueryString());
     p.method.Invoke(scheduler, p.parameters.ToArray());
     return new Response.RedirectResponse(p.redirect);
 }
開發者ID:modulexcite,項目名稱:QuartzNetWebConsole,代碼行數:7,代碼來源:SchedulerController.cs

示例3: Execute

 public static Response Execute(Uri url)
 {
     var querystring = url.ParseQueryString();
     var resource = querystring["r"];
     resource = string.Format("{0}.Resources.{1}", assembly.FullName.Split(',')[0], resource);
     var content = ReadResource(resource);
     return new Response.ContentResponse(content: content, contentType: querystring["t"]);
 }
開發者ID:modulexcite,項目名稱:QuartzNetWebConsole,代碼行數:8,代碼來源:StaticController.cs

示例4: SelectedCurrencyLinkChanged

        private void SelectedCurrencyLinkChanged(Uri link)
        {
            string currencyName;
            link.ParseQueryString().TryGetValue("Name", out currencyName);

            var selectedCurrency = _context.Currencies.FirstOrDefault(x => x.Name == currencyName);

            if (selectedCurrency != null)
                Messenger.Default.Send(selectedCurrency, "currencyChangedMsg");
        }
開發者ID:kneefer,項目名稱:CurrencyCalc,代碼行數:10,代碼來源:HistoryViewModel.cs

示例5: GetRequestFromXamlUri

	    public virtual MvxShowViewModelRequest GetRequestFromXamlUri(Uri viewUri)
		{
	        var parsed = viewUri.ParseQueryString();

	        string queryString;
            if (!parsed.TryGetValue(QueryParameterKeyName, out queryString))
			    throw new MvxException("Unable to find incoming MvxShowViewModelRequest");

			var text = Uri.UnescapeDataString(queryString);
			return JsonConvert.DeserializeObject<MvxShowViewModelRequest>(text);
		}
開發者ID:GSerjo,項目名稱:MvvmCross,代碼行數:11,代碼來源:MvxPhoneViewsContainer.cs

示例6: GetRequestFromXamlUri

        public virtual MvxViewModelRequest GetRequestFromXamlUri(Uri viewUri)
        {
            var parsed = viewUri.ParseQueryString();

            string queryString;
            if (!parsed.TryGetValue(QueryParameterKeyName, out queryString))
                throw new MvxException("Unable to find incoming MvxViewModelRequest");

            var converter = Mvx.Resolve<IMvxNavigationSerializer>();
            return converter.Serializer.DeserializeObject<MvxViewModelRequest>(queryString);
        }
開發者ID:indazoo,項目名稱:MvvmCross_DesignData,代碼行數:11,代碼來源:MvxPhoneViewsContainer.cs

示例7: Execute

 public static Response Execute(Uri url, Func<ISchedulerWrapper> getScheduler)
 {
     var scheduler = getScheduler();
     var qs = url.ParseQueryString();
     var highlight = qs["highlight"];
     var group = qs["group"];
     var triggers = GetTriggers(scheduler, group);
     var paused = scheduler.IsTriggerGroupPaused(group);
     var v = Views.Views.TriggerGroup(group, paused, url.PathAndQuery, highlight, triggers);
     return new Response.XDocumentResponse(Helpers.XHTML(v));
 }
開發者ID:modulexcite,項目名稱:QuartzNetWebConsole,代碼行數:11,代碼來源:TriggerGroupController.cs

示例8: Execute

 public static Response Execute(Uri url, Func<ISchedulerWrapper> getScheduler)
 {
     var scheduler = getScheduler();
     var querystring = url.ParseQueryString();
     var highlight = querystring["highlight"];
     var group = querystring["group"];
     var job = querystring["job"];
     var jobKey = new JobKey(job, group);
     var triggers = GetTriggers(scheduler, jobKey);
     var m = new TriggersByJobModel(triggers, url.PathAndQuery, group, job, highlight);
     return new Response.XDocumentResponse(Helpers.XHTML(Views.Views.TriggersByJob(m)));
 }
開發者ID:modulexcite,項目名稱:QuartzNetWebConsole,代碼行數:12,代碼來源:TriggersByJobController.cs

示例9: Authenticate

        public static async Task<string> Authenticate()
        {
            var startURI = new Uri(START_URL);
            var endURI = new Uri(END_URL);
            string result;

            var webAuthResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, startURI, endURI);

            switch (webAuthResult.ResponseStatus)
            {
                case WebAuthenticationStatus.Success:
                    result = webAuthResult.ResponseData.ToString();
                    break;
                case WebAuthenticationStatus.ErrorHttp:
                    result = webAuthResult.ResponseData.ToString();
                    throw new Exception(result);
                default:
                    throw new Exception("Error :(");
            }
            var resultURI = new Uri(result);
            var query = resultURI.ParseQueryString();
            var code = query["code"];
            var tokenURL = "https://api.slack.com/api/oauth.access?code="
                + Uri.EscapeUriString(code)
                + "&client_id=" + Uri.EscapeUriString(CLIENT_ID)
                + "&client_secret=" + Uri.EscapeUriString(CLIENT_SECRET);
            var tokenURI = new Uri(tokenURL);
            var httpClient = new HttpClient();
            string tokenResponse;
            try
            {
                tokenResponse = await httpClient.GetStringAsync(tokenURI);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                httpClient.Dispose();
            }
            JsonObject tokenObject;
            if (!JsonObject.TryParse(tokenResponse, out tokenObject))
            {
                throw new Exception("Couldn't parse HTTP response. Try again later.");
            }
            if (!tokenObject.GetNamedBoolean("ok"))
            {
                throw new Exception("You are not authorized to access this team.");
            }
            return tokenObject.GetNamedString("access_token");
        }
開發者ID:kureuil,項目名稱:Taper,代碼行數:52,代碼來源:LoginProvider.cs

示例10: ParseAuthenticationResponseUri

    /// <summary>
    /// Parses the authentication response URI and creates the response object.
    /// </summary>
    /// <param name="uri">The URI where the user has been redirected to after authentication.</param>
    /// <returns></returns>
    public AuthenticationResponse ParseAuthenticationResponseUri(Uri uri)
    {
      Dictionary<string, string> queryParams = uri.ParseQueryString();
      string code = null;
      string error = null;
      string state = null;

      queryParams.TryGetValue("code", out code);
      queryParams.TryGetValue("error", out error);
      queryParams.TryGetValue("state", out state);

      return new AuthenticationResponse() { Code = code, Error = error, State = state };
    }
開發者ID:jvanrhyn,項目名稱:FeedlySharp,代碼行數:18,代碼來源:Auth.cs

示例11: GetOrderKey

        private static int GetOrderKey(
            IHttpRouteData routeData, Uri requestUri)
        {
            object orderKeyString;
            if (routeData.Values.TryGetValue("key", out orderKeyString)) {

                return int.Parse(orderKeyString.ToString());
            }

            // It's now sure that query string has the shipmentKey value
            var quesryString = requestUri.ParseQueryString();
            return int.Parse(quesryString["key"]);
        }
開發者ID:tugberkugurlu,項目名稱:AdvancedWebAPI,代碼行數:13,代碼來源:EnsureOrderOwnershipAttribute.cs

示例12: FromForm

 public static NameValueCollection FromForm(this IWebResponse response)
 {
     if (response == null)
     {
         throw new ArgumentNullException("response");
     }
     using (var stream = response.Response.GetResponseStream())
     using (var reader = new StreamReader(stream))
     {
         string formData = reader.ReadToEnd();
         Uri fakeUri = new Uri("http://localhost/?" + formData);
         return fakeUri.ParseQueryString();
     }
 }
開發者ID:jehugaleahsa,項目名稱:NRest,代碼行數:14,代碼來源:FormExtensions.cs

示例13: Parse

        public static OAuthRequest Parse(Uri uri)
        {
            NameValueCollection queryString = uri.ParseQueryString();
            string responseType = queryString.Get("response_type");
            string clientId = queryString.Get("client_id");
            string state = queryString.Get("state");
            string scope = queryString.Get("scope");
            string jwt = queryString.Get("jwt_token");
            var redirectUri = new Uri(queryString.Get("redirect_uri"), UriKind.Absolute);
            
            var originalUri = uri.ToString().Replace("&jwt_token=" + jwt, "");

            return new OAuthRequest(responseType, clientId, state, scope, redirectUri, jwt, originalUri);
        }
開發者ID:jayway,項目名稱:JayLabs.Owin.OAuthAuthorization,代碼行數:14,代碼來源:OAuthRequest.cs

示例14: Execute

 public static Response Execute(Uri url)
 {
     var thisUrl = url.PathAndQuery.Split('?')[0];
     var qs = url.ParseQueryString();
     var pageSize = GetPageSize(qs);
     var pagination = new PaginationInfo(
         firstItemIndex: GetStartIndex(qs),
         pageSize: pageSize,
         totalItemCount: logsQ.Count(),
         pageUrl: "log.ashx?start=!0&max=" + pageSize);
     var logs = logsQ.Skip(pagination.FirstItemIndex).Take(pagination.PageSize).ToList();
     var v = GetView(qs.AllKeys);
     var view = v.Value(logs, pagination, thisUrl);
     return new Response.XDocumentResponse(view, v.Key);
 }
開發者ID:modulexcite,項目名稱:QuartzNetWebConsole,代碼行數:15,代碼來源:LogController.cs

示例15: Callback

        public ActionResult Callback()
        {
            string input;
            using (var reader = new StreamReader(Request.InputStream))
            {
                input = reader.ReadToEnd();
            }

            string locationBase = string.Format("{0}/auth/broker/end",
                                                Request.Url.GetComponents(UriComponents.SchemeAndServer,
                                                                          UriFormat.Unescaped));
            var inputInQueryStringUri = new Uri(locationBase + "?" + input);
            NameValueCollection tokenValues = inputInQueryStringUri.ParseQueryString();
            string tokenData = tokenValues["wresult"];

            //Validate SWT token
            var tokenSerializer = new WSTrustFeb2005ResponseSerializer();
            RequestSecurityTokenResponse requestSecrityTokenResponse =
                tokenSerializer.ReadXml(new XmlTextReader(new StringReader(tokenData)),
                                        new WSTrustSerializationContext());

            var simpleWebTokenHandler = new SimpleWebTokenHandler("https://" + _registrationService.ServiceNamespace + ".accesscontrol.windows.net/", _swtSigningKey);
            var securityToken = simpleWebTokenHandler.ReadToken(requestSecrityTokenResponse.RequestedSecurityToken.SecurityTokenXml.InnerText) as SimpleWebToken;
            simpleWebTokenHandler.ValidateToken(securityToken, _acsRealm);

            //Create delegation in ACS
            var authServerIdentifier = securityToken.Claims.FirstOrDefault(c => c.ClaimType == ClaimTypes.NameIdentifier);
            var authServerIdentity = new AuthorizationServerIdentity
                                         {
                                             NameIdentifier = authServerIdentifier.Value,
                                             IdentityProvider = authServerIdentifier.Issuer
                                         };

            //todo: Check if we can add some claims (role claims) to the scope
            string code = _registrationService.GetAuthorizationCode(_clientId, authServerIdentity, "scope");

            //todo: use OAuth parameter names in the return URL
            //return the token
            string location = string.Format("{0}?acsToken={1}", locationBase, code);

            Response.StatusCode = (int)HttpStatusCode.Redirect;
            Response.Headers.Add("Location", location);
            Response.End();

            return null;
        }
開發者ID:smetsth,項目名稱:AuthenticationBroker,代碼行數:46,代碼來源:BrokerController.cs


注:本文中的System.Uri.ParseQueryString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。