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