當前位置: 首頁>>代碼示例>>C#>>正文


C# Web.Url類代碼示例

本文整理匯總了C#中N2.Web.Url的典型用法代碼示例。如果您正苦於以下問題:C# Url類的具體用法?C# Url怎麽用?C# Url使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Url類屬於N2.Web命名空間,在下文中一共展示了Url類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CanConstruct_AbsoluteLocalPath_WithFragment

 public void CanConstruct_AbsoluteLocalPath_WithFragment()
 {
     Url u = new Url("/hello.aspx#somebookmark");
     Assert.That(u.Path, Is.EqualTo("/hello.aspx"));
     Assert.That(u.Fragment, Is.EqualTo("somebookmark"));
     Assert.That(u.ToString(), Is.EqualTo("/hello.aspx#somebookmark"));
 }
開發者ID:rohancragg,項目名稱:n2cms,代碼行數:7,代碼來源:UrlTests.cs

示例2: CanConstruct_FromHostName

 public void CanConstruct_FromHostName()
 {
     Url u = new Url("http://somesite/");
     Assert.That(u.Scheme, Is.EqualTo("http"));
     Assert.That(u.Authority, Is.EqualTo("somesite"));
     Assert.That(u.ToString(), Is.EqualTo("http://somesite/"));
 }
開發者ID:rohancragg,項目名稱:n2cms,代碼行數:7,代碼來源:UrlTests.cs

示例3: CanConstruct_AbsoluteLocalPath_WithQuery

 public void CanConstruct_AbsoluteLocalPath_WithQuery()
 {
     Url u = new Url("/hello.aspx?something=someotherthing");
     Assert.That(u.Path, Is.EqualTo("/hello.aspx"));
     Assert.That(u.Query, Is.EqualTo("something=someotherthing"));
     Assert.That(u.ToString(), Is.EqualTo("/hello.aspx?something=someotherthing"));
 }
開發者ID:rohancragg,項目名稱:n2cms,代碼行數:7,代碼來源:UrlTests.cs

示例4: FakeHttpContext

		public FakeHttpContext(Url url)
			: this()
		{
			request.appRelativeCurrentExecutionFilePath = "~" + url.Path;
			foreach (var q in url.GetQueries())
				request.query[q.Key] = q.Value;
			request.rawUrl = url.PathAndQuery;
		}
開發者ID:grbbod,項目名稱:drconnect-jungo,代碼行數:8,代碼來源:FakeHttpContext.cs

示例5: FakeHttpContext

        public FakeHttpContext(Url url)
            : this()
        {
            request.appRelativeCurrentExecutionFilePath = "~" + url.Path;
            foreach (var q in url.GetQueries())
                request.query[q.Key] = q.Value;
            request.rawUrl = url.PathAndQuery;
			if (url.Path.IndexOf(".ashx/") > 0)
				request.pathInfo = url.Path.Substring(url.Path.IndexOf(".ashx/") + 5);
        }
開發者ID:rukmareddy,項目名稱:n2cms,代碼行數:10,代碼來源:FakeHttpContext.cs

示例6: CreateSize

        public virtual void CreateSize(Url virtualPath, byte[] image, ImageSizeElement size)
        {
            if (!size.ResizeOnUpload)
                return;

            string resizedPath = ImagesUtility.GetResizedPath(virtualPath, size.Name);

			using (var sourceStream = new MemoryStream(image))
			{
				if (size.Width <= 0 && size.Height <= 0)
				{
					using (var destinationStream = files.OpenFile(resizedPath))
					{
						int b;
						while ((b = sourceStream.ReadByte()) != -1)
						{
							destinationStream.WriteByte((byte)b);
						}
					}
				}
				else
				{
					// Delete the image before writing.
					// Fixes a weird bug where overwriting the original file while it still exists
					//  leaves the resized image the with the exact same file size as the original even 
					//  though it should be smaller.
					if (files.FileExists(resizedPath))
					{
						files.DeleteFile(resizedPath);
					}

					try
					{
						using (var destinationStream = files.OpenFile(resizedPath))
						{
							resizer.Resize(sourceStream, new ImageResizeParameters(size.Width, size.Height, size.Mode) { Quality = size.Quality }, destinationStream);
						}
					}
					catch
					{
					}
				}
			}
		}
開發者ID:EzyWebwerkstaden,項目名稱:n2cms,代碼行數:44,代碼來源:UploadedFilesResizer.cs

