当前位置: 首页>>代码示例>>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;未经允许,请勿转载。