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


C# Uri.AddQuery方法代码示例

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


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

示例1: Upload

        /// <summary>
        /// Uploads the UI5 Project int <see cref="ProjectDir"/> to the SAP system specified by <see cref="Credentials"/>. If <see cref="Credentials.Username"/> is <c>null</c>, a single sign on authentification is performed.
        /// </summary>
        public void Upload()
        {
            if (string.IsNullOrWhiteSpace(ProjectDir)) throw new InvalidOperationException("ProjectDir not set.");
             if (!Directory.Exists(ProjectDir)) throw new InvalidOperationException("ProjectDir not set to a folder.");
             if (Credentials == null) throw new InvalidOperationException("Credentials not set.");
             if (string.IsNullOrWhiteSpace(Credentials.System)) throw new InvalidOperationException("Credentials.System not set.");
             if (string.IsNullOrWhiteSpace(AppName)) throw new InvalidOperationException("AppName not set.");

             if (TestMode) Log.Instance.Write("Test mode on!");

             try
             {
            var uri = new Uri(this.Credentials.System);
            uri = uri.AddQuery("sap-client", Credentials.Mandant.ToString());
            uri = uri.AddQuery("sapui5applicationname", AppName);
            uri = uri.AddQuery("sapui5applicationdescription", AppDescription);
            uri = uri.AddQuery("sapui5applicationpackage", Package);
            uri = uri.AddQuery("workbenchrequest", TransportRequest);
            uri = uri.AddQuery("externalcodepage", ExternalCodepage);
            uri = uri.AddQuery("deltamode", DeltaMode ? "true" : "false");
            uri = uri.AddQuery("testmode", TestMode ? "true" : "false");

            if (IgnoreCertificateErrors)
            {
               System.Net.ServicePointManager.ServerCertificateValidationCallback += ServerCertificateValidationIgnoreAll;
            }

            var cookieContainer = new System.Net.CookieContainer();
            //Try to Authenticate with a HEAD request and retrieve an authentification token cookie before uploading the whole application.
            var headRequest = System.Net.HttpWebRequest.Create(uri);
            headRequest.PreAuthenticate = false;
            headRequest.Timeout = 10000;
            headRequest.Method = System.Net.WebRequestMethods.Http.Head;
            ((System.Net.HttpWebRequest)headRequest).CookieContainer = cookieContainer;

            if (Credentials.Username != null)
            {
               headRequest.Credentials = new System.Net.NetworkCredential(Credentials.Username, Credentials.Password);
            }
            else //SSO
            {
               headRequest.ImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
               headRequest.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
            }
            headRequest.GetResponse().Close();

            //The actual POST request with the ziped project.
            var request = System.Net.HttpWebRequest.Create(uri);
            request.Timeout = Timeout * 1000;
            request.PreAuthenticate = true;
            request.UseDefaultCredentials = false;
            ((System.Net.HttpWebRequest)request).CookieContainer = cookieContainer; //Contains the authentification token if acquired
            if (Credentials.Username != null)                                       //if not: credentials to reauthenficiate.
            {
               request.Credentials = new System.Net.NetworkCredential(Credentials.Username, Credentials.Password);
            }
            else //SSO
            {
               request.ImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
               request.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
            }
            Log.Instance.Write("Uploading project...");
            request.Method = System.Net.WebRequestMethods.Http.Post;
            request.ContentType = "application/zip";
            using (var stream = request.GetRequestStream())
            {
               using (var zipHelper = new ZipHelper(stream))
               {
                  zipHelper.Zip(".Ui5RepositoryUploadParameters", Encoding.UTF8.GetBytes(cleanedConfigFileContent));
                  zipHelper.Zip(ProjectDir, new[] { ".Ui5Repository*", "WebContent" }, IgnoreMasks.ToArray());
               }
               stream.Close();
            }
            Log.Instance.Write("Installing App...");
            var response = (System.Net.HttpWebResponse)request.GetResponse();
            HandleResponse(response);
             }
             catch (System.Net.WebException ex)
             {
            if (ex.Response != null)
            {
               HandleResponse((System.Net.HttpWebResponse)ex.Response);
            }
            else
            {
               Log.Instance.Write(ex.ToString());
               Log.Instance.Write("Upload failed!");
               throw new UploadFailedException();
            }
             }
        }
