本文整理匯總了C#中System.Url.Clone方法的典型用法代碼示例。如果您正苦於以下問題:C# Url.Clone方法的具體用法?C# Url.Clone怎麽用?C# Url.Clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Url
的用法示例。
在下文中一共展示了Url.Clone方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Evaluate
/// <summary>
/// Gets the <see cref="Uri"/> without the query string.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="source">The source <see cref="Url"/> from which to copy the query string.</param>
/// <returns>The <see cref="Url"/> with the modified query string.</returns>
public Url Evaluate(IMansionContext context, Url source)
{
// validate arguments
if (context == null)
throw new ArgumentNullException("context");
if (source == null)
throw new ArgumentNullException("source");
var clone = source.Clone();
clone.QueryString.Clear();
clone.Fragment = string.Empty;
return clone;
}
示例2: Evaluate
/// <summary>
/// Copies the query string from <paramref name="source"/> to <paramref name="target"/>.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="source">The source <see cref="Url"/> from which to copy the query string.</param>
/// <param name="target">The target <see cref="Url"/> to which to copy the query string.</param>
/// <returns>The <see cref="Url"/> with the modified query string.</returns>
public Url Evaluate(IMansionContext context, Url source, Url target)
{
// validate arguments
if (context == null)
throw new ArgumentNullException("context");
if (source == null)
throw new ArgumentNullException("source");
if (target == null)
throw new ArgumentNullException("target");
var clone = target.Clone();
foreach (var entry in source.QueryString)
clone.QueryString[entry.Key] = entry.Value;
return clone;
}
示例3: Evaluate
/// <summary>
/// Changes the value of an attribute in the query string.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="url">The <see cref="Url"/> which to change.</param>
/// <param name="dataspace">The <see cref="IPropertyBag"/> which to add to the query string.</param>
/// <returns>The <see cref="Url"/> with the modified query string.</returns>
public Url Evaluate(IMansionContext context, Url url, IPropertyBag dataspace)
{
// validate arguments
if (context == null)
throw new ArgumentNullException("context");
if (url == null)
throw new ArgumentNullException("url");
if (dataspace == null)
throw new ArgumentNullException("dataspace");
var modifiableUri = url.Clone();
// merge the dataspace
foreach (var entry in dataspace)
modifiableUri.QueryString[entry.Key] = conversionService.Convert<string>(context, entry.Value);
// return the url
return modifiableUri;
}
示例4: Evaluate
/// <summary>
/// Changes the value of an attribute in the query string.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="url">The <see cref="Url"/> which to change.</param>
/// <param name="parameterName">The name of the parmeters which to set.</param>
/// <param name="value">The value of the parameters.</param>
/// <returns>The <see cref="Url"/> with the modified query string.</returns>
public Url Evaluate(IMansionContext context, Url url, string parameterName, string value)
{
// validate arguments
if (context == null)
throw new ArgumentNullException("context");
if (url == null)
throw new ArgumentNullException("url");
if (string.IsNullOrEmpty(parameterName))
throw new ArgumentNullException("parameterName");
var modifiableUri = url.Clone();
// set the property or clear it when already in the query string
if (!string.IsNullOrEmpty(value))
modifiableUri.QueryString[parameterName] = value;
else if (modifiableUri.QueryString.ContainsKey(parameterName))
modifiableUri.QueryString.Remove(parameterName);
// return the url
return modifiableUri;
}