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


C# QueryString.ToString方法代码示例

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


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

示例1: With_no_parameters

            public void With_no_parameters()
            {
                var uri = new Uri("http://foo/bar");
                var qs = new QueryString(uri);

                qs.ToString().ShouldBe(string.Empty);
                qs.ToString(canonical: true).ShouldBe(string.Empty);
            }
开发者ID:ssankar1234,项目名称:stormpath-sdk-dotnet,代码行数:8,代码来源:QueryString_tests.cs

示例2: BuildAbsolute

        /// <summary>
        /// Combines the given URI components into a string that is properly encoded for use in HTTP headers.
        /// Note that unicode in the HostString will be encoded as punycode.
        /// </summary>
        /// <param name="scheme">http, https, etc.</param>
        /// <param name="host">The host portion of the uri normally included in the Host header. This may include the port.</param>
        /// <param name="pathBase">The first portion of the request path associated with application root.</param>
        /// <param name="path">The portion of the request path that identifies the requested resource.</param>
        /// <param name="query">The query, if any.</param>
        /// <param name="fragment">The fragment, if any.</param>
        /// <returns></returns>
        public static string BuildAbsolute(
            string scheme,
            HostString host,
            PathString pathBase = new PathString(),
            PathString path = new PathString(),
            QueryString query = new QueryString(),
            FragmentString fragment = new FragmentString())
        {
            var combinedPath = (pathBase.HasValue || path.HasValue) ? (pathBase + path).ToString() : "/";

            var encodedHost = host.ToString();
            var encodedQuery = query.ToString();
            var encodedFragment = fragment.ToString();

            // PERF: Calculate string length to allocate correct buffer size for StringBuilder.
            var length = scheme.Length + SchemeDelimiter.Length + encodedHost.Length
                + combinedPath.Length + encodedQuery.Length + encodedFragment.Length;

            return new StringBuilder(length)
                .Append(scheme)
                .Append(SchemeDelimiter)
                .Append(encodedHost)
                .Append(combinedPath)
                .Append(encodedQuery)
                .Append(encodedFragment)
                .ToString();
        }
开发者ID:tuespetre,项目名称:HttpAbstractions,代码行数:38,代码来源:UriHelper.cs

示例3: Execute

    public virtual IPromise<IHttpResponse> Execute(string method, string baseUrl, QueryString queryString, System.Net.ICredentials credentials, bool async, Action<IHttpRequest> configure)
    {
      var uri = baseUrl + (queryString == null ? "" : queryString.ToString());

      var req = (HttpWebRequest)System.Net.WebRequest.Create(uri);
      req.AllowAutoRedirect = this.AllowAutoRedirect;
      if (this.AutomaticDecompression) req.AutomaticDecompression = (DecompressionMethods.GZip | DecompressionMethods.Deflate);
      if (this.StoreCookies) req.CookieContainer = _cookieContainer;
      req.Method = method;
      req.ReadWriteTimeout = 300000;
      req.Timeout = DefaultTimeout;
      if (method == "POST")
      {
        req.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
      }
      req.Credentials = credentials;
      var result = new WebRequest(req, this.Compression);
      if (configure != null) configure.Invoke(result);

      var st = Stopwatch.StartNew();
      return result.Execute(async).Convert(r => {
        if (r.Core.Cookies.Count > 0) SetCookies(r.Core.Cookies);
        return (IHttpResponse)r;
      }).Always(() => {
        st.Stop();
        _httpTracing.TraceData(TraceEventType.Verbose, 0, st.ElapsedMilliseconds);
      });
    }
开发者ID:rneuber1,项目名称:InnovatorAdmin,代码行数:28,代码来源:DefaultHttpService.cs

示例4: Process

        public ActionResult Process(HttpRequestBase request, ModelStateDictionary modelState)
        {
            IpnVerificationBinder binder = new IpnVerificationBinder();
            Transaction tx = binder.Bind(request.Form, modelState);

            ContentResult cr = new ContentResult();
            cr.ContentEncoding = Encoding.UTF8;
            cr.ContentType = "text/html";
            cr.Content = "INVALID";

            if (tx != null)
            {
                Transaction dbTx = m_txRepository.GetAll().Where(x => x.Tx == tx.Tx).FirstOrDefault();
                if (dbTx != null)
                {
                    string expected = dbTx.ToIpnQueryString().ToString();
                    QueryString actualQs = new QueryString();
                    actualQs.Add(request.Form);
                    actualQs.Remove("cmd");
                    string actual = actualQs.ToString();

                    if (expected == actual)
                    {
                        cr.Content = "VERIFIED";
                    }
                }
            }

            return cr;
        }
开发者ID:triggerfish,项目名称:PayPalEmulator,代码行数:30,代码来源:AuthoriseIpnHandler.cs

示例5: Creating_from_empty_map

            public void Creating_from_empty_map()
            {
                var args = new Dictionary<string, string>();
                var qs = new QueryString(args);

                qs.ToString().ShouldBe(string.Empty);
            }
开发者ID:ssankar1234,项目名称:stormpath-sdk-dotnet,代码行数:7,代码来源:QueryString_tests.cs

示例6: MyFact

        public void MyFact()
        {
            var queryString = new QueryString();

            queryString.Add("q", "mcdonald");

            Assert.Equal("q=mcdonald", queryString.ToString());
        }
