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")); }
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 ""; }
/// <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()); }
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); }
/// <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(); }
public static Uri Append(this Uri uri, object querysting) { return(uri.Append(querysting.ToString().Escape())); }
/// <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"); }
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); }
public Ngsi10ProviderService( Uri baseAddress, IIncomingProviderOperations serverOperations ) { _baseAddress = baseAddress.Append( "/NGSI10" ); _serverOperation = serverOperations; }
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; }
public void AppendToUriWithoutQueryString() { var uri = new Uri("http://host"); var uri2 = uri.Append("c", "4"); Assert.IsTrue(uri2.HasValue("c", "4")); }
/// <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; }