示例7: CanGet_EmptyQueryDictionary

 public void CanGet_EmptyQueryDictionary()
 {
     Url u = new Url("/hello.aspx");
     var q = u.GetQueries();
     Assert.That(q.Count, Is.EqualTo(0));
 }
開發者ID:rohancragg,項目名稱:n2cms,代碼行數:6,代碼來源:UrlTests.cs

示例8: CanGet_QueryDictionary

 public void CanGet_QueryDictionary()
 {
     Url u = new Url("/hello.aspx?something=someotherthing");
     var q = u.GetQueries();
     Assert.That(q.Count, Is.EqualTo(1));
     Assert.That(q["something"], Is.EqualTo("someotherthing"));
 }
開發者ID:rohancragg,項目名稱:n2cms,代碼行數:7,代碼來源:UrlTests.cs

示例9: CanSplitPath_IntoPathWithoutExtension

 public void CanSplitPath_IntoPathWithoutExtension()
 {
     Url u = new Url("/hello.aspx?something=someotherthing");
     Assert.That(u.PathWithoutExtension, Is.EqualTo("/hello"));
 }
開發者ID:rohancragg,項目名稱:n2cms,代碼行數:5,代碼來源:UrlTests.cs

示例10: CanConstruct_WithBaseSchemeAndRawUrl

		public void CanConstruct_WithBaseSchemeAndRawUrl()
		{
			Url u = new Url("http", "www.n2cms.com", "/Default.aspx?");
			Assert.That(u.Scheme, Is.EqualTo("http"));
			Assert.That(u.Authority, Is.EqualTo("www.n2cms.com"));
			Assert.That(u.PathAndQuery, Is.EqualTo("/Default.aspx"));
		}
開發者ID:rohancragg,項目名稱:n2cms,代碼行數:7,代碼來源:UrlTests.cs

示例11: UpdatingQueryToNull_ReturnsOtherParameters_WhenUpdatingLast

        public void UpdatingQueryToNull_ReturnsOtherParameters_WhenUpdatingLast()
        {
            Url u = new Url("/hello.aspx?something=someotherthing&query=value&query3=value3");
            u = u.SetQueryParameter("query3", null);
            Assert.That(u.ToString(), Is.EqualTo("/hello.aspx?something=someotherthing&query=value"));
		}
開發者ID:rohancragg,項目名稱:n2cms,代碼行數:6,代碼來源:UrlTests.cs

示例12: Getting_Query_WhenNoQueries_GivesNull

 public void Getting_Query_WhenNoQueries_GivesNull()
 {
     Url u = new Url("/hello.aspx");
     var q = u.GetQuery("something");
     Assert.That(q, Is.Null);
 }
開發者ID:rohancragg,項目名稱:n2cms,代碼行數:6,代碼來源:UrlTests.cs

示例13: NullUrl

		public void NullUrl()
		{
			Url u = new Url((string)null);
			Assert.That(u.Path, Is.EqualTo(""));
			Assert.That(u.ToString(), Is.EqualTo(""));
		}
開發者ID:rohancragg,項目名稱:n2cms,代碼行數:6,代碼來源:UrlTests.cs

示例14: EmptyUrl

        public void EmptyUrl()
        {
            Url u = new Url("");
            Assert.That(u.Path, Is.EqualTo(""));
            Assert.That(u.ToString(), Is.EqualTo(""));
		}
開發者ID:rohancragg,項目名稱:n2cms,代碼行數:6,代碼來源:UrlTests.cs

示例15: CanConstruct_FromHostName_WithPath_AndQuery_AndFragment

 public void CanConstruct_FromHostName_WithPath_AndQuery_AndFragment()
 {
     Url u = new Url("http://somesite/some/path?key=value#bookmark");
     Assert.That(u.Scheme, Is.EqualTo("http"));
     Assert.That(u.Authority, Is.EqualTo("somesite"));
     Assert.That(u.Path, Is.EqualTo("/some/path"));
     Assert.That(u.Query, Is.EqualTo("key=value"));
     Assert.That(u.Fragment, Is.EqualTo("bookmark"));
     Assert.That(u.ToString(), Is.EqualTo("http://somesite/some/path?key=value#bookmark"));
 }
開發者ID:rohancragg,項目名稱:n2cms,代碼行數:10,代碼來源:UrlTests.cs


注:本文中的N2.Web.Url類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。