开发者ID:kleferbe,项目名称:ui5uploader,代码行数:94,代码来源:Engine.cs

示例2: GetSectionTeacherAssociationTeacherListAsync

 /// <summary>
 ///     Gets teachers in teacher section associations within the sections.
 /// </summary>
 /// <param name="accessToken"></param>
 /// <param name="sectionId"></param>
 /// <param name="limit">Max number of sections to return(optional)</param>
 /// <param name="offset">Starting position of result set(optional)</param>
 /// <returns></returns>
 public async Task<JArray> GetSectionTeacherAssociationTeacherListAsync(string accessToken, string sectionId, int? limit, int? offset)
 {
     Uri apiEndPoint = new Uri(String.Format(ApiHelper.BaseUrl + "/sections/{0}/teacherSectionAssociations/teachers", sectionId));
     if (limit != null) { apiEndPoint = apiEndPoint.AddQuery("limit", limit.ToString()); }
     if (offset != null) { apiEndPoint = apiEndPoint.AddQuery("offset", offset.ToString()); }
     return (await ApiHelper.CallApiForGetAsync(apiEndPoint.ToString(), accessToken));
 }
开发者ID:upeo,项目名称:inbloom-dotnet,代码行数:15,代码来源:SectionDataService.cs

示例3: GetSectionStudentAssociationStudentList

 /// <summary>
 ///      Gets students details in student section associations within the sections.
 /// </summary>
 /// <param name="accessToken"></param>
 /// <param name="sectionId"></param>
 /// <param name="limit">Max number of sections to return(optional)</param>
 /// <param name="offset">Starting position of result set(optional)</param>
 /// <param name="views">View name (optional)</param>
 /// <returns></returns>
 public JArray GetSectionStudentAssociationStudentList(string accessToken, string sectionId, int? limit, int? offset, string views)
 {
     Uri apiEndPoint = new Uri(String.Format(ApiHelper.BaseUrl + "/sections/{0}/studentSectionAssociations/students", sectionId));
     if (limit != null) { apiEndPoint = apiEndPoint.AddQuery("limit", limit.ToString()); }
     if (offset != null) { apiEndPoint = apiEndPoint.AddQuery("offset", offset.ToString()); }
     if (!string.IsNullOrEmpty(views)) { apiEndPoint = apiEndPoint.AddQuery("views", views); }
     return ApiHelper.CallApiForGet(apiEndPoint.ToString(), accessToken);
 }
开发者ID:upeo,项目名称:inbloom-dotnet,代码行数:17,代码来源:SectionDataService.cs

示例4: ScrapeVideos

        public override ScrapedPage ScrapeVideos(SearchParameters sparam = null)
        {
            var rootUrl = RootUrl;
            if (sparam != null )
            {
                if (!String.IsNullOrEmpty(sparam.Url))
                    rootUrl = sparam.Url;
                var ub = new Uri(rootUrl);
                if (!String.IsNullOrEmpty(sparam.Query))
                {
                    ub = ub.AddQuery("k", sparam.Query);
                    ub = ub.AddQuery("sort", sparam.SortBy == VideoSortby.Relevance ? "relevance"
                        : (sparam.SortBy == VideoSortby.Rating ? "rating" : "uploaddate"));
                    ub = ub.AddQuery("durf", sparam.Duration == VideoDuration.All ? "allduration" : (sparam.Duration == VideoDuration.Long ? "10min_more" :
                        (sparam.Duration == VideoDuration.Short ? "1-3min" : "3-10min")));
                    ub = ub.AddQuery("datef", sparam.Period == VideoPeriod.Anytime ? "all" : (sparam.Period == VideoPeriod.Today ? "today" :
                        ((sparam.Period == VideoPeriod.ThisWeek ? "week" : "month"))));
                    rootUrl = ub.AbsoluteUri;
                }
            }

            var page = new ScrapedPage();
            var elem = GotoUrl(rootUrl);
            page.Videos =  ScrapThumbnailVideos(elem);
            //get next page
            var pages = SelectItems(elem, ".pagination.small.top a").ToList();
            foreach (var p in pages)
            {
                bool selected = p.Attributes["class"] != null && p.Attributes["class"].Value == "sel";
                page.Links.Add(new PagingLink
                {
                    Url = selected? rootUrl : new Uri(new Uri(RootUrl), p.Attributes["href"].Value).AbsoluteUri,
                    IsSelected = selected,
                    Text = p.InnerText
                });
            }

               var showMore = SelectItem(elem, ".showMore a");
               if (showMore != null)
               {
                page.Links.Add(new PagingLink
                {
                    Url = String.Format("{0}{1}", RootUrl, showMore.Attributes["href"].Value),
                    Text = showMore.InnerText,
                });
               }

            return page;
        }