开发者ID:McDonaldConsulting,项目名称:Utility,代码行数:8,代码来源:QueryStringTests.cs

示例7: BuildRelative

 /// <summary>
 /// Combines the given URI components into a string that is properly encoded for use in HTTP headers.
 /// </summary>
 /// <param name="pathBase">The first portion of the request path associated with application root.</param>
 /// <param name="path">The portion of the request path that identifies the requested resource.</param>
 /// <param name="query">The query, if any.</param>
 /// <param name="fragment">The fragment, if any.</param>
 /// <returns></returns>
 public static string BuildRelative(
     PathString pathBase = new PathString(),
     PathString path = new PathString(),
     QueryString query = new QueryString(),
     FragmentString fragment = new FragmentString())
 {
     string combinePath = (pathBase.HasValue || path.HasValue) ? (pathBase + path).ToString() : "/";
     return combinePath + query.ToString() + fragment.ToString();
 }
开发者ID:tuespetre,项目名称:HttpAbstractions,代码行数:17,代码来源:UriHelper.cs

示例8: ShouldEncodeWhenConvertingToString

        public void ShouldEncodeWhenConvertingToString()
        {
            // arrange
            QueryString qs = new QueryString();
            qs.Add("1", "http://");

            // act and assert
            Assert.AreEqual("?1=http%3a%2f%2f", qs.ToString());
        }
开发者ID:triggerfish,项目名称:Common,代码行数:9,代码来源:QueryStringTests.cs

示例9: ShouldBuildHttpPostString

        public void ShouldBuildHttpPostString()
        {
            // arrange
            QueryString qs = new QueryString();
            qs.Add("1", "2");
            qs.Add("3", "4");

            // act and assert
            Assert.AreEqual("1=2&3=4", qs.ToString(HttpAction.Post));
        }
开发者ID:triggerfish,项目名称:Common,代码行数:10,代码来源:QueryStringTests.cs

示例10: Creating_from_map

            public void Creating_from_map()
            {
                var args = new Dictionary<string, string>()
            {
                { "foo", "bar" },
                { "abc", "123" },
            };
                var qs = new QueryString(args);

                qs.ToString().ShouldBe("abc=123&foo=bar");
            }
开发者ID:ssankar1234,项目名称:stormpath-sdk-dotnet,代码行数:11,代码来源:QueryString_tests.cs

示例11: AssertEqual

        private static void AssertEqual(QueryString expected, QueryString actual)
        {
            Assert.IsTrue(expected.Equals(actual), "Expected: " + expected + "\nActual: " + actual);

            Assert.IsTrue(expected.Equals(QueryString.Parse(actual.ToString())), "After serializing and parsing actual, result changed.\n\nExpected: " + expected + "\nActual: " + QueryString.Parse(actual.ToString()));
            Assert.IsTrue(QueryString.Parse(expected.ToString()).Equals(actual), "After serializing and parsing expected, result changed.\n\nExpected: " + QueryString.Parse(expected.ToString()) + "\nActual: " + actual);
            Assert.IsTrue(QueryString.Parse(expected.ToString()).Equals(QueryString.Parse(actual.ToString())), "After serializing and parsing both, result changed.\n\nExpected: " + QueryString.Parse(expected.ToString()) + "\nActual: " + QueryString.Parse(actual.ToString()));
        }
开发者ID:WindowsNotifications,项目名称:QueryString.NET,代码行数:8,代码来源:QueryStringTest.cs

示例12: Canonicalize_flag_is_observed

            public void Canonicalize_flag_is_observed()
            {
                var qs = new QueryString("search=start*&test=one two&tilde=~");

                qs.ToString().ShouldBe("search=start*&test=one+two&tilde=%7E");
                qs.ToString(canonical: true).ShouldBe("search=start%2A&test=one%20two&tilde=~");
            }
开发者ID:ssankar1234,项目名称:stormpath-sdk-dotnet,代码行数:7,代码来源:QueryString_tests.cs

示例13: Keys_with_no_values_are_ok

            public void Keys_with_no_values_are_ok()
            {
                var qs = new QueryString(new Uri("https://foo.bar?foo=bar&baz=&three"));

                qs.ToString().ShouldBe("baz=&foo=bar&three=");
            }
开发者ID:ssankar1234,项目名称:stormpath-sdk-dotnet,代码行数:6,代码来源:QueryString_tests.cs

示例14: Keys_are_sorted

            public void Keys_are_sorted()
            {
                var qs = new QueryString(new Uri("https://foo.bar/?zulu=5&beta=foo&alpha=9"));

                qs.ToString(canonical: true).ShouldBe("alpha=9&beta=foo&zulu=5");
            }
开发者ID:ssankar1234,项目名称:stormpath-sdk-dotnet,代码行数:6,代码来源:QueryString_tests.cs

示例15: Keys_and_value_case_is_preserved

            public void Keys_and_value_case_is_preserved()
            {
                var qs = new QueryString(new Uri("http://foo.bar/baz?TEST=foo&bar=BAZ"));

                qs.ToString().ShouldBe("bar=BAZ&TEST=foo");
            }
开发者ID:ssankar1234,项目名称:stormpath-sdk-dotnet,代码行数:6,代码来源:QueryString_tests.cs


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