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


C# Uri.AppendParameter方法代碼示例

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


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

示例1: AppendParameterSuccessEmptyQuery

        public void AppendParameterSuccessEmptyQuery()
        {
            Uri url = new Uri(BaseUrl);
            const string key = "Test";
            const string value = "InsertedValue";

            string appendedUrl = url.AppendParameter(key, value);
           
            Assert.AreEqual($"{BaseUrl}?{key}={value}",appendedUrl);
        }
開發者ID:Chris1415,項目名稱:Hach.Library,代碼行數:10,代碼來源:UriExtensionTest.cs

示例2: AppendParameterEmptyKey

        public void AppendParameterEmptyKey()
        {
            string key = string.Empty;
            const string value = "InsertedValue";
            string extendedBaseUrl = $"{BaseUrl}";
            Uri url = new Uri(extendedBaseUrl);

            string appendedUrl = url.AppendParameter(key, value);

            Assert.AreEqual(url.AbsoluteUri, appendedUrl);
        }
開發者ID:Chris1415,項目名稱:Hach.Library,代碼行數:11,代碼來源:UriExtensionTest.cs

示例3: AppendParameterSuccessBaseUrlWithExistingKey

        public void AppendParameterSuccessBaseUrlWithExistingKey()
        {
            const string key = "Test";
            const string value = "InsertedValue";
            string extendedBaseUrl = $"{BaseUrl}?{key}=PreValue";
            Uri url = new Uri(extendedBaseUrl);

            string appendedUrl = url.AppendParameter(key, value);

            Assert.AreEqual($"{BaseUrl}?{key}={value}", appendedUrl);
        }
開發者ID:Chris1415,項目名稱:Hach.Library,代碼行數:11,代碼來源:UriExtensionTest.cs

示例4: AppendParameterSuccessBaseUrlWithSubPageAndQuery

        public void AppendParameterSuccessBaseUrlWithSubPageAndQuery()
        {
            string extendedBaseUrl = $"{BaseUrl}/SubPage?ExtendedParam=Value";
            Uri url = new Uri(extendedBaseUrl);
            const string key = "Test";
            const string value = "InsertedValue";

            string appendedUrl = url.AppendParameter(key, value);

            Assert.AreEqual($"{extendedBaseUrl}&{key}={value}", appendedUrl);
        }
開發者ID:Chris1415,項目名稱:Hach.Library,代碼行數:11,代碼來源:UriExtensionTest.cs

示例5: GeneratePaging

 /// <summary>
 /// Generates a List of Paging Elements based on the parameter
 /// </summary>
 /// <returns>List of Paging elements, without previous and next</returns>
 public PagingModel GeneratePaging(Uri url, int pageNumber, int totalNumberOfElements)
 {
     int lastElement = (totalNumberOfElements / Settings.ElementsPerPage) + 1;
     return new PagingModel()
     {
         Elements = GeneratePagingElements(url, pageNumber, totalNumberOfElements),
         Last = new PageElement()
         {
             IsActive = false,
             Text = Labels.NextPagingElementText,
             Url = url.AppendParameter(Labels.PagingKey, lastElement.ToString())
         },
         First = new PageElement()
         {
             IsActive = false,
             Text = Labels.PreviousPagingElementText,
             Url = url.AppendParameter(Labels.PagingKey, "1")
         }
     };
 }
開發者ID:Chris1415,項目名稱:Petrolcalculator,代碼行數:24,代碼來源:PagingService.cs

示例6: GeneratePagingElements

        /// <summary>
        /// Helper to generate a specific paging element with the given parameters
        /// </summary>
        /// <param name="url">url</param>
        /// <param name="pageNumber">page number</param>
        /// <param name="totalNumberOfElements">total number of elements</param>
        /// <returns>a filled paging element</returns>
        private static IEnumerable<PageElement> GeneratePagingElements(Uri url, int pageNumber, int totalNumberOfElements)
        {
            // Prepare the limits for the Paging elements
            int numberOfPagingElements = Settings.NumberOfPaingElements;
            int startIndex = pageNumber - numberOfPagingElements > 1 ? pageNumber - numberOfPagingElements : 1;
            int endIndex = pageNumber + numberOfPagingElements <= ((totalNumberOfElements / Settings.ElementsPerPage) + 1)
                ? pageNumber + numberOfPagingElements
                : (totalNumberOfElements / Settings.ElementsPerPage) + 1;

            // Use the limits for building the Paging
            for (int index = startIndex; index <= endIndex; index++)
            {
                string newUrl = url.AppendParameter(Labels.PagingKey, index.ToString());

                yield return new PageElement()
                {
                    Text = index.ToString(),
                    Url = newUrl,
                    IsActive = pageNumber == index
                };
            }
        }
開發者ID:Chris1415,項目名稱:Petrolcalculator,代碼行數:29,代碼來源:PagingService.cs

示例7: AppendParameterNullValue

        public void AppendParameterNullValue()
        {
            const string key = "Test";
            string value = null;
            string extendedBaseUrl = $"{BaseUrl}";
            Uri url = new Uri(extendedBaseUrl);

            string appendedUrl = url.AppendParameter(key, value);

            Assert.AreEqual(url.AbsoluteUri, appendedUrl);
        }
開發者ID:Chris1415,項目名稱:Hach.Library,代碼行數:11,代碼來源:UriExtensionTest.cs


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