本文整理汇总了C#中MindTouch.Dream.XUri.PathStartsWith方法的典型用法代码示例。如果您正苦于以下问题:C# XUri.PathStartsWith方法的具体用法?C# XUri.PathStartsWith怎么用?C# XUri.PathStartsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MindTouch.Dream.XUri
的用法示例。
在下文中一共展示了XUri.PathStartsWith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
/// <summary>
/// Update the jar with a collection cookies.
/// </summary>
/// <param name="collection">List of cookies to store.</param>
/// <param name="uri">Uri cookies apply to.</param>
public void Update(List<DreamCookie> collection, XUri uri)
{
if(collection == null) {
throw new ArgumentNullException("collection");
}
// process all cookies
foreach(DreamCookie c in collection) {
DreamCookie cookie = c;
if(!string.IsNullOrEmpty(cookie.Name)) {
string[] segments = null;
if(uri != null) {
// set default domain if needed
if(string.IsNullOrEmpty(cookie.Domain)) {
cookie = cookie.WithHostPort(uri.HostPort);
} else if(!StringUtil.EqualsInvariantIgnoreCase(cookie.Domain, uri.HostPort)) {
// domain doesn't match, ignore cookie
continue;
}
// set default path if needed
if(string.IsNullOrEmpty(cookie.Path)) {
cookie = cookie.WithPath(uri.Path);
segments = uri.Segments;
} else {
segments = cookie.Uri == null ? new string[0] : cookie.Uri.Segments;
if(!uri.PathStartsWith(segments)) {
// path doesn't match ignore cookie
continue;
}
}
}
if(!string.IsNullOrEmpty(cookie.Path) && !string.IsNullOrEmpty(cookie.Domain)) {
if(segments == null) {
segments = cookie.Uri == null ? new string[0] : cookie.Uri.Segments;
}
if(cookie.Expired) {
Delete(cookie, segments, 0);
} else {
Insert(cookie, segments, 0);
}
}
}
}
}