本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例9: GetSymbol
public Task<string> GetSymbol (Url<Instrument> instrumentUrl)
{
return this.GetSymbol(instrumentUrl.ToString());
}
示例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());
}
示例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) + '/';
}
示例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());
}
示例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));
}
示例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());
}