开发者ID:huoxudong125,项目名称:VideoSearch,代码行数:49,代码来源:VideoScraperBase.cs

示例5: GetStudents

 /// <summary>
 ///     Gets students details.
 /// </summary>
 /// <param name="accessToken"></param>
 /// <returns></returns>
 public JArray GetStudents(string accessToken, int? limit, int? offset)
 {
     Uri apiEndPoint = new Uri(ApiHelper.BaseUrl + "/students");
     if (limit != null) { apiEndPoint = apiEndPoint.AddQuery("limit", limit.ToString()); }
     if (offset != null) { apiEndPoint = apiEndPoint.AddQuery("offset", offset.ToString()); }
     return ApiHelper.CallApiForGet(apiEndPoint.ToString(), accessToken);
 }
开发者ID:upeo,项目名称:inbloom-dotnet,代码行数:12,代码来源:StudentDataService.cs

示例6: GetStudentAttendancesAsync

 /// <summary>
 ///     Gets attendances within the students.
 /// </summary>
 /// <param name="accessToken"></param>
 /// <param name="studentId"></param>
 /// <returns></returns>
 public async Task<JArray> GetStudentAttendancesAsync(string accessToken, string studentId, int? limit)
 {
     Uri apiEndPoint = new Uri(String.Format(ApiHelper.BaseUrl + "/students/{0}/attendances", studentId));
     if (limit != null) { apiEndPoint = apiEndPoint.AddQuery("limit", limit.ToString()); }
     return await ApiHelper.CallApiForGetAsync(apiEndPoint, accessToken);
 }
开发者ID:upeo,项目名称:inbloom-dotnet,代码行数:12,代码来源:StudentDataService.cs

示例7: GetStudentStudentSectionAssociations

 /// <summary>
 ///     Gets student section associations within the students.
 /// </summary>
 /// <param name="accessToken"></param>
 /// <param name="studentId"></param>
 /// <param name="studentId"></param>
 /// <returns></returns>
 public JArray GetStudentStudentSectionAssociations(string accessToken, string studentId, string views)
 {
     Uri apiEndPoint = new Uri(String.Format(ApiHelper.BaseUrl + "/students/{0}/studentSectionAssociations", studentId));
     if (!string.IsNullOrEmpty(views)) { apiEndPoint = apiEndPoint.AddQuery("views", views); }
     return ApiHelper.CallApiForGet(apiEndPoint.ToString(), accessToken);
 }
开发者ID:upeo,项目名称:inbloom-dotnet,代码行数:13,代码来源:StudentDataService.cs

示例8: GetTeachersAsync

 /// <summary>
 ///     Gets teachers details.
 /// </summary>
 /// <param name="accessToken"></param>
 /// <returns></returns>
 public async Task<JArray> GetTeachersAsync(string accessToken, int? limit, int? offset)
 {
     Uri apiEndPoint = new Uri(String.Format(ApiHelper.BaseUrl + "/teachers"));
     if (limit != null) { apiEndPoint = apiEndPoint.AddQuery("limit", limit.ToString()); }
     if (offset != null) { apiEndPoint = apiEndPoint.AddQuery("offset", offset.ToString()); }
     return await ApiHelper.CallApiForGetAsync(apiEndPoint, accessToken);
 }
开发者ID:upeo,项目名称:inbloom-dotnet,代码行数:12,代码来源:TeacherDataService.cs


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