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


C# UriBuilder.SetQueryParam方法代码示例

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


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

示例1: SetQueryParamTest

        public void SetQueryParamTest()
        {
            UriBuilder uriBuilder = new UriBuilder("http://", "mccoysoftware.uk");
            uriBuilder.SetQueryParam("FirstName", "Arthur");
            Assert.AreEqual("http://mccoysoftware.uk/?FirstName=Arthur", uriBuilder.ToString());
            uriBuilder.SetQueryParam("Surname", "Dent");
            Assert.AreEqual("http://mccoysoftware.uk/?FirstName=Arthur&Surname=Dent", uriBuilder.ToString());

            // It should be possible to overwrite the values set above
            uriBuilder.SetQueryParam("FirstName", "Ford");
            uriBuilder.SetQueryParam("Surname", "Prefect");
            Assert.AreEqual("http://mccoysoftware.uk/?FirstName=Ford&Surname=Prefect", uriBuilder.ToString());
        }
开发者ID:gitter-badger,项目名称:UrlUtilities,代码行数:13,代码来源:ExtensionTests.cs

示例2: GetMediaInfosAsync

        public override async Task<MediaInfo[]> GetMediaInfosAsync(Uri Url) {
            if (!this.IsMatch(Url)) throw new NotSupportedException("不正確的網址");

            HtmlDocument youtubePage = await this.DownloadHtmlAsync(Url);
            
            OnProcess?.Invoke(this,0.2);

            JObject mediaJObject = this.GetMediaJObject(youtubePage);

            if(mediaJObject["args"]["livestream"]?.Value<string>() == "1") {
                throw new NotSupportedException("不支援直播串流解析");
            }

            string description = youtubePage.DocumentNode.SelectSingleNode("//meta[@name='description']").GetAttributeValue("content", null);

            JsFactory.Func decoding = await this.GetDecodingSignature("https:" + (string)mediaJObject["assets"]["js"]);
            Dictionary<string, string> streamFormatList = this.GetStreamFormatList(mediaJObject);
            JObject[] streamMap = this.GetStreamMap(mediaJObject);

            Dictionary<string, MediaTypes> MIME = new Dictionary<string, MediaTypes>() {
                ["audio"] = MediaTypes.Audio,
                ["video"] = MediaTypes.Video
            };

            OnProcess?.Invoke(this, 0.5);
            double processValue = 0.5;


            List<MediaInfo> result = new List<MediaInfo>();
            foreach(var item in streamMap) {
                MediaInfo resultItem = new MediaInfo();
                #region 通用屬性
                resultItem.SourceUrl = Url;
                resultItem.ExtractorType = this.GetType();
                resultItem.Name = mediaJObject["args"]["title"].Value<string>();
                resultItem.Duration = mediaJObject["args"]["length_seconds"].Value<int>();
                resultItem.Description = description;
                resultItem.Thumbnail = new Uri(mediaJObject["args"]["thumbnail_url"].Value<string>());
                resultItem.Type = (MediaTypes)Enum.Parse(
                    typeof(MediaTypes),
                    new string(
                        item["type"]["mime"].Value<string>()
                        .TakeWhile(Ch => Ch != '/').ToArray()
                    ),
                    true
                );
                
                #region 連結解密
                UriBuilder realUrlBuilder = new UriBuilder(item["url"].Value<string>());
                var UrlSignature = realUrlBuilder.GetQueryParam("s") ??
                                  realUrlBuilder.GetQueryParam("sig") ??
                                  realUrlBuilder.GetQueryParam("signature");
                var ItemSignature = item["s"]?.Value<string>() ??
                                    item["sig"]?.Value<string>() ??
                                    item["signature"]?.Value<string>();
                realUrlBuilder.SetQueryParam("signature",decoding(UrlSignature ?? ItemSignature , UrlSignature != null));
                resultItem.RealUrl = realUrlBuilder.Uri;
                #endregion
                #endregion

                #region 擴充屬性
                resultItem.Attributes["mime"] = item["type"]["mime"].Value<string>();
                resultItem.Attributes["codecs"] = item["type"]["codecs"]?.Value<string>();
                resultItem.Attributes["author"] = mediaJObject["args"]["author"].Value<string>();
                if (resultItem.Type == MediaTypes.Video) {
                    resultItem.Attributes["size"] = item["size"]?.Value<string>() ?? streamFormatList[item["itag"]?.Value<string>()];
                    resultItem.Attributes["quality"] = item["quality"]?.Value<string>();
                } else if(resultItem.Type == MediaTypes.Audio) {
                    resultItem.Attributes["bitrate"] = item["bitrate"].Value<string>();
                }
                #endregion

                result.Add(resultItem);

                processValue = processValue + 0.5 / streamMap.Count();
                OnProcess?.Invoke(this, processValue);
            }

            MediaInfo[] output = result.ToArray();
            OnCompleted?.Invoke(this, output);
            return output;
        }
开发者ID:XuPeiYao,项目名称:MediaGetCore,代码行数:82,代码来源:YoutubeExtractor.cs

示例3: GetQuery

        private static string GetQuery(int? limit = null, int? offset= null, DateTime? startDate = null, DateTime? endDate = null)
        {
            const string dateFormat = "yyyy-mm-ddThh:mm:ssZ";
            var uri = new UriBuilder(HotmailBaseUrl);

            if (limit.HasValue)
            {
                uri.SetQueryParam(LiveSdkConstants.Limit, limit.Value.ToString());
            }

            if (offset.HasValue)
            {
                uri.SetQueryParam(LiveSdkConstants.Offset, offset.Value.ToString());
            }

            if (startDate.HasValue)
            {
                uri.SetQueryParam(HotmailConstants.StartDate, startDate.Value.ToString(dateFormat));
            }

            if (endDate.HasValue)
            {
                uri.SetQueryParam(HotmailConstants.EndDate, endDate.Value.ToString(dateFormat));
            }

            return uri.Query;
        }
开发者ID:modulexcite,项目名称:LiveSDKHelper,代码行数:27,代码来源:HotmailHelper.cs

示例4: GetQuery

        private static string GetQuery(List<FolderFilter> filters, int? limit, int? offset, SortBy? sortBy, SortOrder? sortOrder)
        {
            var uri = new UriBuilder(SkyDriveBaseUrl + SkyDriveConstants.GetFiles);

            var filterString = ParseFilters(filters);
            uri.SetQueryParam(SkyDriveConstants.Filters, filterString);

            if (limit.HasValue)
            {
                uri.SetQueryParam(LiveSdkConstants.Limit, limit.Value.ToString());
            }

            if (offset.HasValue)
            {
                uri.SetQueryParam(LiveSdkConstants.Offset, offset.Value.ToString());
            }

            if (sortBy.HasValue)
            {
                uri.SetQueryParam(SkyDriveConstants.SortBy, sortBy.ToString().ToLower());
            }

            if (sortOrder.HasValue)
            {
                uri.SetQueryParam(SkyDriveConstants.SortOrder, sortBy.ToString().ToLower());
            }

            return uri.Query;
        }
开发者ID:modulexcite,项目名称:LiveSDKHelper,代码行数:29,代码来源:SkyDriveHelper.cs


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