当前位置: 首页>>代码示例>>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;未经允许,请勿转载。