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


C# Url.ToString方法代碼示例

本文整理匯總了C#中System.Url.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# Url.ToString方法的具體用法?C# Url.ToString怎麽用?C# Url.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Url的用法示例。


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

示例1: RegisterEntryPointControllerDescriptionBuilder

 private static void RegisterEntryPointControllerDescriptionBuilder(this IComponentProvider container, Url entryPoint)
 {
     container.Register<IHttpControllerDescriptionBuilder, EntryPointControllerDescriptionBuilder>(
         entryPoint.ToString().Substring(1),
         () => new EntryPointControllerDescriptionBuilder(entryPoint, container.Resolve<IDefaultValueRelationSelector>()),
         Lifestyles.Singleton);
 }
開發者ID:alien-mcl,項目名稱:URSA,代碼行數:7,代碼來源:ComponentProviderExtensions.cs

示例2: GetInstrument

 public async Task<Instrument> GetInstrument (Url<Instrument> instrumentUrl)
 {
     Instrument instrument = null;
     if (!_instrumentKeyToIntrument.TryGetValue(instrumentUrl.ToString(), out instrument))
     {
         instrument = await _client.DownloadInstrument(instrumentUrl);
         addInstrument(instrument);
     }
     return instrument;
 }
開發者ID:wchuanghard,項目名稱:RobinhoodNet,代碼行數:10,代碼來源:InstrumentCache.cs

示例3: it_can_create_with_a_host

        public void it_can_create_with_a_host()
        {
            // Arrange
            var connectionString = String.Format("http://{0}:{1}/remote", SERVER_NAME, DEFAULT_PORT.ToString());

            // Act
            var url = new Url(connectionString);

            // Assert
            Assert.AreEqual(connectionString, url.ToString());
            Assert.AreEqual(DEFAULT_PORT, url.Server.Port);
            Assert.AreEqual(SERVER_NAME, url.Server.Host);
        }
開發者ID:sprucemedia,項目名稱:oinq,代碼行數:13,代碼來源:UrlTests.cs

示例4: it_can_create_with_a_host_and_port

        public void it_can_create_with_a_host_and_port()
        {
            // Arrange
            Int32 port = 12345;
            var connectionString = String.Format("http://{0}:{1}/remote", SERVER_NAME, port.ToString());

            // Act
            var url = new Url(connectionString);

            // Assert
            Assert.AreEqual(connectionString, url.ToString());
            Assert.AreEqual(port, url.Server.Port);
            Assert.AreEqual(SERVER_NAME, url.Server.Host);
        }
開發者ID:sprucemedia,項目名稱:oinq,代碼行數:14,代碼來源:UrlTests.cs

示例5: it_can_create_with_a_host_and_port_and_database

        public void it_can_create_with_a_host_and_port_and_database()
        {
            // Arrange
            Int32 port = 12345;
            var connectionString = String.Format("http://{0}:{1}/remote?edgemart={2}", SERVER_NAME, port.ToString(), EDGEMART_NAME);

            // Act
            var url = new Url(connectionString);

            // Assert
            Assert.AreEqual(connectionString, url.ToString());
            Assert.AreEqual(port, url.Server.Port);
            Assert.AreEqual(SERVER_NAME, url.Server.Host);
            Assert.AreEqual(EDGEMART_NAME, url.EdgeMartName);
        }
開發者ID:sprucemedia,項目名稱:oinq,代碼行數:15,代碼來源:UrlTests.cs

示例6: Get

        /// <summary>
        /// Generates a cache key from the supplied Request
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public string Get(Request request)
        {
            if (request == null || request.Url == null)
                return string.Empty;

            var query = new Dictionary<string, string>();

            if (request.Query is DynamicDictionary)
            {
                var dynDict = (request.Query as DynamicDictionary);
                foreach (var key in dynDict.Keys)
                {
                    query[key] = (string)dynDict[key];
                }
            }

            if (request.Form is DynamicDictionary)
            {
                var dynDict = (request.Form as DynamicDictionary);
                foreach (var key in dynDict.Keys)
                {
                    query[key] = (string)dynDict[key];
                }
            }

            var removeParamKeys = query.Where(a => !_varyParams.Contains(a.Key.Replace("?", "").ToLower())).Select(a => a.Key).ToArray();
            foreach (var removeParamKey in removeParamKeys)
                query.Remove(removeParamKey);

            var url = new Url
            {
                BasePath = request.Url.BasePath,
                Fragment = request.Url.Fragment,
                HostName = request.Url.HostName,
                Path = request.Url.Path,
                Port = request.Url.Port,
                Query = (query.Count > 0 ? "?" : string.Empty) + string.Join("&", query.Select(a => string.Join("=", a.Key, a.Value))),
                Scheme = request.Url.Scheme,
            };

            return url.ToString();
        }
