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


C# Uri.Append方法代码示例

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


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

示例1: AppendToExistingQueryStringArgument

 public void AppendToExistingQueryStringArgument()
 {
     var uri = new Uri("http://host/?c=5");
     var uri2 = uri.Append("c", "4");
     Assert.IsTrue(uri2.HasValue("c", "5"));
     Assert.IsTrue(uri2.HasValue("c", "4"));
 }
开发者ID:thaneswarreddy,项目名称:netfx,代码行数:7,代码来源:UriExtensionsFixture.cs

示例2: Get

        public string Get(string projectId)
        {
            Uri requestUri = HttpContext.Current.Request.Url;
            Uri rootUri = new Uri(requestUri.GetLeftPart(UriPartial.Authority));
            string uriPath = HttpContext.Current.Request.Path;

            string baseDirectory = Directory.GetParent(HttpContext.Current.Request.PhysicalPath).ToString();
            string rootDirectory = Directory.GetParent(HttpContext.Current.Server.MapPath("~")).ToString();

            Uri uri = rootUri.Append(string.Format("GetProject?projectId={0}", projectId));

            //todo: Test if the Uri constructor will be more easily to use.
            //new Uri(new Uri(requestUri.GetLeftPart(UriPartial.Authority)), string.Format("GetProject?projectId={0}", projectId)).ToString();

            try
            {
                DocumentModel.Load(uri.ToString(), baseDirectory, baseDirectory, identity: null)
               .Transform(doc =>
               {
                   //todo: Ensure is not null.
                   var element = doc.getElementById("div");
                   if (element != null)
                   {
                       doc.body.innerHTML = element.outerHTML;
                   }
               })
               .RemoveElementsByIds("")
               .SaveAs(@"D:\Result\hello.docx");
            }
            catch (Exception ex)
            {
                throw ex;
            }
            HttpContext.Current.Response.Headers.Add("Content-Type", MimeMapping.GetMimeMapping(".docx"));
            HttpContext.Current.Response.Headers.Add("Content-Disposition", string.Format("inline;filename=\"{0}\"", "hello.docx"));
            HttpContext.Current.Response.WriteFile(@"D:\Result\hello.docx");
            return "";
        }
开发者ID:JuntaoWu,项目名称:chaos-document-model,代码行数:38,代码来源:DownloadWordDocumentController.cs

示例3: GetRole

 /// <summary>
 /// Retrieves detailed information about the selected role in the specified project.
 /// </summary>
 /// <param name="projectUri">The URI of the project resource.</param>
 /// <param name="roleId">The Id of the role.</param>
 /// <returns>Detailed information about the selected role.</returns>
 /// <exception cref="WebServiceException">The project role or role ID was not found, or the calling user does not have permission to view it.</exception>
 public ProjectRole GetRole(Uri projectUri, int roleId)
 {
     var uri = projectUri.Append(ProjectRoleUriPostfix).Append(roleId.ToString());
     return client.Get<ProjectRole>(uri.ToString());
 }
开发者ID:Tdue21,项目名称:Jira-Rest-Client-Dot-Net-Update,代码行数:12,代码来源:JiraProjectRolesRestClient.cs

示例4: AddActorToRole

 private ProjectRole AddActorToRole(Uri projectUri, int roleId, string actorType, string actorName)
 {
     var uri = projectUri.Append(ProjectRoleUriPostfix).Append(roleId.ToString());
     var actors = new List<string> { actorName };
     var request = new JsonObject { { actorType, actors.ToJson() } };
     return client.Post<ProjectRole>(uri.ToString(), request);
 }
开发者ID:Tdue21,项目名称:Jira-Rest-Client-Dot-Net-Update,代码行数:7,代码来源:JiraProjectRolesRestClient.cs

示例5: GetRoles

 /// <summary>
 /// Retrieves detailed information for all roles for the specified project.
 /// </summary>
 /// <param name="projectUri">The URI of the project resource.</param>
 /// <returns>A collection of all roles for the project.</returns>
 /// <exception cref="WebServiceException">The project was not found, or the calling user does not have permission to view it.</exception>
 public IEnumerable<ProjectRole> GetRoles(Uri projectUri)
 {
     var uri = projectUri.Append(ProjectRoleUriPostfix);
     var json = client.Get<Dictionary<string, Uri>>(uri.ToString());
     return json.Values.Select(b => GetRole(b)).ToList();
 }
开发者ID:Tdue21,项目名称:Jira-Rest-Client-Dot-Net-Update,代码行数:12,代码来源:JiraProjectRolesRestClient.cs

示例6: GetComponentRelatedIssuesCount

 /// <summary>
 /// Returns count of issues related to this component.
 /// </summary>
 /// <param name="componentUri">The URI for the selected component.</param>
 /// <returns>The number of issues associated with the component.</returns>
 /// <exception cref="WebServiceException">The caller is not logged in and does not have permission to view the component.</exception>
 public int GetComponentRelatedIssuesCount(Uri componentUri)
 {
     var uri = componentUri.Append("relatedIssueCounts");
     var json = client.Get<JsonObject>(uri.ToString());
     return json.Get<int>("issueCount");
 }
