本文整理汇总了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;
}