開發者ID:richardprice,項目名稱:Nancy.LightningCache,代碼行數:47,代碼來源:DefaultCacheKeyGenerator.cs

示例7: GetReferenceFromUrl

 /// <summary>
 /// Get a page reference from the url
 /// </summary>
 /// <param name="url"></param>
 /// <returns></returns>
 public static int GetReferenceFromUrl(Url url)
 {
     if (url != null)
     {
         var reference = UrlResolver.Current.Route(new UrlBuilder(url.ToString()));
         if (reference != null && reference.ContentLink.ID > 0)
         {
             return reference.ContentLink.ID;
         }
     }
     return -1;
 }
開發者ID:episerver,項目名稱:Commerce-Demo-Kit,代碼行數:17,代碼來源:UrlHelpers.cs

示例8: GetReferenceFromUrl

 /// <summary>
 /// Get a page reference from the url
 /// </summary>
 /// <param name="url"></param>
 /// <returns></returns>
 public static int GetReferenceFromUrl(Url url)
 {
     if (url != null)
     {
         var reference = PermanentLinkUtility.GetContentReference(new UrlBuilder(url.ToString()));
         if (reference != null && reference.ID > 0)
         {
             return reference.ID;
         }
     }
     return -1;
 }
開發者ID:smchristenson,項目名稱:CommerceStarterKit,代碼行數:17,代碼來源:UrlHelpers.cs

示例9: GetSymbol

 public Task<string> GetSymbol (Url<Instrument> instrumentUrl)
 {
     return this.GetSymbol(instrumentUrl.ToString());
 }
開發者ID:wchuanghard,項目名稱:RobinhoodNet,代碼行數:4,代碼來源:InstrumentCache.cs

示例10: Should_Not_Add_Equals_Without_Value

 public void Should_Not_Add_Equals_Without_Value()
 {
     var url = new Url("http://example.com?123456");
     Assert.AreEqual("http://example.com?123456", url.ToString());
 }
開發者ID:rafaelsteil,項目名稱:Flurl,代碼行數:5,代碼來源:UrlBuilderTests.cs

示例11: FormatUri

		/// <summary>
		/// Formats the uri.
		/// </summary>
		/// <param name="url"></param>
		/// <returns></returns>
		protected static string FormatUri(Url url)
		{
			// validate arguments
			if (url == null)
				throw new ArgumentNullException("url");

			return url.ToString().Trim(Dispatcher.Constants.UrlPartTrimCharacters) + '/';
		}
開發者ID:Erikvl87,項目名稱:Premotion-Mansion,代碼行數:13,代碼來源:CommandHandlerBase.cs

示例12: encodes_plus

		public void encodes_plus() {
			var url = new Url("http://www.mysite.com").SetQueryParam("x", "1+2");
			Assert.AreEqual("http://www.mysite.com?x=1%2B2", url.ToString());
		}
開發者ID:llenroc,項目名稱:Flurl,代碼行數:4,代碼來源:UrlBuilderTests.cs

示例13: can_encode_space_as_plus

		public void can_encode_space_as_plus() {
			var url = new Url("http://www.mysite.com/foo+bar?x=1+2");
			Assert.AreEqual("http://www.mysite.com/foo+bar?x=1+2", url.ToString(true));
		}
開發者ID:llenroc,項目名稱:Flurl,代碼行數:4,代碼來源:UrlBuilderTests.cs

示例14: interprets_plus_as_space

		public void interprets_plus_as_space() {
			var url = new Url("http://www.mysite.com/foo+bar?x=1+2");
			Assert.AreEqual("1 2", url.QueryParams["x"]);
			// encode + in query string but not path segment
			Assert.AreEqual("http://www.mysite.com/foo+bar?x=1%202", url.ToString());
		}
開發者ID:llenroc,項目名稱:Flurl,代碼行數:6,代碼來源:UrlBuilderTests.cs


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