开发者ID:Tdue21,项目名称:Jira-Rest-Client-Dot-Net-Update,代码行数:12,代码来源:JiraComponentRestClient.cs

示例7: LoginToOIDCTestProvider

 private Uri LoginToOIDCTestProvider(Uri uri)
 {
     var formURL = uri.Append($"/_oidc_testing/authenticate?client_id=CLIENTID&redirect_uri=http%3A%2F%2F{GetReplicationServer()}%3A{GetReplicationPort()}%2Fopenid_db%2F_oidc_callback&response_type=code&scope=openid+email&state=");
     var formData = Encoding.ASCII.GetBytes("username=pupshaw&authenticated=true");
     var request = (HttpWebRequest)WebRequest.Create(formURL);
     request.Method = "POST";
     request.AllowAutoRedirect = false;
     request.ContentType = "application/x-www-form-urlencoded";
     request.ContentLength = formData.Length;
     request.GetRequestStream().Write(formData, 0, formData.Length);
     var response = (HttpWebResponse)request.GetResponse();
     Assert.AreEqual(HttpStatusCode.Found, response.StatusCode);
     var authURLStr = response.Headers["Location"];
     Trace.WriteLine($"Redirected to {authURLStr}");
     Assert.IsNotNull(authURLStr);
     return new Uri(authURLStr);
 }
开发者ID:jonfunkhouser,项目名称:couchbase-lite-net,代码行数:17,代码来源:AuthTest.cs

示例8: Ngsi10ProviderService

 public Ngsi10ProviderService( Uri baseAddress, IIncomingProviderOperations serverOperations )
 {
     _baseAddress = baseAddress.Append( "/NGSI10" );
      _serverOperation = serverOperations;
 }
开发者ID:FINESCE,项目名称:ComponentCompositionFramework,代码行数:5,代码来源:Ngsi10ProviderService.cs

示例9: Convert

        private IEnumerable<WebDavResource> Convert(IEnumerable<SystemFile> files, Uri baseUri)
        {
            var convertResult = new List<WebDavResource>();

            var credentials = new NetworkCredential(WspContext.User.Login,
                _cryptography.Decrypt(WspContext.User.EncryptedPassword),
                WebDavAppConfigManager.Instance.UserDomain);

            foreach (var file in files)
            {
                 var webDavitem = new WebDavResource();

                webDavitem.SetCredentials(credentials);

                webDavitem.SetHref(baseUri.Append(WspContext.User.OrganizationId).Append(file.RelativeUrl.Replace("\\","/")));

                webDavitem.SetItemType(file.IsDirectory? ItemType.Folder : ItemType.Resource);
                webDavitem.SetLastModified(file.Changed);
                webDavitem.ContentLength = file.Size;
                webDavitem.AllocatedSpace = file.FRSMQuotaMB;
                webDavitem.Summary = file.Summary;

                convertResult.Add(webDavitem);
            }

            return convertResult;
        }
开发者ID:jonwbstr,项目名称:Websitepanel,代码行数:27,代码来源:WebDavManager.cs

示例10: AppendToUriWithoutQueryString

 public void AppendToUriWithoutQueryString()
 {
     var uri = new Uri("http://host");
     var uri2 = uri.Append("c", "4");
     Assert.IsTrue(uri2.HasValue("c", "4"));
 }
开发者ID:thaneswarreddy,项目名称:netfx,代码行数:6,代码来源:UriExtensionsFixture.cs

示例11: GetRedirectUri

        /// <summary>
        /// Gets the redirect URI.
        /// </summary>
        /// <param name="routeData">The route data.</param>
        /// <param name="requestedUri">The requested URI.</param>
        /// <returns>Uri.</returns>
        private static Uri GetRedirectUri(RouteData routeData, Uri requestedUri)
        {
            if (routeData == null) return null;

            var route = routeData.Route as Route;
            if (route == null) return null;

            var requestedSegments = GetSegmentCount(requestedUri.AbsolutePath);
            var mappedSegements = GetSegmentCount(route.Url);

            if (requestedSegments == mappedSegements)
            {
                var slashRequired = route.Url.EndsWith(SLASH, StringComparison.Ordinal);

                if (slashRequired && !requestedUri.AbsolutePath.EndsWith(SLASH, StringComparison.Ordinal))
                    return requestedUri.Append(SLASH);

                if (!slashRequired && requestedUri.AbsolutePath.EndsWith(SLASH, StringComparison.Ordinal))
                    return requestedUri.TrimPathEnd(SLASH[0]);
            }
            else if (!requestedUri.AbsolutePath.EndsWith(SLASH, StringComparison.Ordinal)) // requestedSegments < mappedSegements
                return requestedUri.Append(SLASH);

            return null;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:31,代码来源:RouteConfig.cs


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